OpenGL ES texture rendered not as expected with disproportional aspect ratio triangles

I cannot seem to understand how texture coordinates work. I try to render a texture into two triangles and this is what I get

enter image description here

Where the expected output is a normal continuous image as you can imagine.

Triangles coordinates (where w = 1080, h = 1920):

0, 0, w, 0, 0, h,
w, 0, 0, h, w, h

Texture coordinates

0, 1, 1, 1, 0, 0,
1, 1, 1, 0, 0, 0

Texture parameters

gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);

Answers 1

  • Take a piece of paper and draw your 2 triangles vertices coords and uv coords. They seem to be misplaced (e.g. 0,h corresponds one time to 0,0 and other time to 1,0)


    For such cases I could also recommend to use textures with clearly defined characteristics, e.g. a checkerboard with marked uv coords:

    enter image description here


Related Questions