【问题标题】:Invalid operation when glEnable(GL_MULTISAMPLE) in pyopenglpyopengl 中 glEnable(GL_MULTISAMPLE) 时的无效操作
【发布时间】:2021-10-02 05:36:35
【问题描述】:

代码:

from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

def draw():
    pass

def main():
    glutInit()
    glEnable(GL_MULTISAMPLE)
    glutCreateWindow('Demo')
    glutDisplayFunc(draw)
    glutMainLoop()

if __name__ == '__main__':
    main()

错误:

Traceback (most recent call last):
  File ".\test.py", line 16, in <module>
    main()
  File ".\test.py", line 10, in main
    glEnable(GL_MULTISAMPLE)
  File "D:\Program\Anaconda\lib\site-packages\OpenGL\platform\baseplatform.py", line 415, in __call__
    return self( *args, **named )
  File "D:\Program\Anaconda\lib\site-packages\OpenGL\error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'\xce\xde\xd0\xa7\xb2\xd9\xd7\xf7',
        baseOperation = glEnable,
        cArguments = (GL_MULTISAMPLE,)
)

错误描述为“无效操作”。

我正在研究 OpenGL,我想尝试抗锯齿。我不知道为什么这不起作用。我应该如何解决这个问题?如何发现有没有环境问题?还是我犯了一些低级错误?

【问题讨论】:

    标签: python opengl pyopengl


    【解决方案1】:

    仅当存在有效的 OpenGL 上下文时调用 OpenGL 命令才有效。使用 glut 时,上下文由glutCreateWindow 命令创建。之前调用的所有方法都会抛出错误,因为上下文无效。

    正确代码:

    glutInit()
    glutCreateWindow('Demo')
    glEnable(GL_MULTISAMPLE)
    glutDisplayFunc(draw)
    glutMainLoop()
    

    【讨论】:

      猜你喜欢
      • 2018-08-24
      • 2014-12-25
      • 1970-01-01
      • 2014-07-30
      • 2018-09-22
      • 2015-10-31
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多