使用 python opengl (PyOpenGL) 创建几何着色器失败 [英] Create geometry shader using python opengl (PyOpenGL) failed

查看:279
本文介绍了使用 python opengl (PyOpenGL) 创建几何着色器失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 glCreateShader(GL_GEOMETRY_SHADER) 创建 geometry_shader,但出现错误.

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
)

我的环境:Python 版本:3.6.7
OpenGL 核心配置文件版本字符串:4.5(核心配置文件)Mesa 18.0.5
操作系统版本:ubuntu 18.04(ubuntu 16.04 测试相同)
这个站点我知道最低版本是 3.2.所以应该不是版本问题.
是否可能是opengl的python包装器的错误?这是我的测试代码.

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

推荐答案

验证上下文的 GL_VERSION 字符串实际上是您所假设的.

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

Mesa 通常只为您提供 OpenGL 2.1 上下文,除非您特别要求版本化的 Core 上下文,但随着时间的推移,越来越多的驱动程序获得了兼容性上下文支持.

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.

对于 GLFW,您通常通过之前设置的提示请求 GL 版本创建窗口,特别是您需要为 GLFW_CONTEXT_VERSION_MAJORGLFW_CONTEXT_VERSION_MINORGLFW_OPENGL_PROFILE 设置值.

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.

这篇关于使用 python opengl (PyOpenGL) 创建几何着色器失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆