/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld() { modelViewMatrix.moveTo(0.0f, 0.8f, 0.0f); modelViewMatrix.push(); modelViewMatrix.moveTo(-0.3f, 0.f, 0.0f); modelViewMatrix.scaleTo(0.40, 0.8, 0.40); modelViewMatrix.rotateTo(50.0, 0.0, 10.0, 0.0); glSampleMaski(0, 0x02); shaderManager.useStockShader(GLT_SHADER_FLAT, transformPipeline.GetMVPMatrix(), vLtYellow); glass1Batch.draw(); modelViewMatrix.pop(); modelViewMatrix.push(); modelViewMatrix.moveTo(0.4f, 0.0f, 0.0f); modelViewMatrix.scaleTo(0.5, 0.8, 1.0); modelViewMatrix.rotateTo(-20.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x04); shaderManager.useStockShader(GLT_SHADER_FLAT, transformPipeline.GetMVPMatrix(), vLtGreen); glass2Batch.draw(); modelViewMatrix.pop(); modelViewMatrix.push(); modelViewMatrix.moveTo(1.0f, 0.0f, -0.6f); modelViewMatrix.scaleTo(0.3, 0.9, 1.0); modelViewMatrix.rotateTo(-40.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x08); shaderManager.useStockShader(GLT_SHADER_FLAT, transformPipeline.GetMVPMatrix(), vLtMagenta); glass3Batch.draw(); modelViewMatrix.pop(); modelViewMatrix.push(); modelViewMatrix.moveTo(-0.8f, 0.0f, -0.60f); modelViewMatrix.scaleTo(0.6, 0.9, 0.40); modelViewMatrix.rotateTo(60.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x10); shaderManager.useStockShader(GLT_SHADER_FLAT, transformPipeline.GetMVPMatrix(), vLtBlue); glass4Batch.draw(); modelViewMatrix.pop(); modelViewMatrix.push(); modelViewMatrix.moveTo(0.1f, 0.0f, 0.50f); modelViewMatrix.scaleTo(0.4, 0.9, 0.4); modelViewMatrix.rotateTo(205.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x20); shaderManager.useStockShader(GLT_SHADER_FLAT, transformPipeline.GetMVPMatrix(), vLtPink); glass4Batch.draw(); modelViewMatrix.pop(); }
/** * Called to draw scene */ void RenderScene(void) { static GLfloat vFloorColor[] = { 1.0f, 1.0f, 1.0f, 0.75f }; static CStopWatch rotTimer; float yRot = rotTimer.delta() * 60.0f; // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.push(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); // draw the world upside down modelViewMatrix.push(); modelViewMatrix.scaleTo(1.0f, -1.0f, 1.0f); // flips the Y axis modelViewMatrix.moveTo(0.0f, 0.8f, 0.0f); // scootch the world down a bit... glFrontFace(GL_CW); DrawSongAndDance(yRot); glFrontFace(GL_CCW); // restore it modelViewMatrix.pop(); // draw the solid ground glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, uiTextures[0]); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); shaderManager.useStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetMVPMatrix(), vFloorColor, 0); floorBatch.draw(); glDisable(GL_BLEND); DrawSongAndDance(yRot); modelViewMatrix.pop(); // Render the overlay // Creating this matrix really doesn't need to be done every frame. I'll leave it here // so all the pertenant code is together M3DMatrix44f mScreenSpace; m3dMakeOrthographicMatrix(mScreenSpace, 0.0f, 800.0f, 0.0f, 600.0f, -1.0f, 1.0f); // turn blending on, and dephth testing off glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glUseProgram(rectReplaceShader); glUniform1i(locRectTexture, 0); glUniformMatrix4fv(locRectMVP, 1, GL_FALSE, mScreenSpace); glBindTexture(GL_TEXTURE_RECTANGLE, uiTextures[3]); logoBatch.draw(); // restore no blending and depth test glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); // Perform the buffer swap to display back buffer glutSwapBuffers(); glutPostRedisplay(); }