Why doesn't my OpenGL ES view update when using the following code?
I am programming an OpenGL game for the iPhone, and have this code that is called 24 times a second, meant to update the view:
[gameWorld update];开发者_如何学编程
glColor3f(1.0f, 0.85f, 0.35f);
glBegin(GL_QUADS); {
glVertex3f(gameWorld.player.x, gameWorld.player.y, 0);
glVertex3f(gameWorld.player.x+10, gameWorld.player.y, 0);
glVertex3f(gameWorld.player.x+10, gameWorld.player.y+20, 0);
glVertex3f(gameWorld.player.x, gameWorld.player.y+20, 0);
}
glEnd();
Where [gameWorld update] calls the code necessary to change the gameWorld.player.x based on what key is pressed (this works). My problem is that the yellow rectangle drawn on the screen doesn't move after the glBegin() block. Any ideas why?
glBegin()/glEnd() is not supported on OpenGL ES 1.1.
You might want to take a look at this post which explains how to perform similar operations. Basically, for drawing a triangle:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, triVertices);
glDrawArrays(GL_TRIANGLES, 0, 3);
精彩评论