diff options
| author | Manolo Gouy <Manolo> | 2018-11-01 14:34:22 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2018-11-01 14:34:22 +0000 |
| commit | 3a2439e31c71f827db7b32536974c54fb11b1842 (patch) | |
| tree | 024acb4056e92c619ac0a6b54d164c96d7f3751b /src | |
| parent | 6c8115ee9b30a89724df122c0af20c24ac6cfe52 (diff) | |
MacOS Mojave: restore use of gl_start()/gl_finish()
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@13105 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_cocoa.mm | 24 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H | 1 | ||||
| -rw-r--r-- | src/gl_start.cxx | 2 |
3 files changed, 21 insertions, 6 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index dec3f3592..0c450eac0 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2270,9 +2270,11 @@ static CGContextRef prepare_bitmap_for_layer(int w, int h ) { Fl_Cocoa_Window_Driver::q_release_context(); through_drawRect = NO; window->clear_damage(); - CGImageRef cgimg = CGBitmapContextCreateImage(layer_data.gc); // requires 10.4 - layer.contents = (id)cgimg; - CGImageRelease(cgimg); + if (layer_data.gc) { + CGImageRef cgimg = CGBitmapContextCreateImage(layer_data.gc); // requires 10.4 + layer.contents = (id)cgimg; + CGImageRelease(cgimg); + } } } @@ -2903,7 +2905,7 @@ NSOpenGLContext* Fl_Cocoa_Window_Driver::create_GLcontext_for_window(NSOpenGLPix { NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx]; if (context) { - NSView *view = [fl_xid(window) contentView]; + FLView *view = (FLView*)[fl_xid(window) contentView]; if (fl_mac_os_version >= 100700 && Fl::use_high_res_GL()) { //replaces [view setWantsBestResolutionOpenGLSurface:YES] without compiler warning typedef void (*bestResolutionIMP)(id, SEL, BOOL); @@ -2912,7 +2914,9 @@ NSOpenGLContext* Fl_Cocoa_Window_Driver::create_GLcontext_for_window(NSOpenGLPix } [context setView:view]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 - if (views_use_CA) ((FLViewGL*)view)->layer_data.context = context; + if (views_use_CA + && !view->layer_data.gc // avoid use of gl_start()/gl_finish() + ) view->layer_data.context = context; #endif } return context; @@ -4450,6 +4454,16 @@ void Fl_Cocoa_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl CGContextRelease(auxgc); } +void Fl_Cocoa_Window_Driver::gl_start(NSOpenGLContext *ctxt) { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8 + if (views_use_CA) { + Fl_Cocoa_Window_Driver::q_release_context(); + [[fl_window contentView] viewFrameDidChange]; + } +#endif + [ctxt update]; // supports window resizing +} + /* Returns the version of the running Mac OS as an int such as 100802 for 10.8.2 */ int Fl_Darwin_System_Driver::calc_mac_os_version() { diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H index b46a66e9f..70d1dffcf 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H @@ -150,6 +150,7 @@ public: static void flush_context(NSOpenGLContext*); // uses Objective-c static void GLcontext_makecurrent(NSOpenGLContext*); // uses Objective-c static void GL_cleardrawable(void); // uses Objective-c + static void gl_start(NSOpenGLContext*); // uses Objective-c }; #endif // FL_COCOA_WINDOW_DRIVER_H diff --git a/src/gl_start.cxx b/src/gl_start.cxx index 9a61b7d42..c1e86107c 100644 --- a/src/gl_start.cxx +++ b/src/gl_start.cxx @@ -100,7 +100,7 @@ void Fl_Gl_Window_Driver::gl_visual(Fl_Gl_Choice *c) { #include "drivers/Cocoa/Fl_Cocoa_Window_Driver.H" void Fl_Cocoa_Gl_Window_Driver::gl_start() { - Fl_Cocoa_Window_Driver::GLcontext_update(context); // supports window resizing + Fl_Cocoa_Window_Driver::gl_start(context); } #endif |
