On a past OpenGL project where I supported resizing, I used GLFW and responded to its framebuffer size callback by calling glViewport
and resetting the projection matrix (in my case with glLoadIdentity
followed by glOrtho
-- it's not fresh in my memory any more, but I don't think that project used shaders at all). I also called glClear
with GL_COLOR_BUFFER_BIT
as part of my regular redraw. That worked fine for my needs.
It looks like what GLFW was doing under the hood to trigger that callback was looking for an XEvent
from X11 (via XNextEvent
in a loop with a condition based on the result of calling XQLength
) with type
set to ConfigureNotify
and which had an xconfigure
entry with a width or height that differed from what was tracked directly by GLFW on its own window structure. When it saw an event like that, it would call the callback. After processing the event queue, GLFW called XFlush
on the display.
See x11_window.c in GLFW's source code for more detail: https://github.com/glfw/glfw/blob/master/src/x11_window.c
Direct link to raw code, if you prefer: https://raw.githubusercontent.com/glfw/glfw/master/src/x11_window.c
Hopefully comparing with what GLFW did can help you debug your own implementation. Good luck!