Sign in to follow this  
bootstrap

OpenGL help: problem resizing GLX window

Recommended Posts

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 rest of the area inside the frame is not cleared or drawn. The objects in the window get larger as the window is made larger and larger, so the viewport and the projection matrices are being altered correctly (it seems). Then when I resize the window smaller again, some of the window along the top is not being 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.

Share this post


Link to post
Share on other sites
sorry no idea, if u used SDL u wouldnt have this problem ( sorry not helpful ), though what u can do is check out the source code of SDL included with the development download + see how it handles window resizing

Share this post


Link to post
Share on other sites
What I do in OpenTK is this:
- glXChooseVisual
- XCreateColormap (from the visual above)
- XCreateWindow (make sure you request to be informed about size/move events)
- glXCreateContext
- glXMakeCurrent

Works perfectly, as long as you call glViewport inside the resize event handler.

I don't know what glXCreateWindow does, and I've never seen it used either. :)

Check the glxgears source code (scroll to the end of the file, and check main() and make_window()). You can also take a look at the source of GLFW (zlib licensed, check lib/x11/x11_window.c) and the source of SDL (LGPL licensed, careful!)

Share this post


Link to post
Share on other sites
Thanks for the information, fiddler.

I had the same problem with the GLX 1.2 functions you list in your message. After having so much trouble finding the cause of this problem, I decided to switch to the newer GLX 1.3 functions out of desparation!

I did finally solve the problem. To my surprise, the bug was in XWindows, not my code! I did not expect that!

Specifically, the problem was caused (by coincidence - or pure bad luck) by my decision to capture the width and height of the resized window in the XWindows ResizeRequest event. I found that the mere fact of selecting to receive that event (when calling the XCreateWindow() function) was sufficient to cause this problem. No kidding!

I moved my code that captures the resized width and height of the window into the ConfigureNotify event, and simply returned from function when the event was a ResizeRequest --- but the problem persisted, even though my code was doing nothing whatsoever in response to the ResizeRequest event. However, if I simply cleared the bit in the "event_mask" in the XSetWindowAttributes structure argument to XCreateWindow() --- poof --- problem gone. Yikes!

I bet you a dime if you simply set this one bit into your code that you encounter the identical problem --- even though you do not handle the event!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this