MCPcopy Create free account
hub / github.com/cinder/Cinder / renderSceneToFbo

Method renderSceneToFbo

samples/_opengl/FboBasic/src/FboBasicApp.cpp:38–64  ·  view source on GitHub ↗

Render the color cube into the FBO

Source from the content-addressed store, hash-verified

36
37// Render the color cube into the FBO
38void FboBasicApp::renderSceneToFbo()
39{
40 // this will restore the old framebuffer binding when we leave this function
41 // on non-OpenGL ES platforms, you can just call mFbo->unbindFramebuffer() at the end of the function
42 // but this will restore the "screen" FBO on OpenGL ES, and does the right thing on both platforms
43 gl::ScopedFramebuffer fbScp( mFbo );
44 // clear out the FBO with blue
45 gl::clear( Color( 0.25, 0.5f, 1.0f ) );
46
47 // setup the viewport to match the dimensions of the FBO
48 gl::ScopedViewport scpVp( ivec2( 0 ), mFbo->getSize() );
49
50 // setup our camera to render the torus scene
51 CameraPersp cam( mFbo->getWidth(), mFbo->getHeight(), 60.0f );
52 cam.setPerspective( 60, mFbo->getAspectRatio(), 1, 1000 );
53 cam.lookAt( vec3( 2.8f, 1.8f, -2.8f ), vec3( 0 ));
54 gl::setMatrices( cam );
55
56 // set the modelview matrix to reflect our current rotation
57 gl::setModelMatrix( mRotation );
58
59 // render the color cube
60 gl::ScopedGlslProg shaderScp( gl::getStockShader( gl::ShaderDef().color() ) );
61 gl::color( Color( 1.0f, 0.5f, 0.25f ) );
62 gl::drawColorCube( vec3( 0 ), vec3( 2.2f ) );
63 gl::color( Color::white() );
64}
65
66void FboBasicApp::update()
67{

Callers

nothing calls this directly

Calls 15

setMatricesFunction · 0.85
setModelMatrixFunction · 0.85
drawColorCubeFunction · 0.85
whiteFunction · 0.85
setPerspectiveMethod · 0.80
lookAtMethod · 0.80
colorMethod · 0.80
clearFunction · 0.50
ColorFunction · 0.50
ShaderDefClass · 0.50
colorFunction · 0.50
getSizeMethod · 0.45

Tested by

no test coverage detected