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( vec3( 2.6f, 1.6f, -2.6f ), vec3( 0 ) ); gl::setMatrices( cam ); // use the scene we rendered into the FBO as a texture mFbo->bindTexture(); // draw a cube textured with the FBO { gl::ScopedGlslProg shaderScp( gl::getStockShader( gl::ShaderDef().texture() ) ); gl::drawCube( vec3( 0 ), vec3( 2.2f ) ); } // show the FBO color texture in the upper left corner gl::setMatricesWindow( toPixels( getWindowSize() ) ); gl::draw( mFbo->getColorTexture(), Rectf( 0, 0, 128, 128 ) ); // and draw the depth texture adjacent gl::draw( mFbo->getDepthTexture(), Rectf( 128, 0, 256, 128 ) ); }
void BayBridgeApp::drawFbo() { mFboRaw->bindFramebuffer(); gl::clear(Color::black()); gl::setMatrices(mCamera); drawBridge(vec3(0), 0.0f); mBridge.Draw(); mFboRaw->unbindFramebuffer(); //////////////////////////////////////////////////// mFboHiPass->bindFramebuffer(); mFboRaw->bindTexture(0); mShaderHiPass->bind(); gl::enableAlphaBlending(); gl::clear(ColorA::zero()); gl::setMatricesWindow(getWindowSize()); gl::drawSolidRect(Rectf({vec2(0), getWindowSize()})); gl::disableAlphaBlending(); mFboRaw->unbindTexture(0); mFboHiPass->unbindFramebuffer(); //////////////////////////////////////////////////// mFboBlurU->bindFramebuffer(); mFboHiPass->bindTexture(0); mShaderBlur->bind(); mShaderBlur->uniform("uBlurAxis", vec2(1.0, 0.0)); mShaderBlur->uniform("uBlurStrength", 2.0f); mShaderBlur->uniform("uBlurSize", 1.0f); gl::clear(ColorA::zero()); gl::setMatricesWindow(getWindowSize()); gl::drawSolidRect(Rectf({ vec2(0), getWindowSize() })); mFboHiPass->unbindTexture(0); mFboBlurU->unbindFramebuffer(); //////////////////////////////////////////////////// mFboBlurV->bindFramebuffer(); mFboBlurU->bindTexture(0); mShaderBlur->bind(); mShaderBlur->uniform("uBlurAxis", vec2(0.0, 1.0)); mShaderBlur->uniform("uBlurStrength", 2.0f); mShaderBlur->uniform("uBlurSize", 2.0f); gl::clear(ColorA::zero()); gl::setMatricesWindow(getWindowSize()); gl::drawSolidRect(Rectf({ vec2(0), getWindowSize() })); mFboBlurU->unbindTexture(0); mFboBlurV->unbindFramebuffer(); }