Jump to content
  • Advertisement
Sign in to follow this  
Tasaq

OpenGL multitexturing, strange noise with alpha

This topic is 2529 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!