Board index » cppbuilder » Transparent texture in OpenGL

Transparent texture in OpenGL


2004-07-04 01:07:44 AM
cppbuilder101
How to display a texture with selected color as transparent in OpenGL?
Example:
Suppose that we have a bitmap file consist of horizontal bars each has its
own unique color.
R, G, B
Bar 1 - 10, 10, 10
Bar 2 - 10, 20, 130
Bar 3- 100, 45, 15
Bar 4- 255, 64, 0
...
If we select (10,20,130) as the transparent color then the second bar on
the texture will appear as transparent.
How to implement this?
 
 

Re:Transparent texture in OpenGL

<Cahgerti Ghaviery>wrote in message news: XXXX@XXXXX.COM ...
Quote
How to display a texture with selected color as transparent in OpenGL?
Example:
Suppose that we have a bitmap file consist of horizontal bars each has
its
own unique color.
R, G, B
Bar 1 - 10, 10, 10
Bar 2 - 10, 20, 130
Bar 3- 100, 45, 15
Bar 4- 255, 64, 0
...

If we select (10,20,130) as the transparent color then the second bar on
the texture will appear as transparent.

How to implement this?
You need to create a texture object with appropriate Alpha values for the
colors. Then when you render, the blending function needs to blend with
source as source alpha, and the destination as one minus source alpha.
Simon.