diff options
Diffstat (limited to 'src/Fl_Gl_Choice.cxx')
| -rw-r--r-- | src/Fl_Gl_Choice.cxx | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index 476bb08d8..a831eb4b6 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -295,21 +295,35 @@ GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int lay } # elif defined(__APPLE_QUARTZ__) - // warning: the Quartz version should probably use Core GL (CGL) instead of AGL - GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { - GLContext context, shared_ctx = 0; - if (context_list && nContext) shared_ctx = context_list[0]; - context = aglCreateContext( g->pixelformat, shared_ctx); - if (!context) return 0; - add_context((GLContext)context); - if ( window->parent() ) { - Rect wrect; GetWindowPortBounds( fl_xid(window), &wrect ); - GLint rect[] = { window->x(), wrect.bottom-window->h()-window->y(), window->w(), window->h() }; - aglSetInteger( (GLContext)context, AGL_BUFFER_RECT, rect ); - aglEnable( (GLContext)context, AGL_BUFFER_RECT ); - } - aglSetDrawable( context, GetWindowPort( fl_xid(window) ) ); - return (context); +// warning: the Quartz version should probably use Core GL (CGL) instead of AGL +GLContext fl_create_gl_context(Fl_Window* window, const Fl_Gl_Choice* g, int layer) { + GLContext context, shared_ctx = 0; + if (context_list && nContext) shared_ctx = context_list[0]; + context = aglCreateContext( g->pixelformat, shared_ctx); + if (!context) return 0; + add_context((GLContext)context); + if ( window->parent() ) { +#ifdef __APPLE_COCOA__ + int H = window->window()->h(); + GLint rect[] = { window->x(), H-window->h()-window->y(), window->w(), window->h() }; +#else + Rect wrect; + GetWindowPortBounds( fl_xid(window), &wrect ); + GLint rect[] = { window->x(), wrect.bottom-window->h()-window->y(), window->w(), window->h() }; +#endif + aglSetInteger( (GLContext)context, AGL_BUFFER_RECT, rect ); + aglEnable( (GLContext)context, AGL_BUFFER_RECT ); + } +#if defined(__APPLE_COCOA__) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + aglSetWindowRef(context, MACwindowRef(window) ); +#else + aglSetDrawable( context, GetWindowPort( MACwindowRef(window) ) ); +#endif +#else + aglSetDrawable( context, GetWindowPort( fl_xid(window) ) ); +#endif + return (context); } # else # error unsupported platform @@ -329,12 +343,26 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) { # elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL if ( w->parent() ) { //: resize our GL buffer rectangle - Rect wrect; GetWindowPortBounds( fl_xid(w), &wrect ); +#ifdef __APPLE_COCOA__ + int H = w->window()->h(); + GLint rect[] = { w->x(), H-w->h()-w->y(), w->w(), w->h() }; +#else + Rect wrect; + GetWindowPortBounds( fl_xid(w), &wrect ); GLint rect[] = { w->x(), wrect.bottom-w->h()-w->y(), w->w(), w->h() }; +#endif aglSetInteger( context, AGL_BUFFER_RECT, rect ); aglEnable( context, AGL_BUFFER_RECT ); } - aglSetDrawable(context, GetWindowPort( fl_xid(w) ) ); +#if defined(__APPLE_COCOA__) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + aglSetWindowRef(context, MACwindowRef(w) ); +#else + aglSetDrawable( context, GetWindowPort( MACwindowRef(w) ) ); +#endif +#else + aglSetDrawable( context, GetWindowPort( fl_xid(w) ) ); +#endif aglSetCurrentContext(context); # else # error unsupported platform |
