5

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

Tim
  • 35,413
  • 11
  • 95
  • 121
SteveL
  • 3,331
  • 4
  • 32
  • 57
  • Can you guarantee that the textures are Power of 2 size? If you're getting your data from a bitmap factory it can be scaled with the screen density, thus causing PO2 source images to become NPO2. – Tim Oct 11 '12 at 20:56
  • Yes the textures are pot and no i dont get them from bitmap factory.I actually loading them from c++ (by accesing the apk)but i dont thing there is the problem since its just c++ things not opengl , if the problem was there them i would had it on all devices. – SteveL Oct 11 '12 at 21:06
  • 1
    Is every single texture white, or just some of them? Are they all RGBA, RGB, or mixed? Why do you use an unpack alignment of 2? – Tim Oct 24 '12 at 18:26
  • If I'm correct Galaxy Variant has Mali400 GPU. I've experienced some issues with shaders (related to color precision) on Mali400, so this might be related to shaders too. How do you draw this texture? Have you tried to reproduce a bug on different GPUs? – keaukraine Oct 25 '12 at 11:03
  • @Tim the textures are mixed (some RGB some RGBA) and yes every texture is white.I don't remember why i use 2 for the unpack alignment :) and this sounds like a good reason for the wrongs textures .Should i use 1 or 4? – SteveL Oct 25 '12 at 12:06
  • @KeauKraine I forgot to mention that i use Opengl es 1.0 so no shaders...I added the Opengl ES 2.0 tag cause its basically the same code when loading texts – SteveL Oct 25 '12 at 12:09
  • 1
    @SteveL - That depends on what your `image_data` looks like. Are the rows aligned on any boundary? If your textures are RGBA they should always be dword aligned, so 1 or 4 is fine. If they are RGB, and you don't have any row padding, you'll need a value of 1. – Tim Oct 25 '12 at 14:58

1 Answers1

4

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.

the swine
  • 10,713
  • 7
  • 58
  • 100
  • 1)I am enabling GL_TEXTURE_2D each time before i draw 2)I dont thing so that is causing the problem 3)I have the same problem in small textures like 64*64 4)Like you say this is not a reason for the white textures 5)nope i only draw square textures with <=1 texcoords 6)i didnt understood that :) .Thanks for the answer, it was the most complete one – SteveL Nov 01 '12 at 13:39
  • 6) is what i do if i have problems with something simple not working - implement a simple test which should work everywhere. It is a pity that none of those solves your problem. If you happen to solve it, let us know what was the problem. Good luck ... – the swine Nov 02 '12 at 10:42