PDA

View Full Version : Argh problems with blending


Mars_999
2003.03.26, 01:54 AM
When I was on the PC I had no problems with setting up alpha transparency now I am on the Mac again I am having a problem getting my textures to use alpha? I have almost tried all the possible combos to get it to work and no dice. Anyone have any ideas what might be wrong?


//these functions are used in the init opengl function
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

void Render(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnable(GL_TEXTURE_2D);

glLoadIdentity();
glTranslatef(0.5f, 0.0f, -10.0f);

glBindTexture(GL_TEXTURE_2D, textures[1]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 1.0f, 0.0f);
glEnd();

glLoadIdentity();
glTranslatef(0.0f, 0.0f, -10.0f);

glEnable(GL_BLEND);
glEnable(GL_ALPHA_TEST);

glBindTexture(GL_TEXTURE_2D, textures[0]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(0.0f, 1.0f, 0.0f);
glEnd();

glDisable(GL_BLEND);
glDisable(GL_ALPHA);
glDisable(GL_TEXTURE_2D);

SDL_GL_SwapBuffers();
}

Mark Levin
2003.03.26, 02:35 AM
What are you setting the blend function to?

Also, if you are loading the texture image with Carbon you will have to convert it from ARGB to RGBA for OpenGL. There are several ways to do this, but I can't recall any of them offhand...

OneSadCookie
2003.03.26, 03:00 AM
glEnable(GL_BLEND);

Mars_999
2003.03.26, 12:54 PM
Originally posted by OneSadCookie
glEnable(GL_BLEND);

That didn't work? I removed it and still am having the same problem? I have a texture on the screen that has no alpha value and is behind the texture that has alpha. The texture in front has alpha and is a explosion and when rendered covers up half of the texture with no alpha? I am totally baffled now?

Mars_999
2003.03.26, 01:06 PM
Think I fixed it? I do need glEnable(GL_BLEND). Also OSC remember when you said try and use transparency in Photoshop Elements 2 for alpha well I have been using that to make images and no dice. I downloaded someone elses gfx that had alpha in a tiff format and used gfxconverter to convert it to .tga and now it works? So is it possible Photoshop Elements isn't able to do alpha? GOD what a nerve racking time!!!!!!!!!!!!!!!!!!!!