hao li
hao li

Reputation: 437

Create geometry shader using python opengl (PyOpenGL) failed

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()

Upvotes: 2

Views: 521

Answers (1)

genpfault
genpfault

Reputation: 52090

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.

Upvotes: 1

Related Questions