Closed mrj001 closed 2 years ago
When you squeeze this Profile = ContextProfile.Compatability,
in between the other properties, will that fix the problem for you?
If yes, maybe we can wrap it with something like
#if MACOS
Profile = ContextProfile.Compatability,
#endif
Just noted the spelling error.. Compatability
:D Isn't it Compatibility
?
If this fix works, maybe you can provide a PR with both :) That also means we should modify the csproj files so that they can emit a symbol/definition "MACOS" when you are on that platform...
Maybe this works
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)'=='true'">
<DefineConstants>WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsOSX)'=='true'">
<DefineConstants>OSX</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinux)'=='true'">
<DefineConstants>LINUX</DefineConstants>
</PropertyGroup>
in conjunction with
#if OSX
...
#endif
My "git diff" on Program.cs now looks like this (compared to the tutorial):
--- a/Program.cs +++ b/Program.cs @@ -1,5 +1,6 @@ <U+FEFF>using System; using OpenTK.Mathematics; +using OpenTK.Windowing.Common; using OpenTK.Windowing.Desktop;
namespace LearnOpenTK @@ -12,6 +13,8 @@ namespace LearnOpenTK { Size = new Vector2i(800, 600), Title = "LearnOpenTK - Creating a Window",
- Profile = ContextProfile.Compatability,
APIVersion = new Version(3, 2) };
// To create a new window, create a class that extends GameWindow, then call Run() on it.
And, I'm still getting the same runtime exception:
Unhandled exception. OpenTK.Windowing.GraphicsLibraryFramework.GLFWException: NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above at OpenTK.Windowing.Desktop.GLFWProvider.<>c.<.cctor>b__5_0(ErrorCode errorCode, String description)
This also happens with APIVersion set to 3.3 and 4.1. I only tried OpenTK version 5.0.0-pre.6 today.
What you need is not to enable compatibility context (macos doesn't support it), instead you need to set the forward-compatible flag (which removes compatibility context functions).
Flags = ContextFlags.ForwardCompatible,
@NogginBops, this worked, the current 'git diff' against Program.cs is:
--- a/Program.cs +++ b/Program.cs @@ -1,5 +1,6 @@ <U+FEFF>using System; using OpenTK.Mathematics; +using OpenTK.Windowing.Common; using OpenTK.Windowing.Desktop;
namespace LearnOpenTK @@ -12,6 +13,8 @@ namespace LearnOpenTK { Size = new Vector2i(800, 600), Title = "LearnOpenTK - Creating a Window",
- Flags = ContextFlags.ForwardCompatible,
APIVersion = new Version(4, 1) };
// To create a new window, create a class that extends GameWindow, then call Run() on it.
@deccer, I think rather than a PR against the tutorials, that it would be better to change the value of the ContextFlags.Default on MacOS. See opentk/opentk#1307
I guess that's possible.
I've copied the code from the repo commit d71bd15.
I've tried both versions 4.6.4 and 5.0.0-pre.6.
I've modified Program.cs like this:
I've tried versions 3.2, 3.3 and 4.1. The comments in the NativeWindowSettings.cs indicate these should all work on MacOS.
I'm consistently getting this exception:
Here is the output of my "dotnet --info"