I am writing a plate-based game engine for the iPhone, and it works, in general, in addition to the following crash. In principle, the camera will always keep the player in the center of the screen, and it moves to properly follow the player and draws correctly when it is stationary. However, while the player is moving, the tile surface of the player comes with a glitch, as shown:
http://img41.imageshack.us/img41/9422/movingy.png
Compared to fixed (correct):
http://img689.imageshack.us/img689/7026/still.png
Can anyone understand why this could be?
Thanks for the answers so far. The floating point error was my first thought, and I tried to slightly increase the size of the tile, but that did not help. Changing glClearColor to red still leaves black gaps, so maybe this is not a floating point error. Since tiles will use different textures in general, I donβt know if vertex arrays can be used (I always thought that the same texture should be applied to the whole array, correct me if I am wrong) and I do not think VBO Available in OpenGL ES. Setting filtering for the closest neighbor improved the situation, but a failure still occurs every ten frames or so, and a pixelly result means that this solution is not viable in any case.
The main difference between what I am doing now and what I have done in the past is that this time I am moving the camera, not the stationary objects in the world (i.e. tiles, the player is still moving). The code I use to move the camera:
void Camera::CentreAtPoint( GLfloat x, GLfloat y ) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(x - size.x / 2.0f, x + size.x / 2.0f, y + size.y / 2.0f, y - size.y / 2.0f, 0.01f, 5.0f); glMatrixMode(GL_MODELVIEW); }
Is there a problem with this, and if there is a solution?