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 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 ); }
void renderScene() { //Colours: static GLfloat vDarkRed[] = {0.0f, 0.396f, 0.702f, 1.0f}; static GLfloat vDarkGrey[] = {0.2f, 0.2f, 0.2f, 1.0f}; static CStopWatch inputTimer; //Clear buffers glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); //Beginning push: modelViewStack.PushMatrix(); //Camera matrix: M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewStack.PushMatrix(mCamera); modelViewStack.Rotate(-15.0f, 1.0f, 0.0f, 0.0f); if (screenshot) { cameraFrame.SetForwardVector(0, 0, -1); cameraFrame.SetUpVector(0, 1, 0); cameraFrame.GetCameraMatrix(mCamera); modelViewStack.PushMatrix(mCamera); } //Light source: static M3DVector4f vAmbient = {0.1f, 0.1f, 0.1f, 1.0f}; static M3DVector4f vLightPos = {4.0f, -6.5f, 10.0f, 1.0f}; static M3DVector4f vLightEyePos; m3dTransformVector4(vLightEyePos, vLightPos, mCamera); //Draw floor and grid: glEnable(GL_MULTISAMPLE); cRoom.draw(shaderManager, tPipeline, modelViewStack); // Highlight grid hlGrid.draw(shaderManager, tPipeline, modelViewStack); //Draw desks: stuDesks.drawAll(shaderManager, tPipeline, vLightEyePos, modelViewStack, vAmbient); //Draw polygon version of desks glDisable(GL_MULTISAMPLE); //Disable multisampling (to use AA) glEnable(GL_BLEND); //Enable blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPolygonOffset(-1.0f, -1.0f); glEnable(GL_POLYGON_OFFSET_LINE); //Render wireframe in front of polygon glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //Wireframe mode glEnable(GL_LINE_SMOOTH); //Enable AA stuDesks.drawAll(shaderManager, tPipeline, vLightEyePos, modelViewStack, vAmbient, vDarkGrey); //Draw wireframe version of desks //Reset stuff as they were before: glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_OFFSET_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_BLEND); //End cam push: modelViewStack.PopMatrix(); //End pop: modelViewStack.PopMatrix(); if (!screenshot) { newDeskButton.draw(W_WIDTH, W_HEIGHT); removeDeskButton.draw(W_WIDTH, W_HEIGHT); exportButton.draw(W_WIDTH, W_HEIGHT); } glutSwapBuffers(); if (screenshot) { char name[38]; sprintf(name, "Exports/screenshot%d.tga", expCounter); gltWriteTGA(name); counterSaver(); modelViewStack.PopMatrix(); screenshot = false; } glutPostRedisplay(); handleInput(inputTimer); }