PDA

View Full Version : help: problems resizing GLX windows



bootstrap
03-21-2008, 06:16 PM
I just ported my 3D engine from OpenGL on Windows to OpenGL on Linux. But now that I have the core running, I have a couple problems I do not understand. Here is one of them.

When I grab the boundary of the graphics window with the mouse and resize it to a larger size, the area inside the window that is cleared (each frame) does not change size from the original size. The newly exposed area inside the expanded frame is transparent (the desktop is visible). Presumably this means XWindows is (appropriately) not clearing the window, but the OpenGL glClear() continues to clear only the original window dimensions - not the resized/expanded dimensions.

The objects in the window do get larger as the window is resized larger (and printf() statements in the code confirm the viewport and projection matrices are being recomputed and installed correctly (by glViewport() and glLoadMatrixd() calls) every time XWindows sees the window size change). When I resize the window smaller again, some of the window along the top is not drawn - as if the viewport is offset downward (but not rightward).

I do not understand in any significant way what the distinction between the XWindow and GLXWindow are. When my code creates a window, it first calls XCreateWindow() to create an XWindow, then calls glXCreateWindow() to create (and associate) a corresponding GLXWindow. That's what the GLX sample code that I found seems to want. Not sure whether perhaps the XWindow is being resized but not the GLXWindow - but I do not see any GLX resize functions. Furthermore, when I try to resize the GLXWindow with xlib functions, my applications blows up (and XWindows prints a nasty error message). So that doesn't seem to be how this should be handled.

Any ideas?

video card = nvidia 8600GT + 512MB. The nvidia drivers are up to date.

bootstrap
03-23-2008, 08:32 AM
BTW, I had the same problem with the GLX 1.2 functions (no glXCreateWindow() and several alternate functions). After having so much trouble finding the cause of this problem, I switched over to the newer GLX 1.3 functions - just in case it might fix this.

I finally did solve this problem - after an awful lot of time and effort. To my surprise, the bug is in XWindows, not my code. I definitely did not expect that.

I encountered the problem (by coincidence - or pure bad luck) because I was capturing the width and height of the resized window in the XWindows ResizeRequest event. I found the mere fact of *selecting* to receive this event (when calling the XCreateWindow() function) causes this problem. No kidding! No need to process the event.

In the end, I moved my code that captures the resized width and height of the window into the ConfigureNotify event. Even when my code ignores the ResizeRequest event or simply returns from function --- the problem persists! However, simply clear the bit that selects this event [in the "event_mask" in the XSetWindowAttributes structure argument to XCreateWindow()] and --- poof --- problem gone. Yikes!

Consider this a bug report to whoever cares for X.