problem with OpenGL ES

Started by
6 comments, last by kabu 14 years, 7 months ago
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: 1. Initialize OpenGL ES 2. Define projection matrix: Code: glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90,1,1,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); 3. Draw the frame. The scene consists of only triangle, which I rotate for an rotation angle. Code: 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 .
Advertisement

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
//Define an angle
rotation+=(5*Order);

maybe should be
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Define an angle
rotation+=(5*Order);

What is your resize code?

Hope this helps.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
I set MatrixMode on initialization.
When I render the frame active is GL_MODELVIEW

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90,1,1,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
Quote:Original post by kabu
I set MatrixMode on initialization.
When I render the frame active is GL_MODELVIEW

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90,1,1,100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


Yes, I see it, but maybe your program is calling a resize method and changing current matrix, that's a common mistake on windows opengl programs, however I'm not sure how this part works on a handheld device, where program window has always the same size. Try it out, maybe is that.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time, like tears in rain. Time to die.
This programm code works on desktop successfully (!), but on mobile devices it works illegal. I posted my problem in many forums, but solution not found yet. Programm code is very simple, I just draw a triangle and rotate it. That's all
What's the real problem? Can you post screenshots that describe what problem do you have? Any GL errors?
First up, which OpenGL ES device are you using? Because the two I have used don't support glu.

Secondly, it is very hard to diagnose this sort of problem without a screen shot (hint, hint)...

However, my first guess would be to check your depth buffer precision - some OpenGL ES implementations default to an anaemic 12-bit depth buffer.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

You can download sources (C#) and video here: http://rapidshare.com/files/278479494/GLProblem.rar.html
There are desktop and mobile application sources, and video from my screen in this archive.

I have no GL errors. All operation are success

This topic is closed to new replies.

Advertisement