Opengl es Opengl es 2.0中的正交投影矩阵
==================================================================================Opengl es Opengl es 2.0中的正交投影矩阵,opengl-es,opengl-es-2.0,Opengl Es,Opengl Es 2.0,================================================================================== 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 = "\ a
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;\
}";
=====================================================================
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(GLU颜色缓冲位);
int i32Location=glGetUniformLocation(uiProgramObject,“myPMVMatrix”);
glUniformMatrix4fv(I32位置,1,GL_假,pfIdentity);
GlenableVertexAttributeArray(顶点数组);
glvertexattributepointer(顶点数组,3,GL\u浮点,GL\u假,0,0);
gldrawArray(GL_三角形,0,i);
EGLSWAPBuffer(EGL显示、EGL表面);
}
返回0;
}
p、 s:我正在用kronos头在Ubuntu10.10中制作opengl es,它是linux中opengl es 2.0的模拟器。你根本没有投影。要将
myPMVMatrix
设置为统一的投影模型视图矩阵为
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;
}
顺便说一句:制服的概念是,你不需要在每次原始迭代中设置它们
无论如何,这是一个单位矩阵,由于它是唯一应用的变换,它将只通过顶点,就像它们通过碎片阶段一样。问题的解决方案是对其应用正交投影,即将该矩阵与正交投影矩阵相乘,然后使用该运算的结果 嗨,我做不到这一点,我不知道在哪里可以改变这件事,如果你能告诉我,这对我来说很容易走得更远。阅读它,理解它,使用您的新知识构建正交投影矩阵,并使用glUniformMatrix将其提供给着色器。