which blend function to use?

Started by
4 comments, last by griswald14 13 years, 4 months ago
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]
Advertisement
The grey part is alpha = 0? Did you upload your texture as RGBA.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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
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.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Yes, I can process my game without that sub window. I got the result I wanted using Orthographic Render like dpadam450 suggested. Thanks man. 0/

This topic is closed to new replies.

Advertisement