Skip to content

Commit

Permalink
Fix STR# 2944 [1]: When an app uses overlays and gl_draw(),
Browse files Browse the repository at this point in the history
		   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
  • Loading branch information
erco77 committed Apr 8, 2013
1 parent c3a84e4 commit 2a5d5aa
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions src/Fl_Gl_Window.cxx
Expand Up @@ -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_);
Expand Down

0 comments on commit 2a5d5aa

Please sign in to comment.