| 400 | } |
| 401 | |
| 402 | void DeferredShadingApp::resize() |
| 403 | { |
| 404 | mCamera.setAspectRatio( getWindowAspectRatio() ); |
| 405 | |
| 406 | // Color texture format |
| 407 | const gl::Texture2d::Format colorTextureFormat = gl::Texture2d::Format() |
| 408 | .internalFormat( GL_RGBA8 ) |
| 409 | .magFilter( GL_NEAREST ) |
| 410 | .minFilter( GL_NEAREST ) |
| 411 | .wrap( GL_CLAMP_TO_EDGE ); |
| 412 | |
| 413 | // Data texture format |
| 414 | const gl::Texture2d::Format dataTextureFormat = gl::Texture2d::Format() |
| 415 | .internalFormat( GL_RGBA16F ) |
| 416 | .magFilter( GL_NEAREST ) |
| 417 | .minFilter( GL_NEAREST ) |
| 418 | .wrap( GL_CLAMP_TO_EDGE ); |
| 419 | |
| 420 | // Create FBO for the the geometry buffer (G-buffer). This G-buffer uses |
| 421 | // three color attachments to store position, normal, emissive (light), and |
| 422 | // color (albedo) data. |
| 423 | const ivec2 winSize = getWindowSize(); |
| 424 | const int32_t h = winSize.y; |
| 425 | const int32_t w = winSize.x; |
| 426 | try { |
| 427 | gl::Fbo::Format fboFormat; |
| 428 | mTextureFboGBuffer[ 0 ] = gl::Texture2d::create( w, h, colorTextureFormat ); |
| 429 | mTextureFboGBuffer[ 1 ] = gl::Texture2d::create( w, h, dataTextureFormat ); |
| 430 | mTextureFboGBuffer[ 2 ] = gl::Texture2d::create( w, h, dataTextureFormat ); |
| 431 | for ( size_t i = 0; i < 3; ++i ) { |
| 432 | fboFormat.attachment( GL_COLOR_ATTACHMENT0 + (GLenum)i, mTextureFboGBuffer[ i ] ); |
| 433 | } |
| 434 | fboFormat.depthTexture(); |
| 435 | mFboGBuffer = gl::Fbo::create( w, h, fboFormat ); |
| 436 | const gl::ScopedFramebuffer scopedFramebuffer( mFboGBuffer ); |
| 437 | const gl::ScopedViewport scopedViewport( ivec2( 0 ), mFboGBuffer->getSize() ); |
| 438 | gl::clear(); |
| 439 | } |
| 440 | catch( const std::exception& e ) { |
| 441 | console() << "mFboGBuffer failed: " << e.what() << std::endl; |
| 442 | } |
| 443 | |
| 444 | // Create FBO for the light buffer (L-buffer). The L-buffer reads the |
| 445 | // G-buffer textures to render the scene inside light volumes. |
| 446 | try { |
| 447 | mFboLBuffer = gl::Fbo::create( w, h, gl::Fbo::Format().colorTexture() ); |
| 448 | const gl::ScopedFramebuffer scopedFramebuffer( mFboLBuffer ); |
| 449 | const gl::ScopedViewport scopedViewport( ivec2( 0 ), mFboLBuffer->getSize() ); |
| 450 | gl::clear(); |
| 451 | } |
| 452 | catch( const std::exception& e ) { |
| 453 | console() << "mFboLBuffer failed: " << e.what() << std::endl; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | #if !defined( CINDER_GL_ES ) |
| 458 | void DeferredShadingApp::screenShot() |
nothing calls this directly
no test coverage detected