I have a problem with OpenGL ES on Windows Mobile 5.0 devices.
This code works correctly on desctop applications. But on devices there are many problems when the rotation angle is sharp. When the vertexs of triangle has a positive sign of Z value I get a strange picture.
OpenGL ES library is here: http://sourceforge.net/projects/ogl-es/files/
The program algorithm:
- Initialize OpenGL ES
- Define projection matrix:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90,1,1,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- Draw the frame. The scene consists of only triangle, which I rotate for an rotation angle.
void Render()
{
static int Order = 1;
static float rotation = -5;
GLshort vertexArray[9] = {-25,-25,0, 25,-25,0, 0,25,0 };
GLubyte colorArray[12] = {200,0,0,0, 0,200,0,0, 0,0,200,0};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//Define an angle
rotation+=(5*Order);
// Triangle posigion
glTranslatef(0,0,-20);
glRotatef(-rotation,1,0,0);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_SHORT, 0, vertexArray);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4,GL_UNSIGNED_BYTE, 0, colorArray);
glDrawArrays(GL_TRIANGLES, 0, 3);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
eglSwapBuffers(glesDisplay, glesSurface);
}
- I wrote on eMbedded C++4.0. But I’ve tred on C# and it works the same .