在PyOpenGL / PyQt中创建一个大型(2 ^ 13)帧缓冲对象时出现内存不足错误:
width = 8192
height = 8192
self.textureFbo = QtOpenGL.QGLFramebufferObject(width,height)
self.textureFbo.bind()
texture = self.bindTexture(QtGui.QPixmap(self.textureFilePath)) # 2^13
glClearColor (0.0, 0.0, 0.0, 0.0);
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity()
glViewport(0, 0, width, height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity()
glOrtho(0, +1, +1, 0, -0.1, 2.0);
glBegin(GL_POLYGON);
glTexCoord2d(1.0, 0.0)
glVertex3f (0.0, 0.0, 0.0)
glTexCoord2d(1.0, 1.0)
glVertex3f (1.0, 0.0, 0.0)
glTexCoord2d(0.0, 1.0)
glVertex3f (1.0, 1.0, 0.0)
glTexCoord2d(0.0, 0.0)
glVertex3f (0.0, 1.0, 0.0)
glEnd();
self.deleteTexture(texture)
self.textureFbo.release()
self.textureFboLoaded = True
给出:
OpenGL.error.GLError: GLError(
err = 1285,
description = 'out of memory',
baseOperation = glClear,
cArguments = (GL_COLOR_BUFFER_BIT,)
)
QGLFramebufferObject: Framebuffer incomplete attachment.
Traceback (most recent call last):
File "main.py", line 286, in paintGL
self.loadTextureFBO()
File "main.py", line 357, in loadTextureFBO
glEnable(GL_TEXTURE_2D)
File "C:\Python27\lib\site-packages\OpenGL\error.py", line 208, in glCheckErro
r
baseOperation = baseOperation,
OpenGL.error.GLError: GLError(
err = 1285,
description = 'out of memory',
baseOperation = glEnable,
cArguments = (GL_TEXTURE_2D,)
)
QImage: out of memory, returning null image
然而,如果我下降到2 ^ 12纹理或FBO,这样可以正常工作。
对我来说,两个图像(FBO + texure)大约 132mb 268mb(4字节* 8192 ^ 2)应该填满我的1gb视频内存似乎是不合理的。我错过了什么?
答案 0 :(得分:1)
首先,请注意4 x 8192 ^ 2是268M,而不是132,所以我们谈论这两个对象超过半GB。据推测,对记忆也有其他要求。我同意听起来你不应该有问题,但我不知道还有什么事情发生。