From 59fc60ea4cb8db6ee43a1ac37cd4bbbefcb87faa Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Tue, 27 Sep 2022 14:12:39 +0200 Subject: Simpler code to support FLTK widgets in macOS OpenGL 3 windows. Also, the application-level code to add widgets to a GL3 window becomes platform-independent. --- src/Fl_cocoa.mm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/Fl_cocoa.mm') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 47be438fc..783273662 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2940,6 +2940,28 @@ NSOpenGLContext* Fl_Cocoa_Window_Driver::create_GLcontext_for_window(NSOpenGLPix return context; } + +NSOpenGLContext *Fl_Cocoa_Window_Driver::gl1ctxt_create() { + FLView *view = (FLView*)[fl_xid(pWindow) contentView]; + NSView *gl1view = [[NSView alloc] initWithFrame:[view frame]]; + [view addSubview:gl1view]; + [gl1view release]; + 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); + [gl1ctxt setView:gl1view]; + return gl1ctxt; +} + + +void Fl_Cocoa_Window_Driver::gl1ctxt_resize(NSOpenGLContext *ctxt) { + [[ctxt view] setFrame:[[[ctxt view] superview] frame]]; +} + #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0 # define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity #endif -- cgit v1.2.3