Reputation: 6950
I'm creating an openGL window in X11 and using glxswapbuffers
for double buffering.
The problem is: rendering seems fine but I get openGL contents bouncing around and the window border stuttering when resizing.
I tried filtering the ConfigureNotify events, delaying them, setting vsync off with glXSwapInterval
... nothing worked.
This is the code I'm using
void Window::redraw() { // Called by any control which needs redrawing
XEvent event;
memset(&event, 0, sizeof(event));
event.type = Expose;
event.xexpose.display = display;
XSendEvent(display, window, False, ExposureMask, &event);
}
void Window::resize(int width, int height) {
this->Width = width;
this->Height = height;
}
bool Window::wndProc(XEvent *evt) {
switch (evt->type) {
case Expose: {
if (evt->xexpose.count == 0) { // handle last one only
while (XCheckTypedWindowEvent(display, window, Expose, evt));
if (Width != oldWidth || Height != oldHeight)
resizeViewportAndUpdateDimensions();
Renderer.drawGLStuff();
this->redraw();
}
return true;
} break;
case ConfigureNotify: {
this->resize(evt->xconfigure.width, evt->xconfigure.height);
this->redraw();
return true;
} break;
}
}
Notice that this is a different issue (strictly linked to resizing) than this previous post which I solved via XCheckTypedWindowEvent
.
Upvotes: 4
Views: 3317
Reputation: 5301
https://tronche.com/gui/x/xlib/events/window-state-change/configure.html
https://tronche.com/gui/x/xlib/events/structure-control/resize.html
From what I can read from those two links ConfigureNotify happens when a change has completed. ResizeRequest happens when a resize is attempted. Specifically:
The X server can report ResizeRequest events to clients wanting information about another client's attempts to change the size of a window.
I don´t like the sound of "CAN report", but I suppose you should give it a shot. Don´t forget to set proper event bit as instructed in the link. As for what you should do when capturing event I´m not too sure... I would clear the front buffer and await resize to complete.
Upvotes: 2