summaryrefslogtreecommitdiffstats
path: root/examples/opengl/framebufferobject
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-06-25 13:49:53 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-06-25 13:49:53 (GMT)
commitdb8f05e257019694f5e8076845626008f2adc3dd (patch)
tree05d3959403cf15ac5f702091439e028af01f343b /examples/opengl/framebufferobject
parent8aafaa65a1d16f8b982279f5aceedf1e281ddb5a (diff)
parent796a5a2c7d8c91a46ac761dde18b7da2ec6c177b (diff)
downloadQt-db8f05e257019694f5e8076845626008f2adc3dd.zip
Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.gz
Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.bz2
Merge commit 'qt/master-stable' into 4.6-stable
Bring Qt 4.6 into the Qt-S60 repo. Conflicts: configure.exe mkspecs/features/qttest_p4.prf qmake/generators/makefile.cpp src/corelib/io/qdir.cpp src/corelib/io/qprocess.h src/corelib/kernel/qcoreevent.h src/corelib/kernel/qobject.cpp src/corelib/kernel/qsharedmemory_unix.cpp src/corelib/thread/qthread_p.h src/corelib/tools/qvector.h src/gui/dialogs/qdialog.cpp src/gui/dialogs/qfiledialog.cpp src/gui/dialogs/qfiledialog_p.h src/gui/dialogs/qmessagebox.cpp src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsview.cpp src/gui/image/qpixmapcache.cpp src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication_p.h src/gui/kernel/qwidget.cpp src/gui/kernel/qwidget_p.h src/gui/painting/qdrawhelper.cpp src/gui/painting/qpaintengine_raster.cpp src/gui/text/qfontengine_qpf.cpp src/gui/widgets/qmenubar.cpp src/network/socket/qlocalserver.cpp src/testlib/qtestcase.cpp src/testlib/testlib.pro tests/auto/qimagereader/tst_qimagereader.cpp tests/auto/qitemdelegate/tst_qitemdelegate.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp tests/auto/qpixmap/qpixmap.pro
Diffstat (limited to 'examples/opengl/framebufferobject')
-rw-r--r--examples/opengl/framebufferobject/glwidget.cpp28
-rw-r--r--examples/opengl/framebufferobject/glwidget.h3
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;
};