Support Modern macOS
This project will not build on the current release of macOS (10.15). This is because it has many warnings about deprecated code, and since the compiler uses -Werror to convert all warnings to errors, it will convert these deprecations to errors.
A simple fix is to remove this flag and build it, nothing seems to go wrong, but this is not a good answer. This pull request has changed parts of the code to support the newer macOS systems. Since I am not familiar with older macOS, nor do I have a machine that runs it, I cannot test it, and do not know what libraries are included in the older OS's. So I have created ifdefs around the problem parts. This will use the old code for older systems, but if it is deprecated, it will use the newer code.
Some caveats to this approach:
ftmac.cis part of a third party library, and I did not feel right modifying it. So I just had the compiler ignore the entire file.- This code is also above me, and I couldn't fix it in a weekend project. So this can be left for someone else
Window_cocoa.mhas had many parts ifdef'd, but some required more work- I had to add a framework for later versions of macOS
- I'm not sure if apple changed the required parameters of functions, but some errors were from improper casting
- I added a cast to these systems, if this causes an error on older systems, we can easily add another ifdef for those
- The final problem is OpenGL
- macOS has deprecated OpenGL in favor of Metal (which could be causing the high CPU/GPU usage in some cases)
- This would require a bit of refactoring, that did not feel right doing in this issue
- so I left this code alone and told the compiler to ignore these errors.
Any questions or comments let me know. I am unable to test on older macOS, but I do not change the original code too much. This project is very interesting, and I was sad when it wouldn't compile in a single step.
Just FYI I still need to look at some things regarding this
- Changing to
NSObject<NSWindowDelegate>will cause compilation issues on much older compilers - Need to work out why it's necessary to manually disable clang deprecation warnings to hide OpenGL deprecation messages - I had previously added
#define GL_SILENCE_DEPRECATIONso that shouldn't have been necessary
I might have fixed the first issue. my text highlighter is complaining, the #else and #endif get highlighted red if an @ is inside it.
But the code compiles, so maybe it just doesn't like Obj-C.
As for the OpenGL, that is interesting. here is the output I get from Make.
src/Window_cocoa.m:833:16: error: 'NSOpenGLPFAFullScreen' is deprecated: first deprecated in macOS 10.6 [-Werror,-Wdeprecated-declarations]
833 | fullscreen ? NSOpenGLPFAFullScreen : 0,
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:91:5: note: 'NSOpenGLPFAFullScreen' has been explicitly marked deprecated here
91 | NSOpenGLPFAFullScreen API_DEPRECATED("", macos(10.0,10.6)) = 54,
| ^
src/Window_cocoa.m:855:13: error: 'setView:' is deprecated: first deprecated in macOS 10.14 - Use NSOpenGLView to provide OpenGL content in a Cocoa app. [-Werror,-Wdeprecated-declarations]
855 | [ctxHandle setView:viewHandle];
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:193:36: note: property 'view' is declared deprecated here
193 | @property (nullable, weak) NSView *view NS_SWIFT_UI_ACTOR API_DEPRECATED("", macos(10.0,10.14));
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:194:1: note: 'setView:' has been explicitly marked deprecated here
194 | - (void)setView:(nullable NSView *)view NS_SWIFT_UI_ACTOR API_DEPRECATED("Use NSOpenGLView to provide OpenGL content in a Cocoa app.", macos(10.0,10.14));
| ^
src/Window_cocoa.m:888:44: error: 'NSOpenGLCPSwapInterval' is deprecated: first deprecated in macOS 10.14 [-Werror,-Wdeprecated-declarations]
888 | [ctxHandle setValues:&value forParameter: NSOpenGLCPSwapInterval];
| ^~~~~~~~~~~~~~~~~~~~~~
| NSOpenGLContextParameterSwapInterval
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:258:39: note: 'NSOpenGLCPSwapInterval' has been explicitly marked deprecated here
258 | static const NSOpenGLContextParameter NSOpenGLCPSwapInterval API_DEPRECATED_WITH_REPLACEMENT("NSOpenGLContextParameterSwapInterval", macos(10.5,10.14)) = NSOpenGLContextParameterSwapInterval;
| ^
src/Window_cocoa.m:1001:13: error: 'setView:' is deprecated: first deprecated in macOS 10.14 - Use NSOpenGLView to provide OpenGL content in a Cocoa app. [-Werror,-Wdeprecated-declarations]
1001 | [ctxHandle setView:viewHandle];
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:193:36: note: property 'view' is declared deprecated here
193 | @property (nullable, weak) NSView *view NS_SWIFT_UI_ACTOR API_DEPRECATED("", macos(10.0,10.14));
| ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:194:1: note: 'setView:' has been explicitly marked deprecated here
194 | - (void)setView:(nullable NSView *)view NS_SWIFT_UI_ACTOR API_DEPRECATED("Use NSOpenGLView to provide OpenGL content in a Cocoa app.", macos(10.0,10.14));
| ^
4 errors generated.
make[1]: *** [build-macos/Window_cocoa.o] Error 1
make: *** [darwin] Error 2
OpenGL is deprecated in favor of Metal, but you are right that the define should make it work. It just has to be defined before OpenGL is included