Hi,
I try to use OpenGL|ES in QWidget.
All is fine, when i compile and run for Win32 configuration for the PC.
But when i compile&run the same code for WM5.0 PocketPC, geometry displaying shifted.
All GLES initialization works. Nothing wrong with projection and modelview matrixes.
Here the code fragment:
Initialization GL/GLES:
CreateContext(); // platform specific initialization
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ();
glOrthof(-100, 100, 100, -100, -1, 1); // glOrtho for Win32
glMatrixMode ( GL_MODELVIEW );
glLoadIdentity ();
Resizing:
glViewport(0, 0, (GLint)width(), (GLint)height());
Draw:
SetCurrentContext(); // platform specific
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
GLfloat vertexes[] = { -100.0f, -100.0f, 0.0f, 100.0f, -100.0f, 0.0f, 100.0f, 100.0f, 0.0f, -100.0f, 100.0f, 0.0f};
GLushort indexes [] = { 2,1,0,2,0,3};
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnableClientState (GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glVertexPointer (3, GL_FLOAT, 0, vertexes);
glDrawElements (GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, indexes);
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glDrawElements (GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, indexes+3);
SwapContextBuffers();
The QT painting(QPainter) is well at correct place. GLES painting is shifted up on nealer 24 pixels.
What's wrong?
Thanks
Bookmarks