View Full Version : Change bg color for main window from subwindow

03-27-2010, 08:35 AM
Hello there,

I have following problem: I want to change the background color of my main window by clicking on a button (rectangle and mouse function) in the subwindow. Is it possible to call the init function for another window? I tried glutSetWindow(main window id) and in the next line glClearColor() but that doesn’t work.
Another attempt was to define global variables for red, green and blue and have a reshape function for the main window with glClearColor(). But the color obviously changes after reshaping the window and not immediately.

I hope anybody can help me.

03-28-2010, 09:41 AM
So it works but only after resizing? glClearColor won't redraw the main window for you. If you set the main window using glutSetWindow, you should be able to call glutPostRedisplay to redraw it. Different windows have different contextes, so when a function is being called from one window and you call glutSetWindow, I believe the gl* calls are still going to the subwindow context. You should probably set the color in a global variable, use glutSetWindow and call glutPostRedisplay to redraw that window.