本文整理汇总了C++中GLMatrixStack::PopMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ GLMatrixStack::PopMatrix方法的具体用法?C++ GLMatrixStack::PopMatrix怎么用?C++ GLMatrixStack::PopMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLMatrixStack
的用法示例。
在下文中一共展示了GLMatrixStack::PopMatrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderScene
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();
}
示例2: DrawWorld
///////////////////////////////////////////////////////////////////////////////
// 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();
}
示例3: Display
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();
}
示例4: render
/**
* @fn void ScreenRepaint::render(GLMatrixStack &modelViewStack, GLMatrixStack &projectionStack,
* GLShaderManager &shaderManager);
*
* @brief Renders the quad. Note! THis should be called *after* all 3D drawing (i.e. after postDraw3D()), but *before* draw2D()
* The steps are as follows:
* First bind the PBO as the pack buffer, then read the pixels directly to the PBO and unbind
* Next bind the PBO as the unpack buffer, then push the pixels straight into the texture
* Setup texture unit for the render surface
* switch to the GL_TEXTURE* value that we are using as our screen texture holder
* write the pixels
* unbind
* Draw full screen quad with screen textures, calling setupScreenRenderProg() to access the chaders for the effect desired.
*
*
*
* @author Phil
* @date 3/15/2012
*
* @param [in,out] modelViewStack modelviewMatrix stack
* @param [in,out] projectionStack projection matrix stack
* @param [in,out] shaderManager Manager of default shaders
*/
void ScreenRepaint::render(GLMatrixStack &modelViewStack, GLMatrixStack &projectionStack, GLShaderManager &shaderManager){
// First bind the PBO as the pack buffer, then read the pixels directly to the PBO
glBindBuffer(GL_PIXEL_PACK_BUFFER, pixBuffObjs[0]); // bind
glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, NULL); // act
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); // unbind
// Next bind the PBO as the unpack buffer, then push the pixels straight into the texture
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixBuffObjs[0]); // bind
// Setup texture unit for the render surface
glActiveTexture(screenTextureID); // switch to the GL_TEXTURE* value that we are using as our screen texture holder
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); // write the pixels
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); // unbind
// Draw full screen quad with screen textures
projectionStack.PushMatrix();
projectionStack.LoadMatrix(orthoMatrix);
modelViewStack.PushMatrix();
modelViewStack.LoadIdentity();
glDisable(GL_DEPTH_TEST);
setupScreenRenderProg(projectionStack.GetMatrix());
screenQuad.Draw();
glEnable(GL_DEPTH_TEST);
modelViewStack.PopMatrix();
projectionStack.PopMatrix();
}
示例5: render_scene
void render_scene(void) {
float angle = timer.GetElapsedSeconds() * 3.14f / 10.0f;
location[0] = -8.0f * cos(angle / 2.0f);
location[1] = -8.0f * sin(angle / 2.0f);
location[2] = 5.0f;
light_0.position[0] = 10.0f * cos(-angle);
light_0.position[1] = 10.0f * sin(-angle);
light_0.position[2] = 3.0f;
look_at(camera_frame, location, target, up_dir);
camera_frame.GetCameraMatrix(camera_matrix);
p_stack.LoadMatrix(view_frustum.GetProjectionMatrix());
mv_stack.LoadMatrix(camera_matrix);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
//--
glUseProgram(shader_color);
mv_stack.PushMatrix();
mv_stack.Translate(light_0.position[0], light_0.position[1], light_0.position[2]);
mv_stack.Scale(0.25f, 0.25f, 0.25f);
glUniformMatrix4fv(mvp_matrix_location_shader_color, 1, GL_FALSE, geometry_pipeline.GetModelViewProjectionMatrix());
draw_light();
mv_stack.PopMatrix();
//--
glUseProgram(shader_light);
glUniformMatrix3fv(normal_matrix_location, 1, GL_FALSE, geometry_pipeline.GetNormalMatrix());
glUniformMatrix4fv(v_matrix_location, 1, GL_FALSE, camera_matrix);
glUniform3fv(intensity_ambient_component_location, 1, intensity_ambient_component);
glUniform3fv(light_0_position_location, 1, light_0.position);
glUniform3fv(light_0_intensity_diffuse_location, 1, light_0.intensity_diffuse);
glUniform3fv(light_0_intensity_specular_location, 1, light_0.intensity_specular);
glUniform3fv(light_0_attenuation_location, 1, light_0.attenuation);
glUniform1f(material_0_ka_location, material_0.ka);
glUniform1f(material_0_kd_location, material_0.kd);
glUniform1f(material_0_ks_location, material_0.ks);
glUniform1f(material_0_alpha_location, material_0.alpha);
//--
for(int i = -10; i <= 10; i += 3)
for(int j = -10; j <= 10; j += 3) {
mv_stack.PushMatrix();
mv_stack.Translate(i, j, 0.0f);
glUniformMatrix4fv(mvp_matrix_location, 1, GL_FALSE, geometry_pipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(mv_matrix_location, 1, GL_FALSE, geometry_pipeline.GetModelViewMatrix());
glDrawElements(GL_TRIANGLES, faces.size(), GL_UNSIGNED_INT, 0);
mv_stack.PopMatrix();
}
//--
glUseProgram(0);
glutSwapBuffers();
glutPostRedisplay();
}
示例6: DrawWorld
///////////////////////////////////////////////////////////////////////////////
// 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();
}
示例7: RenderScene
// 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();
}
示例8: RenderScene
///////////////////////////////////////////////////////////////////////////////
// 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();
}
示例9: RenderScene
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();
}
示例10: RenderScene
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
modelViewMatrix.MultMatrix(mRotation);
glUseProgram(myShader);
//mWcgCube.Draw(locMVP, modelViewMatrix, transformPipeline);
mWcgCube.DrawRotate(0, 30, locMVP, modelViewMatrix, transformPipeline);
//glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
//cubeBatch.Draw();
//sphereBatch.Draw();
//triangleBatch.Draw();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例11: RenderScene
void RenderScene(void)
{
static CStopWatch rotTimer;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
{
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.f, 0.0f, 1.0f, 0.0f);
glUseProgram(toonShader);
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeLine.GetModelViewMatrix());
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeLine.GetModelViewProjectionMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeLine.GetNormalMatrix());
glUniform3fv(locLP, 1, vEyeLight);
glUniform1i(locColorTable, 0);
torusBatch.Draw();
}
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例12: RenderScene
// 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();
}
示例13: RenderScene
// Called to draw scene
void RenderScene(void)
{
static CStopWatch rotTimer;
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 10.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Rotate(rotTimer.GetElapsedSeconds() * 13.0f, 1.0f, 0.0f, 0.0f);
GLfloat vEyeLight[] = { -100.0f, 100.0f, 100.0f };
GLfloat vAmbientColor[] = { 0.1f, 0.1f, 0.1f, 1.0f };
GLfloat vDiffuseColor[] = { 0.1f, 1.0f, 0.1f, 1.0f };
GLfloat vSpecularColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
glUseProgram(explodeProgram);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix());
float push_out = sinf(rotTimer.GetElapsedSeconds() * 3.0f) * 0.1f + 0.2f;
glUniform1f(locPushOut, push_out);
torusBatch.Draw();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例14: RenderScene
// Called to draw scene
static void RenderScene(void)
{
static CStopWatch rotTimer;
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewMatrix.PushMatrix(viewFrame);
modelViewMatrix.Rotate(40.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Rotate(20.0f, 1.0f, 0.0f, 0.0f);
float f = (float)rotTimer.GetElapsedSeconds();
GLfloat vViewpoint[] = { sinf(f * 3.1f) * 30.0f, cosf(f * 2.4f) * 30.0f, sinf(f * 1.7f) * 30.0f };
glUseProgram(cullingShader);
glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(locMV, 1, GL_FALSE, transformPipeline.GetModelViewMatrix());
glUniformMatrix3fv(locNM, 1, GL_FALSE, transformPipeline.GetNormalMatrix());
glUniform3fv(locViewpoint, 1, vViewpoint);
torusBatch.Draw();
modelViewMatrix.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例15: RenderScene
///////////////////////////////////////////////////////
// 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();
}