diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2009-12-06 22:21:55 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2009-12-06 22:21:55 +0000 |
| commit | b2cffc688ea7abbddabc9ed23deea1921f59ac9d (patch) | |
| tree | 74a50bdb133fd6b5af7c785541bcc46e2e8e9c15 /src/Fl_Gl_Choice.cxx | |
| parent | 1ea4b4573538f2d53960dd8a4ef4f35480d2f5f7 (diff) | |
Moved OS X code base to the more moder Cocoa toolkit thanks to the awesome work of Manolo Gouy (STR #2221). This is a big one! I tested all test applications under 32-bit autoconf and Xcode, and a few apps under 64bit intel. No PPC testing was done. Please verify this patch if you have the machine!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6951 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
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 |
