float pfIdentity[] =
{
-1.0f,0.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f
};
=============================================== ===================================
const char* pszVertShader = "\
attribute highp vec4 myVertex;\
uniform mediump mat4 myPMVMatrix;\
invariant gl_Position;\
void main(void)\
{\
gl_Position = myPMVMatrix * myVertex;\
}";
=============================================== ======================
for(int i = 0; i < 80000; ++i)
{
glClear(GL_COLOR_BUFFER_BIT);
int i32Location = glGetUniformLocation(uiProgramObject, "myPMVMatrix");
glUniformMatrix4fv( i32Location, 1, GL_FALSE, pfIdentity);
glEnableVertexAttribArray(VERTEX_ARRAY);
glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLES, 0,i);
eglSwapBuffers(eglDisplay, eglSurface);
}
return 0;
}
p.s:我正在使用kronos头文件在ubuntu 10.10中执行opengl-es,它是linux中opengl-es 2.0的模拟器。
答案 0 :(得分:1)
根本没有投影。您将myPMVMatrix
制服设置为的投影 - 模型 - 视图矩阵是
float pfIdentity[] =
{
-1.0f,0.0f,0.0f,0.0f,
0.0f,1.0f,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f
};
/* ... */
glUniformMatrix4fv( i32Location, 1, GL_FALSE, pfIdentity);
BTW:制服的想法是,你没有在每次原始迭代中设置它们。
无论如何,这是一个单位矩阵,因为它是唯一应用的变换,它只会通过顶点传递到片段阶段。您的问题的解决方案是对其应用正交投影,即将该矩阵与正投影矩阵相乘并使用该操作的结果。 http://www.songho.ca/opengl/gl_projectionmatrix.html