void SmoothDisplacementMappingApp::renderDisplacementMap() { if( mDispMapShader && mDispMapFbo ) { mDispMapFbo.bindFramebuffer(); { // clear the color buffer gl::clear(); // setup viewport and matrices glPushAttrib( GL_VIEWPORT_BIT ); gl::setViewport( mDispMapFbo.getBounds() ); gl::pushMatrices(); gl::setMatricesWindow( mDispMapFbo.getSize(), false ); // render the displacement map mDispMapShader.bind(); mDispMapShader.uniform( "time", float( getElapsedSeconds() ) ); mDispMapShader.uniform( "amplitude", mAmplitude ); gl::drawSolidRect( mDispMapFbo.getBounds() ); mDispMapShader.unbind(); // clean up after ourselves gl::popMatrices(); glPopAttrib(); } mDispMapFbo.unbindFramebuffer(); } }
void HiKinectApp::generateNormalMap() { // bind the Fbo mFbo.bindFramebuffer(); // match the viewport to the Fbo dimensions gl::setViewport( mFbo.getBounds() ); // setup an ortho projection gl::setMatricesWindow( mFbo.getWidth(), mFbo.getHeight() ); // clear the Fbo gl::clear( Color( 0, 0, 0 ) ); // bind the shader, set its variables mNormalShader.bind(); mNormalShader.uniform( "normalStrength", mNormalStrength); mNormalShader.uniform( "texelWidth", 1.0f / (float)CAPTURE_WIDTH ); if ( mDepthTexture ) { gl::pushModelView(); // gl::translate( Vec3f( 0, mDepthTexture.getHeight(), 0 ) ); // gl::scale( Vec3f( 1, -1, 1 ) ); gl::draw( mDepthTexture ); gl::popModelView(); } // unbind the shader mNormalShader.unbind(); // unbind the Fbo mFbo.unbindFramebuffer(); }
void PixarDemo2012::renderGradientFBO() { gl::enableAlphaBlending(); gl::SaveFramebufferBinding bindingSaver; mGradientFBO.bindFramebuffer(); gl::setViewport( mGradientFBO.getBounds() ); gl::setMatricesWindow( getWindowSize(), true ); gl::clear( ColorA(0.0f,0.0f,0.0f,1.0f) ); glDisable( GL_TEXTURE_2D ); // mGradientFBO.bindTexture(0); mGradientShader.bind(); float what = mTime; mGradientShader.uniform("mTime", what); mGradientShader.uniform("resolution", Vec2f((float)getWindowWidth(),(float)getWindowHeight())); gl::drawSolidRect( getWindowBounds() ); mGradientShader.unbind(); // mGradientFBO.unbindTexture(); gl::popMatrices(); }
void SlytherinApp::setup() { // setup webcam try { mCapture = Capture::create(640, 480); mCapture->start(); } catch(...) { console() << "ERROR - failed to initialize capture" << endl; quit(); } // setup webcam FBO gl::Fbo::Format format; format.enableColorBuffer(true); format.enableDepthBuffer(false); format.setWrap(GL_CLAMP, GL_CLAMP); mFBO = gl::Fbo(mCapture->getWidth(), mCapture->getHeight(), format); mFBO.bindFramebuffer(); gl::setViewport(mFBO.getBounds()); gl::clear(); mFBO.unbindFramebuffer(); setFrameRate(60.0f); mLastUpdateFrame = UINT32_MAX; mLinesPerFrame = 2.0f; // 1 line every 2 frames (at getFrameRate()) mLineIndex = 0; }
void MemExploreApp::draw() { mTexture = gl::Texture(mDataPointer, GL_RGBA, mVolumeDim * mTilesDim, mVolumeDim * mTilesDim); mTexture.setWrap(GL_REPEAT, GL_REPEAT); mTexture.setMinFilter(GL_NEAREST); mTexture.setMagFilter(GL_NEAREST); float frustum[6]; mCamera.getFrustum(&frustum[0], &frustum[1], &frustum[2], &frustum[3], &frustum[4], &frustum[5]); mFbo.bindFramebuffer(); gl::setMatricesWindow(mFbo.getSize(), false); mProgram.bind(); mProgram.uniform("uTexture", 0); mProgram.uniform("uVolumeDim", mVolumeDim); mProgram.uniform("uTilesDim", mTilesDim); mProgram.uniform("uTime", (float)getElapsedSeconds()); mProgram.uniform("uEyePoint", mCamera.getEyePoint()); mProgram.uniform("uXAxis", mCamera.getOrientation() * Vec3f::xAxis()); mProgram.uniform("uYAxis", mCamera.getOrientation() * Vec3f::yAxis()); mProgram.uniform("uViewDistance", mCamera.getAspectRatio() / abs(frustum[2] - frustum[0]) * mCamera.getNearClip()); mProgram.uniform("uNegViewDir", -mCamera.getViewDirection().normalized()); mProgram.uniform("uAspectRatio", mCamera.getAspectRatio()); mTexture.enableAndBind(); gl::drawSolidRect(mFbo.getBounds()); mTexture.unbind(); mProgram.unbind(); mFbo.unbindFramebuffer(); gl::setMatricesWindow(getWindowSize()); gl::draw(mFbo.getTexture(), getWindowBounds()); }
void ShadedSphereApp::drawIntoRoomFbo() { mRoomFbo.bindFramebuffer(); gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true ); gl::setMatricesWindow( mRoomFbo.getSize(), false ); gl::setViewport( mRoomFbo.getBounds() ); gl::disableAlphaBlending(); gl::enable( GL_TEXTURE_2D ); glEnable( GL_CULL_FACE ); glCullFace( GL_BACK ); Matrix44f m; m.setToIdentity(); m.scale( mRoom.getDims() ); // mLightsTex.bind( 0 ); mRoomShader.bind(); mRoomShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix ); mRoomShader.uniform( "mMatrix", m ); mRoomShader.uniform( "eyePos", mSpringCam.getEye() ); mRoomShader.uniform( "roomDims", mRoom.getDims() ); mRoomShader.uniform( "mainPower", mRoom.getPower() ); mRoomShader.uniform( "lightPower", mRoom.getLightPower() ); mRoom.draw(); mRoomShader.unbind(); mRoomFbo.unbindFramebuffer(); glDisable( GL_CULL_FACE ); }
// Render the torus into the FBO void FBOMultipleTargetsApp::renderSceneToFbo() { // bind the framebuffer - now everything we draw will go there mFbo.bindFramebuffer(); // setup the viewport to match the dimensions of the FBO gl::setViewport( mFbo.getBounds() ); // setup our camera to render the torus scene CameraPersp cam( mFbo.getWidth(), mFbo.getHeight(), 60.0f ); cam.setPerspective( 60, mFbo.getAspectRatio(), 1, 1000 ); cam.lookAt( Vec3f( 2.8f, 1.8f, -2.8f ), Vec3f::zero() ); gl::setMatrices( cam ); // set the modelview matrix to reflect our current rotation gl::multModelView( mTorusRotation ); // clear out both of the attachments of the FBO with black gl::clear(); // render the torus with our multiple-output shader mShaderMultipleOuts.bind(); gl::drawTorus( 1.4f, 0.3f, 32, 64 ); mShaderMultipleOuts.unbind(); // unbind the framebuffer, so that drawing goes to the screen again mFbo.unbindFramebuffer(); }
void CatalogApp::setFboPositions( gl::Fbo &fbo ) { int numBrightStars = mBrightStars.size(); int index = 0; Surface32f posSurface( fbo.getTexture() ); Surface32f::Iter it = posSurface.getIter(); while( it.line() ){ while( it.pixel() ){ Vec3f pos = Vec3f( 1000000.0f, 0.0f, 0.0f ); float col = 0.4f; float rad = 0.0f; if( index < numBrightStars ){ pos = mBrightStars[index]->mPos; col = mBrightStars[index]->mColor; rad = floor( constrain( ( ( 6.0f - ( mBrightStars[index]->mAbsoluteMag ) )/6.0f ), 0.3f, 1.0f ) * 3.0f * 1000 ); } it.r() = pos.x; it.g() = pos.y; it.b() = pos.z; it.a() = rad + col; index ++; } } gl::Texture posTexture( posSurface ); fbo.bindFramebuffer(); gl::setMatricesWindow( fbo.getSize(), false ); gl::setViewport( fbo.getBounds() ); gl::clear( ColorA( 0, 0, 0, 0 ), true ); gl::draw( posTexture ); fbo.unbindFramebuffer(); }
void BubbleChamberApp::drawIntoRoomFbo() { mRoomFbo.bindFramebuffer(); gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true ); gl::setMatricesWindow( mRoomFbo.getSize(), false ); gl::setViewport( mRoomFbo.getBounds() ); gl::disableAlphaBlending(); gl::enable( GL_TEXTURE_2D ); glEnable( GL_CULL_FACE ); glCullFace( GL_BACK ); Matrix44f m; m.setToIdentity(); m.scale( mRoom.getDims() ); mRoomShader.bind(); mRoomShader.uniform( "mvpMatrix", mActiveCam.mMvpMatrix ); mRoomShader.uniform( "mMatrix", m ); mRoomShader.uniform( "eyePos", mActiveCam.mCam.getEyePoint() ); mRoomShader.uniform( "roomDims", mRoom.getDims() ); mRoomShader.uniform( "power", mRoom.getPower() ); mRoomShader.uniform( "lightPower", mRoom.getLightPower() ); mRoomShader.uniform( "timePer", mRoom.getTimePer() * 1.5f + 0.5f ); mRoom.draw(); mRoomShader.unbind(); mRoomFbo.unbindFramebuffer(); glDisable( GL_CULL_FACE ); }
void ChargesApp::setup() { //gl::disableVerticalSync(); gl::Fbo::Format format; format.enableDepthBuffer( false ); format.setSamples( 4 ); mFbo = gl::Fbo( 1280, 800, format ); mKawaseBloom = mndl::gl::fx::KawaseBloom( mFbo.getWidth(), mFbo.getHeight() ); mEffectCharge.setup(); mEffectCharge.instantiate(); mEffectCharge.setBounds( mFbo.getBounds() ); // Leap mLeap = LeapSdk::Device::create(); mLeapCallbackId = mLeap->addCallback( &ChargesApp::onFrame, this ); // params mndl::kit::params::PInterfaceGl::load( "params.xml" ); mParams = mndl::kit::params::PInterfaceGl( "Parameters", Vec2i( 200, 300 ) ); mParams.addPersistentSizeAndPosition(); mParams.addParam( "Fps", &mFps, "", true ); mParams.addSeparator(); mParams.addPersistentParam( "Line width", &mLineWidth, 4.5f, "min=.5 max=10 step=.1" ); mParams.addPersistentParam( "Bloom strength", &mBloomStrength, .8f, "min=0 max=1 step=.05" ); mParams.addPersistentParam( "Finger disapperance thr", &mFingerDisapperanceThreshold, .1f, "min=0 max=2 step=.05" ); mndl::kit::params::PInterfaceGl::showAllParams( false ); }
// Render the torus into the FBO void FBOBasicApp::renderSceneToFbo() { // this will restore the old framebuffer binding when we leave this function // on non-OpenGL ES platforms, you can just call mFbo.unbindFramebuffer() at the end of the function // but this will restore the "screen" FBO on OpenGL ES, and does the right thing on both platforms gl::SaveFramebufferBinding bindingSaver; // bind the framebuffer - now everything we draw will go there mFbo.bindFramebuffer(); // setup the viewport to match the dimensions of the FBO gl::setViewport( mFbo.getBounds() ); // setup our camera to render the torus scene CameraPersp cam( mFbo.getWidth(), mFbo.getHeight(), 60.0f ); cam.setPerspective( 60, mFbo.getAspectRatio(), 1, 1000 ); cam.lookAt( Vec3f( 2.8f, 1.8f, -2.8f ), Vec3f::zero() ); gl::setMatrices( cam ); // set the modelview matrix to reflect our current rotation gl::multModelView( mTorusRotation ); // clear out the FBO with blue gl::clear( Color( 0.25, 0.5f, 1.0f ) ); // render an orange torus, with no textures glDisable( GL_TEXTURE_2D ); gl::color( Color( 1.0f, 0.5f, 0.25f ) ); gl::drawTorus( 1.4f, 0.3f, 32, 64 ); // gl::drawColorCube( Vec3f::zero(), Vec3f( 2.2f, 2.2f, 2.2f ) ); }
/* * @Description: need to blur[the SSAO texture] horizonatally then vertically (for shader performance reasons). Called ping-ponging as it one FBO drawn to another * @param: KeyEvent * @return: none */ void Base_ThreeD_ProjectApp::pingPongBlur() { //render horizontal blue first gl::setViewport( mPingPongBlurH.getBounds() ); mPingPongBlurH.bindFramebuffer(); glClearColor( 0.5f, 0.5f, 0.5f, 1 ); glClearDepth(1.0f); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); gl::setMatricesWindow( mPingPongBlurH.getSize() ); mSSAOMap.getTexture().bind(0); mHBlurShader.bind(); mHBlurShader.uniform("RTScene", 0); gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) ); mHBlurShader.unbind(); mSSAOMap.getTexture().unbind(0); mPingPongBlurH.unbindFramebuffer(); //gl::setViewport( getWindowBounds() ); //redundant //now render vertical blur gl::setViewport( mPingPongBlurV.getBounds() ); mPingPongBlurV.bindFramebuffer(); glClearColor( 0.5f, 0.5f, 0.5f, 1 ); glClearDepth(1.0f); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); gl::setMatricesWindow( mPingPongBlurV.getSize() ); mPingPongBlurH.getTexture().bind(0); mHBlurShader.bind(); mHBlurShader.uniform("RTBlurH", 0); gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) ); mHBlurShader.unbind(); mPingPongBlurH.getTexture().unbind(0); mPingPongBlurV.unbindFramebuffer(); gl::setViewport( getWindowBounds() ); }
void KinectEcard::snapshot(){ gl::Fbo fbo( 640, 480, false ); // render stored depth FBO fbo.bindFramebuffer(); gl::pushMatrices(); gl::clear( Color::black() ); gl::color( Color::white() ); gl::setMatricesWindowPersp( fbo.getSize() ); mDepthCompareShader.bind(); mDepthCompareShader.uniform( "tex0", 0 ); mDepthCompareShader.uniform( "tex1", 1 ); mDepthFbo.bindTexture(0); mStoredDepthFbo.bindTexture(1); gl::translate( 0, 480 ); gl::scale( 1, -1 ); gl::drawSolidRect( fbo.getBounds() ); mDepthCompareShader.unbind(); gl::popMatrices(); fbo.unbindFramebuffer(); // save stored depth fbo fbo.blitTo( mStoredDepthFbo, fbo.getBounds(), mStoredDepthFbo.getBounds() ); // render substracted video fbo fbo.bindFramebuffer(); gl::pushMatrices(); gl::clear( Color::black() ); gl::color( Color::white() ); gl::setMatricesWindowPersp( mSubstractedVideoFbo.getSize() ); gl::draw( mSubstractedVideoFbo.getTexture() ); gl::popMatrices(); fbo.unbindFramebuffer(); // save it fbo.blitTo( mStoredVideoFbo, fbo.getBounds(), mStoredVideoFbo.getBounds() ); }
/* * @Description: render SSAO now - woohoo! * @param: KeyEvent * @return: none */ void Base_ThreeD_ProjectApp::renderSSAOToFBO() { gl::setViewport( mSSAOMap.getBounds() ); //render out main scene to FBO mSSAOMap.bindFramebuffer(); glClearColor( 0.5f, 0.5f, 0.5f, 1 ); glClearDepth(1.0f); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); gl::setMatricesWindow( mSSAOMap.getSize() ); mRandomNoise.bind(1); mNormalDepthMap.getTexture().bind(2); mSSAOShader.bind(); mSSAOShader.uniform("rnm", 1 ); mSSAOShader.uniform("normalMap", 2 ); //look at shader and see you can set these through the client if you so desire. // mSSAOShader.uniform("rnm", 1 ); // mSSAOShader.uniform("normalMap", 2 ); // mSSAOShader.uniform("totStrength", 1.38f); // mSSAOShader.uniform("strength", 0.07f); // mSSAOShader.uniform("offset", 10.0f); // mSSAOShader.uniform("falloff", 0.2f); // mSSAOShader.uniform("rad", 0.8f); // mSSAOShader.uniform("rnm", 1 ); // mSSAOShader.uniform("normalMap", 2 ); // mSSAOShader.uniform("farClipDist", 20.0f); // mSSAOShader.uniform("screenSizeWidth", (float)getWindowWidth()); // mSSAOShader.uniform("screenSizeHeight", (float)getWindowHeight()); // mSSAOShader.uniform("grandom", 1 ); // mSSAOShader.uniform("gnormals", 2 ); // mSSAOShader.uniform("gdepth", 1 ); // mSSAOShader.uniform("gdiffuse", 1 ); gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) ); mSSAOShader.unbind(); mNormalDepthMap.getTexture().unbind(2); mRandomNoise.unbind(1); mSSAOMap.unbindFramebuffer(); gl::setViewport( getWindowBounds() ); }
void Grove::copyBlur(gl::Fbo& source, gl::Fbo& target, Vec2f sampleOffset) { // bind the blur shader mBlurShader.bind(); mBlurShader.uniform("tex0", 0); // use texture unit 0 mBlurShader.uniform("sampleOffset", sampleOffset); // copy a horizontally blurred version of our scene into the first blur Fbo gl::setViewport( target.getBounds() ); target.bindFramebuffer(); source.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(target.getSize(), false); gl::clear( Color::black() ); gl::drawSolidRect( target.getBounds() ); gl::popMatrices(); source.unbindTexture(); target.unbindFramebuffer(); // unbind the shader mBlurShader.unbind(); }
void SmoothDisplacementMappingApp::renderNormalMap() { if( mNormalMapShader && mNormalMapFbo ) { mNormalMapFbo.bindFramebuffer(); { // setup viewport and matrices glPushAttrib( GL_VIEWPORT_BIT ); gl::setViewport( mNormalMapFbo.getBounds() ); gl::pushMatrices(); gl::setMatricesWindow( mNormalMapFbo.getSize(), false ); // clear the color buffer gl::clear(); // bind the displacement map mDispMapFbo.getTexture().bind(0); // render the normal map mNormalMapShader.bind(); mNormalMapShader.uniform( "texture", 0 ); mNormalMapShader.uniform( "amplitude", 4.0f ); Area bounds = mNormalMapFbo.getBounds(); //bounds.expand(-1, -1); gl::drawSolidRect( bounds ); mNormalMapShader.unbind(); // clean up after ourselves mDispMapFbo.getTexture().unbind(); gl::popMatrices(); glPopAttrib(); } mNormalMapFbo.unbindFramebuffer(); } }
void syphonImpApp::renderSceneToFbo() { // this will restore the old framebuffer binding when we leave this function // on non-OpenGL ES platforms, you can just call mFbo.unbindFramebuffer() at the end of the function // but this will restore the "screen" FBO on OpenGL ES, and does the right thing on both platforms gl::SaveFramebufferBinding bindingSaver; // bind the framebuffer - now everything we draw will go there myFbo.bindFramebuffer(); gl::setViewport(myFbo.getBounds() ); gl::setMatricesWindow( myFbo.getSize(), false ); // clear out the FBO with blue gl::clear(); mParticleController.update(); mParticleController.draw(); }
/* * @Description: render scene normals to FBO ( required for SSAO calculations ) * @param: none * @return: none */ void Base_ThreeD_ProjectApp::renderNormalsDepthToFBO() { gl::setViewport( mNormalDepthMap.getBounds() ); //render out main scene to FBO mNormalDepthMap.bindFramebuffer(); glClearColor( 0.5f, 0.5f, 0.5f, 1 ); glClearDepth(1.0f); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); mNormalDepthShader.bind(); drawTestObjects(); mNormalDepthShader.unbind(); mNormalDepthMap.unbindFramebuffer(); gl::setViewport( getWindowBounds() ); }
void ardroneApp::draw() { renderFbo.bindFramebuffer(); gl::clear( Color( 0, 0, 0 ) ); gl::color( Color::white() ); if ( mFrameTexture ) { Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true ); gl::draw( mFrameTexture, centeredRect ); } renderFbo.blitToScreen(renderFbo.getBounds(), getWindowBounds()); mSyphonServer.publishTexture(renderFbo.getTexture(), false); renderFbo.unbindFramebuffer(); // return rendering to the window's own frame buffer if( mInfoTexture ) { glDisable( GL_TEXTURE_RECTANGLE_ARB ); gl::draw( mInfoTexture, Vec2f( 5, getWindowHeight() - 5 - mInfoTexture.getHeight() ) ); } }
void ScreenShadersApp::draw() { // clear out the window with black gl::clear( Color( 0, 0, 0 ) ); // bind the Fbo mFbo.bindFramebuffer(); // match the viewport to the Fbo dimensions gl::setViewport( mFbo.getBounds() ); // setup an ortho projection gl::setMatricesWindow( mFbo.getWidth(), mFbo.getHeight() ); // clear the Fbo gl::clear( Color( 0, 0, 0 ) ); if ( mTexture ) { gl::draw( mTexture ); } // unbind the Fbo mFbo.unbindFramebuffer(); gl::setMatricesWindow( getWindowWidth(), getWindowHeight() ); float kernelRes = 21.0f; mBlurShader.bind(); mBlurShader.uniform( "kernelRes", kernelRes ); mBlurShader.uniform( "invKernelRes", 1.0f / kernelRes ); mBlurShader.uniform( "fboTex", 0 ); mBlurShader.uniform( "kernelTex", 1 ); mBlurShader.uniform( "orientationVector", Vec2f( 1.0f, 1.0f ) ); mBlurShader.uniform( "blurAmt", 1.0f ); mBlurShader.uniform( "colMulti", 1.0f ); mBlurKernel.bind( 1 ); gl::draw( mFbo.getTexture(0), Rectf( 0, getWindowHeight(), getWindowWidth(), 0 ) ); mBlurShader.unbind(); }
void KinectEcard::renderVideo(){ if( !mVideoSurface ) return; gl::pushMatrices(); { // mVideoFbo.bindFramebuffer(); // clear FBO gl::clear( Color::black() ); gl::color( Color::white() ); // gl::Texture tex0( mVideoSurface ); gl::Texture tex1( mCorrectionMap ); mDepthCorrectionShader.bind(); mDepthCorrectionShader.uniform( "tex0", 0 ); mDepthCorrectionShader.uniform( "tex1", 1 ); tex0.bind(0); tex1.bind(1); gl::setMatricesWindowPersp( mVideoFbo.getSize() ); // draw video surface gl::drawSolidRect( mVideoFbo.getBounds() ); //gl::draw( mCorrectionMap ); mDepthCorrectionShader.unbind(); mVideoFbo.unbindFramebuffer(); } gl::popMatrices(); }
void KinectEcard::renderSubstractedVideo(){ mSubstractedVideoFbo.bindFramebuffer(); gl::pushMatrices(); { // clear FBO gl::clear( Color::black() ); gl::color( Color::white() ); // gl::setMatricesWindowPersp( mSubstractedVideoFbo.getSize() ); mSubstractShader.bind(); mSubstractShader.uniform( "tex0", 0 ); mSubstractShader.uniform( "tex1", 1 ); mSubstractShader.uniform( "tex2", 2 ); mSubstractShader.uniform( "tex3", 3 ); mVideoFbo.bindTexture(0); mDepthFbo.bindTexture(1); mStoredVideoFbo.bindTexture(2); mStoredDepthFbo.bindTexture(3); gl::drawSolidRect( mSubstractedVideoFbo.getBounds() ); mVideoFbo.unbindTexture(); mDepthFbo.unbindTexture(); mStoredVideoFbo.unbindTexture(); mStoredDepthFbo.unbindTexture(); mSubstractShader.unbind(); } gl::popMatrices(); mSubstractedVideoFbo.unbindFramebuffer(); }
void ChargesApp::draw() { mFbo.bindFramebuffer(); gl::setViewport( mFbo.getBounds() ); gl::setMatricesWindow( mFbo.getSize() ); gl::clear( Color::black() ); mEffectCharge.setLineWidth( mLineWidth ); mEffectCharge.draw(); mFbo.unbindFramebuffer(); gl::color( Color::white() ); gl::Texture output = mKawaseBloom.process( mFbo.getTexture(), 8, mBloomStrength ); gl::setViewport( getWindowBounds() ); gl::setMatricesWindow( getWindowSize() ); gl::clear( Color::black() ); gl::color( Color::white() ); gl::draw( output, getWindowBounds() ); mndl::kit::params::PInterfaceGl::draw(); }
void FolApp::draw() { gl::clear( Color::black() ); if ( !mDepthTexture ) return; // blur depth mDepthFbo.bindFramebuffer(); gl::setMatricesWindow( mDepthFbo.getSize(), false ); gl::setViewport( mDepthFbo.getBounds() ); mBlurShader.bind(); mBlurShader.uniform( "kernelSize", (float)mBlurKernelTexture.getWidth() ); mBlurShader.uniform( "invKernelSize", 1.f / mBlurKernelTexture.getWidth() ); mBlurShader.uniform( "imageTex", 0 ); mBlurShader.uniform( "kernelTex", 1 ); mBlurShader.uniform( "blurAmount", mBlurAmount ); // pass 1 glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT ); //gl::enable( GL_TEXTURE_2D ); mDepthTexture.bind( 0 ); mBlurKernelTexture.bind( 1 ); mBlurShader.uniform( "stepVector", Vec2f( 1. / mDepthTexture.getWidth(), 0. ) ); gl::drawSolidRect( mDepthFbo.getBounds() ); mDepthTexture.unbind(); // pass 2 glDrawBuffer( GL_COLOR_ATTACHMENT1_EXT ); mDepthFbo.bindTexture( 0 ); mBlurShader.uniform( "stepVector", Vec2f( 0., 1. / mDepthFbo.getHeight() ) ); gl::drawSolidRect( mDepthFbo.getBounds() ); mDepthFbo.unbindTexture(); mBlurKernelTexture.unbind(); mBlurShader.unbind(); mDepthFbo.unbindFramebuffer(); // wave output mOutputFbo.bindFramebuffer(); gl::setMatricesWindow( mOutputFbo.getSize(), false ); gl::setViewport( mOutputFbo.getBounds() ); gl::clear( Color::black() ); gl::disableDepthRead(); gl::disableDepthWrite(); gl::enableAdditiveBlending(); gl::color( ColorA( 1, 1, 1, .0195 ) ); gl::pushMatrices(); gl::scale( Vec2f( getWindowWidth() / (float)VBO_X_SIZE, getWindowHeight() / (float)VBO_Y_SIZE) ); mDepthFbo.getTexture( 1 ).bind(); mWaveShader.bind(); mWaveShader.uniform( "tex", 0 ); mWaveShader.uniform( "invSize", Vec2f( mStep / mDepthFbo.getWidth(), mStep / mDepthFbo.getHeight() ) ); mWaveShader.uniform( "clip", mClip ); gl::draw( mVboMesh ); mWaveShader.unbind(); gl::popMatrices(); gl::disableAlphaBlending(); mOutputFbo.unbindFramebuffer(); // bloom mBloomFbo.bindFramebuffer(); gl::setMatricesWindow( mBloomFbo.getSize(), false ); gl::setViewport( mBloomFbo.getBounds() ); gl::color( Color::white() ); mOutputFbo.getTexture().bind(); mBloomShader.bind(); for (int i = 0; i < 8; i++) { glDrawBuffer( GL_COLOR_ATTACHMENT0_EXT + i ); mBloomShader.uniform( "iteration", i ); gl::drawSolidRect( mBloomFbo.getBounds() ); mBloomFbo.bindTexture( 0, i ); } mBloomShader.unbind(); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); mBloomFbo.unbindFramebuffer(); // output mixer gl::setMatricesWindow( getWindowSize() ); gl::setViewport( getWindowBounds() ); mMixerShader.bind(); gl::enable( GL_TEXTURE_2D ); mOutputFbo.getTexture().bind( 0 ); for (int i = 0; i < 8; i++) { mBloomFbo.getTexture( i ).bind( i + 1 ); } gl::drawSolidRect( mOutputFbo.getBounds() ); gl::disable( GL_TEXTURE_2D ); mMixerShader.unbind(); //gl::draw( mOutputFbo.getTexture(), getWindowBounds() ); //gl::draw( mDepthFbo.getTexture( 1 ), getWindowBounds() ); params::InterfaceGl::draw(); }
void StereoscopicRenderingApp::draw() { // find dimensions of each viewport int w = getWindowWidth(); int h = getWindowHeight(); // clear color and depth buffers gl::clear( mBackgroundColor ); // stereoscopic rendering switch( mRenderMethod ) { case MONO: // render mono camera mCamera.disableStereo(); render(); break; case SIDE_BY_SIDE: // store current viewport glPushAttrib( GL_VIEWPORT_BIT ); // draw to left half of window only gl::setViewport( Area(0, 0, w / 2, h) ); // render left camera mCamera.enableStereoLeft(); render(); // draw to right half of window only gl::setViewport( Area(w / 2, 0, w, h) ); // render right camera mCamera.enableStereoRight(); render(); // restore viewport glPopAttrib(); break; case OVER_UNDER: // store current viewport glPushAttrib( GL_VIEWPORT_BIT ); // draw to top half of window only gl::setViewport( Area(0, 0, w, h / 2) ); // render left camera mCamera.enableStereoLeft(); render(); // draw to bottom half of window only gl::setViewport( Area(0, h / 2, w, h) ); // render right camera mCamera.enableStereoRight(); render(); // restore viewport glPopAttrib(); break; case ANAGLYPH_RED_CYAN: // store current viewport glPushAttrib( GL_VIEWPORT_BIT ); // bind the left FBO and adjust the viewport to its bounds mAnaglyphLeft.bindFramebuffer(); gl::setViewport( mAnaglyphLeft.getBounds() ); // because glClear() does not respect the color mask, // clear the color (and depth) buffers using a red filtered background color gl::clear( mBackgroundColor * Color( 1, 0, 0 ) ); // set up color mask to only draw red and render left camera glColorMask( true, false, false, true ); mCamera.enableStereoLeft(); render(); glColorMask( true, true, true, true ); mAnaglyphLeft.unbindFramebuffer(); // bind the right FBO and adjust the viewport to its bounds mAnaglyphRight.bindFramebuffer(); gl::setViewport( mAnaglyphRight.getBounds() ); // because glClear() does not respect the color mask, // clear the color (and depth) buffers using a cyan filtered background color gl::clear( mBackgroundColor * Color( 0, 1, 1 ) ); // set up color mask to only draw cyan and render right camera glColorMask( false, true, true, true ); mCamera.enableStereoRight(); render(); glColorMask( true, true, true, true ); mAnaglyphRight.unbindFramebuffer(); // restore viewport glPopAttrib(); // draw the FBO's on top of each other using a special additive blending operation gl::color( Color::white() ); gl::draw( mAnaglyphLeft.getTexture(), Rectf( 0, (float) h, (float) w, 0 ) ); glEnable( GL_BLEND ); glBlendFunc( GL_ONE, GL_ONE ); gl::draw( mAnaglyphRight.getTexture(), Rectf( 0, (float) h, (float) w, 0) ); glDisable( GL_BLEND ); break; } // draw auto focus visualizer if( mDrawAutoFocus ) mAF.draw(); }
void BloomingNeonApp::draw() { // clear our window gl::clear( Color::black() ); // store our viewport, so we can restore it later Area viewport = gl::getViewport(); // render scene into mFboScene using illumination texture mTextureIllumination.enableAndBind(); mTextureSpecular.bind(1); gl::setViewport( mFboScene.getBounds() ); mFboScene.bindFramebuffer(); gl::pushMatrices(); gl::setMatricesWindow(SCENE_SIZE, SCENE_SIZE, false); gl::clear( Color::black() ); render(); gl::popMatrices(); mFboScene.unbindFramebuffer(); // bind the blur shader mShaderBlur.bind(); mShaderBlur.uniform("tex0", 0); // use texture unit 0 // tell the shader to blur horizontally and the size of 1 pixel mShaderBlur.uniform("sample_offset", Vec2f(1.0f/mFboBlur1.getWidth(), 0.0f)); mShaderBlur.uniform("attenuation", 2.5f); // copy a horizontally blurred version of our scene into the first blur Fbo gl::setViewport( mFboBlur1.getBounds() ); mFboBlur1.bindFramebuffer(); mFboScene.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(BLUR_SIZE, BLUR_SIZE, false); gl::clear( Color::black() ); gl::drawSolidRect( mFboBlur1.getBounds() ); gl::popMatrices(); mFboScene.unbindTexture(); mFboBlur1.unbindFramebuffer(); // tell the shader to blur vertically and the size of 1 pixel mShaderBlur.uniform("sample_offset", Vec2f(0.0f, 1.0f/mFboBlur2.getHeight())); mShaderBlur.uniform("attenuation", 2.5f); // copy a vertically blurred version of our blurred scene into the second blur Fbo gl::setViewport( mFboBlur2.getBounds() ); mFboBlur2.bindFramebuffer(); mFboBlur1.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(BLUR_SIZE, BLUR_SIZE, false); gl::clear( Color::black() ); gl::drawSolidRect( mFboBlur2.getBounds() ); gl::popMatrices(); mFboBlur1.unbindTexture(); mFboBlur2.unbindFramebuffer(); // unbind the shader mShaderBlur.unbind(); // render scene into mFboScene using color texture mTextureColor.enableAndBind(); mTextureSpecular.bind(1); gl::setViewport( mFboScene.getBounds() ); mFboScene.bindFramebuffer(); gl::pushMatrices(); gl::setMatricesWindow(SCENE_SIZE, SCENE_SIZE, false); gl::clear( Color::black() ); render(); gl::popMatrices(); mFboScene.unbindFramebuffer(); // restore the viewport gl::setViewport( viewport ); // because the Fbo's have their origin in the LOWER-left corner, // flip the Y-axis before drawing gl::pushModelView(); gl::translate( Vec2f(0, 256) ); gl::scale( Vec3f(1, -1, 1) ); // draw the 3 Fbo's gl::color( Color::white() ); gl::draw( mFboScene.getTexture(), Rectf(0, 0, 256, 256) ); drawStrokedRect( Rectf(0, 0, 256, 256) ); gl::draw( mFboBlur1.getTexture(), Rectf(260, 0, 260 + 256, 256) ); drawStrokedRect( Rectf(260, 0, 260 + 256, 256) ); gl::draw( mFboBlur2.getTexture(), Rectf(520, 0, 520 + 256, 256) ); drawStrokedRect( Rectf(520, 0, 520 + 256, 256) ); // draw our scene with the blurred version added as a blend gl::color( Color::white() ); gl::draw( mFboScene.getTexture(), Rectf(780, 0, 780 + 256, 256) ); gl::enableAdditiveBlending(); gl::draw( mFboBlur2.getTexture(), Rectf(780, 0, 780 + 256, 256) ); gl::disableAlphaBlending(); drawStrokedRect( Rectf(780, 0, 780 + 256, 256) ); // restore the modelview matrix gl::popModelView(); // draw info gl::enableAlphaBlending(); gl::drawStringCentered("Basic Scene", Vec2f(128, 236)); gl::drawStringCentered("First Blur Pass (Horizontal)", Vec2f(260 + 128, 236)); gl::drawStringCentered("Second Blur Pass (Vertical)", Vec2f(520 + 128, 236)); gl::drawStringCentered("Final Scene", Vec2f(780 + 128, 236)); gl::disableAlphaBlending(); }
void StarsApp::draw() { int w = getWindowWidth(); int h = getWindowHeight(); gl::clear( Color::black() ); if(mIsStereoscopic) { glPushAttrib( GL_VIEWPORT_BIT ); gl::pushMatrices(); // render left eye mCamera.enableStereoLeft(); gl::setViewport( Area(0, 0, w / 2, h) ); gl::setMatrices( mCamera.getCamera() ); render(); // draw user interface mUserInterface.draw("Stereoscopic Projection"); // render right eye mCamera.enableStereoRight(); gl::setViewport( Area(w / 2, 0, w, h) ); gl::setMatrices( mCamera.getCamera() ); render(); // draw user interface mUserInterface.draw("Stereoscopic Projection"); gl::popMatrices(); glPopAttrib(); } else if(mIsCylindrical) { // make sure we have a frame buffer to render to createFbo(); // determine correct aspect ratio and vertical field of view for each of the 3 views w = mFbo.getWidth() / 3; h = mFbo.getHeight(); const float aspect = float(w) / float(h); const float hFoV = 60.0f; const float vFoV = toDegrees( 2.0f * math<float>::atan( math<float>::tan( toRadians(hFoV) * 0.5f ) / aspect ) ); // for values smaller than 1.0, this will cause each view to overlap the other ones const float overlap = 1.0f; // bind the frame buffer object mFbo.bindFramebuffer(); // store viewport, camera and matrices, so we can restore later glPushAttrib( GL_VIEWPORT_BIT ); CameraStereo original = mCamera.getCamera(); gl::pushMatrices(); // setup camera CameraStereo cam = mCamera.getCamera(); cam.disableStereo(); cam.setAspectRatio(aspect); cam.setFov( vFoV ); Vec3f right, up; cam.getBillboardVectors(&right, &up); Vec3f forward = up.cross(right); // render left side gl::setViewport( Area(0, 0, w, h) ); cam.setViewDirection( Quatf(up, overlap * toRadians(hFoV)) * forward ); cam.setWorldUp( up ); gl::setMatrices( cam ); render(); // render front side gl::setViewport( Area(w, 0, w*2, h) ); cam.setViewDirection( forward ); cam.setWorldUp( up ); gl::setMatrices( cam ); render(); // draw user interface mUserInterface.draw( (boost::format("Cylindrical Projection (%d degrees)") % int( (1.0f + 2.0f * overlap) * hFoV ) ).str() ); // render right side gl::setViewport( Area(w*2, 0, w*3, h) ); cam.setViewDirection( Quatf(up, -overlap * toRadians(hFoV)) * forward ); cam.setWorldUp( up ); gl::setMatrices( cam ); render(); // unbind the frame buffer object mFbo.unbindFramebuffer(); // restore states gl::popMatrices(); mCamera.setCurrentCam(original); glPopAttrib(); // draw frame buffer and perform cylindrical projection using a fragment shader if(mShader) { float sides = 3; float radians = sides * toRadians( hFoV ); float reciprocal = 0.5f / sides; mShader.bind(); mShader.uniform("texture", 0); mShader.uniform("sides", sides); mShader.uniform("radians", radians ); mShader.uniform("reciprocal", reciprocal ); } Rectf centered = Rectf(mFbo.getBounds()).getCenteredFit( getWindowBounds(), false ); gl::draw( mFbo.getTexture(), centered ); if(mShader) mShader.unbind(); } else { mCamera.disableStereo(); gl::pushMatrices(); gl::setMatrices( mCamera.getCamera() ); render(); gl::popMatrices(); // draw user interface mUserInterface.draw("Perspective Projection"); } // fade in at start of application gl::enableAlphaBlending(); double t = math<double>::clamp( mTimer.getSeconds() / 3.0, 0.0, 1.0 ); float a = ci::lerp<float>(1.0f, 0.0f, (float) t); if( a > 0.0f ) { gl::color( ColorA(0,0,0,a) ); gl::drawSolidRect( getWindowBounds() ); } gl::disableAlphaBlending(); }
void TextTestApp::draw() { // this pair of lines is the standard way to clear the screen in OpenGL glClearColor( 0,0,0,1 ); glClear( GL_COLOR_BUFFER_BIT ); if (flipScreen==true){ gl::pushMatrices(); gl::scale( Vec3f(-1, 1, 1) ); gl::translate( Vec2f(-ci::app::getWindowWidth(), 0 ) ); gl::translate( Vec3f(-1, 1, 1) ); } gl::enableAlphaBlending(); gl::enableAdditiveBlending(); mbackground.draw(); drawSkeleton(); // FONT NOW GETS RENDERED AFTER SCENE SO WE CAN OVERRIDE DRAW OPERATION IF REQUIRED currentScene->draw(); myFont.draw(); // kill this all and refresh gl::disableAlphaBlending(); gl::enableAdditiveBlending(); // store our viewport, so we can restore it later Area viewport = gl::getViewport(); // render a simple scene into mFboScene gl::setViewport( mFboScene.getBounds() ); mFboScene.bindFramebuffer(); gl::pushMatrices(); gl::setMatricesWindow( viewport.getWidth(), viewport.getHeight(), false ); gl::clear( ColorA( 0,0,0,1 )); fgParticles.draw(); //gl::drawSolidCircle( Vec2f(50,50), 20 ); //gl::draw( mFboScene.getTexture() );//TODO - screenshot? gl::popMatrices(); mFboScene.unbindFramebuffer(); // bind the blur shader mShaderBlur.bind(); mShaderBlur.uniform("tex0", 0); // use texture unit 0 // tell the shader to blur horizontally and the size of 1 pixel mShaderBlur.uniform("sampleOffset", Vec2f(1.0f/mFboBlur1.getWidth(), 0.0f)); // copy a horizontally blurred version of our scene into the first blur Fbo gl::setViewport( mFboBlur1.getBounds() ); mFboBlur1.bindFramebuffer(); mFboScene.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow( viewport.getWidth(), viewport.getHeight(), false ); gl::clear( Color::black() ); gl::drawSolidRect( mFboBlur1.getBounds() ); gl::popMatrices(); mFboScene.unbindTexture(); mFboBlur1.unbindFramebuffer(); // tell the shader to blur vertically and the size of 1 pixel mShaderBlur.uniform("sampleOffset", Vec2f(0.0f, 1.0f/mFboBlur2.getHeight())); // copy a vertically blurred version of our blurred scene into the second blur Fbo gl::setViewport( mFboBlur2.getBounds() ); mFboBlur2.bindFramebuffer(); mFboBlur1.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow( viewport.getWidth(), viewport.getHeight(), false ); gl::clear( Color::black() ); gl::drawSolidRect( mFboBlur2.getBounds() ); gl::popMatrices(); mFboBlur1.unbindTexture(); mFboBlur2.unbindFramebuffer(); // unbind the shader mShaderBlur.unbind(); // restore the viewport gl::setViewport( viewport ); // because the Fbo's have their origin in the LOWER-left corner, // flip the Y-axis before drawing gl::pushModelView(); gl::translate( Vec2f(0, 0 ) );// viewport.getHeight() ) ); gl::scale( Vec3f(1, 1, 1) ); // draw the 3 Fbo's //gl::color( Color::white() ); //gl::draw( mFboScene.getTexture(), Rectf(0, 0, 256, 256) ); //gl::draw( mFboBlur1.getTexture(), Rectf(260, 0, 260 + 256, 256) ); //gl::draw( mFboBlur2.getTexture(), Rectf(520, 0, 520 + 256, 256) ); // draw our scene with the blurred version added as a blend gl::color( Color::white() ); gl::enableAdditiveBlending(); gl::draw( mFboScene.getTexture(), Rectf(0, 0, viewport.getWidth(), viewport.getHeight() )); gl::draw( mFboBlur2.getTexture(), Rectf(0, 0, viewport.getWidth(), viewport.getHeight() )); gl::disableAlphaBlending(); // restore the modelview matrix gl::popModelView(); if (flipScreen == true){ gl::popMatrices(); } gl::color( Color(1.0,1.0,1.0) ); //These are for debug only //drawTitleSafeArea(); //OutlineParams::getInstance()->draw(); }
void Simulacra::blur() { // glEnable( GL_TEXTURE_2D ); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); Area viewport = gl::getViewport(); // render a simple scene into mFboScene gl::setViewport( sceneFBO.getBounds() ); sceneFBO.bindFramebuffer(); // gl::pushMatrices(); // gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); gl::pushMatrices(); gl::setMatrices(camera); try{ //Draw points synthMenu->drawTerrain(); synthMenu->drawSynths(); } catch(...) { std::cout << "drawing error!" << std::endl; } gl::popMatrices(); sceneFBO.unbindFramebuffer(); // bind the blur shader blurShader.bind(); blurShader.uniform("tex0", 0); // use texture unit 0 // tell the shader to blur horizontally and the size of 1 pixel blurShader.uniform("sampleOffset", Vec2f(1.0f/blurFBO1.getWidth(), 0.0f)); //FIRST PASS // copy a horizontally blurred version of our scene into the first blur Fbo gl::setViewport( blurFBO1.getBounds() ); blurFBO1.bindFramebuffer(); sceneFBO.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor4f(1,1,1,1); gl::drawSolidRect( blurFBO1.getBounds() ); gl::popMatrices(); sceneFBO.unbindTexture(); blurFBO1.unbindFramebuffer(); // tell the shader to blur vertically and the size of 1 pixel blurShader.uniform("sampleOffset", Vec2f(0.0f, 1.0f/blurFBO2.getHeight())); // copy a vertically blurred version of our blurred scene into the second blur Fbo gl::setViewport( blurFBO2.getBounds() ); blurFBO2.bindFramebuffer(); blurFBO1.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor4f(1,1,1,1); gl::drawSolidRect( blurFBO2.getBounds() ); gl::popMatrices(); blurFBO1.unbindTexture(); blurFBO2.unbindFramebuffer(); //SECOND PASS // copy a horizontally blurred version of our scene into the first blur Fbo blurShader.uniform("sampleOffset", Vec2f(1.0f/blurFBO1.getWidth(), 0.0f)); gl::setViewport( blurFBO1.getBounds() ); blurFBO1.bindFramebuffer(); blurFBO2.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor4f(1,1,1,1); gl::drawSolidRect( blurFBO1.getBounds() ); gl::popMatrices(); blurFBO2.unbindTexture(); blurFBO1.unbindFramebuffer(); // tell the shader to blur vertically and the size of 1 pixel blurShader.uniform("sampleOffset", Vec2f(0.0f, 1.0f/blurFBO2.getHeight())); // copy a vertically blurred version of our blurred scene into the second blur Fbo gl::setViewport( blurFBO2.getBounds() ); blurFBO2.bindFramebuffer(); blurFBO1.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor4f(1,1,1,1); gl::drawSolidRect( blurFBO2.getBounds() ); gl::popMatrices(); blurFBO1.unbindTexture(); blurFBO2.unbindFramebuffer(); if(section == 1) { //SECOND PASS // copy a horizontally blurred version of our scene into the first blur Fbo blurShader.uniform("sampleOffset", Vec2f(3.0f/blurFBO1.getWidth(), 0.0f)); gl::setViewport( blurFBO1.getBounds() ); blurFBO1.bindFramebuffer(); blurFBO2.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor4f(1,1,1,1); gl::drawSolidRect( blurFBO1.getBounds() ); gl::popMatrices(); blurFBO2.unbindTexture(); blurFBO1.unbindFramebuffer(); // tell the shader to blur vertically and the size of 1 pixel blurShader.uniform("sampleOffset", Vec2f(0.0f, 3.0f/blurFBO2.getHeight())); // copy a vertically blurred version of our blurred scene into the second blur Fbo gl::setViewport( blurFBO2.getBounds() ); blurFBO2.bindFramebuffer(); blurFBO1.bindTexture(0); gl::pushMatrices(); gl::setMatricesWindow(FBO_WIDTH, FBO_HEIGHT, false); gl::clear( ColorA(0,0,0,0) ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor4f(1,1,1,1); gl::drawSolidRect( blurFBO2.getBounds() ); gl::popMatrices(); blurFBO1.unbindTexture(); blurFBO2.unbindFramebuffer(); } // unbind the shader blurShader.unbind(); //gl::translate(0,0,250); gl::setViewport( viewport ); glEnable(GL_BLEND); glBlendFunc (GL_SRC_ALPHA,GL_ONE); // draw our scene with the blurred version added as a blend glColor4f(1,1,1,1); // gl::enableAlphaBlending(true); if(section==1) { finalFBO.bindFramebuffer(); } gl::clear(ColorA(0,0,0,1)); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); if(section!=1) { gl::pushMatrices(); gl::setMatrices(camera); synthMenu->drawTerrain(); synthMenu->drawSynths(); gl::popMatrices(); } gl::enableAdditiveBlending(); if(section == 1 || section == 2 || section == 3) { // gl::enableAlphaBlending(true); gl::draw( blurFBO2.getTexture(), getWindowBounds() ); gl::draw( blurFBO2.getTexture(), getWindowBounds() ); gl::draw( blurFBO2.getTexture(), getWindowBounds() ); gl::draw( blurFBO2.getTexture(), getWindowBounds() ); } gl::draw( blurFBO2.getTexture(), getWindowBounds() ); gl::disableAlphaBlending(); if(section==1) { finalFBO.unbindFramebuffer(); } }