Python 使用PyQT5的OpenGL帧缓冲区屏幕外、屏幕上渲染问题
我正在尝试渲染到fbo以使用glReadPixels。我可以渲染到fbo并读取像素值,但我无法在屏幕上进行渲染,我遇到如下错误: err=1286, description=b“无效的帧缓冲区操作” 以下是我的步骤:Python 使用PyQT5的OpenGL帧缓冲区屏幕外、屏幕上渲染问题,python,opengl,pyqt5,framebuffer,pyopengl,Python,Opengl,Pyqt5,Framebuffer,Pyopengl,我正在尝试渲染到fbo以使用glReadPixels。我可以渲染到fbo并读取像素值,但我无法在屏幕上进行渲染,我遇到如下错误: err=1286, description=b“无效的帧缓冲区操作” 以下是我的步骤: class MyGLWidget(QOpenGLWidget): ... ... def paintGl(): ### offscreen rendering ### glBind
class MyGLWidget(QOpenGLWidget):
...
...
def paintGl():
### offscreen rendering ###
glBindFramebuffer(GL_FRAMEBUFFER, self.fbo);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
# ... bind texture ...
# ... shader program...
# ... VAO
# ... EBO
# ... uniforms
# ... draw
glBindFramebuffer(GL_FRAMEBUFFER, 0) #<--- The problem is here. i don't know why
### read pixel ###
glBindFramebuffer(GL_READ_FRAMEBUFFER, self.fbo)
glReadBuffer(GL_COLOR_ATTACHMENT0)
print(glReadPixels(0, 0, _width, _height, _format, _type)) #<-- I got correct value here.
### on screen render ###
glClearColor(0.0, 0.0, 0.0, 1.0) #<---I got an error here
glClear(GL_COLOR_BUFFER_BIT)
# ... bind texture (color attachment texture)
# ... shader program...
# ... VAO
# ... EBO
glDrawElements(mode, count, _type, indices) #<--- If i don't use glClear, I get an error here.
类MyGLWidget(QOpenGLWidget):
...
...
def paintGl():
###屏幕外渲染###
glBindFramebuffer(GL_FRAMEBUFFER,self.fbo);
glClearColor(0.0,0.0,0.0,1.0);
glClear(GL_颜色_缓冲_位| GL_深度_缓冲_位);
# ... 绑定纹理。。。
# ... 着色器程序。。。
# ... 沃
# ... 埃博
# ... 制服
# ... 画
glBindFramebuffer(GLU帧缓冲区,0)#
glBindFramebuffer(GL\u帧缓冲区,0)#
glBindFramebuffer(GL_FRAMEBUFFER, 0) #<--- The problem is here. i don't know why