PDA

View Full Version : create transparent window



dvm
11-17-2003, 01:26 PM
Hello, I'd like to ask if it's possible to create a transparent window on top of another one using glut. My code thus far looks like this:



int mainWindow, infoWindow;

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_ALPHA);
glutInitWindowPosition(100, 0);
glutInitWindowSize(600, 600);
glutInit(&argc, argv);
mainWindow = glutCreateWindow("Walky walky...");
glutDisplayFunc(display);
glutSpecialFunc(special);
glutKeyboardFunc(keyboard);
glutReshapeFunc(reshape);
init();
infoWindow = glutCreateSubWindow(mainWindow, 0, 0, 600, 600);
glutDisplayFunc(info_display);
glutReshapeFunc(info_reshape);
glutMainLoop();

The main window is drawn normally. I want the info window to be created on top of the main window (such as an overlay, only my graphics card doesn't support it) and be drawn transparent. I use the following info_reshape function.



glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glClearColor(0.5, 0.5, 0.5, 0.0);
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glOrtho(-300, 300, -300, 300, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

I thought I would only need to change the alpha value of the clear color but that does not work. Any suggestions? Also if the alpha value of clear color does not work that way, what is it good for? Thanks in advance.