Transparent Images

Hello!
I am doing a OpenGL project. In this i need to display one Image on the another Image Transparently. In my machine multitexturing is not supported. So iam using texture mapping; when i place one image on the another the bottom image is not visible.

How is it possible to display the overlapped images? Please give info.?

bye.,

[This message has been edited by ramana (edited 10-11-2003).]

Blending is applied to the framebuffer and not per-fragment.So if you want proper blending,you’ll have to sort your objects according to their z-position.
If you only have a few transparent objects,then just draw your solid objects first and your transparent objects last.

You can use also multitexturing :

// ************************************
// Left Quad - We module the 2 textures
// ************************************

// We move the quad on the left
glTranslatef(-1.0f,0.0f,0.0f);

// 1. First Texture Unit
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, Texture_TGA[0].Texture_ID);
glEnable(GL_TEXTURE_2D);

// 2. Second Texture Unit
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
/*
GL_MODULATE ==> Module the 2 textures
GL_REPLACE ==> Replace the first texture
*/
glBindTexture(GL_TEXTURE_2D, Texture_TGA[1].Texture_ID);
glEnable(GL_TEXTURE_2D);

glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f);
glVertex3f( 0.75f, 0.75f, 0);

  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f);
  glVertex3f( 0.75f, -0.75f, 0);

  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);
  glVertex3f(-0.75f, -0.75f, 0);

  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f);
  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f);
  glVertex3f(-0.75f,  0.75f, 0);

glEnd();

// We disable the First Texture Unit
glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

// We disable the Second Texture Unit
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);

Panzer: an image probably doesn’t have triangle sort issues.
Leyder: he said multitexture wasn’t supported on his hardware.

ramana: I suggest you read a good reference about multi-passing and blending, such as the red book. In brief, you want to glEnable( GL_BLEND ); before drawing the second image, and you want to set your glBlendFunc() appropriately, such as glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) if the second image has an alpha (coverage) channel, or glBlendFunc( GL_ONE, GL_ONE ) if you want to add them together. Don’t forget to disable the blend when you’re done!

Hmm, I just noticed this is the “advanced” board. Neither the question nor the replies seemed to indicate such was the case, though :slight_smile: Curious.

Hi,

I finished a demo with “Polygon Offset”. This program does the same as multitexturing without any extension.

But the problem is that, now, the server is down, so please wait a day.

Now, I’ve uploaded the demo.

http://www.slug-production.be.tf