Sign in to follow this  
griswald14

which blend function to use?

Recommended Posts

griswald14    100
a 2D subwindow on top of a 3D subwindow.

http://img576.imageshack.us/img576/70/asdfas.jpg

I was using glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA), but I still couldn't remove the grey part. Thanks in advance.

PS. The top subwindow was texture mapped with alpha values. Texture Envi mode was GL_MODULATE. Blending was enabled during rendering.

[Edited by - griswald14 on December 5, 2010 5:38:46 AM]

Share this post


Link to post
Share on other sites
griswald14    100
Yes, the image was uploaded as RGBA. It worked fine on other subwindows.

The following is what i have for the top subwindow, which is Subwindow5:

Subwindow5 = glutCreateSubWindow(Subwindow1, SubW1*5.0/6.0,SubH1/6.0,SubW1*5.0/6.0,SubH1*5.0/6.0);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA );
glutDisplayFunc(sub5Display);
glutReshapeFunc(reshape5);
StatsWindow = textureALPHA("subwindow5.raw",512,512,0,TRUE);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glutMainLoop();

------------------------------------------------------------------
The display function:

void sub5Display (void)
{
glClear(GL_COLOR_BUFFER_BIT );
glEnable(GL_BLEND);
SetBackground (W5_width, W5_height, StatsWindow);
glDisable(GL_BLEND);
glutSwapBuffers();
}

Setbackground just make a polygon of W5_width X W5_height, and texture StatsWindow on it. Also, I rendered sub window 5 last.

The grey part is Alpha = 0, am i missing glColor4 or glClearColor?

Thanks again

Share this post


Link to post
Share on other sites
karwosts    840
I think you might be getting foiled by glut here. I'm not sure if glut subwindows will allow blending in between them like that, but I don't use it so I couldn't say.

Try setting the clear color to (x,x,x,0) before you glClear the subwindow, see if that works.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this