本文整理汇总了C++中gl::Fbo::getTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ Fbo::getTexture方法的具体用法?C++ Fbo::getTexture怎么用?C++ Fbo::getTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl::Fbo
的用法示例。
在下文中一共展示了Fbo::getTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
void ShaderToyApp::resize()
{
// Create/resize frame buffers (no multisampling)
mBufferCurrent = gl::Fbo( getWindowWidth(), getWindowHeight() );
mBufferNext = gl::Fbo( getWindowWidth(), getWindowHeight() );
mBufferCurrent.getTexture().setFlipped(true);
mBufferNext.getTexture().setFlipped(true);
}
示例2: renderSSAOToFBO
/*
* @Description: render SSAO now - woohoo!
* @param: KeyEvent
* @return: none
*/
void Base_ThreeD_ProjectApp::renderSSAOToFBO()
{
gl::setViewport( mSSAOMap.getBounds() );
//render out main scene to FBO
mSSAOMap.bindFramebuffer();
glClearColor( 0.5f, 0.5f, 0.5f, 1 );
glClearDepth(1.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
gl::setMatricesWindow( mSSAOMap.getSize() );
mRandomNoise.bind(1);
mNormalDepthMap.getTexture().bind(2);
mSSAOShader.bind();
mSSAOShader.uniform("rnm", 1 );
mSSAOShader.uniform("normalMap", 2 );
//look at shader and see you can set these through the client if you so desire.
// mSSAOShader.uniform("rnm", 1 );
// mSSAOShader.uniform("normalMap", 2 );
// mSSAOShader.uniform("totStrength", 1.38f);
// mSSAOShader.uniform("strength", 0.07f);
// mSSAOShader.uniform("offset", 10.0f);
// mSSAOShader.uniform("falloff", 0.2f);
// mSSAOShader.uniform("rad", 0.8f);
// mSSAOShader.uniform("rnm", 1 );
// mSSAOShader.uniform("normalMap", 2 );
// mSSAOShader.uniform("farClipDist", 20.0f);
// mSSAOShader.uniform("screenSizeWidth", (float)getWindowWidth());
// mSSAOShader.uniform("screenSizeHeight", (float)getWindowHeight());
// mSSAOShader.uniform("grandom", 1 );
// mSSAOShader.uniform("gnormals", 2 );
// mSSAOShader.uniform("gdepth", 1 );
// mSSAOShader.uniform("gdiffuse", 1 );
gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
mSSAOShader.unbind();
mNormalDepthMap.getTexture().unbind(2);
mRandomNoise.unbind(1);
mSSAOMap.unbindFramebuffer();
gl::setViewport( getWindowBounds() );
}
示例3: draw
void FBOMultipleTargetsApp::draw()
{
// clear the window to gray
gl::clear( Color( 0.35f, 0.35f, 0.35f ) );
// set the viewport to match our window
gl::setViewport( getWindowBounds() );
// draw the two textures we've created side-by-side
gl::setMatricesWindow( getWindowSize() );
gl::draw( mFbo.getTexture(0), mFbo.getTexture(0).getBounds() );
gl::draw( mFbo.getTexture(1), mFbo.getTexture(1).getBounds() + Vec2f(mFbo.getTexture(0).getWidth(),0) );
}
示例4: setup
void GroupingApp::setup() {
fbo = gl::Fbo(getWindowWidth(), getWindowHeight());
gui = new SimpleGUI(this, Font(loadResource(RES_SGUI_FONT), 8));
gui->lightColor = ColorA(1, 1, 0, 1);
gui->addColumn();
gui->addLabel("CONTROLS");
gui->addParam("Rotation", &rotation, 0, 360, 0);
gui->addParam("Size", &size, 100, 600, 200);
gui->addParam("Color", &color, ColorA(0,0.5,1,0.5), SimpleGUI::RGB); //use R,G,B,A sliders
gui->addColumn();
gui->addLabel("RENDER TYPE");
gui->addParam("Fill", &fill, true, RENDER_TYPE_GROUP); //if we specify group id, we create radio button set
gui->addParam("Stroke", &stroke, false, RENDER_TYPE_GROUP); //i.e. only one of the buttons can be active at any time
strokePanel = gui->addPanel();
gui->addParam("Thickness", &thickness, 1, 10);
gui->addColumn();
gui->addLabel("OPTIONS");
gui->addParam("Auto Rotation", &autoRotation, false);
gui->addColumn();
gui->addLabel("PREVIEW");
gui->addParam("PreviewTex", &fbo.getTexture());
gui->load(CONFIG_FILE); //we load settings after specifying all the
//params because we need to know their name and type
timer.start();
prevTime = timer.getSeconds();
}
示例5: draw
void MemExploreApp::draw()
{
mTexture = gl::Texture(mDataPointer, GL_RGBA, mVolumeDim * mTilesDim, mVolumeDim * mTilesDim);
mTexture.setWrap(GL_REPEAT, GL_REPEAT);
mTexture.setMinFilter(GL_NEAREST);
mTexture.setMagFilter(GL_NEAREST);
float frustum[6];
mCamera.getFrustum(&frustum[0], &frustum[1], &frustum[2], &frustum[3], &frustum[4], &frustum[5]);
mFbo.bindFramebuffer();
gl::setMatricesWindow(mFbo.getSize(), false);
mProgram.bind();
mProgram.uniform("uTexture", 0);
mProgram.uniform("uVolumeDim", mVolumeDim);
mProgram.uniform("uTilesDim", mTilesDim);
mProgram.uniform("uTime", (float)getElapsedSeconds());
mProgram.uniform("uEyePoint", mCamera.getEyePoint());
mProgram.uniform("uXAxis", mCamera.getOrientation() * Vec3f::xAxis());
mProgram.uniform("uYAxis", mCamera.getOrientation() * Vec3f::yAxis());
mProgram.uniform("uViewDistance", mCamera.getAspectRatio() / abs(frustum[2] - frustum[0]) * mCamera.getNearClip());
mProgram.uniform("uNegViewDir", -mCamera.getViewDirection().normalized());
mProgram.uniform("uAspectRatio", mCamera.getAspectRatio());
mTexture.enableAndBind();
gl::drawSolidRect(mFbo.getBounds());
mTexture.unbind();
mProgram.unbind();
mFbo.unbindFramebuffer();
gl::setMatricesWindow(getWindowSize());
gl::draw(mFbo.getTexture(), getWindowBounds());
}
示例6: setFboVelocities
void RepulsionApp::setFboVelocities( gl::Fbo &fbo )
{
Surface32f vel( fbo.getTexture() );
Surface32f::Iter it = vel.getIter();
while( it.line() ){
while( it.pixel() ){
Vec3f r = Rand::randVec3f() * 0.1f;
it.r() = 0.0f;//r.x;
it.g() = 0.0f;//r.y;
it.b() = 0.0f;//r.z;
it.a() = 0.0f;
}
}
gl::Texture velTexture( vel );
velTexture.bind();
gl::setMatricesWindow( mFboSize, false );
gl::setViewport( mFboBounds );
fbo.bindFramebuffer();
mVelInitShader.bind();
mVelInitShader.uniform( "initTex", 0 );
gl::drawSolidRect( mFboBounds );
mVelInitShader.unbind();
fbo.unbindFramebuffer();
}
示例7: draw
void LEDCamApp::draw()
{
// clear out the window with black
gl::clear( kClearColor );
if( !mTexture ) return;
mFbo.bindFramebuffer();
mTexture.enableAndBind();
mShader.bind();
float aspect = kWindowHeight/kWindowWidth;
cout << "Aspect: " << aspect << " \n";
mShader.uniform( "aspect", aspect );
mShader.uniform( "tex", 0 );
mShader.uniform( "bright", 3.0f );
mShader.uniform( "spacing", 3 );
mShader.uniform( "ledCount", 100.0f );
gl::drawSolidRect( getWindowBounds() );
mTexture.unbind();
mShader.unbind();
mFbo.unbindFramebuffer();
gl::Texture fboTexture = mFbo.getTexture();
fboTexture.setFlipped();
gl::draw( fboTexture );
}
示例8: draw
void FBOBasicApp::draw()
{
// clear the window to gray
gl::clear( Color( 0.35f, 0.35f, 0.35f ) );
// setup our camera to render the cube
CameraPersp cam( getWindowWidth(), getWindowHeight(), 60.0f );
cam.setPerspective( 60, getWindowAspectRatio(), 1, 1000 );
cam.lookAt( Vec3f( 2.6f, 1.6f, -2.6f ), Vec3f::zero() );
gl::setMatrices( cam );
// set the viewport to match our window
gl::setViewport( getWindowBounds() );
// use the scene we rendered into the FBO as a texture
glEnable( GL_TEXTURE_2D );
mFbo.bindTexture();
// draw a cube textured with the FBO
gl::color( Color::white() );
gl::drawCube( Vec3f::zero(), Vec3f( 2.2f, 2.2f, 2.2f ) );
// show the FBO texture in the upper left corner
gl::setMatricesWindow( getWindowSize() );
gl::draw( mFbo.getTexture(0), Rectf( 0, 0, 96, 96 ) );
#if ! defined( CINDER_GLES ) // OpenGL ES can't do depth textures, otherwise draw the FBO's
gl::draw( mFbo.getDepthTexture(), Rectf( 96, 0, 96 + 96, 96 ) );
#endif
}
示例9: renderAnaglyph
void StereoscopicRenderingApp::renderAnaglyph( const Vec2i &size, const ColorA &left, const ColorA &right )
{
// bind the FBO and clear its buffer
mFbo.bindFramebuffer();
gl::clear( mColorBackground );
// render the scene using the side-by-side technique
renderSideBySide( mFbo.getSize() );
// unbind the FBO
mFbo.unbindFramebuffer();
// enable the anaglyph shader
mShaderAnaglyph.bind();
mShaderAnaglyph.uniform( "tex0", 0 );
mShaderAnaglyph.uniform( "clr_left", left );
mShaderAnaglyph.uniform( "clr_right", right );
// bind the FBO texture and draw a full screen rectangle,
// which conveniently is exactly what the following line does
gl::draw( mFbo.getTexture(), Rectf(0, float(size.y), float(size.x), 0) );
// disable the anaglyph shader
mShaderAnaglyph.unbind();
}
示例10: setFboPositions
void CatalogApp::setFboPositions( gl::Fbo &fbo )
{
int numBrightStars = mBrightStars.size();
int index = 0;
Surface32f posSurface( fbo.getTexture() );
Surface32f::Iter it = posSurface.getIter();
while( it.line() ){
while( it.pixel() ){
Vec3f pos = Vec3f( 1000000.0f, 0.0f, 0.0f );
float col = 0.4f;
float rad = 0.0f;
if( index < numBrightStars ){
pos = mBrightStars[index]->mPos;
col = mBrightStars[index]->mColor;
rad = floor( constrain( ( ( 6.0f - ( mBrightStars[index]->mAbsoluteMag ) )/6.0f ), 0.3f, 1.0f ) * 3.0f * 1000 );
}
it.r() = pos.x;
it.g() = pos.y;
it.b() = pos.z;
it.a() = rad + col;
index ++;
}
}
gl::Texture posTexture( posSurface );
fbo.bindFramebuffer();
gl::setMatricesWindow( fbo.getSize(), false );
gl::setViewport( fbo.getBounds() );
gl::clear( ColorA( 0, 0, 0, 0 ), true );
gl::draw( posTexture );
fbo.unbindFramebuffer();
}
示例11: renderInterlacedHorizontal
void StereoscopicRenderingApp::renderInterlacedHorizontal( const Vec2i &size )
{
// bind the FBO and clear its buffer
mFbo.bindFramebuffer();
gl::clear( mColorBackground );
// render the scene using the over-under technique
renderOverUnder( mFbo.getSize() );
// unbind the FBO
mFbo.unbindFramebuffer();
// enable the interlace shader
mShaderInterlaced.bind();
mShaderInterlaced.uniform( "tex0", 0 );
mShaderInterlaced.uniform( "window_origin", Vec2f( getWindowPos() ) );
mShaderInterlaced.uniform( "window_size", Vec2f( getWindowSize() ) );
// bind the FBO texture and draw a full screen rectangle,
// which conveniently is exactly what the following line does
gl::draw( mFbo.getTexture(), Rectf(0, float(size.y), float(size.x), 0) );
// disable the interlace shader
mShaderInterlaced.unbind();
}
示例12: pingPongBlur
/*
* @Description: need to blur[the SSAO texture] horizonatally then vertically (for shader performance reasons). Called ping-ponging as it one FBO drawn to another
* @param: KeyEvent
* @return: none
*/
void Base_ThreeD_ProjectApp::pingPongBlur()
{
//render horizontal blue first
gl::setViewport( mPingPongBlurH.getBounds() );
mPingPongBlurH.bindFramebuffer();
glClearColor( 0.5f, 0.5f, 0.5f, 1 );
glClearDepth(1.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
gl::setMatricesWindow( mPingPongBlurH.getSize() );
mSSAOMap.getTexture().bind(0);
mHBlurShader.bind();
mHBlurShader.uniform("RTScene", 0);
gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
mHBlurShader.unbind();
mSSAOMap.getTexture().unbind(0);
mPingPongBlurH.unbindFramebuffer();
//gl::setViewport( getWindowBounds() ); //redundant
//now render vertical blur
gl::setViewport( mPingPongBlurV.getBounds() );
mPingPongBlurV.bindFramebuffer();
glClearColor( 0.5f, 0.5f, 0.5f, 1 );
glClearDepth(1.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
gl::setMatricesWindow( mPingPongBlurV.getSize() );
mPingPongBlurH.getTexture().bind(0);
mHBlurShader.bind();
mHBlurShader.uniform("RTBlurH", 0);
gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
mHBlurShader.unbind();
mPingPongBlurH.getTexture().unbind(0);
mPingPongBlurV.unbindFramebuffer();
gl::setViewport( getWindowBounds() );
}
示例13: draw
void syphonImpApp::draw()
{
gl::enableAlphaBlending();
gl::clear( Color( 0.1f, 0.1f, 0.1f ) );
renderSceneToFbo();
mTextureSyphon.publishTexture(&myFbo.getTexture()); //publish our texture
Vec2f upperLeftCorner = Vec2f( 0, WIDTH );
Vec2f lowerRightCorner = Vec2f(WIDTH,WIDTH-(WIDTH/1.33) );
Rectf rect = Rectf( upperLeftCorner, lowerRightCorner );
gl::draw( myFbo.getTexture(0),rect);
}
示例14: draw
void Narcotic::draw()
{
gl::clear();
fboProjection.bindFramebuffer();
gl::clear(Color::gray(0.25));
v1.draw();
fboProjection.unbindFramebuffer();
gl::draw(fboProjection.getTexture(), Rectf(projectionWindow->getBounds()));
//fboProjection.unbindTexture();
}
示例15: renderNormalMap
void SmoothDisplacementMappingApp::renderNormalMap()
{
if( mNormalMapShader && mNormalMapFbo )
{
mNormalMapFbo.bindFramebuffer();
{
// setup viewport and matrices
glPushAttrib( GL_VIEWPORT_BIT );
gl::setViewport( mNormalMapFbo.getBounds() );
gl::pushMatrices();
gl::setMatricesWindow( mNormalMapFbo.getSize(), false );
// clear the color buffer
gl::clear();
// bind the displacement map
mDispMapFbo.getTexture().bind(0);
// render the normal map
mNormalMapShader.bind();
mNormalMapShader.uniform( "texture", 0 );
mNormalMapShader.uniform( "amplitude", 4.0f );
Area bounds = mNormalMapFbo.getBounds(); //bounds.expand(-1, -1);
gl::drawSolidRect( bounds );
mNormalMapShader.unbind();
// clean up after ourselves
mDispMapFbo.getTexture().unbind();
gl::popMatrices();
glPopAttrib();
}
mNormalMapFbo.unbindFramebuffer();
}
}