I'm trying to get a minimal OpenGL shader working in pyglet but getting the following error when it compiles:
ERROR: 0:1: '' : version '420' is not supported
It seems like this might be due to pyglet using the legacy OpenGL profile as in this question but if that is the case how can I get pyglet to use a diffrent profile? I can't find it documented anywhere and feel like I must be missing something obvious.
The following code reproduces the problem (adapted from this example):
import pyglet
import pyglet.gl as gl
import ctypes
window = pyglet.window.Window()
handle = gl.glCreateProgram()
shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
source = """
#version 420
in vec3 vertex_position;
void main() {
gl_Position = vec4(vertex_position, 1.0);
}
"""
src = ctypes.c_char_p(source)
gl.glShaderSource(shader, 1,
ctypes.cast(ctypes.pointer(src),
ctypes.POINTER(ctypes.POINTER(ctypes.c_char))), None)
gl.glCompileShader(shader)
# Retrieve compilation status
status = ctypes.c_int(0)
gl.glGetShaderiv(shader, gl.GL_COMPILE_STATUS, ctypes.byref(status))
# If compilation failed, print the log
if not status:
gl.glGetShaderiv(shader, gl.GL_INFO_LOG_LENGTH, ctypes.byref(status))
buffer = ctypes.create_string_buffer(status.value)
gl.glGetShaderInfoLog(shader, status, None, buffer)
print buffer.value
pyglet.app.run()
Seems to be an open bug, there is an unresolved issue here in the old Google code repo, and I've filed a new bug here.
So I guess currently (as of pyglet 1.2.4) it's not possible to get a >3.0 OpenGL context.