summaryrefslogtreecommitdiff
path: root/src/Fl_cocoa.mm
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-09-28 17:06:00 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-09-28 17:06:00 +0200
commitc2efb0d8494b101d9700afc79302fcf371995a6e (patch)
treebd18b6ba6d706e2cd638a45fee43dce61a92af60 /src/Fl_cocoa.mm
parent7d58e2385452b8373448e3f91013a8cda39c7aa3 (diff)
macOS: support of FLTK widgets in OpenGL 3 windows - cont'd.
This code is OK under macOS 10 9 and 13.
Diffstat (limited to 'src/Fl_cocoa.mm')
-rw-r--r--src/Fl_cocoa.mm16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 9cb302dcb..ccb4ebe81 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2941,25 +2941,29 @@ NSOpenGLContext* Fl_Cocoa_Window_Driver::create_GLcontext_for_window(NSOpenGLPix
}
-NSOpenGLContext *Fl_Cocoa_Window_Driver::gl1ctxt_create() {
+NSOpenGLContext *Fl_Cocoa_Window_Driver::gl1ctxt_create(NSView **gl1view) {
FLView *view = (FLView*)[fl_xid(pWindow) contentView];
- NSView *gl1view = [[NSView alloc] initWithFrame:[view frame]];
- [view addSubview:gl1view];
- [gl1view release];
+ *gl1view = [[NSView alloc] initWithFrame:[view frame]];
NSOpenGLPixelFormat *gl1pixelformat =
Fl_Cocoa_Window_Driver::mode_to_NSOpenGLPixelFormat(
FL_RGB8 | FL_ALPHA | FL_SINGLE, NULL);
NSOpenGLContext *gl1ctxt = [[NSOpenGLContext alloc]
initWithFormat:gl1pixelformat shareContext:nil];
[gl1pixelformat release];
- remove_gl_context_opacity(gl1ctxt);
+ return gl1ctxt;
+}
+
+void Fl_Cocoa_Window_Driver::gl1ctxt_add(NSOpenGLContext *gl1ctxt, NSView *gl1view) {
+ FLView *flview = (FLView*)[fl_xid(pWindow) contentView];
+ [flview addSubview:gl1view];
+ [gl1view release];
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_7
if (fl_mac_os_version >= 100700 && Fl::use_high_res_GL()) {
[gl1view setWantsBestResolutionOpenGLSurface:YES];
}
#endif
[gl1ctxt setView:gl1view];
- return gl1ctxt;
+ remove_gl_context_opacity(gl1ctxt);
}