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

Method draw

samples/_opengl/ShadowMapping/src/ShadowMappingApp.cpp:280–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void ShadowMappingApp::draw()
281{
282 gl::clear( Color( 0.07f, 0.05f, 0.1f ) );
283
284 // Elapsed time called here: the scene must be absolutely identical on both renders!
285 float spinAngle = 0.5f * (float) app::getElapsedSeconds();
286
287 // Offset to help combat surface acne (self-shadowing)
288 gl::enable( GL_POLYGON_OFFSET_FILL );
289 glPolygonOffset( mPolygonOffsetFactor, mPolygonOffsetUnits );
290
291 // Render scene into shadow map
292 gl::setMatrices( mLight.camera );
293 gl::viewport( mShadowMap->getSize() );
294 {
295 gl::ScopedFramebuffer bindFbo( mShadowMap->getFbo() );
296 gl::clear();
297 drawScene( spinAngle );
298 }
299
300 // Render shadowed scene
301 gl::setMatrices( mLight.toggleViewpoint ? mLight.camera : mCamera );
302 gl::viewport( toPixels( getWindowSize() ) );
303 {
304 gl::ScopedGlslProg bind( mShadowShader );
305 gl::ScopedTextureBind texture( mShadowMap->getTexture() );
306
307 mShadowShader->uniform( "uShadowMap", 0 );
308 mShadowShader->uniform( "uShadowMatrix", mLight.camera.getProjectionMatrix() * mLight.camera.getViewMatrix() );
309 mShadowShader->uniform( "uShadowTechnique", mShadowTechnique );
310 mShadowShader->uniform( "uDepthBias", mDepthBias );
311 mShadowShader->uniform( "uOnlyShadowmap", mOnlyShadowmap );
312 mShadowShader->uniform( "uRandomOffset", mRandomOffset );
313 mShadowShader->uniform( "uNumRandomSamples", mNumRandomSamples );
314 mShadowShader->uniform( "uEnableNormSlopeOffset", mEnableNormSlopeOffset );
315 mShadowShader->uniform( "uLightPos", vec3( gl::getModelView() * vec4( mLight.viewpoint, 1.0 ) ) );
316
317 drawScene( spinAngle, mShadowShader );
318 }
319
320 gl::disable( GL_POLYGON_OFFSET_FILL );
321
322 // Render light direction vector
323 gl::drawVector( mLight.viewpoint, 4.5f * normalize( mLight.viewpoint ) );
324}
325
326void ShadowMappingApp::keyDown( KeyEvent event )
327{

Callers 1

drawSceneMethod · 0.45

Calls 15

setMatricesFunction · 0.85
getModelViewFunction · 0.85
drawVectorFunction · 0.85
uniformMethod · 0.80
clearFunction · 0.50
ColorFunction · 0.50
getElapsedSecondsFunction · 0.50
enableFunction · 0.50
viewportFunction · 0.50
toPixelsFunction · 0.50
getWindowSizeFunction · 0.50
disableFunction · 0.50

Tested by

no test coverage detected