The Fl_Gl_Window public API offers 2 ways to control the OpenGL capabilities of a window:

1) Fl_Gl_Window::mode(int m) is platform-independent and uses an argument containing bit flags
(e.g., FL_DOUBLE, FL_RGB8) to express desired capabilities. The m argument is assigned to
the mode_ private member variable of the Fl_Gl_Window object.
2) Fl_Gl_Window::mode(const int *a) is highly platform-dependent. It uses a zero-ending
array of attributes or attribute-value pairs to express capabilities. This member function
can be used on the X11 and the Mac OS platforms, but not with MSWindows.
Before this patch, the mode_ private member variable of the Fl_Gl_Window object
is assigned 0 by this member function.

The Fl_Gl_Window::flush() member function tests whether the FL_DOUBLE flag
is ON in the mode_ variable, and changes code path accordingly. Therefore,
the second API to control OpenGL capabilities fails when a double-buffered
GL context is required, because the code path followed by Fl_Gl_Window::flush() 
does not match the GL context requirements.

With this patch,  Fl_Gl_Window::mode(const int *a) scans the content of its 
array argument, and sets the FL_DOUBLE bit of the mode_ member variable
if the array requires a double-buffered GL context.

This patch does that for the X11 platform. The same was introduced for the
Mac OS platform at r. 10854.  The MSWindows platform does not use the
Fl_Gl_Window::mode(const int *a) API.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10859 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2015-09-08 11:43:48 +00:00
parent a650237edf
commit fa9880e7fe
1 changed files with 9 additions and 2 deletions

View File

@ -127,12 +127,19 @@ int Fl_Gl_Window::mode(int m, const int *a) {
if (m == mode_ && a == alist) return 0;
#ifndef __APPLE__
int oldmode = mode_;
#else
#endif
#if defined(__APPLE__) || defined(USE_X11)
if (a) { // when the mode is set using the a array of system-dependent values, and if asking for double buffer,
// the FL_DOUBLE flag must be set in the mode_ member variable
const int *aa = a;
while (*aa) {
if (*(aa++) == kCGLPFADoubleBuffer) m |= FL_DOUBLE;
if (*(aa++) ==
# if defined(__APPLE__)
kCGLPFADoubleBuffer
# else
GLX_DOUBLEBUFFER
# endif
) { m |= FL_DOUBLE; break; }
}
}
#endif // !__APPLE__