我试图将我的 OpenGL 应用程序转换为 OpenGL ES。我以这种方式在 Mac 上绘制元素:
glUseProgram(m_program);
// Update uniform value.
glUniform4f(uniforms[UNIFORM_COLOR], (GLfloat)color[0], (GLfloat)color[1], (GLfloat)color[2], (GLfloat)color[3]);
// Update attribute values.
glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, data);
glEnableVertexAttribArray(ATTRIB_VERTEX);
// Validate program before drawing. This is a good check, but only really necessary in a debug build.
// DEBUG macro must be defined in your debug configurations if that's not already the case.
glDrawElements(GL_TRIANGLE_STRIP, count, GL_UNSIGNED_INT, indices);
一切都很好,但是当我尝试在 iPhone 4(iOS 4.2 和 XCode 3.2.5)上以这种方式绘制时,我什么也看不到。奇怪的是所有计算都完成了,当我尝试用 glDrawArrays 绘制它时,屏幕上会显示一些东西(但顶点没有按正确的顺序呈现):
glUseProgram(m_program);
// Update uniform value.
glUniform4f(uniforms[UNIFORM_COLOR], (GLfloat)color[0], (GLfloat)color[1], (GLfloat)color[2], (GLfloat)color[3]);
// Update attribute values.
glVertexAttribPointer(ATTRIB_VERTEX, 3, GL_FLOAT, 0, 0, data);
glEnableVertexAttribArray(ATTRIB_VERTEX);
glDrawArrays(GL_TRIANGLE_STRIP, 0, count);
我错过了什么吗?