I'm a beginner playing with OPENGL ES on Android now. Now I'm hung on a problem , please read and see what's wrong:[font=Wingdings][/font]
What I want to do, should be quite simple :
1. Setup the view using perspective projection ( call glFrustum API)
2. Draw a sphere at {0,0,-3}
3. Use glTranslatef(X-2, Y-2, -3) to move the sphere at the X-Y surface.
It works fine at #1 and #2, as the image I attach
But when I call glTranslatef(X-2 , Y-2 , -3) , the sphere get bened got the same result on both Android mobile and emulator.
The sphere’s vertices are imported from 3D MAX generated file. I suspect the root cause is from the Open GL ES projection matrix’s setup.
Here’s how I setup the projection matrix:
[size=2] [size=2]public[size=2] [size=2]void[size=2] onSurfaceChanged(GL10 gl, [size=2]int[size=2] width, [size=2]int[size=2] height) {[size=2]
[size=2] gl.glViewport(0, 0, width, height);[size=2]
[size=2] gl.glMatrixMode(GL10.[size=2]GL_PROJECTION[size=2]);[size=2]
[size=2] gl.glLoadIdentity();[size=2]
[size=2] [size=2]ratio[size=2] = ([size=2]float[size=2]) width / height;[size=2]
[size=2] gl.glFrustumf(-[size=2]ratio[size=2], [size=2]ratio[size=2], -[size=2]1[size=2], [size=2]1[size=2], [size=2]2[size=2], [size=2]15[size=2]); [size=2]
[size=2] gl.glMatrixMode(GL10.[size=2]GL_MODELVIEW[size=2]);[size=2]
[size=2] }
And it look bad only to Sphere ,, when moving a cube it just works fine.
Really grateful to any suggestion !!