diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-27 14:12:39 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-27 14:12:39 +0200 |
| commit | 59fc60ea4cb8db6ee43a1ac37cd4bbbefcb87faa (patch) | |
| tree | 072de9da3e8f6c0b69f0872320ff7ad117e6aee9 /src/Fl_cocoa.mm | |
| parent | 2ffd4e4f1af16b17a286ff354603a717f5d828a5 (diff) | |
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.
Diffstat (limited to 'src/Fl_cocoa.mm')
| -rw-r--r-- | src/Fl_cocoa.mm | 22 |
1 files changed, 22 insertions, 0 deletions
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 |
