所以我开始学习OpenGL,阅读“OpenGL Super Bible 5 ed.”一书.它解释得非常好,我自己也能够创建我的第一个gl程序!简单的东西,一个旋转的三维金字塔.
现在由于某种原因,其中一个面不会渲染.我检查了椎体(首先在纸上绘制)并且看起来是正确的.如果我更改着色器以绘制线环,则会发现它会渲染.但是它不会呈现三角形.有人可以解释为什么吗
void setupRC() { glClearColor(0.0f,0.0f,1.0f); shaderManager.InitializeStockShaders(); M3DVector3f vVerts1[] = {-0.5f,-0.5f,0.5f,-0.5f}; M3DVector3f vVerts2[] = {-0.5f,0.5f}; M3DVector3f vVerts3[] = {-0.5f,0.5f}; M3DVector3f vVerts4[] = {0.5f,-0.5f}; triangleBatch1.Begin(GL_LINE_LOOP,3); triangleBatch1.CopyVertexData3f(vVerts1); triangleBatch1.End(); triangleBatch2.Begin(GL_TRIANGLES,3); triangleBatch2.CopyVertexData3f(vVerts2); triangleBatch2.End(); triangleBatch3.Begin(GL_TRIANGLES,3); triangleBatch3.CopyVertexData3f(vVerts3); triangleBatch3.End(); triangleBatch4.Begin(GL_TRIANGLES,3); triangleBatch4.CopyVertexData3f(vVerts4); triangleBatch4.End(); glEnable(GL_CULL_FACE); } float rot = 1; void renderScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GLfloat vRed[] = {1.0f,0.5f}; GLfloat vBlue[] = {0.0f,1.0f,0.5f}; GLfloat vGreen[] = {0.0f,0.5f}; GLfloat vWhite[] = {1.0f,0.5f}; M3DMatrix44f transformMatrix; if (rot >= 360) rot = 0; else rot = rot + 1; m3dRotationMatrix44(transformMatrix,m3dDegToRad(rot),0.0f); shaderManager.UseStockShader(GLT_SHADER_FLAT,transformMatrix,vRed); triangleBatch1.Draw(); shaderManager.UseStockShader(GLT_SHADER_FLAT,vBlue); triangleBatch2.Draw(); shaderManager.UseStockShader(GLT_SHADER_FLAT,vGreen); triangleBatch3.Draw(); shaderManager.UseStockShader(GLT_SHADER_FLAT,vWhite); triangleBatch4.Draw(); glutSwapBuffers(); glutPostRedisplay(); Sleep(10); }