Search code examples
c#macosopenglopentk

GLSL 1.2+ not supported on Mac OS?


I'm recieving the error

ERROR: 0:1: '' :  version '330' is not supported
ERROR: One or more attached shaders not successfully compiled

when trying to compile the following shader:

#version 330

in vec3 vPosition;
in  vec3 vColor;
out vec4 color;
uniform mat4 modelview;

void main()
{
    gl_Position = modelview * vec4(vPosition, 1.0);

    color = vec4( vColor, 1.0);
}

Re-writing the shader to version 110 spec compiles and runs fine:

#version 110

attribute vec3 vPosition;
attribute  vec3 vColor;
varying vec4 color;
uniform mat4 modelview;

void main()
{
    gl_Position = modelview * vec4(vPosition, 1.0);

    color = vec4( vColor, 1.0);
}

This worked for a while, but now I need to use 330 features.

I'm on a 2011 MacBook Pro running El Captian 10.11.2 and using the latest versions of OpenTK.dll and OpenTK.dll.config from the OpenTK website.

I have tried enabling the SDL2 backend by copying libSDL2.dylib from opentk/Dependencies/x86 to my application directory as suggested by another user, but no difference.

What must I do to support 330 features?


Solution

  • All MacBook Pros support at least OpenGL 3.3. The issue was in the defaults for OpenTK's GameWindow constructor. Their official documentation seems to imply that it defaults to OpenGL 2.1, but it definitely doesn't behave that way on Windows.

    Adding this override fixed it.

    public Game() : base(800, 600, new GraphicsMode(new ColorFormat(8), 3, 3, 4), "Welcome To Hell", GameWindowFlags.Default, DisplayDevice.Default, 3, 0, GraphicsContextFlags.Default)
    {
    }