当我叫QGLBuffer时,允许QGLWidget.renderText停止工作。 事实上,所有QPainter功能都停止了工作,如果你超载QGLwidget的话。 油漆 活动
下面的《惩罚法》表明了这一问题。 它将打开两个QGLwidget窗口:
- one calls QGLBuffer.allocate and you can not see the text.
- The other works fine.
法典:
from PySide.QtGui import *
from PySide.QtOpenGL import *
from OpenGL.GL import *
import sys
class GLWidget(QGLWidget):
def __init__(self, alloc=False):
QGLWidget.__init__(self)
self.alloc = alloc
def initializeGL(self):
self.buffer = buffer = QGLBuffer(QGLBuffer.VertexBuffer)
buffer.create()
buffer.bind()
buffer.setUsagePattern(QGLBuffer.StaticDraw)
if self.alloc: # If true text will not be drawn
buffer.allocate(80)
def resizeGL(self, h, w):
glViewport(0, 0, h, w)
def paintGL(self):
glClearColor(1, 1, 1, 1)
glClear(GL_COLOR_BUFFER_BIT)
glColor(0, 0, 0, 1)
self.renderText(50, 50, "Text to Render")
def main(argv):
app = QApplication(argv)
widget = GLWidget(alloc=True)
widget.show()
widget2 = GLWidget(alloc=False)
widget2.show()
app.exec_()
if __name__ == __main__ :
main(sys.argv)
谁能向我指出正确的方向?