本文整理汇总了C++中GLMatrixStack::Scale方法的典型用法代码示例。如果您正苦于以下问题:C++ GLMatrixStack::Scale方法的具体用法?C++ GLMatrixStack::Scale怎么用?C++ GLMatrixStack::Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLMatrixStack
的用法示例。
在下文中一共展示了GLMatrixStack::Scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: RenderDwudziestoscian
void RenderDwudziestoscian(float xPos, float yPos, float zPos, float scale) {
matrixStack.PushMatrix();
matrixStack.Translate(xPos, yPos, zPos);
matrixStack.Scale(scale, scale, scale);
M3DMatrix44f MVMatrix;
m3dCopyMatrix44(MVMatrix, matrixStack.GetMatrix());
glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,MVMatrix);
M3DMatrix44f normalMatrix;
m3dInvertMatrix44(normalMatrix,MVMatrix);
float tmp;
// transponse
for(int n = 0; n < 3; n++) {
for(int m = n + 1; m <= 3; m++) {
tmp = normalMatrix[4*n + m];
normalMatrix[4*n + m] = normalMatrix[4*m + n];
normalMatrix[4*m + n] = tmp;
}
}
glUniformMatrix3fv(NormalMatrixLocation,1,GL_FALSE,normalMatrix);
glDrawElements(GL_TRIANGLES,3*n_faces,GL_UNSIGNED_INT,0);
matrixStack.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: DrawBaeumchen
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();
}
示例5: DrawMaennchen
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();
}
示例6: 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();
}
示例7: animate
void animate() {
frameNo++;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glUseProgram(shader);
//cameraAngleX += randf() * 5.0;
//cameraAngleY += randf() * 2.7;
//cameraAngleZ += randf() * 50.0;
cameraBothZ += randf() * 10.0;
matrixStack.LoadIdentity();
matrixStack.PushMatrix();
matrixStack.Scale(0.1,0.1,0.1);
//Perspektywa + krêcenie kamery
matrixStack.Rotate(40, 1, 0, 0);
matrixStack.Rotate(cameraBothZ, 0, 0, 1);
glUniformMatrix4fv(PMatrixLocation,1,GL_FALSE,matrixStack.GetMatrix());
float ambient[] = {0.5,0.2,0.2}, diffuse[] = {0.5,0.2,1}, specular[] = {0.2,1,0.2};
material.setMaterial(ambient, diffuse, specular, 1);
float color[] = {1,1,1}, position[] = {0,0,-1};
light.setLight(position, color, 180, 1, 1, 2);
float ambientLight[] = {1,1,1};
glUniform3fv(ambientLightLocation, 1, ambientLight);
float small_color[] = {1,1,1}, small_position[] = {5 + 2*cos(frameNo/180.0*PI/2.0), 5 + 2*sin(frameNo/180.0*PI/2.0), -1};
small_light.setLight(small_position, small_color, 180, 1, 1, 2);
matrixStack.PopMatrix();
//siatka
pushSiatka();
float ambient2[] = {0.2,0.2,0.2};
material.setMaterial(ambient2, diffuse, specular, 1);
RenderDwudziestoscian(5,5,-2,0.8);
RenderDwudziestoscian(-5,-5,-2,0.5);
RenderDwudziestoscian(small_position[0], small_position[1], small_position[2], 0.2);
glutSwapBuffers();
}
示例8: 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();
}
示例9: 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();
}
示例10: 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();
}
示例11: 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);
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();
}
示例12: 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();
}
示例13: RenderScene
void RenderScene(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glFrontFace(GL_CW);
glUseProgram(shader);
M3DVector3f at={0.0f, 0.0f, 0.0f};
M3DVector3f up={0.0f, 0.0f, 1.0f};
M3DVector3f eye;
float angle = timer.GetElapsedSeconds()*3.14159f/8;
eye[0]= 6.8f * cos(angle);
eye[1]= 6.0f * sin(angle);
eye[2]= 25.0f;
LookAt(cameraFrame,eye,at,up);
projection.LoadMatrix(viewFrustum.GetProjectionMatrix());
modelView.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelView.LoadMatrix(mCamera);
modelView.PushMatrix();
glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix());
szachownica();
modelView.Translate(0.0f, 0.0f, 0.0f);
glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix());
rysujPiramidke();
modelView.PopMatrix();
modelView.PushMatrix();
modelView.Translate(5.0f, 0.0f, 0.0f);
glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix());
rysujPiramidke();
modelView.PopMatrix();
modelView.PushMatrix();
modelView.Translate(-5.0f, 0.0f, 0.0f);
modelView.Scale(2.0f, 2.0f, 2.0f);
glUniformMatrix4fv(MVMatrixLocation,1,GL_FALSE,geometryPipeline.GetModelViewProjectionMatrix());
rysujPiramidke();
modelView.PopMatrix();
modelView.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}
示例14: Display
void Display()
{
static CStopWatch timer;
GLfloat yRot = timer.GetElapsedSeconds() * 60.0;
M3DVector3f vCameraPosition;
M3DVector3f vCameraForward;
M3DVector3f vMirrorPosition;
M3DVector3f vMirrorForward;
void movingCylinder();
cameraFrame.GetOrigin(vCameraPosition);
cameraFrame.GetForwardVector(vCameraForward);
vMirrorPosition[0] = 0.0f;
vMirrorPosition[1] = 0.1f;
vMirrorPosition[2] = -20.0f;
mirrorFrame.SetOrigin(vMirrorPosition);
vMirrorForward[0] = vCameraPosition[0];
vMirrorForward[1] = vCameraPosition[1];
vMirrorForward[2] = (vCameraPosition[2] + 20);
m3dNormalizeVector3(vMirrorForward);
mirrorFrame.SetForwardVector(vMirrorForward);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER,fboName);
glDrawBuffers(1,fboBuffers);
glViewport(0,0,mirrorWidth,mirrorHeight);
modelViewMatrix.PushMatrix();
M3DMatrix44f mMirrorView;
mirrorFrame.GetCameraMatrix(mMirrorView);
modelViewMatrix.MultMatrix(mMirrorView);
modelViewMatrix.Scale(-1.0f,1.0f,1.0f);
glBindTexture(GL_TEXTURE_2D,textures[0]);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE,
transformPipeline.GetModelViewProjectionMatrix(),
vWhite,0);
floorBatch.Draw();
drawSun();
drawTorus(yRot);
modelViewMatrix.PopMatrix();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
glDrawBuffers(1,windowBuffer);
glViewport(0,0,mirrorWidth,mirrorHeight);
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.MultMatrix(mCamera);
modelViewMatrix.PushMatrix();
glBindTexture(GL_TEXTURE_2D,mirrorTexture);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE,
transformPipeline.GetModelViewProjectionMatrix(),0);
mirrorFrontBatch.Draw();
modelViewMatrix.PopMatrix();
modelViewMatrix.PushMatrix();
glBindTexture(GL_TEXTURE_2D,textures[0]);
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_MODULATE,
transformPipeline.GetModelViewProjectionMatrix(),
vWhite,0);
floorBatch.Draw();
drawSun();
drawTorus(yRot);
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
//control to moving cylinder
movingCylinder();
glutSwapBuffers();
glutPostRedisplay();
}
示例15: renderScene
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
modelViewM.PushMatrix();
M3DMatrix44f cameraM;
cameraFrame.GetCameraMatrix(cameraM);
modelViewM.MultMatrix(cameraM);
M3DVector4f lightPos = {0.0f, 10.0f, 5.0f, 1.0f};
M3DVector4f lightEyePos;
m3dTransformVector4(lightEyePos, lightPos, cameraM);
GLfloat whiteLight[] = {1.0f, 1.0f, 1.0f, 1.0f};
modelViewM.PushMatrix();
modelViewM.Translate(0, 0, -3);
M3DMatrix44f objectM;
objectFrame.GetMatrix(objectM);
modelViewM.MultMatrix(objectM);
glBindTexture(GL_TEXTURE_2D, textureID[0]);
#if 0
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF,
pipelineTransform.GetModelViewMatrix(),
pipelineTransform.GetProjectionMatrix(),
lightEyePos, whiteLight, 0);
#else
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE,
pipelineTransform.GetModelViewProjectionMatrix(),
0);
#endif
cuboidBatch.Draw();
modelViewM.PopMatrix();
static CStopWatch timer;
float angle = timer.GetElapsedSeconds() * 120;
modelViewM.Translate(0.5f, 0.6f, -5);
modelViewM.Rotate(angle, 1, 1, 1);
modelViewM.Scale(0.5/cuboidLength, 0.3/cuboidHeigth, 0.4/cuboidWidth);
glBindTexture(GL_TEXTURE_2D, textureID[1]);
#if 0
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF,
pipelineTransform.GetModelViewMatrix(),
pipelineTransform.GetProjectionMatrix(),
lightEyePos, whiteLight, 0);
#else
shaderManager.UseStockShader(GLT_SHADER_TEXTURE_REPLACE,
pipelineTransform.GetModelViewProjectionMatrix(),
0);
#endif
cuboidBatch.Draw();
modelViewM.PopMatrix();
glutSwapBuffers();
glutPostRedisplay();
}