PDA

View Full Version : Problem with SGIS_generate_mipmap



Stebet
01-28-2003, 06:14 AM
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(bGL_SGIS_generate_mipmap)
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
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);
else
glTexImage2D(GL_TEXTURE_2D, 0, (int)GL_RGB, bmpTexture->w, bmpTexture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, bmpTexture->pixels);
}
else
{
if(bmpTexture->format->BytesPerPixel == 4)
gluBuild2DMipmaps(GL_TEXTURE_2D, (int)GL_RGBA, bmpTexture->w, bmpTexture->h, GL_RGBA, GL_UNSIGNED_BYTE, bmpTexture->pixels);
else
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?

Humus
01-28-2003, 06:55 AM
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);

instead.

Stebet
01-28-2003, 07:01 AM
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?

Stebet
01-28-2003, 12:24 PM
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.

Thanks.

dorbie
01-28-2003, 12:40 PM
What size is your rgb bmp image?

The glubuild function will scale non power of two images.

Stebet
01-28-2003, 12:47 PM
hmm.. it was 1000x500, which was the problem. I rescaled it to 1024x512 and it worked fine then.

Thanks for the tip http://www.opengl.org/discussion_boards/ubb/smile.gif