diff options
| author | Greg Ercolano <erco@seriss.com> | 2013-04-08 16:49:55 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2013-04-08 16:49:55 +0000 |
| commit | 2a5d5aab3000c5bc326b314bda144b98d5549633 (patch) | |
| tree | 939483c877b52aeabd906810fbd0f46a9211681d /src | |
| parent | c3a84e475f6f7d4474e0f67353e1d6b71ea2c44e (diff) | |
Fix STR# 2944 [1]: When an app uses overlays and gl_draw(),
gl_draw() would mess up the raster position
affecting the Mac overlay emulation in swapbuffer code.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9865 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Gl_Window.cxx | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/Fl_Gl_Window.cxx b/src/Fl_Gl_Window.cxx index b9bf61096..355865ab1 100644 --- a/src/Fl_Gl_Window.cxx +++ b/src/Fl_Gl_Window.cxx @@ -249,10 +249,34 @@ void Fl_Gl_Window::swap_buffers() { # endif #elif defined(__APPLE_QUARTZ__) if(overlay != NULL) { - //aglSwapBuffers does not work well with overlays under cocoa - glReadBuffer(GL_BACK); - glDrawBuffer(GL_FRONT); - glCopyPixels(0,0,w(),h(),GL_COLOR); + // STR# 2944 [1] + // Save matrixmode/proj/modelview/rasterpos before doing overlay. + // + int wo=w(), ho=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 aglSwapBuffers((AGLContext)context_); |
