Reputation: 1216
I'm rendering simple scene with library GLESv1_CM on Android with NDK.
void render(Rect viewport)
{
glViewport(viewport.left, viewport.top, viewport.Width(), viewport.Height());
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(viewport.left, viewport.right, viewport.top, viewport.bottom, -1, 1);
GLfloat points[] = { 5, 50, 1, 1, 1, 1,
7, 50, 1, 1, 1, 1,
7, 50, 1, 0, 0, 1,
7, 52, 1, 0, 0, 1,
8, 50, 0, 1, 0, 1,
10, 50, 0, 1, 0, 1};
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(2,GL_FLOAT,sizeof(GLfloat)*6,&points);
glColorPointer(4,GL_FLOAT,sizeof(GLfloat)*6,&points[2]);
glDrawArrays(GL_LINES,0,6);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
}
I wish to have 3 crossed lines, but when I run it on device with android 2.2 or 3.2 i have this:
Even more, on Android emulator with Android 4 (update: same on emulator with 2.3) i have this:
Is it possible to make it looks like on this picture on all devices with all Android versions without using opengl2?
Thank you
Upvotes: 0
Views: 620
Reputation: 38717
According to the OpenGL FAQ for this type of projection:
If exact pixelization is required, you might want to put a small translation in the ModelView matrix, as shown below:
glMatrixMode (GL_MODELVIEW); glLoadIdentity (); glTranslatef (0.375, 0.375, 0.);
I imagine this reduces the likelihood of rounding issues.
Upvotes: 1