problem with OpenGL ES
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 .
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 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();
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement