本文整理汇总了C++中gl::Fbo::getDepthTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ Fbo::getDepthTexture方法的具体用法?C++ Fbo::getDepthTexture怎么用?C++ Fbo::getDepthTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gl::Fbo
的用法示例。
在下文中一共展示了Fbo::getDepthTexture方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: draw
void ShadowMapSample::draw()
{
gl::clear();
gl::enableDepthWrite();
glEnable( GL_LIGHTING );
updateShadowMap();
gl::enableDepthRead();
glEnable( GL_TEXTURE_2D );
mDepthFbo.bindDepthTexture();
mShader.bind();
mShader.uniform( "shadowTransMatrix", mLight->getShadowTransformationMatrix( *mCamera ) );
if( mLookThroughCamera )
gl::setMatrices( *mCamera );
else
gl::setMatrices( mLight->getShadowCamera() );
mLight->update( *mCamera );
glPushMatrix();
mBackboard.draw();
mTorus.draw();
gl::drawCube( vec3::zero(), vec3( 1, 1, 1 ) );
glPopMatrix();
mShader.unbind();
mDepthFbo.unbindTexture();
// Draw the lighting frustum unless we're looking through it
if( mLookThroughCamera ) {
glDisable( GL_LIGHTING );
glColor3f( 1.0f, 1.0f, 0.1f );
gl::drawFrustum( mLight->getShadowCamera() );
}
if( mDrawDepthMap ) { // there are faster ways to achieve this, but this is a handy way to see the depth map
gl::setMatricesWindow( getWindowSize() );
Surface32f shadowMapSurface( mDepthFbo.getDepthTexture() );
ip::hdrNormalize( &shadowMapSurface );
gl::color( Color::white() );
gl::draw( gl::Texture( shadowMapSurface ), Rectf( 0, 0, 128, 128 ) );
}
}
示例3: createFbo
void StarsApp::createFbo()
{
// determine the size of the frame buffer
int w = getWindowWidth() * 2;
int h = getWindowHeight() * 2;
if( mFbo && mFbo.getSize() == Vec2i(w, h) )
return;
// create the FBO
gl::Fbo::Format fmt;
fmt.setWrap( GL_REPEAT, GL_CLAMP_TO_BORDER );
mFbo = gl::Fbo( w, h, fmt );
// work-around for the flipped texture issue
mFbo.getTexture().setFlipped();
mFbo.getDepthTexture().setFlipped();
}