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()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.