Create geometry shader using python opengl (PyOpenGL) failed

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-28 13:46:46

问题


I want to create geometry_shader using glCreateShader(GL_GEOMETRY_SHADER), but I get error.

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    geometry_shader = glCreateShader(GL_GEOMETRY_SHADER)
  File "errorchecker.pyx", line 53, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError (src/errorchecker.c:1218)
OpenGL.error.GLError: GLError(
        err = 1280,
        description = b'invalid enumerant',
        baseOperation = glCreateShader,
        cArguments = (GL_GEOMETRY_SHADER,),
        result = 0
)

My environment: Python version:3.6.7
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.0.5
OS version: ubuntu 18.04(ubuntu 16.04 tested same)
From this site I know that the minimum version is 3.2. So it should not be version issue.
Is it possible the bug of python wrapper of opengl? Here is my test code.

import glfw
from OpenGL.GL import *
glfw.init()
glfw.window_hint(glfw.SAMPLES, 4)
window_size = (800, 600)
window = glfw.create_window(*window_size, 'Vehicle Model', None, None)
glfw.make_context_current(window)
vertice_shader = glCreateShader(GL_VERTEX_SHADER)
geometry_shader = glCreateShader(GL_GEOMETRY_SHADER)
glfw.terminate()

回答1:


Verify that the GL_VERSION string of your context is actually what you're assuming it is.

Mesa generally only gives you an OpenGL 2.1 context unless you specifically ask for a versioned Core context, though more drivers are getting Compatibility context support as time goes on.

With GLFW you generally request GL versions via hints set before window creation, in particular you'll want to set values for GLFW_CONTEXT_VERSION_MAJOR, GLFW_CONTEXT_VERSION_MINOR, and GLFW_OPENGL_PROFILE.



来源:https://stackoverflow.com/questions/54939551/create-geometry-shader-using-python-opengl-pyopengl-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!