Do you have to adjust the pixel format to allow for blending?
I was just wondering.
I have this at the top:
glEnable(GL_BLEND);
glBlendFunc(GL_ALPHA, GL_ONE);
glDisable(GL_DEPTH_TEST);
This is a chunk of my pfd setup:
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.cAlphaBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
and here is my render function.
void Render(void)
{
// OpenGL animation code goes here
static float theta = 0.0f;
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
glPushMatrix();
glRotatef( theta, 0.0f, 0.0f, 1.0f );
glBegin( GL_TRIANGLES );
glColor4f( 1.0f, 0.0f, 0.0f,1.0 ); glVertex2f( 0.0f, 4.0f );
glColor4f( 0.0f, 1.0f, 0.0f,1.0 ); glVertex2f( 0.87f*4, -0.5f*4 );
glColor4f( 0.0f, 0.0f, 1.0f,1.0 ); glVertex2f( -0.87f*4, -.5f*4 );
glEnd();
glPushMatrix();
glRotatef( theta, 0.0f, 0.0f, 1.0f );
glBegin(GL_QUADS);
glColor4f(1,1,1,0);
glVertex2f(-2,2);
glVertex2f(2,2);
glVertex2f(2,-2);
glVertex2f(-2,-2);
glEnd();
glPopMatrix();
glPopMatrix();
theta += 1.0f;
}
Whats weird is that the quad shows up fully opaque. I'm stumped. I think that I might not be setting the the PFD right.
Try 32 instead of 24 - I believe ALPHA is lumped in with the color bits. 24 bits imply no alpha.
That should only matter if you need the colour buffer to have alpha, which you don't in this case. Is your glEnable(GL_BLEND); etc. called before or after you create your OpenGL context? It should be after.
Enigma
Enigma
GL_ALPHA is not a valid blend function factor. Check the documentation on glBlendFunc for a list of valid factors.
And the cColorBit in the pixel format descriptor is the number of color bits in the framebuffer, excluding alpha. But you don't need a destination alpha if you're only doing source alpha blending.
And the cColorBit in the pixel format descriptor is the number of color bits in the framebuffer, excluding alpha. But you don't need a destination alpha if you're only doing source alpha blending.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement