OpenGL04
来源:互联网 发布:逐浪cms开源吗 编辑:程序博客网 时间:2024/04/28 19:33
void glFrontFace(GLenum mode);
作用是控制多边形的正面是如何决定的。在默认情况下,mode是GL_CCW。
mode的值为:
GL_CCW 表示窗口坐标上投影多边形的顶点顺序为逆时针方向的表面为正面。
GL_CW 表示顶点顺序为顺时针方向的表面为正面。
顶点的方向又称为环绕。
创建镜子里图像
MoudleMatrix.Scale(1.0f, -1.0f, 1.0f); // 翻转矩阵
MoudleMatrix.Translate(0.0f, 0.8f, 0.0f);
MoudleMatrix.Translate(0.0f, 0.8f, 0.0f);
glFrontFace(GL_CW);
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 spaceM3DVector4fvLightTransformed;M3DMatrix44f mCamera;modelViewMatrix.GetMatrix(mCamera);m3dTransformVector4(vLightTransformed, vLightPos, mCamera);// Draw the light sourcemodelViewMatrix.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 dancemodelViewMatrix.Translate(0.0f, 0.2f, -2.5f);modelViewMatrix.PushMatrix();// Saves the translated originmodelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);// Draw stuff relative to the cameraglBindTexture(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 rotatemodelViewMatrix.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();
glFrontFace(GL_CCW);
0 0