Transparent Images

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.?


[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

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

// 2. Second Texture Unit
GL_MODULATE ==> Module the 2 textures
GL_REPLACE ==> Replace the first texture
glBindTexture(GL_TEXTURE_2D, Texture_TGA[1].Texture_ID);

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);


// We disable the First Texture Unit

// We disable the Second Texture Unit

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.


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.