本文整理汇总了C++中GLMatrixStack::MultMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ GLMatrixStack::MultMatrix方法的具体用法?C++ GLMatrixStack::MultMatrix怎么用?C++ GLMatrixStack::MultMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLMatrixStack
的用法示例。
在下文中一共展示了GLMatrixStack::MultMatrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: RenderScene
///////////////////////////////////////////////////////////////////////////////
// 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();
}
示例4: 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();
}
示例5: RenderScene
// Called to draw scene
void RenderScene(void)
{
// Clear the window
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
M3DMatrix44f mCamera;
M3DMatrix44f mCameraRotOnly;
M3DMatrix44f mInverseCamera;
viewFrame.GetCameraMatrix(mCamera, false);
viewFrame.GetCameraMatrix(mCameraRotOnly, true);
m3dInvertMatrix44(mInverseCamera, mCameraRotOnly);
modelViewMatrix.PushMatrix();
// Draw the sphere
modelViewMatrix.MultMatrix(mCamera);
glUseProgram(reflectionShader);
glUniformMatrix4fv(locMVPReflect, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
glUniformMatrix4fv(locMVReflect, 1, GL_FALSE, transformPipeline.GetModelViewMatrix());
glUniformMatrix3fv(locNormalReflect, 1, GL_FALSE, transformPipeline.GetNormalMatrix());
glUniformMatrix4fv(locInvertedCamera, 1, GL_FALSE, mInverseCamera);
glUniform1i(locCubeMap, 0);
glUniform1i(locTarnishMap, 1);
glEnable(GL_CULL_FACE);
sphereBatch.Draw();
glDisable(GL_CULL_FACE);
modelViewMatrix.PopMatrix();
modelViewMatrix.PushMatrix();
modelViewMatrix.MultMatrix(mCameraRotOnly);
glUseProgram(skyBoxShader);
glUniformMatrix4fv(locMVPSkyBox, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());
cubeBatch.Draw();
modelViewMatrix.PopMatrix();
// Do the buffer Swap
glutSwapBuffers();
}
示例6: RenderScene
// 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();
}
示例7: RenderScene
///////////////////////////////////////////////////////////////////////////////
// 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);
// Reflection step... draw cube upside down, the floor
// blended on top of it
if(nStep == 5) {
glDisable(GL_CULL_FACE);
modelViewMatrix.PushMatrix();
modelViewMatrix.Scale(1.0f, -1.0f, 1.0f);
modelViewMatrix.Translate(0.0f, 2.0f, 0.0f);
modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f);
RenderBlock();
modelViewMatrix.PopMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderFloor();
glDisable(GL_BLEND);
}
modelViewMatrix.PushMatrix();
// Draw normally
modelViewMatrix.Rotate(35.0f, 0.0f, 1.0f, 0.0f);
RenderBlock();
modelViewMatrix.PopMatrix();
// If not the reflection pass, draw floor last
if(nStep != 5)
RenderFloor();
modelViewMatrix.PopMatrix();
// Flush drawing commands
glutSwapBuffers();
}
示例8: RenderScene
void RenderScene(void) {
// Clear the window with current clearing color
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glUseProgram(shader);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CW);
CStopWatch timer;
float angle = timer.GetElapsedSeconds()*3.14f;
M3DVector3f mAt={0,0,0};
M3DVector3f mUp={0,0,1};
M3DVector3f mEye;
mEye[0]=6.8f*cos(angle);
mEye[1]=6.0f*sin(angle);
mEye[2]=5.0f;
LookAt(mFrame,mEye,mAt,mUp);
mFrame.GetCameraMatrix(mCameraMatrix);
matrixStack.LoadMatrix(mFrustrum.GetProjectionMatrix());
matrixStack.MultMatrix(mCameraMatrix);
glUniformMatrix4fv(MVPMatrixLocation, 1, GL_FALSE, matrixStack.GetMatrix());
drawGrid();
matrixStack.Translate(1.0f,7.0f,0.0f);
matrixStack.Rotate(30.0f,0.0,0.0,1.0);
glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix());
drawPyramid();
matrixStack.PopMatrix();
matrixStack.Translate(-7.0f,0.0f,0.0f);
matrixStack.Scale(2.0f, 2.0f, 2.0f);
glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix());
drawPyramid();
matrixStack.PopMatrix();
// Perform the buffer swap to display back buffer
glutSwapBuffers();
glutPostRedisplay();
}
示例9: RenderScene
void RenderScene()
{
// Clear the window and the depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
{ ScopedMatrix m(modelViewMatrix);
modelViewMatrix.MultMatrix(viewFrame);
glUseProgram(texturedIdentity);
glBindTexture(GL_TEXTURE_2D, stoneTexture);
locTextureUniform = glGetUniformLocation(texturedIdentity, "colorMap");
glUniform1i(locTextureUniform, 0);
triangleBatch.Draw();
}
glutSwapBuffers();
}
示例10: Display
void Display()
{
// 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();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
if (reflecting)
{
// Draw the "reflection" of the scene upside down
modelViewMatrix.PushMatrix();
// Flip the y-axis last.
modelViewMatrix.Scale(1.0f, -1.0f, 1.0f);
// The scene is essentially in a pit, bo elevate it an equal distance from the
// x-z plane to ensure that its reflection will appear to be below the ground.
modelViewMatrix.Translate(0.0f, -2.0f * FLOOR_HEIGHT, 0.0f);
// Reverse the orientation of all polygonsm in the scene so the orientation of
// their reflections will produce the same lighting as the above-ground scene.
glFrontFace(GL_CW);
DrawScene();
glFrontFace(GL_CCW);
modelViewMatrix.PopMatrix();
}
DrawGround();
DrawScene();
modelViewMatrix.PopMatrix();
// Do the buffer Swap
glutSwapBuffers();
// Tell GLUT to do it again
glutPostRedisplay();
}
示例11: DrawSongAndDance
void DrawSongAndDance(GLfloat yRot) // Called to draw dancing objects
{
static GLfloat vWhite[] = { 1.0f, 1.0f, 1.0f, 1.0f };
static GLfloat vLightPos[] = { 0.0f, 3.0f, 0.0f, 1.0f };
// Get the light position in eye space
M3DVector4f vLightTransformed;
M3DMatrix44f mCamera;
modelViewMatrix.GetMatrix(mCamera);
m3dTransformVector4(vLightTransformed, vLightPos, mCamera);
// Draw the light source
modelViewMatrix.PushMatrix();
modelViewMatrix.Translatev(vLightPos);
shaderManager.UseStockShader(GLT_SHADER_FLAT,
transformPipeLine.GetModelViewProjectionMatrix(),
vWhite);
sphereBatch.Draw();
modelViewMatrix.PopMatrix();
glBindTexture(GL_TEXTURE_2D, uiTextures[2]);
for (int i = 0; i < NUM_SPHERES; i++) {
modelViewMatrix.PushMatrix();
modelViewMatrix.MultMatrix(spheres[i]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF,
modelViewMatrix.GetMatrix(),
transformPipeLine.GetProjectionMatrix(),
vLightTransformed,
vWhite,
0);
sphereBatch.Draw();
modelViewMatrix.PopMatrix();
}
// Song and dance
modelViewMatrix.Translate(0.0f, 0.2f, -2.5f);
modelViewMatrix.PushMatrix(); // Saves the translated origin
modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);
// Draw stuff relative to the camera
glBindTexture(GL_TEXTURE_2D, uiTextures[1]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF,
modelViewMatrix.GetMatrix(),
transformPipeLine.GetProjectionMatrix(),
vLightTransformed,
vWhite,
0);
torusBatch.Draw();
modelViewMatrix.PopMatrix(); // Erased the rotate
modelViewMatrix.Rotate(yRot * -2.0f, 0.0f, 1.0f, 0.0f);
modelViewMatrix.Translate(0.8f, 0.0f, 0.0f);
glBindTexture(GL_TEXTURE_2D, uiTextures[2]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF,
modelViewMatrix.GetMatrix(),
transformPipeLine.GetProjectionMatrix(),
vLightTransformed,
vWhite,
0);
sphereBatch.Draw();
}
示例12: RenderScene
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);
modelViewMatrix.PushMatrix();
{
//反向
modelViewMatrix.Scale(1.0f, -1.0f, 1.0f);
//因为是反向,所以正数是向下
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();
// 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 depth testing off
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glUseProgram(sphereWolrdShader);
glUniform1i(locTexture, 0);
glUniformMatrix4fv(locMVP, 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);
// Do the buffer Swap
glutSwapBuffers();
// Do it again
glutPostRedisplay();
}
示例13: RenderScene
///////////////////////////////////////////////////////////////////////////////
// Render a frame. The owning framework is responsible for buffer swaps,
// flushes, etc.
void RenderScene(void)
{
static CStopWatch animationTimer;
static float totalTime = 6; // To go back and forth
static float halfTotalTime = totalTime/2;
float seconds = animationTimer.GetElapsedSeconds() * speedFactor;
float xPos = 0;
// Calculate the next postion of the moving object
// First perform a mod-like operation on the time as a float
while(seconds > totalTime)
seconds -= totalTime;
// Move object position, if it's gone half way across
// start bringing it back
if(seconds < halfTotalTime)
xPos = seconds -halfTotalTime*0.5f;
else
xPos = totalTime - seconds -halfTotalTime*0.5f;
// First draw world to screen
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]); // Marble
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE, transformPipeline.GetModelViewProjectionMatrix(), vWhite, 0);
floorBatch.Draw();
DrawWorld(0.0f, xPos);
modelViewMatrix.PopMatrix();
if(bUsePBOPath)
{
#ifndef OPENGL_ES
// First bind the PBO as the pack buffer, then read the pixels directly to the PBO
glBindBuffer(GL_PIXEL_PACK_BUFFER, pixBuffObjs[0]);
glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
// Next bind the PBO as the unpack buffer, then push the pixels straight into the texture
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixBuffObjs[0]);
// Setup texture unit for new blur, this gets imcremented every frame
glActiveTexture(GL_TEXTURE0+GetBlurTarget0() );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
#endif
}
else
{
// Grab the screen pixels and copy into local memory
glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, pixelData);
// Push pixels from client memory into texture
// Setup texture unit for new blur, this gets imcremented every frame
glActiveTexture(GL_TEXTURE0+GetBlurTarget0() );
#ifndef OPENGL_ES
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pixelData);
#else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, pixelData);
#endif
}
// Draw full screen quad with blur shader and all blur textures
projectionMatrix.PushMatrix();
projectionMatrix.LoadIdentity();
projectionMatrix.LoadMatrix(orthoMatrix);
modelViewMatrix.PushMatrix();
modelViewMatrix.LoadIdentity();
glDisable(GL_DEPTH_TEST);
SetupBlurProg();
screenQuad.Draw();
glEnable(GL_DEPTH_TEST);
modelViewMatrix.PopMatrix();
projectionMatrix.PopMatrix();
// Move to the next blur texture for the next frame
AdvanceBlurTaget();
// Do the buffer Swap
glutSwapBuffers();
// Do it again
glutPostRedisplay();
UpdateFrameCount();
}
示例14: RenderScene
// Aufruf draw scene
void RenderScene(void) {
// Clearbefehle für den color buffer und den depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Schalte culling ein falls das Flag gesetzt ist
if (bCull) {
glEnable(GL_CULL_FACE);
}
else {
glDisable(GL_CULL_FACE);
}
// Schalte depth testing ein falls das Flag gesetzt ist
if (bDepth) {
glEnable(GL_DEPTH_TEST);
}
else {
glDisable(GL_DEPTH_TEST);
}
// Zeichne die Rückseite von Polygonen als Drahtgitter falls das Flag gesetzt ist
if (bOutline) {
glPolygonMode(GL_BACK, GL_LINE);
}
else {
glPolygonMode(GL_BACK, GL_FILL);
}
// Speichere den matrix state und führe die Rotation durch
modelViewMatrix.PushMatrix();
M3DMatrix44f rot;
m3dQuatToRotationMatrix(rot, rotation);
modelViewMatrix.MultMatrix(rot);
//setze den Shader für das Rendern
shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix());
// zusaetzliche Transformationen bei persp. Projektion
if (bPerspectiveProj) {
// Vektor fuer UFO-Bewegungsmodus draufrechnen
modelViewMatrix.Translate(ufoMove[0], ufoMove[1], ufoMove[2]);
// Vektor fuer Drehungen um x- oder y-Achse draufrechnen
modelViewMatrix.Rotate(viewAngleX, 0.0f, 1.0f, 0.0f );
modelViewMatrix.Rotate(viewAngleY, 1.0f, 0.0f, 0.0f);
// Augenpunktstransformation
modelViewMatrix.Translate(0.0f, 0.0f, -1000.0f);
}
//Zeichne Objekte
modelViewMatrix.PushMatrix();
modelViewMatrix.Translate(0, -110, 0);
DrawBaeumchen();
modelViewMatrix.PopMatrix();
DrawMaennchen(animationAngle += GL_PI / 15);
// Hole die im Stack gespeicherten Transformationsmatrizen wieder zurück
modelViewMatrix.PopMatrix();
TwDraw();
// Vertausche Front- und Backbuffer
glutSwapBuffers();
glutPostRedisplay();
}
示例15: RenderScene
/**
* 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();
}