English 中文(简体)
QGLBuffer.allocate messes with QGLWidget.renderText
原标题:QGLBuffer.allocate messes with QGLWidget.renderText
  • 时间:2011-11-20 19:46:23
  •  标签:
  • qt
  • opengl

当我叫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)

谁能向我指出正确的方向?

最佳回答

我并不确切知道Qt开放式GL班是如何运作的,但根据我混合Qt和原始开放式GL3.3的经验,在你完成缓冲工作时,你就应该放弃,因为它用的是任何机制QPainter。

因此,在开始使用时,LGunbind和在油漆工中捆绑/bin。

问题回答

暂无回答




相关问题
Qt: Do events get processed in order?

If I had a class A, where one of its functions does: void A::func() { emit first_signal(); emit second_signal(); } Assuming that a class B has 2 slots, one connected to first_signal, and the ...

How to determine how much free space on a drive in Qt?

I m using Qt and want a platform-independent way of getting the available free disk space. I know in Linux I can use statfs and in Windows I can use GetDiskFreeSpaceEx(). I know boost has a way, ...

Drag & drop with .ui files

I m having big troubles with drag & drop. I ve created a new Qt Designer Form Class in which I have one QListWidget and one QWidget. Now I want to enable dragging & dropping between these two ...

Link errors on Snow Leopard

I creating a small desktop application using Qt and Poco on Mac OS X Snow Leopard. Qt works fine, but once I started linking with Poco I get the following warning: ld: warning: in /Developer/SDKs/...

Showing two windows in Qt4

My friend and I have each created parts of a GUI using Qt 4. They both work independently and I am trying to integrate his form with the my main window. As of now this is the code I am using to try ...

Qt equivalent of .NET data binding?

Is there an equivalent of .NET s data binding in Qt? I want to populate some combo boxes and other widgets with QStrings that refer to specific entities in my database. However, it would be cleaner ...

热门标签