Textures upside down and back to front.

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Textures upside down and back to front.

Postby sockmonster » Sat Jan 02, 2010 5:18 am

Hi, I'm trying to texture a quad made up of two triangles. I'm using glDrawArrays instead of glDrawElements so I specify 6 vertices instead of just 4. This is what it looks like:

vertices
---------
new Vector3(-0.5f, -0.5f, 0f),
new Vector3( 0.5f, -0.5f, 0f),
new Vector3( 0.5f, 0.5f, 0f),
new Vector3(-0.5f, -0.5f, 0f),
new Vector3( 0.5f, 0.5f, 0f),
new Vector3(-0.5f, 0.5f, 0f)

texture coords
-----------------
new Vector2(0f, 0f),
new Vector2(1f, 0f),
new Vector2(1f, 1f),
new Vector2(0f, 0f),
new Vector2(1f, 1f),
new Vector2(0f, 1f)

When I texture the quad the image is upside down and back to front! Does the Android BitmapFactory do this to the image? Because I can't see anything wrong with the vertices and texture coordinates I'm passing to opengl.

Many thanks.
sockmonster
Freshman
Freshman
 
Posts: 3
Joined: Sat Jan 02, 2010 4:50 am

Top

Postby hardcoras » Sat Jan 02, 2010 2:12 pm

With glDrawArrays use TRIANGLE_STRIP mode so 4 vertices should do the trick (instead of 6).

Textures in android is up side down. But front with back is not reversed. The upper left corner coordinates are 0,0.

I didn't investigate your texture coords mappings. If my info won't help you, i'll take a look at your vertex mappings.

Good luck and happy new year :).
hardcoras
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Sat Nov 14, 2009 2:31 pm
Location: Lithunia

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 8 guests