Problem with SGIS_generate_mipmap

I’m having a little problem with this extension. The thing is that i doesn’t seem to generate the alpha channels? Here’s my code:

if(bmpTexture->format->BytesPerPixel == 4)
glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGBA, bmpTexture->w, bmpTexture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);
glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGB, bmpTexture->w, bmpTexture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, bmpTexture->pixels);
if(bmpTexture->format->BytesPerPixel == 4)
gluBuild2DMipmaps(GL_TEXTURE_2D, (int)GL_RGBA, bmpTexture->w, bmpTexture->h, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);
gluBuild2DMipmaps(GL_TEXTURE_2D, (int)GL_RGB, bmpTexture->w, bmpTexture->h, GL_RGB, GL_UNSIGNED_BYTE, bmpTexture->pixels);

If i just do the gluBuild2DMipmaps everything goes as expected! Any ideas?

I don’t think this is the problem, but I’d use

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, bmpTexture->w, bmpTexture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);


Thanks for the reply although i noticed something.

Dumb me didn’t debug enough before i posted this and i found out that the alpha channel part is actually working, but it’s the one that doesn’t have an alpha channel (GL_RGB) that’s not working. That texture just ends up grey?

Ok… i tried running my demo with MESA and it still has the same problems, so the bug must be in my code.

A can not imagine as to why gluBuild2DMipmaps works fine but glTexImage2D doesn’t when they’re using the exact same parameters. As before, the problems seems to appear with textures that have 3 bytes per pixel (RGB) but 4 bytes per pixel (RGBA) work perfectly fine.

If anyone has any suggestions as to why this happens then please let me know.


What size is your rgb bmp image?

The glubuild function will scale non power of two images.

hmm… it was 1000x500, which was the problem. I rescaled it to 1024x512 and it worked fine then.

Thanks for the tip