OpenGL multitexturing, strange noise with alpha

Started by
1 comment, last by Tasaq 12 years, 3 months ago
Okay, so I try to modificate class i found on the net to use multitexturing. When I use it w/o alpha everything works ok, but when i change it to GL_RGBA everything becomes noisy. Here's a screenshot:
zlee.jpg
Blue is the background color. 1st texture is white with alpha having a white gradient point in center, 2nd is green with black alpha.

And now for the code for loading image:

void GLTexture::LoadBMP(char *name1, char *name2)
{
AUX_RGBImageRec *TextureImage[2];
memset(TextureImage,0,sizeof(void *)*2);
TextureImage[0] = auxDIBImageLoad(name1);
TextureImage[1] = auxDIBImageLoad(name2);
width = TextureImage[0]->sizeX;
height = TextureImage[0]->sizeY;
width_mult = TextureImage[1]->sizeX;
height_mult = TextureImage[1]->sizeY;
glGenTextures(2, texture);
for(int i=0; i<2; i++){
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, TextureImage->sizeX, TextureImage->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, TextureImage->data);
}
for(int i=0; i<2; i++){
if (TextureImage)
{
if (TextureImage->data)
free(TextureImage->data);
free(TextureImage);
}
}
}

then before glBegin(GL_QUAD); i call:

void GLTexture::Use()
{
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, texture[1]);
}

when i set gluBuild2DMipmaps back to GL_RGB everything seems to work ok, i can se 2 textures blending.
Advertisement
Does your source bmp file define an alpha channel, if not glu will read the image in wrong and color channels end up in different places all over the image.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion


Does your source bmp file define an alpha channel, if not glu will read the image in wrong and color channels end up in different places all over the image.

Yes, i did that, also when i draw stripes on alpha channel it appear there, but they were also "noised"

This topic is closed to new replies.

Advertisement