PDA

View Full Version : Blending problem



enmaniac
11-22-2003, 01:17 AM
HI!

Recently I have met problem you can see below:

Here is a code:



void MainInterface::RenderScene( void )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBegin( GL_QUADS );

glColor3ub( 0, 255, 0 );

glVertex2i( 0, 0 );
glVertex2i( 0, 10 );
glVertex2i( 5, 10 );
glVertex2i( 5, 0 );

glColor3ub( 255, 0, 0 );

glVertex2i( 5, 0 );
glVertex2i( 5, 10 );
glVertex2i( 10, 10 );
glVertex2i( 10, 0 );

glEnd();

glBlendFunc( GL_ONE, GL_ALPHA );
glEnable( GL_BLEND );

glBegin ( GL_TRIANGLES );

glColor4ub( 0, 0, 255, 100 );

glVertex2i( 2, 2 );
glVertex2i( 5, 8 );
glVertex2i( 8, 2 );

glEnd();

glDisable( GL_BLEND );

//////
glBlendFunc( GL_DST_COLOR, GL_ZERO ); // THIS IS A LINE OF INTEREST!!!!!

//////
SwapBuffers(hDC);
}

The output can be found here:

http://republika.pl/enmaniac/

I thought if you change blending function without enabling it does not work in any way. Am I wrong ??
I have checked this with GeForce 4MX ( 'couse I'm using Radeon 9000 with Catalyst 3.9 drivers ) and it worked properly ( I thing because the triangles were the same ).
Can anybody explain it to me ??

Thx in advance

PS This is my first post here so if I made any mistakes with tags or anything please forgive me :-)

[This message has been edited by enmaniac (edited 11-22-2003).]

Bob
11-22-2003, 01:51 AM
Since noone (at least noone visiting these boards) have direct access to your computers hard drive, we can't see your images. You need to upload them to a public HTTP-server.

enmaniac
11-22-2003, 07:21 AM
Sorry my mistake. I have added the link to the page with the reults ;-)

Bob
11-22-2003, 09:40 AM
All I had in my mind when posting the first time was to point out the mistake with the links, and I completely forgot to look at the code and the actual problem. http://www.opengl.org/discussion_boards/ubb/wink.gif

Anyways, changing blending function will always work. Whether it's disabled or not only affects whether blending is used or not. In this case, I would expect the code to show a blue triangle when the line is commented, and a black when it's not. Why? The first call to glBlendFunc is illegal, and will be ignored (leaving the actual blending function with either the default (replace), or multiplicative blending (as set by the second call to glBlendFunc)). GL_ALPHA is not a valid parameter, but GL_SRC_ALPHA is, which is probably what you want.

enmaniac
11-22-2003, 01:39 PM
Thx a lot http://www.opengl.org/discussion_boards/ubb/smile.gif It was my BIG mistake!!! I haven't noticed that GL_ALPHA is not a valid parameter...Now everything seems to be ok. I'm new to OGL so the mistakes are inseparable http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Thx again!!!