Navigation Menu

Skip to content

Commit

Permalink
[Mac] OpenGL 3.x/4.x require core profile flag
Browse files Browse the repository at this point in the history
SDL will fail to construct an OpenGL 3.x/4.x context on Mac OS X,
unless ContextProfileFlags.CORE is specified.

Fixes issue #44

Upstream enhancement request at
https://bugzilla.libsdl.org/show_bug.cgi?id=2342
  • Loading branch information
thefiddler committed Jan 9, 2014
1 parent 7f64945 commit a4d2a31
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Source/OpenTK/Platform/SDL2/Sdl2GraphicsContext.cs
Expand Up @@ -157,6 +157,8 @@ static GraphicsMode GetGLAttributes(ContextHandle sdlContext, out GraphicsContex
int major, int minor, int major, int minor,
GraphicsContextFlags flags) GraphicsContextFlags flags)
{ {
ContextProfileFlags cpflags = 0;

if (mode.AccumulatorFormat.BitsPerPixel > 0) if (mode.AccumulatorFormat.BitsPerPixel > 0)
{ {
SDL.GL.SetAttribute(ContextAttribute.ACCUM_ALPHA_SIZE, mode.AccumulatorFormat.Alpha); SDL.GL.SetAttribute(ContextAttribute.ACCUM_ALPHA_SIZE, mode.AccumulatorFormat.Alpha);
Expand Down Expand Up @@ -203,6 +205,15 @@ static GraphicsMode GetGLAttributes(ContextHandle sdlContext, out GraphicsContex
{ {
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MAJOR_VERSION, major); SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MAJOR_VERSION, major);
SDL.GL.SetAttribute(ContextAttribute.CONTEXT_MINOR_VERSION, minor); 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.
if (Configuration.RunningOnMacOS && major >= 3 &&
(flags & GraphicsContextFlags.Embedded) == 0)
{
cpflags |= ContextProfileFlags.CORE;
}
} }


if ((flags & GraphicsContextFlags.Debug) != 0) if ((flags & GraphicsContextFlags.Debug) != 0)
Expand All @@ -223,7 +234,6 @@ static GraphicsMode GetGLAttributes(ContextHandle sdlContext, out GraphicsContex
*/ */


{ {
ContextProfileFlags cpflags = 0;
if ((flags & GraphicsContextFlags.Embedded) != 0) if ((flags & GraphicsContextFlags.Embedded) != 0)
{ {
cpflags |= ContextProfileFlags.ES; cpflags |= ContextProfileFlags.ES;
Expand Down

0 comments on commit a4d2a31

Please sign in to comment.