Sign in to follow this  
kabu

problem with OpenGL ES

Recommended Posts

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 .

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this