diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2024-11-08 12:25:49 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2024-11-08 12:25:49 +0100 |
| commit | 55db651a960b78e2884462dfc27c097e5a2e7c56 (patch) | |
| tree | bdf1b493f97c907a1643cf14601db482fca15e4d /src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx | |
| parent | c46a92809e86d22520e01cd4d1581d7c288cd320 (diff) | |
Fix: X11: test/gl_overlay stale overlay rendering (#1111)
Diffstat (limited to 'src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx')
| -rw-r--r-- | src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx index 862172463..3a3f80c28 100644 --- a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx @@ -278,6 +278,33 @@ int Fl_X11_Gl_Window_Driver::mode_(int m, const int *a) { void Fl_X11_Gl_Window_Driver::swap_buffers() { if (!fl_xid(pWindow)) // window not shown return; + if (overlay()) { + int wo = pWindow->pixel_w(), ho = pWindow->pixel_h(); + GLint matrixmode; + GLfloat pos[4]; + glGetIntegerv(GL_MATRIX_MODE, &matrixmode); + glGetFloatv(GL_CURRENT_RASTER_POSITION, pos); // save original glRasterPos + glMatrixMode(GL_PROJECTION); // save proj/model matrices + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glScalef(2.0f/wo, 2.0f/ho, 1.0f); + glTranslatef(-wo/2.0f, -ho/2.0f, 0.0f); // set transform so 0,0 is bottom/left of Gl_Window + glRasterPos2i(0,0); // set glRasterPos to bottom left corner + { + // Emulate overlay by doing copypixels + glReadBuffer(GL_BACK); + glDrawBuffer(GL_FRONT); + glCopyPixels(0, 0, wo, ho, GL_COLOR); // copy GL_BACK to GL_FRONT + } + glPopMatrix(); // GL_MODELVIEW // restore model/proj matrices + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(matrixmode); + glRasterPos3f(pos[0], pos[1], pos[2]); // restore original glRasterPos + } else glXSwapBuffers(fl_display, fl_xid(pWindow)); } |
