PDA

View Full Version : Android OpenGL Texture Scaling Problem



LBarrettAnderson
02-18-2010, 05:32 PM
I have a texture with 8 equally sized stripes that I am using as a wall with OpenGL. On my Nexus One (android) it scales it properly, as the stripes get smaller the further away they get ( http://lbarrettanderson.com/pongGood.png ).
However, in emulators and on a G1 (android) (and probably on other hardware), it
does not scale properly, as the stripes remain the same width, while
the height scales as it should. ( http://lbarrettanderson.com/pongBad.png ).
Is there an option that I need to set that is set to default on my nexus one but not on other platforms?
I can post code if needed, but I figured this would be a simple option/ configuration fix.
Thanks

Alfonse Reinheart
02-18-2010, 06:11 PM
Since this is on an Android, you're using OpenGL ES, which despite the name isn't the same as OpenGL.

However, it looks very much like what you're getting is non-perspective correct texturing in the bad one. If GL ES 2.x works like GL 3.x does, this is controlled by the shader. If you declare your input/output between the vertex and fragment shaders to be "noperspective", then it won't be perspective correct. "smooth" means perspective-correct, which should be the default.

LBarrettAnderson
02-18-2010, 09:19 PM
Well, it's a "subset" of OpenGL, and based on it, so they should be close enough for this issue.

Thanks for the info, though. That's much more helpful than googling has been. Hopefully I'll get this sorted out.

Thanks!

LBarrettAnderson
02-19-2010, 01:22 AM
Figured it out. In case anyone else has this issue, here's the fix:
glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL10.GL_NICE ST);

dukey
02-19-2010, 03:50 AM
It's doing affine texturing, which essentially means, texturing without perspective correction. I've never seen any opengl implementation do this :eek: You should not need to use the glHints, since these are hints ONLY and can be totally ignored by the driver. You shouldn't rely on them. I guess on phones with very limited 3d hardware this insanity is to be expected.