I get white textures on the samsung galaxy variant but on the other phones that i tested the textures are working just fine .So my questing is what is the usual suspect that causing such behavior? is the galaxy variant having any special hardware and is missing something?
My texture loading code is this
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE);
if(alpha)glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) image_data);
else glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) image_data);
And the drawing is happening as usual with GL_TRIANGLES
*I dont have the actual device in front of me so i cant do glGetError
Since it is OpenGL ES 1.0, you also need to call
glEnable(GL_TEXTURE_2D);
which is otherwise a no-op on OpenGL ES 2.0 where shader says which texture type is being read (well, it is actually an error).
Calling glTexParameterf() and glTexEnvf() seems slightly strange to me, I'd use glTexParameteri() and glTexEnvi() instead (the passed values are enums, which are integers, not floats). But that shouldn't cause errors.
Another thing is maximal texture size (you already said that it is POT). Is the texture large by any chance? Some devices might have max texture size limit as low as 512 by 512 pixels.
The unpack alignment should not have a big effect in general. It should be 1 if you store your RGB data as 3 bytes, or 4 if you store both RGB and RGBA as one double-word (= 4 bytes). If you specify a bad alignment, I can imagine that the texture is garbled (RGB or scanline skew), but it should not in general end up being white. On the other hand, if the driver refused this unpack alignment, it might leave the texture blank and generate GL error. See if it does.
Another factor is texture coordinates. Some devices have small number of bits in texcoord interpolators, and specifying large texture coordinates (e.g. such as -10000, +10000 on a terrain quad) might result in graphical glitches. This is really mostly undocumented and many devices have problems with it.
It was always helpful for me to make an 8x8 bright greenish texture (not 0x00ff00, e.g. 0x8AC43C is much easier to spot in cases it is converted to grayscale or somehow only a single component is used). This texture should then be applied on a "small" quad (one that is fully on screen and big enough to be visible) with texcoords in the [0-1] range.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With