summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-08-28 13:51:22 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-08-28 13:51:22 (GMT)
commit31a0ef1d1dd55096652c1c4f0501fce2937a1b23 (patch)
treef728a2e5829e26ed75bfd465d07b336fc77e599f /src/opengl/qgl.cpp
parent7c2620578ba0698a14c1d4ff5c7a4e260f06ad31 (diff)
parentbd3cd571ac061b0ed0e8c001c90c4edeafae67d7 (diff)
downloadQt-31a0ef1d1dd55096652c1c4f0501fce2937a1b23.zip
Qt-31a0ef1d1dd55096652c1c4f0501fce2937a1b23.tar.gz
Qt-31a0ef1d1dd55096652c1c4f0501fce2937a1b23.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt into 4.6
Diffstat (limited to 'src/opengl/qgl.cpp')
-rw-r--r--src/opengl/qgl.cpp56
1 files changed, 50 insertions, 6 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index b4c7e10..f3265b4 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1672,7 +1672,6 @@ QGLContext::QGLContext(const QGLFormat &format)
QGLContext::~QGLContext()
{
- Q_D(QGLContext);
// remove any textures cached in this context
QGLTextureCache::instance()->removeContextTextures(this);
QGLTextureCache::deleteIfEmpty(); // ### thread safety
@@ -2185,6 +2184,9 @@ GLuint QGLContext::bindTexture(const QImage &image, GLenum target, GLint format)
The \a format parameter sets the internal format for the
texture. The default format is \c GL_RGBA.
+ The binding \a options are a set of options used to decide how to
+ bind the texture to the context.
+
The texture that is generated is cached, so multiple calls to
bindTexture() with the same QImage will return the same texture
id.
@@ -2235,7 +2237,7 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint forma
\overload
Generates and binds a 2D GL texture to the current context, based
- on \a image.
+ on \a pixmap.
*/
GLuint QGLContext::bindTexture(const QPixmap &pixmap, GLenum target, GLint format, BindOptions options)
{
@@ -4076,6 +4078,10 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
bool auto_swap = autoBufferSwap();
QPaintEngine *engine = paintEngine();
+#ifndef QT_OPENGL_ES
+ if (engine->type() == QPaintEngine::OpenGL2)
+ static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(true);
+#endif
QPainter *p;
bool reuse_painter = false;
if (engine->isActive()) {
@@ -4101,6 +4107,13 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
setAutoBufferSwap(false);
// disable glClear() as a result of QPainter::begin()
d->glcx->d_func()->clear_on_painter_begin = false;
+ if (engine->type() == QPaintEngine::OpenGL2) {
+ qt_save_gl_state();
+#ifndef QT_OPENGL_ES_2
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+#endif
+ }
p = new QPainter(this);
}
@@ -4124,7 +4137,13 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font,
delete p;
setAutoBufferSwap(auto_swap);
d->glcx->d_func()->clear_on_painter_begin = true;
+ if (engine->type() == QPaintEngine::OpenGL2)
+ qt_restore_gl_state();
}
+#ifndef QT_OPENGL_ES
+ if (engine->type() == QPaintEngine::OpenGL2)
+ static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(false);
+#endif
}
/*! \overload
@@ -4157,6 +4176,10 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
win_y = height - win_y; // y is inverted
QPaintEngine *engine = paintEngine();
+#ifndef QT_OPENGL_ES
+ if (engine->type() == QPaintEngine::OpenGL2)
+ static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(true);
+#endif
QPainter *p;
bool reuse_painter = false;
#ifndef QT_OPENGL_ES
@@ -4175,6 +4198,8 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
setAutoBufferSwap(false);
// disable glClear() as a result of QPainter::begin()
d->glcx->d_func()->clear_on_painter_begin = false;
+ if (engine->type() == QPaintEngine::OpenGL2)
+ qt_save_gl_state();
p = new QPainter(this);
}
@@ -4213,9 +4238,15 @@ void QGLWidget::renderText(double x, double y, double z, const QString &str, con
} else {
p->end();
delete p;
+ if (engine->type() == QPaintEngine::OpenGL2)
+ qt_restore_gl_state();
setAutoBufferSwap(auto_swap);
d->glcx->d_func()->clear_on_painter_begin = true;
}
+#ifndef QT_OPENGL_ES
+ if (engine->type() == QPaintEngine::OpenGL2)
+ static_cast<QGL2PaintEngineEx *>(engine)->setRenderTextActive(false);
+#endif
}
QGLFormat QGLWidget::format() const
@@ -4260,8 +4291,12 @@ GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format)
return d->glcx->bindTexture(image, target, format, QGLContext::DefaultBindOption);
}
+/*!
+ \overload
-
+ The binding \a options are a set of options used to decide how to
+ bind the texture to the context.
+ */
GLuint QGLWidget::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options)
{
Q_D(QGLWidget);
@@ -4297,6 +4332,15 @@ GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format
return d->glcx->bindTexture(pixmap, target, format, QGLContext::DefaultBindOption);
}
+/*!
+ \overload
+
+ Generates and binds a 2D GL texture to the current context, based
+ on \a pixmap. The generated texture id is returned and can be used in
+
+ The binding \a options are a set of options used to decide how to
+ bind the texture to the context.
+ */
GLuint QGLWidget::bindTexture(const QPixmap &pixmap, GLenum target, GLint format,
QGLContext::BindOptions options)
{
@@ -4433,10 +4477,10 @@ QPaintEngine *QGLWidget::paintEngine() const
#elif defined(QT_OPENGL_ES_2)
return qt_gl_2_engine();
#else
- if (!qt_gl_preferGL2Engine())
- return qt_gl_engine();
- else
+ if (qt_gl_preferGL2Engine())
return qt_gl_2_engine();
+ else
+ return qt_gl_engine();
#endif
}