/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld(GLfloat yRot) { M3DMatrix44f mCamera; modelViewMatrix.GetMatrix(mCamera); // Need light position relative to the Camera M3DVector4f vLightTransformed; m3dTransformVector4(vLightTransformed, vLightPos, mCamera); // Draw the light source as a small white unshaded sphere modelViewMatrix.PushMatrix(); modelViewMatrix.Translatev(vLightPos); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vWhite); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); // Draw stuff relative to the camera modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.2f, -2.5f); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeline.GetProjectionMatrix(), vLightTransformed, vGreen, 0); torusBatch.Draw(); modelViewMatrix.PopMatrix(); }
// Called to draw scene void RenderScene(void) { // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); modelViewMatix.PushMatrix(viewFrame); GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f }; GLfloat vGray[] = { 0.75f, 0.75f, 0.75f, 1.0f }; shaderManager.UseStockShader(GLT_SHADER_DEFAULT_LIGHT, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vRed); tubeBatch.Draw(); shaderManager.UseStockShader(GLT_SHADER_DEFAULT_LIGHT, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vGray); innerBatch.Draw(); modelViewMatix.PopMatrix(); glutSwapBuffers(); }
void RenderScene() { static GLfloat vSunColor[] = { 1.0f, 0.0f, 0.0f, 1.0f }; static GLfloat vEarthColor[] = { 0.0f, 0.0f, 1.0f, 1.0f }; static GLfloat vMoonColor[] = { 1.0f, 1.0f, 0.0f, 1.0f }; static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f}; static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.PushMatrix(mCamera); M3DVector4f vLightPos = { 0.0f, 10.0f, 5.0f, 1.0f }; M3DVector4f vLightEyePos; m3dTransformVector4(vLightEyePos, vLightPos, mCamera); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor); floorBatch.Draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); modelViewMatrix.Translate(0.0f, 0.0f, -3.5f); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vSunColor); sunSphereBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.8f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vEarthColor); earthSphereBatch.Draw(); modelViewMatrix.Rotate(yRot * -4.0f, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.4f, 0.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vMoonColor); moonSphereBatch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
void DrawWireFramedBatch(GLBatch* pBatch) { // Draw the batch solid green shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vGreen); pBatch->Draw(); // Draw black outline glPolygonOffset(-1.0f, -1.0f); // Shift depth values glEnable(GL_POLYGON_OFFSET_LINE); // Draw lines antialiased glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Draw black wireframe version of geometry glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glLineWidth(2.5f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack); pBatch->Draw(); // Put everything back the way we found it glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_POLYGON_OFFSET_LINE); glLineWidth(1.0f); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); }
/////////////////////////////////////////////////////////////////////////////// // Render the floor void RenderFloor(void) { GLfloat vBrown [] = { 0.55f, 0.292f, 0.09f, 1.0f}; GLfloat vFloor[] = { 1.0f, 1.0f, 1.0f, 0.6f }; switch(nStep) { // Wire frame case 0: glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glDisable(GL_CULL_FACE); break; // Wire frame, but not the back side.. and only where stencil == 0 case 1: glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_EQUAL, 0, 0xff); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); break; // Solid case 2: case 3: shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBrown); break; // Textured case 4: case 5: default: glBindTexture(GL_TEXTURE_2D, textures[0]); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloor, 0); break; } // Draw the floor floorBatch.Draw(); // Put everything back glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_CULL_FACE); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); glDisable(GL_STENCIL_TEST); }
/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld() { modelViewMatrix.Translate(0.0f, 0.8f, 0.0f); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(-0.3f, 0.f, 0.0f); modelViewMatrix.Scale(0.40, 0.8, 0.40); modelViewMatrix.Rotate(50.0, 0.0, 10.0, 0.0); glSampleMaski(0, 0x02); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtYellow); glass1Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.4f, 0.0f, 0.0f); modelViewMatrix.Scale(0.5, 0.8, 1.0); modelViewMatrix.Rotate(-20.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x04); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtGreen); glass2Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(1.0f, 0.0f, -0.6f); modelViewMatrix.Scale(0.3, 0.9, 1.0); modelViewMatrix.Rotate(-40.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x08); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtMagenta); glass3Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(-0.8f, 0.0f, -0.60f); modelViewMatrix.Scale(0.6, 0.9, 0.40); modelViewMatrix.Rotate(60.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x10); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtBlue); glass4Batch.Draw(); modelViewMatrix.PopMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.1f, 0.0f, 0.50f); modelViewMatrix.Scale(0.4, 0.9, 0.4); modelViewMatrix.Rotate(205.0, 0.0, 1.0, 0.0); glSampleMaski(0, 0x20); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vLtPink); glass4Batch.Draw(); modelViewMatrix.PopMatrix(); }
// Called to draw scene void RenderScene(void) { // Clear the window and the depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Turn culling on if flag is set if(iCull) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); // Enable depth testing if flag is set if(iDepth) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); modelViewMatix.PushMatrix(viewFrame); GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f }; //shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vRed); shaderManager.UseStockShader(GLT_SHADER_DEFAULT_LIGHT, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vRed); torusBatch.Draw(); modelViewMatix.PopMatrix(); glutSwapBuffers(); }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(); { modelViewMatrix.Translate(0.0f, 0.0f, viewZ); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeLine.GetModelViewProjectionMatrix(), 0); glBindTexture(GL_TEXTURE_2D, uiTextures[TEXTURE_FLOOR]); floorBatch.Draw(); glBindTexture(GL_TEXTURE_2D, uiTextures[TEXTURE_CEILING]); ceilingBatch.Draw(); glBindTexture(GL_TEXTURE_2D, uiTextures[TEXTURE_BRICK]); leftWallBatch.Draw(); rightWallBatch.Draw(); } modelViewMatrix.PopMatrix(); glutSwapBuffers(); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { static GLfloat vLightPos [] = { 1.0f, 1.0f, 0.0f }; static GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f }; // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); M3DMatrix44f mObjectFrame; objectFrame.GetMatrix(mObjectFrame); modelViewMatrix.MultMatrix(mObjectFrame); glBindTexture(GL_TEXTURE_2D, textureID); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(), transformPipeline.GetProjectionMatrix(), vLightPos, vWhite, 0); pyramidBatch.Draw(); modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); }
/////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.0f, viewZ); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeline.GetModelViewProjectionMatrix(), 0); glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_FLOOR]); floorBatch.Draw(); glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_CEILING]); ceilingBatch.Draw(); glBindTexture(GL_TEXTURE_2D, textures[TEXTURE_BRICK]); leftWallBatch.Draw(); rightWallBatch.Draw(); modelViewMatrix.PopMatrix(); // Buffer swap glutSwapBuffers(); }
void Display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); static CStopWatch timer; GLfloat yRot = timer.GetElapsedSeconds()*20.0f; GLfloat vWhite[] = {1.0f,1.0f,1.0f,1.0f}; GLfloat vLightPos[] = {0.0f,2.0f,2.0f}; GLfloat vAmbient[] = {0.3f,0.3f,1.0f,1.0f}; modelViewMatrix.PushMatrix(); //move to camera view M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(yRot,1.0,1.0,1.0); glBindTexture(GL_TEXTURE_2D,fbxTexture); shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, transformPipeLine.GetModelViewMatrix(), transformPipeLine.GetProjectionMatrix(), vLightPos, vWhite, 0); //*/shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeLine.GetModelViewProjectionMatrix(),vWhite); modelViewMatrix.Scale(0.05,0.05,0.05); rTest.DrawReader(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); glutSwapBuffers(); glutPostRedisplay(); }
/////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Everything is white GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f }; shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite); // Draw small stars glPointSize(1.0f); smallStarBatch.Draw(); // Draw medium sized stars glPointSize(4.0f); mediumStarBatch.Draw(); // Draw largest stars glPointSize(8.0f); largeStarBatch.Draw(); // Draw the "moon" moonBatch.Draw(); // Draw distant horizon glLineWidth(3.5); mountainRangeBatch.Draw(); moonBatch.Draw(); // Swap buffers glutSwapBuffers(); }
void DrawBaeumchen() { // Boden modelViewMatrix.PushMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, -25, 0); modelViewMatrix.Scale(20, -0.01, 20); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); modelViewMatrix.PopMatrix(); DrawCube(); // Baumstamm modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 0.0, 0); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.3, 0.5, 0.3); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); modelViewMatrix.PopMatrix(); DrawCylinder(); //unterster Kegel modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 25.0, 0); modelViewMatrix.Scale(1.5, 1.5, 1.5); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCone(); // mittlerer Kegel modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 40.0, 0); modelViewMatrix.Scale(0.75, 0.75, 0.75); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCone(); // Spitze modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 50.0, 0); modelViewMatrix.Scale(0.75, 0.75, 0.75); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCone(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); }
void DrawMaennchen(float angle) { //float overallScaleFactor = 0.2 * cos(GL_PI / 200 * angle) + 1; float jumpFactor = abs(cos(GL_PI/10 * angle)); /** * Rumpf zeichnen **/ modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(angle, 0, -1, 0); // generelle Verschiebung aus dem Mittelpunkt heraus modelViewMatrix.Translate(200.0f, 0.0f, 0.0f); // Verschiebung fuer Huepfbahn modelViewMatrix.Translate(0.0f, 30 * jumpFactor, 0); //modelViewMatrix.Scale(overallScaleFactor, overallScaleFactor, overallScaleFactor); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.9, 1.0, 0.7); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCylinder(); modelViewMatrix.PopMatrix(); // Hals modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 55.0f, 0.0f); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.25, 0.15, 0.25); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCylinder(); modelViewMatrix.PopMatrix(); // Kopf modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 40.0f, 0.0f); modelViewMatrix.Scale(0.72, 0.72, 0.72); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawSphere(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); // Giedmaßen zeichnen - abhaengig vom Rumpf! DrawLimbs(angle); modelViewMatrix.PopMatrix(); }
/////////////////////////////////////////////////////////////////////////////// // Draw the scene // void DrawWorld(GLfloat yRot) { M3DMatrix44f mCamera; modelViewMatrix.GetMatrix(mCamera); // Need light position relative to the Camera M3DVector4f vLightTransformed; m3dTransformVector4(vLightTransformed, vLightPos, mCamera); // Draw the light source as a small white unshaded sphere modelViewMatrix.PushMatrix(); modelViewMatrix.Translatev(vLightPos); if(bUseFBO) UseProcessProgram(vLightPos, vWhite, -1); else shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vWhite); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); // Draw stuff relative to the camera modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 0.2f, -2.5f); modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); modelViewMatrix.Translate(0.0, (GLfloat)-0.60, 0.0); modelViewMatrix.Scale((GLfloat)0.02, (GLfloat)0.006, (GLfloat)0.02); glBindTexture(GL_TEXTURE_2D, ninjaTex[0]); if(bUseFBO) { UseProcessProgram(vLightTransformed, vWhite, 0); } else { shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE, transformPipeline.GetModelViewProjectionMatrix(), 0); } ninja.Render(0,0); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); }
void MyGLWidget::paintGL() { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 0.8f }; shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed); squareBatch.Draw(); swapBuffers(); }
/////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Everything is white GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f }; #ifndef OPENGL_ES shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite); // Draw small stars glPointSize(1.0f); #else glUseProgram(pointSizeShader); GLint iTransform, iColor, iPointSize; iTransform = glGetUniformLocation(pointSizeShader, "mvpMatrix"); glUniformMatrix4fv(iTransform, 1, GL_FALSE, viewFrustum.GetProjectionMatrix()); iColor = glGetUniformLocation(pointSizeShader, "vColor"); glUniform4fv(iColor, 1, vWhite); iPointSize = glGetUniformLocation(pointSizeShader, "fPointSize"); glUniform1f(iPointSize, 1.0f); #endif smallStarBatch.Draw(); // Draw medium sized stars #ifdef OPENGL_ES iPointSize = glGetUniformLocation(pointSizeShader, "fPointSize"); glUniform1f(iPointSize, 4.0f); #else glPointSize(4.0f); #endif mediumStarBatch.Draw(); // Draw largest stars #ifdef OPENGL_ES iPointSize = glGetUniformLocation(pointSizeShader, "fPointSize"); glUniform1f(iPointSize, 8.0f); #else glPointSize(8.0f); #endif largeStarBatch.Draw(); // Draw the "moon" moonBatch.Draw(); // Draw distant horizon glLineWidth(3.5); mountainRangeBatch.Draw(); moonBatch.Draw(); // Swap buffers glutSwapBuffers(); }
void drawSun() { //draw the sphere batch as a sun modelViewMatrix.PushMatrix(); modelViewMatrix.Translatev(vLightPosition); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(),vWhite); sphereBatch.Draw(); modelViewMatrix.PopMatrix(); }
// Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); M3DMatrix44f identityMatrix; m3dLoadIdentity44(identityMatrix); shaderManager.UseStockShader(GLT_SHADER_SHADED, identityMatrix); triangleBatch.Draw(); // Perform the buffer swap to display back buffer glutSwapBuffers(); //glutPostRedisplay(); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f }; shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed); triangleBatch.Draw(); // Perform the buffer swap to display back buffer glutSwapBuffers(); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); M3DMatrix44f mObjectFrame; objectFrame.GetMatrix(mObjectFrame); modelViewMatrix.MultMatrix(mObjectFrame); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack); switch(nStep) { case 0: glPointSize(4.0f); pointBatch.Draw(); glPointSize(1.0f); break; case 1: glLineWidth(2.0f); lineBatch.Draw(); glLineWidth(1.0f); break; case 2: glLineWidth(2.0f); lineStripBatch.Draw(); glLineWidth(1.0f); break; case 3: glLineWidth(2.0f); lineLoopBatch.Draw(); glLineWidth(1.0f); break; case 4: DrawWireFramedBatch(&triangleBatch); break; case 5: DrawWireFramedBatch(&triangleStripBatch); break; case 6: DrawWireFramedBatch(&triangleFanBatch); break; } modelViewMatrix.PopMatrix(); // Flush drawing commands glutSwapBuffers(); }
//开始渲染 void RenderScene(void) { //清除一个或一组特定的缓冲区 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //设置一组浮点数来表示红色 GLfloat vRed[] = {1.0f,0.0f,0.0f,1.0f}; //传递到存储着色器,即GLT_SHADER_IDENTITY着色器,这个着色器只是使用指定颜色以默认笛卡尔坐标第在屏幕上渲染几何图形 shaderManager.UseStockShader(GLT_SHADER_IDENTITY,vRed); //提交着色器 triangleBatch.Draw(); //将在后台缓冲区进行渲染,然后在结束时交换到前台 glutSwapBuffers(); }
// Called to draw scene void RenderScene(void) { // Color values static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f}; static GLfloat vTorusColor[] = { 1.0f, 0.0f, 0.0f, 1.0f }; // Time Based animation static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; // Clear the color and depth buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Save the current modelview matrix (the identity matrix) modelViewMatrix.PushMatrix(); // Draw the ground shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor); floorBatch.Draw(); // Draw the spinning Torus modelViewMatrix.Translate(0.0f, 0.0f, -2.5f); modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vTorusColor); torusBatch.Draw(); // Restore the previous modleview matrix (the idenity matrix) modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Tell GLUT to do it again glutPostRedisplay(); }
/////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { static CStopWatch timer; // Clear the window glClear(GL_COLOR_BUFFER_BIT); // Everything is white GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f }; glBindTexture(GL_TEXTURE_2D, starTexture); glUseProgram(starFieldShader); glUniformMatrix4fv(locMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix()); glUniform1i(locStarTexture, 0); // Draw small stars glPointSize(4.0f); smallStarBatch.Draw(); // Draw medium sized stars glPointSize(8.0f); mediumStarBatch.Draw(); // Draw largest stars glPointSize(12.0f); largeStarBatch.Draw(); // Draw distant horizon shaderManager.UseStockShader(GLT_SHADER_FLAT, viewFrustum.GetProjectionMatrix(), vWhite); glLineWidth(3.5); mountainRangeBatch.Draw(); // Draw the "moon" glBindTexture(GL_TEXTURE_2D_ARRAY, moonTexture); glUseProgram(moonShader); glUniformMatrix4fv(locMoonMVP, 1, GL_FALSE, viewFrustum.GetProjectionMatrix()); glUniform1i(locMoonTexture, 0); // fTime goes from 0.0 to 28.0 and recycles float fTime = timer.GetElapsedSeconds(); fTime = fmod(fTime, 28.0f); glUniform1f(locTimeStamp, fTime); moonBatch.Draw(); // Swap buffers glutSwapBuffers(); glutPostRedisplay(); }
void DrawGround() { glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, groundTexture); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); static GLfloat vFloorColor[] = { 1.0f, 1.0f, 1.0f, REFLECTING_ALPHA}; if (reflecting) vFloorColor[3] = REFLECTING_ALPHA; else vFloorColor[3] = NONREFLECTING_ALPHA; shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor, 0); groundBatch.Draw(); glDisable(GL_BLEND); }
void DrawWireFramedBatch(GLBatch* pBatch) { // 绘制绿色 shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vGreen); pBatch->Draw(); // 外框 glPolygonOffset(-1.0f, -1.0f); glEnable(GL_POLYGON_OFFSET_LINE); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glLineWidth(2.5f); shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack); pBatch->Draw(); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_POLYGON_OFFSET_LINE); glLineWidth(1.0f); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); }
/////////////////////////////////////////////////////////////////////////////// // Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GLfloat vRed[] = { 1.0f, 0.0f, 0.0f, 1.0f }; shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed); squareBatch.Draw(); // Flush drawing commands glutSwapBuffers(); BounceFunction(); glutPostRedisplay(); }
void CircleSprite::setRenderState( void ) { // Blends for sprites glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); // Use the stock shader Matrix mvp = ModelView * Camera::getProjMatrix(); // flat shader shaderManager.UseStockShader(GLT_SHADER_FLAT, & mvp, & this->color); };
// Called to draw scene void RenderScene(void) { static CStopWatch rotTimer; float yRot = rotTimer.GetElapsedSeconds() * 60.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); modelViewMatrix.PushMatrix(); M3DMatrix44f mCamera; cameraFrame.GetCameraMatrix(mCamera); modelViewMatrix.MultMatrix(mCamera); // Draw the world upside down modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(1.0f, -1.0f, 1.0f); // Flips the Y Axis modelViewMatrix.Translate(0.0f, 0.8f, 0.0f); // Scootch the world down a bit... glFrontFace(GL_CW); DrawSongAndDance(yRot); glFrontFace(GL_CCW); modelViewMatrix.PopMatrix(); // Draw the solid ground glEnable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, uiTextures[0]); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); static GLfloat vFloorColor[] = { 1.0f, 1.0f, 1.0f, 0.75f}; shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vFloorColor, 0); floorBatch.Draw(); glDisable(GL_BLEND); DrawSongAndDance(yRot); modelViewMatrix.PopMatrix(); // Do the buffer Swap glutSwapBuffers(); // Do it again glutPostRedisplay(); }
void drawTorus(GLfloat yRot) { M3DMatrix44f mCamera; M3DVector4f vLightTransform; modelViewMatrix.GetMatrix(mCamera); m3dTransformVector4(vLightTransform,vLightPosition,mCamera); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0,0.5,-1.0); modelViewMatrix.Rotate(yRot,0.0,1.0,0.0); shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, modelViewMatrix.GetMatrix(), transformPipeline.GetProjectionMatrix(), vLightTransform,vGreen,0); torusBatch.Draw(); modelViewMatrix.PopMatrix(); }