[SDL2] On Mac, OpenGL 3.0 or 3.1 should create 3.2 context

SDL2/Mac fails to create a 3.0 or 3.1 OpenGL context. We implicitly
bump version to 3.2, otherwise 3.0 or 3.1 would give a 2.1 context.
This commit is contained in:
thefiddler 2014-03-16 22:50:12 +01:00
parent 02bf55ad7e
commit f23b93b839

View file

@ -240,9 +240,6 @@ namespace OpenTK.Platform.SDL2
if (major > 0)
{
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MAJOR_VERSION, major);
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MINOR_VERSION, minor);
// Workaround for https://github.com/opentk/opentk/issues/44
// Mac OS X desktop OpenGL 3.x/4.x contexts require require
// ContextProfileFlags.Core, otherwise they will fail to construct.
@ -250,9 +247,19 @@ namespace OpenTK.Platform.SDL2
(flags & GraphicsContextFlags.Embedded) == 0)
{
cpflags |= ContextProfileFlags.CORE;
// According to https://developer.apple.com/graphicsimaging/opengl/capabilities/GLInfo_1075_Core.html
// Mac OS X supports 3.2+. Indeed, requesting 3.0 or 3.1 results in failure.
if (major == 3 && minor < 2)
{
minor = 2;
}
}
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MAJOR_VERSION, major);
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MINOR_VERSION, minor);
}
if ((flags & GraphicsContextFlags.Debug) != 0)
{
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_FLAGS, ContextFlags.DEBUG);