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]
which blend function to use?
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
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
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.
Try setting the clear color to (x,x,x,0) before you glClear the subwindow, see if that works.
Why are you having a second window anyway. It has to have its own GL context and frame-buffer. Seems like a waste. You can always just draw in orthographic mode for 2D stuff.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement