[Qt-interest] How can I get my job done with QGLWidget?
John McClurkin
jwm at nei.nih.gov
Wed Jun 24 13:53:24 CEST 2009
fog public wrote:
> Hi all, I am a newbee in QT development, high performace real-time
> graphic data rendering is what I want to archieved. I did try QGLWidget,
> It's very easy to use, now I was woundering if I can use a off-screen
> framebuffer object to get faster 2D graphic rendering speed, I try to
> declare a QGLFrameBufferObject pointer member in my class
> which inheritances from QGLWidget and initialized it in constructor
> just like
> QMyGLWidget::QMyGLWidget( QWidget *parent)
> :QGLWidget( QGLFormat( QGL::SampleBuffers),parent)
> {
> this->showFullScreen();
> setAutoSwapBuffers(false);
> setAutoFillbackground(false);
> pFrameBuffer = NULL;
> makeCurrent();
> pFrameBuffer = new QGLFrameBufferObject(width(),height());
> ....
> }
> and rewrite the paintEvent(QPaintEvent *e) to get a shot.
> void QMyGLWidget::paintEvent(QPaintEvent *e)
> {
> QPainter painter(pFrameBuffer);
> //do some 2d painting
> painter.end();
> swapbuffers();
> }
> but I got nothing display on the screen, If I must call some functions
> to force QGLWidget using framebuffer I declared,and swap it to
> show??Please give me a advice thanks a lot
Does your system support OpenGL frame buffer objects?
You need to bind the texture in the frame buffer object to the
QGLWidget. There are examples in examples/opengl/framebufferobject and
examples/opengl/framebufferobject2
More information about the Qt-interest-old
mailing list