diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2009-03-11 17:47:47 (GMT) |
---|---|---|
committer | Gunnar Sletta <gunnar@trolltech.com> | 2009-04-01 14:35:48 (GMT) |
commit | 860498a1e63bff2b5a52accda92256c36ba5c23d (patch) | |
tree | a238fbec3d08ca7481712acfd768f08ed006129d /examples | |
parent | b469889f6f9b49f2e52948e3419958b0d8bfc994 (diff) | |
download | Qt-860498a1e63bff2b5a52accda92256c36ba5c23d.zip Qt-860498a1e63bff2b5a52accda92256c36ba5c23d.tar.gz Qt-860498a1e63bff2b5a52accda92256c36ba5c23d.tar.bz2 |
Fixes: Use the blit/multisample FBO API in the framebuffer object example.
RevBy: Trond
Diffstat (limited to 'examples')
-rw-r--r-- | examples/opengl/framebufferobject/glwidget.cpp | 28 | ||||
-rw-r--r-- | examples/opengl/framebufferobject/glwidget.h | 3 |
2 files changed, 26 insertions, 5 deletions
diff --git a/examples/opengl/framebufferobject/glwidget.cpp b/examples/opengl/framebufferobject/glwidget.cpp index d3591d6..3cb3929 100644 --- a/examples/opengl/framebufferobject/glwidget.cpp +++ b/examples/opengl/framebufferobject/glwidget.cpp @@ -53,7 +53,18 @@ GLWidget::GLWidget(QWidget *parent) { setWindowTitle(tr("OpenGL framebuffer objects")); makeCurrent(); - fbo = new QGLFramebufferObject(1024, 1024); + + if (QGLFramebufferObject::hasOpenGLFramebufferBlit()) { + QGLFramebufferObjectFormat format; + format.setSamples(4); + + render_fbo = new QGLFramebufferObject(512, 512, format); + texture_fbo = new QGLFramebufferObject(512, 512); + } else { + render_fbo = new QGLFramebufferObject(1024, 1024); + texture_fbo = render_fbo; + } + rot_x = rot_y = rot_z = 0.0f; scale = 0.1f; anim = new QTimeLine(750, this); @@ -113,7 +124,9 @@ GLWidget::~GLWidget() { delete[] wave; glDeleteLists(tile_list, 1); - delete fbo; + delete texture_fbo; + if (render_fbo != texture_fbo) + delete render_fbo; } void GLWidget::paintEvent(QPaintEvent *) @@ -129,10 +142,16 @@ void GLWidget::draw() saveGLState(); // render the 'bubbles.svg' file into our framebuffer object - QPainter fbo_painter(fbo); + QPainter fbo_painter(render_fbo); svg_renderer->render(&fbo_painter); fbo_painter.end(); + if (render_fbo != texture_fbo) { + QRect rect(0, 0, render_fbo->width(), render_fbo->height()); + QGLFramebufferObject::blitFramebuffer(texture_fbo, rect, + render_fbo, rect); + } + // draw into the GL widget glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); @@ -145,8 +164,9 @@ void GLWidget::draw() glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, fbo->texture()); + glBindTexture(GL_TEXTURE_2D, texture_fbo->texture()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glEnable(GL_TEXTURE_2D); glEnable(GL_MULTISAMPLE); glEnable(GL_CULL_FACE); diff --git a/examples/opengl/framebufferobject/glwidget.h b/examples/opengl/framebufferobject/glwidget.h index b64cfa8..d97ef78 100644 --- a/examples/opengl/framebufferobject/glwidget.h +++ b/examples/opengl/framebufferobject/glwidget.h @@ -77,6 +77,7 @@ private: QImage logo; QTimeLine *anim; QSvgRenderer *svg_renderer; - QGLFramebufferObject *fbo; + QGLFramebufferObject *render_fbo; + QGLFramebufferObject *texture_fbo; }; |