diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-03-04 15:06:36 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-10 15:10:37 +0100 |
commit | 1e8de50674f5b33a50c45224b7e07b3f974f6ab0 (patch) | |
tree | a52d4e421be3c6c2deb4ff07905d5715012b0d9a /src/gui/opengl/qopenglfunctions.cpp | |
parent | 11eb9d37dc191b6e71c903e4f7f4d2da579e7df5 (diff) |
Avoid using direct OpenGL calls in gui and widgets
Change-Id: I5d88a2e204ca23e178a4e3044b9cb13392c3e763
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/gui/opengl/qopenglfunctions.cpp')
-rw-r--r-- | src/gui/opengl/qopenglfunctions.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index 5d30020f49..84c70606b1 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -1993,6 +1993,12 @@ void QOpenGLFunctions::initializeOpenGLFunctions() */ /*! + \fn void QOpenGLFunctions::glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) + + \internal +*/ + +/*! \fn bool QOpenGLFunctions::isInitialized(const QOpenGLFunctionsPrivate *d) \internal */ @@ -2394,6 +2400,15 @@ static void QOPENGLF_APIENTRY qopenglfResolveClearColor(GLclampf red, GLclampf g RESOLVE_FUNC_VOID(0, ClearColor)(red, green, blue, alpha); } +static void QOPENGLF_APIENTRY qopenglfResolveClearDepthf(GLclampf depth) +{ + if (QOpenGLContext::currentContext()->isES()) { + RESOLVE_FUNC_VOID(0, ClearDepthf)(depth); + } else { + RESOLVE_FUNC_VOID(0, ClearDepth)((GLdouble) depth); + } +} + static void QOPENGLF_APIENTRY qopenglfResolveClearStencil(GLint s) { RESOLVE_FUNC_VOID(0, ClearStencil)(s); @@ -2434,6 +2449,15 @@ static void QOPENGLF_APIENTRY qopenglfResolveDepthMask(GLboolean flag) RESOLVE_FUNC_VOID(0, DepthMask)(flag); } +static void QOPENGLF_APIENTRY qopenglfResolveDepthRangef(GLclampf zNear, GLclampf zFar) +{ + if (QOpenGLContext::currentContext()->isES()) { + RESOLVE_FUNC_VOID(0, DepthRangef)(zNear, zFar); + } else { + RESOLVE_FUNC_VOID(0, DepthRange)((GLdouble) zNear, (GLdouble) zFar); + } +} + static void QOPENGLF_APIENTRY qopenglfResolveDisable(GLenum cap) { RESOLVE_FUNC_VOID(0, Disable)(cap); @@ -3131,6 +3155,29 @@ static void QOPENGLF_APIENTRY qopenglfResolveGetBufferSubData(GLenum target, qop (target, offset, size, data); } +#if !defined(QT_OPENGL_ES_2) && !defined(QT_OPENGL_DYNAMIC) + +// Desktop only + +static void QOPENGLF_APIENTRY qopenglfResolveGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) +{ + RESOLVE_FUNC_VOID(0, GetTexLevelParameteriv)(target, level, pname, params); +} + +// Special translation functions for ES-specific calls on desktop GL + +static void QOPENGLF_APIENTRY qopenglfTranslateClearDepthf(GLclampf depth) +{ + ::glClearDepth(depth); +} + +static void QOPENGLF_APIENTRY qopenglfTranslateDepthRangef(GLclampf zNear, GLclampf zFar) +{ + ::glDepthRange(zNear, zFar); +} + +#endif // !ES2 && !DYNAMIC + QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) { /* Assign a pointer to an above defined static function @@ -3145,6 +3192,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) BlendFunc = qopenglfResolveBlendFunc; Clear = qopenglfResolveClear; ClearColor = qopenglfResolveClearColor; + ClearDepthf = qopenglfResolveClearDepthf; ClearStencil = qopenglfResolveClearStencil; ColorMask = qopenglfResolveColorMask; CopyTexImage2D = qopenglfResolveCopyTexImage2D; @@ -3153,6 +3201,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) DeleteTextures = qopenglfResolveDeleteTextures; DepthFunc = qopenglfResolveDepthFunc; DepthMask = qopenglfResolveDepthMask; + DepthRangef = qopenglfResolveDepthRangef; Disable = qopenglfResolveDisable; DrawArrays = qopenglfResolveDrawArrays; DrawElements = qopenglfResolveDrawElements; @@ -3186,6 +3235,8 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) TexParameteriv = qopenglfResolveTexParameteriv; TexSubImage2D = qopenglfResolveTexSubImage2D; Viewport = qopenglfResolveViewport; + + GetTexLevelParameteriv = qopenglfResolveGetTexLevelParameteriv; } else { #ifndef QT_OPENGL_DYNAMIC // Use the functions directly. This requires linking QtGui to an OpenGL implementation. @@ -3193,6 +3244,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) BlendFunc = ::glBlendFunc; Clear = ::glClear; ClearColor = ::glClearColor; + ClearDepthf = qopenglfTranslateClearDepthf; ClearStencil = ::glClearStencil; ColorMask = ::glColorMask; CopyTexImage2D = ::glCopyTexImage2D; @@ -3201,6 +3253,7 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) DeleteTextures = ::glDeleteTextures; DepthFunc = ::glDepthFunc; DepthMask = ::glDepthMask; + DepthRangef = qopenglfTranslateDepthRangef; Disable = ::glDisable; DrawArrays = ::glDrawArrays; DrawElements = ::glDrawElements; @@ -3234,6 +3287,8 @@ QOpenGLFunctionsPrivate::QOpenGLFunctionsPrivate(QOpenGLContext *) TexParameteriv = ::glTexParameteriv; TexSubImage2D = ::glTexSubImage2D; Viewport = ::glViewport; + + GetTexLevelParameteriv = ::glGetTexLevelParameteriv; #else // QT_OPENGL_DYNAMIC // This should not happen. qFatal("QOpenGLFunctions: Dynamic OpenGL builds do not support platforms with insufficient function resolving capabilities"); |