python - Pyside2 - QOpenGLFunction 对象没有属性 glShaderSource
问题描述
我正在尝试使用QOpenGLFunctions
with PySide2
。一切都很好,直到我尝试使用在实施中glShaderSource()
似乎缺少的东西PySide2
QOpenGLFunctions
AttributeError:“PySide2.QtGui.QOpenGLFunctions”对象没有属性“glShaderSource”
此外,https://doc.qt.io/qtforpython-5/PySide2/QtGui/QOpenGLFunctions.htmlglShaderSource
中也缺少
不是很久没解决的bug吗?因为我使用的是 PySide5.12
并且链接的文档是针对5.15
. 有人用QOpenGLFunctions
吗PySide2
?因为你如何在没有着色器的情况下使用它?
from OpenGL import GL
from PySide2 import QtGui
if __name__ == "__main__":
app = QtGui.QGuiApplication()
off_screen = QtGui.QOffscreenSurface()
off_screen.create()
if off_screen.isValid():
context = QtGui.QOpenGLContext()
if context.create():
context.makeCurrent(off_screen)
###
f = QtGui.QOpenGLFunctions(context)
shader = f.glCreateShader(GL.GL_VERTEX_SHADER)
f.glShaderSource(shader, "") # <-AttributeError
f.glCompileShader(shader)
####
解决方案
推荐阅读
- javascript - 如何在反应打字稿中将输入值从孩子传递给父母
- spring - Spring Boot 开发人员应该知道什么?
- java - kaptGenerateStubs 任务抛出 java.lang.StackOverflowError
- c# - 从 AJAX 返回的部分视图是否可以访问模型参数?
- python - k-means 返回 nan 值?
- javascript - Javascript:通过内部的onclick返回函数增加循环索引
- python - Python:如何将 pyautogui.locateOnScreen 中的左侧或顶部作为 int?
- python - Python创建列表列表
- bash - 在shell脚本中获取目录中的文件列表?
- javascript - JS:检查单词“handover”是否包含“hand”