mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 14:52:46 +08:00
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
This commit is contained in:
+28
-4
@@ -249,10 +249,34 @@ void Fl_Gl_Window::swap_buffers() {
|
|||||||
# endif
|
# endif
|
||||||
#elif defined(__APPLE_QUARTZ__)
|
#elif defined(__APPLE_QUARTZ__)
|
||||||
if(overlay != NULL) {
|
if(overlay != NULL) {
|
||||||
//aglSwapBuffers does not work well with overlays under cocoa
|
// STR# 2944 [1]
|
||||||
glReadBuffer(GL_BACK);
|
// Save matrixmode/proj/modelview/rasterpos before doing overlay.
|
||||||
glDrawBuffer(GL_FRONT);
|
//
|
||||||
glCopyPixels(0,0,w(),h(),GL_COLOR);
|
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
|
else
|
||||||
aglSwapBuffers((AGLContext)context_);
|
aglSwapBuffers((AGLContext)context_);
|
||||||
|
|||||||
Reference in New Issue
Block a user