mfc >> OpenGL transparency issues

by Graeme Swallow » Sat, 29 Nov 2003 03:32:00 GMT

Hello! I am programming an OpenGL app using Visual C++
6.0. I've posted this question on OpenGL.org discussion
forums, and no one either knows the answer or is willing
to, so I thought I'd post the question here as well.

I need to do some partially transparent texture mapping
for billboarding. I cannot get this thing to work for the
life of me. I have a sample program from a book which runs
just FINE. But I can't get my own program to work. I used
my debugger to check the bit values of the RGBA-modified
BYTE array to make sure the alpha bit is set correctly.
When I initialize OpenGL, I do use PFD_TYPE_RGBA. My
sequence for the transparent texture mapping is:

glEnable(GL_BLEND) ;
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
glEnable(GL_ALPHA_TEST) ;
glAlphaFunc(GL_GREATER, 0) ;
glBindTexture(...) ;
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,
GL_REPLACE) ;
...and then do the drawing.

Yet when the drawing occurs, the black "transparent" shows
up in full color, creating a black rectangular edge.

Interestingly, if I switch the alpha test to (GL_LESS, 1),
the ENTIRE quad becomes invisible, even though I have
checked the bytes of the texture, and the alpha values
vary correctly between 0 and 255 where I want transparency
or not.

Any suggestions at this point would be greatly
appreciated. I've been working on this for 3 days now.
Maybe I'm overlooking something stupidly obvious. Thanks a
bunch.



mfc >> OpenGL transparency issues

by Johan Rosengren » Sun, 30 Nov 2003 15:49:55 GMT


Graeme,

This is not an OpenGL group, as you've might noticed :-), and neither have I
*any* experience of OpenGL, but as it seems you're getting no answers here
either, I step into the frontline!

If you have an example working the way you want, the solution becomes a
tedious compare between the example and your code. You might want to try
some of the following methods:

A. Breaking apart the test program, changing parameters to API-calls one by
one until - as by magic - some either subtle or not so subtle difference
between the example and your code dawns.

B. If call sequences and -parameters are (functionally) identical, logic
gives that the data *must* be different. If possible, I would try to use
data from the example app to try to verify this.

C. Rebuild your app from scratch - only adding the necessary functionality
(this is to rule out unrelated code interfering in some way).

Johan Rosengren
Abstrakt Mekanik AB

"Graeme Swallow" < XXXX@XXXXX.COM > a rit dans le message de






Similar Threads

1. Good Win32 OpenGL books (no MFC or heavy emphasis on C++ class encapsulation of OpenGL samples)

2. disable mouseclick-transparency in vista

Hello,

I have a transparent form created with:

   this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
   this.SetStyle(ControlStyles.DoubleBuffer, true);
   this.SetStyle(ControlStyles.ResizeRedraw, true);

   this.TransparencyKey = Color.Violet;
   this.BackColor = Color.Violet;

In the OnPaint function I filled the Clientrectangle with Color.Violet. If I
run my program in WindowsXP the Mouse-events get raised. If I run the same
program under Windows Vista the mouse events does not get raised. But why? I
have no Aero enabled.

bye
Sebastian

3. gdi+ newbie: image transparency - CSharp/C#

4. transparency with 32 bit color depth

This is a cross post from windows.forms.  I'm not sure where to post it.

I have an application that uses transparency.  My video settings are
1600x1200 and 32 bit color.  I can make the main dialog transparent but
other controls and child windows are not transparent, I see the colored box
around my control.  If I switch my color depth to 16 bit everything is fine.
Why does it work on some forms but not others.

I can even make my main form transparent and drop a custom control that has
transparency set.  The main form goes transparent but the custom control has
a blue (my transparent color) box around it.  Again if I switch color depth
it works fine.

I heard that somewhere in the .NET documentation it says transparency is not
supported under 32 bit color.  I have a hard time believing this.  Are there
any computers that don't come in 32 bit color mode anymore?

Jim



5. transparency on labels - CSharp/C#

6. Transparency of shaped forms?

7. image color transparency - CSharp/C#

8. Large image slow refresh transparency control