DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2944
Version: 1.3.2
Patches for several Mac OS X Fl_Gl_Window bugs. I believe that these
patches apply to ALL FLTK versions, with possible minor modifications to
account for API differences.
1. Fl_Gl_Window::swap_buffers bug when a Gl_Window (simulated) overlay is
used: glRasterPos is not properly set before calling glCopyPixels. This
occurs when gl_draw(const char* str, int n) has been called to draw a
string into the Gl_Window, which changed glRasterPos.
2. Fl_Gl_Window::make_current bug when the Gl_Window is inside nested
Fl_Windows. The computation for the x and y values of the xywh array
passed to aglSetInteger(context_, AGL_BUFFER_RECT, xywh) does not take
this nesting into account, causing the Gl_Window drawing area to be
incorrectly placed inside the main window.
3. Fl_Gl_Window::redraw_overlay unnecessarily redrawing everything rather
than just the overlay. Apparently this was stale code that assumes that
complete redraws were always needed on Mac OS X.
Link: http://www.fltk.org/str.php?L2944
Version: 1.3.2
Index: src/Fl_Gl_Window.cxx
===================================================================
--- src/Fl_Gl_Window.cxx (revision 9857)
+++ src/Fl_Gl_Window.cxx (working copy)
@@ -181,10 +181,22 @@
// Set the buffer rectangle here, since in resize() we won't have the
// correct parent window size to work with...
GLint xywh[4];
-
if (window()) {
- xywh[0] = x();
- xywh[1] = window()->h() - y() - h();
+ int xp = 0, yp = 0;
+ Fl_Window *win = this;
+ // Code fragment from Fl_Window::make_current() in Fl_mac.cxx
+ // Compute xp, yp offset of upper left corner of Gl_Window relative to
top-level window
+ // accounting possible nesting of windows.
+ while ( win )
+ {
+ if ( !win->window() )
+ break;
+ xp += win->x();
+ yp += win->y();
+ win = (Fl_Window*)win->window();
+ }
+ xywh[0] = xp;
+ xywh[1] = win->h() - yp - h();
} else {
xywh[0] = 0;
xywh[1] = 0;
@@ -195,7 +207,7 @@
aglSetInteger(context_, AGL_BUFFER_RECT, xywh);
aglEnable(context_, AGL_BUFFER_RECT);
-// printf("make_current: xywh=[%d %d %d %d]\n", xywh[0], xywh[1], xywh[2],
xywh[3]);
+ // printf("make_current: xywh=[%d %d %d %d]\n", xywh[0], xywh[1], xywh[2],
xywh[3]);
#endif // __APPLE__
#if defined(WIN32) && USE_COLORMAP
@@ -249,10 +261,28 @@
# endif
#elif defined(__APPLE_QUARTZ__)
if(overlay != NULL) {
- //aglSwapBuffers does not work well with overlays under cocoa
+ int wo=w(); int ho=h();
+ GLint matrixMode;
+ glGetIntegerv (GL_MATRIX_MODE, &matrixMode);
+ glMatrixMode (GL_PROJECTION);
+ glPushMatrix(); // save original GL
matrices
+ 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 that
0,0 is the bottom left corner of Gl_Window
+ GLfloat pos[4];
+ glGetFloatv(GL_CURRENT_RASTER_POSITION, pos); // save original
glRasterPos
+ glRasterPos2i(0,0); // set glRasterPos to
bottom left corner
glReadBuffer(GL_BACK);
glDrawBuffer(GL_FRONT);
- glCopyPixels(0,0,w(),h(),GL_COLOR);
+ glCopyPixels(0,0,wo,ho,GL_COLOR); // copy GL_BACK to GL_FRONT
+ glPopMatrix(); // GL_MODELVIEW // restore original
matrices
+ glMatrixMode (GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode (matrixMode);
+ glRasterPos3f(pos[0],pos[1],pos[2]); // restore original
glRasterPos
}
else
aglSwapBuffers((AGLContext)context_);
@@ -261,6 +291,7 @@
#endif
}
+
#if HAVE_GL_OVERLAY && defined(WIN32)
uchar fl_overlay; // changes how fl_color() works
int fl_overlay_depth = 0;
Index: src/Fl_Gl_Overlay.cxx
===================================================================
--- src/Fl_Gl_Overlay.cxx (revision 9857)
+++ src/Fl_Gl_Overlay.cxx (working copy)
@@ -187,18 +187,18 @@
void Fl_Gl_Window::redraw_overlay() {
if (!shown()) return;
make_overlay();
-#ifdef __APPLE__
- redraw();
-#else
+
#ifndef WIN32
- if (overlay != this)
+ if (overlay && (overlay != this))
((Fl_Gl_Window*)overlay)->redraw();
else
#endif
damage(FL_DAMAGE_OVERLAY);
-#endif
}
+
+
+
void Fl_Gl_Window::make_overlay_current() {
make_overlay();
#ifdef __APPLE__
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs