简体   繁体   中英

Enabling the OpenGL Core Profile in pyglet on OS X

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()
  • Hardware: MacBook Air (13-inch, Mid 2012) Intel HD Graphics 4000 1024 MB
  • OSX: 10.10.1
  • Python: 2.7.6
  • pyglet: 1.2.4

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM