diff options
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qglshader.cpp | 16 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qglshader_p.h | 1 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 6 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/opengl/gl2paintengineex/qglshader.cpp b/src/opengl/gl2paintengineex/qglshader.cpp index 634be84..4ac6e61 100644 --- a/src/opengl/gl2paintengineex/qglshader.cpp +++ b/src/opengl/gl2paintengineex/qglshader.cpp @@ -49,7 +49,11 @@ return false; \ ctx->makeCurrent(); \ - +#if !defined(QT_OPENGL_ES_2) +static const char *qglslDefines = "#define lowp\n#define mediump\n#define highp\n"; +#else +static const char *qglslDefines = ""; +#endif class QGLShaderPrivate @@ -131,9 +135,13 @@ bool QGLShader::compile() return false; const QByteArray src_ba = d->source.toAscii(); - const char* src = src_ba.constData(); + const char* src[2]; + src[0] = qglslDefines; + src[1] = src_ba.constData(); + - glShaderSource(d->shaderId, 1, &src, 0); + QGLContext *ctx = d->ctx; + glShaderSource(d->shaderId, 2, src, 0); glCompileShader(d->shaderId); @@ -160,6 +168,7 @@ QString QGLShader::log() GLint logSize; GLint logLength; + QGLContext *ctx = d->ctx; glGetShaderiv(d->shaderId, GL_INFO_LOG_LENGTH, &logSize); if (!logSize) @@ -377,6 +386,7 @@ void QGLShaderProgram::use() if (!d->valid) return; + QGLContext *ctx = d->ctx; glUseProgram(d->programId); } diff --git a/src/opengl/gl2paintengineex/qglshader_p.h b/src/opengl/gl2paintengineex/qglshader_p.h index 1625b84..4cbf3f6 100644 --- a/src/opengl/gl2paintengineex/qglshader_p.h +++ b/src/opengl/gl2paintengineex/qglshader_p.h @@ -81,6 +81,7 @@ SAMPLER_2D_SHADOW. #include <QtOpenGL> +#include <private/qgl_p.h> typedef struct { GLfloat a; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index a74f044..2948e62 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -845,6 +845,7 @@ void QGL2PaintEngineEx::transformChanged() void QGL2PaintEngineEx::drawPixmap(const QRectF& dest, const QPixmap & pixmap, const QRectF & src) { Q_D(QGL2PaintEngineEx); + QGLContext *ctx = d->ctx; glActiveTexture(QT_BRUSH_TEXTURE_UNIT); d->ctx->d_func()->bindTexture(pixmap, GL_TEXTURE_2D, GL_RGBA, true); @@ -862,6 +863,7 @@ void QGL2PaintEngineEx::drawImage(const QRectF& dest, const QImage& image, const Qt::ImageConversionFlags) { Q_D(QGL2PaintEngineEx); + QGLContext *ctx = d->ctx; glActiveTexture(QT_BRUSH_TEXTURE_UNIT); d->ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, true); @@ -926,6 +928,7 @@ void QGL2PaintEngineEx::drawCachedGlyphs(const QPointF &p, const QTextItemInt &t const QImage &image = cache->image(); int margin = cache->glyphMargin(); + QGLContext *ctx = d->ctx; glActiveTexture(QT_BRUSH_TEXTURE_UNIT); d->ctx->d_func()->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, true); @@ -1000,6 +1003,9 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) d->width = widget->width(); d->height = widget->height(); + qt_resolve_version_1_3_functions(d->ctx); + qt_resolve_glsl_extensions(d->ctx); + if (!d->shaderManager) d->shaderManager = new QGLPEXShaderManager(d->ctx); |