This is a problem we have encountered on a TI OMAP 3730 development board using OpenGL-ES 1.0.
If we create a texture of size 8x32
glGenTextures(1, &imageData->textureID);
glBindTexture(GL_TEXTURE_2D, imageData->textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, textureFormat, 8,32, 0,
textureFormat, format, NULL);
and then fill it with pixels of size 7x17
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 7,17, textureFormat,
format, pixelData);
the resulting texture is broken, only every second scan line from
pixelData is used and the bottom half of the texture is filled with garbage.
If we change the width of the texture to 32 when it is created
glTexImage2D(GL_TEXTURE_2D, 0, textureFormat, 32,32, 0,
textureFormat, format, NULL);
then filling it with the 7x17 image works fine. Also, if we only fill the
first 16 lines, i.e.,
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 7,16, textureFormat,
format, pixelData);
it works as expected. It looks as if the scanline used by glTexSubImage2D when reading pixelData depends on the height
provided.
I hope someone from QNX may help to understand this. Our current workaround is to increase the width of textures in case
the width is less than the height. This is unfortunate, though, since we waste memory for tall images.
We have created a small C program that illustrates the problem that is attached to this post. When drawing into a
texture of size 8x32, the result is crippled as shown in the bottom line in the attached screenshot. The other texture
format 16x32, 32x32, 32x8, 32x16 seem to work.
I compiled the example with
> ntoarm-gcc src/BugglTexImage2D.c -o BugglTexImage2D -lGLESv1_CM -lEGL -lKD -lm
If QNX could please look at this code and confirm whether or not it is a bug. If it is a bug then better suggestions for
a work-around would be appreciated.
Thanks....