summaryrefslogtreecommitdiff
path: root/src/Fl_cocoa.mm
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-09-29 16:25:14 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-09-29 16:25:14 +0200
commitc96a4f3141259d412b249144086492ec4c400355 (patch)
tree5aeffc28022dd6708e792ac88e3331d778795df0 /src/Fl_cocoa.mm
parent694eaef99c25c4f94c4f2d5ffe6598bcca6674fc (diff)
macOS platform: rename Fl_Cocoa_Gl_Window_Driver.cxx to .mm
Diffstat (limited to 'src/Fl_cocoa.mm')
-rw-r--r--src/Fl_cocoa.mm181
1 files changed, 0 insertions, 181 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index ccb4ebe81..694e54ae1 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2831,184 +2831,6 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
@end
-NSOpenGLPixelFormat* Fl_Cocoa_Window_Driver::mode_to_NSOpenGLPixelFormat(int m, const int *alistp)
-{
- NSOpenGLPixelFormatAttribute attribs[32];
- int n = 0;
- // AGL-style code remains commented out for comparison
- if (!alistp) {
- if (m & FL_INDEX) {
- //list[n++] = AGL_BUFFER_SIZE; list[n++] = 8;
- } else {
- //list[n++] = AGL_RGBA;
- //list[n++] = AGL_GREEN_SIZE;
- //list[n++] = (m & FL_RGB8) ? 8 : 1;
- attribs[n++] = NSOpenGLPFAColorSize;
- attribs[n++] = (NSOpenGLPixelFormatAttribute)((m & FL_RGB8) ? 32 : 1);
- if (m & FL_ALPHA) {
- //list[n++] = AGL_ALPHA_SIZE;
- attribs[n++] = NSOpenGLPFAAlphaSize;
- attribs[n++] = (NSOpenGLPixelFormatAttribute)((m & FL_RGB8) ? 8 : 1);
- }
- if (m & FL_ACCUM) {
- //list[n++] = AGL_ACCUM_GREEN_SIZE; list[n++] = 1;
- attribs[n++] = NSOpenGLPFAAccumSize;
- attribs[n++] = (NSOpenGLPixelFormatAttribute)1;
- if (m & FL_ALPHA) {
- //list[n++] = AGL_ACCUM_ALPHA_SIZE; list[n++] = 1;
- }
- }
- }
- if (m & FL_DOUBLE) {
- //list[n++] = AGL_DOUBLEBUFFER;
- attribs[n++] = NSOpenGLPFADoubleBuffer;
- }
- if (m & FL_DEPTH) {
- //list[n++] = AGL_DEPTH_SIZE; list[n++] = 24;
- attribs[n++] = NSOpenGLPFADepthSize;
- attribs[n++] = (NSOpenGLPixelFormatAttribute)24;
- }
- if (m & FL_STENCIL) {
- //list[n++] = AGL_STENCIL_SIZE; list[n++] = 1;
- attribs[n++] = NSOpenGLPFAStencilSize;
- attribs[n++] = (NSOpenGLPixelFormatAttribute)1;
- }
- if (m & FL_STEREO) {
- //list[n++] = AGL_STEREO;
- attribs[n++] = NSOpenGLPFAStereo;
- }
- if ((m & FL_MULTISAMPLE) && fl_mac_os_version >= 100400) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
- attribs[n++] = NSOpenGLPFAMultisample, // 10.4
-#endif
- attribs[n++] = NSOpenGLPFASampleBuffers; attribs[n++] = (NSOpenGLPixelFormatAttribute)1;
- attribs[n++] = NSOpenGLPFASamples; attribs[n++] = (NSOpenGLPixelFormatAttribute)4;
- }
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
-#define NSOpenGLPFAOpenGLProfile (NSOpenGLPixelFormatAttribute)99
-#define kCGLPFAOpenGLProfile NSOpenGLPFAOpenGLProfile
-#define NSOpenGLProfileVersionLegacy (NSOpenGLPixelFormatAttribute)0x1000
-#define NSOpenGLProfileVersion3_2Core (NSOpenGLPixelFormatAttribute)0x3200
-#define kCGLOGLPVersion_Legacy NSOpenGLProfileVersionLegacy
-#endif
- if (fl_mac_os_version >= 100700) {
- attribs[n++] = NSOpenGLPFAOpenGLProfile;
- attribs[n++] = (m & FL_OPENGL3) ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy;
- }
- } else {
- while (alistp[n] && n < 30) {
- if (alistp[n] == kCGLPFAOpenGLProfile) {
- if (fl_mac_os_version < 100700) {
- if (alistp[n+1] != kCGLOGLPVersion_Legacy) return nil;
- n += 2;
- continue;
- }
- }
- attribs[n] = (NSOpenGLPixelFormatAttribute)alistp[n];
- n++;
- }
- }
- attribs[n] = (NSOpenGLPixelFormatAttribute)0;
- NSOpenGLPixelFormat *pixform = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
- /*GLint color,alpha,accum,depth;
- [pixform getValues:&color forAttribute:NSOpenGLPFAColorSize forVirtualScreen:0];
- [pixform getValues:&alpha forAttribute:NSOpenGLPFAAlphaSize forVirtualScreen:0];
- [pixform getValues:&accum forAttribute:NSOpenGLPFAAccumSize forVirtualScreen:0];
- [pixform getValues:&depth forAttribute:NSOpenGLPFADepthSize forVirtualScreen:0];
- NSLog(@"color=%d alpha=%d accum=%d depth=%d",color,alpha,accum,depth);*/
- return pixform;
-}
-
-NSOpenGLContext* Fl_Cocoa_Window_Driver::create_GLcontext_for_window(NSOpenGLPixelFormat *pixelformat,
- NSOpenGLContext *shared_ctx, Fl_Window *window)
-{
- NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:shared_ctx];
- if (shared_ctx && !context) context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:nil];
- if (context) {
- FLView *view = (FLView*)[fl_xid(window) contentView];
- if (fl_mac_os_version >= 100700) {
- //replaces [view setWantsBestResolutionOpenGLSurface:YES] without compiler warning
- typedef void (*bestResolutionIMP)(id, SEL, BOOL);
- static bestResolutionIMP addr = (bestResolutionIMP)[NSView instanceMethodForSelector:@selector(setWantsBestResolutionOpenGLSurface:)];
- addr(view, @selector(setWantsBestResolutionOpenGLSurface:), Fl::use_high_res_GL() != 0);
- }
- [context setView:view];
- if (Fl_Cocoa_Window_Driver::driver(window)->subRect()) {
- remove_gl_context_opacity(context);
- }
- }
- return context;
-}
-
-
-NSOpenGLContext *Fl_Cocoa_Window_Driver::gl1ctxt_create(NSView **gl1view) {
- FLView *view = (FLView*)[fl_xid(pWindow) contentView];
- *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];
- 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];
- remove_gl_context_opacity(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
-
-void Fl_Cocoa_Window_Driver::remove_gl_context_opacity(NSOpenGLContext *ctx) {
- GLint gl_opacity;
- [ctx getValues:&gl_opacity forParameter:NSOpenGLContextParameterSurfaceOpacity];
- if (gl_opacity != 0) {
- gl_opacity = 0;
- [ctx setValues:&gl_opacity forParameter:NSOpenGLContextParameterSurfaceOpacity];
- }
-}
-
-void Fl_Cocoa_Window_Driver::GLcontext_update(NSOpenGLContext* ctxt)
-{
- [ctxt update];
-}
-
-void Fl_Cocoa_Window_Driver::flush_context(NSOpenGLContext* ctxt)
-{
- [ctxt flushBuffer];
-}
-
-void Fl_Cocoa_Window_Driver::GLcontext_release(NSOpenGLContext* ctxt)
-{
- [ctxt release];
-}
-
-void Fl_Cocoa_Window_Driver::GL_cleardrawable(void)
-{
- [[NSOpenGLContext currentContext] clearDrawable];
-}
-
-void Fl_Cocoa_Window_Driver::GLcontext_makecurrent(NSOpenGLContext* ctxt)
-{
- [ctxt makeCurrentContext];
-}
-
/*
* Initialize the given port for redraw and call the window's flush() to actually draw the content
*/
@@ -4561,9 +4383,6 @@ void Fl_Cocoa_Window_Driver::draw_titlebar_to_context(CGContextRef gc, int w, in
}
}
-void Fl_Cocoa_Window_Driver::gl_start(NSOpenGLContext *ctxt) {
- [ctxt update]; // supports window resizing
-}
/* Returns the version of the running Mac OS as an int such as 100802 for 10.8.2,
and also assigns that value to global fl_mac_os_version.