From 7e352512cfd4ab76497de9d66b787a33bdaa8979 Mon Sep 17 00:00:00 2001 From: Wieland Hagen Date: Thu, 17 Dec 2015 19:02:20 +0100 Subject: Add glPointSize() helper functions OpenGL ES 2.0 doesn't support glPointSize(), but OpenGL 2.0+ does, so we need to call it though a QGraphicsHelperInterface. When on OpenGL ES 2.0, just print a warning. Task-number: QTBUG-49562 Change-Id: Icbd5f602cae38f95925d99003ec3ee9aebb3719e Reviewed-by: Sean Harmer --- src/render/graphicshelpers/graphicscontext.cpp | 5 +++++ src/render/graphicshelpers/graphicscontext_p.h | 1 + src/render/graphicshelpers/graphicshelperes2.cpp | 12 ++++++++++++ src/render/graphicshelpers/graphicshelperes2_p.h | 1 + src/render/graphicshelpers/graphicshelpergl2.cpp | 13 +++++++++++++ src/render/graphicshelpers/graphicshelpergl2_p.h | 1 + src/render/graphicshelpers/graphicshelpergl3.cpp | 10 ++++++++++ src/render/graphicshelpers/graphicshelpergl3_3.cpp | 10 ++++++++++ src/render/graphicshelpers/graphicshelpergl3_3_p.h | 1 + src/render/graphicshelpers/graphicshelpergl3_p.h | 1 + src/render/graphicshelpers/graphicshelpergl4.cpp | 10 ++++++++++ src/render/graphicshelpers/graphicshelpergl4_p.h | 1 + src/render/graphicshelpers/graphicshelperinterface_p.h | 1 + 13 files changed, 67 insertions(+) (limited to 'src') diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 41b354c23..92f5abbf4 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -786,6 +786,11 @@ void GraphicsContext::disablePrimitiveRestart() m_glHelper->disablePrimitiveRestart(); } +void GraphicsContext::pointSize(bool programmable, GLfloat value) +{ + m_glHelper->pointSize(programmable, value); +} + /*! \internal Returns a texture unit for a texture, -1 if all texture units are assigned. diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h index cf34806b7..8436166f4 100644 --- a/src/render/graphicshelpers/graphicscontext_p.h +++ b/src/render/graphicshelpers/graphicscontext_p.h @@ -194,6 +194,7 @@ public: GLint maxClipPlaneCount(); void enablePrimitiveRestart(int restartIndex); void disablePrimitiveRestart(); + void pointSize(bool programmable, GLfloat value); // Helper methods static GLint elementType(GLint type); diff --git a/src/render/graphicshelpers/graphicshelperes2.cpp b/src/render/graphicshelpers/graphicshelperes2.cpp index 8d1df2253..2072df3f4 100644 --- a/src/render/graphicshelpers/graphicshelperes2.cpp +++ b/src/render/graphicshelpers/graphicshelperes2.cpp @@ -542,6 +542,18 @@ void GraphicsHelperES2::disablePrimitiveRestart() { } +void GraphicsHelperES2::pointSize(bool programmable, GLfloat value) +{ + // If this is not a reset to default values, print a warning + if (programmable || !qFuzzyCompare(value, 1.0f)) { + static bool warned = false; + if (!warned) { + qWarning() << "glPointSize() and GL_PROGRAM_POINT_SIZE are not supported by ES 2.0"; + warned = true; + } + } +} + QSize GraphicsHelperES2::getRenderBufferDimensions(GLuint renderBufferId) { GLint width = 0; diff --git a/src/render/graphicshelpers/graphicshelperes2_p.h b/src/render/graphicshelpers/graphicshelperes2_p.h index 6d0fc1993..f7d675b82 100644 --- a/src/render/graphicshelpers/graphicshelperes2_p.h +++ b/src/render/graphicshelpers/graphicshelperes2_p.h @@ -102,6 +102,7 @@ public: GLint maxClipPlaneCount() Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl2.cpp b/src/render/graphicshelpers/graphicshelpergl2.cpp index 972d93ffe..c21a6eeba 100644 --- a/src/render/graphicshelpers/graphicshelpergl2.cpp +++ b/src/render/graphicshelpers/graphicshelpergl2.cpp @@ -540,6 +540,19 @@ void GraphicsHelperGL2::disablePrimitiveRestart() { } +void GraphicsHelperGL2::pointSize(bool programmable, GLfloat value) +{ + // Print a warning once for trying to set GL_PROGRAM_POINT_SIZE + if (programmable) { + static bool warned = false; + if (!warned) { + qWarning() << "GL_PROGRAM_POINT_SIZE is not supported by OpenGL 2.0 (since 3.2)"; + warned = true; + } + } + m_funcs->glPointSize(value); +} + QSize GraphicsHelperGL2::getRenderBufferDimensions(GLuint renderBufferId) { Q_UNUSED(renderBufferId); diff --git a/src/render/graphicshelpers/graphicshelpergl2_p.h b/src/render/graphicshelpers/graphicshelpergl2_p.h index 5f86c0d67..6d7a7e8f6 100644 --- a/src/render/graphicshelpers/graphicshelpergl2_p.h +++ b/src/render/graphicshelpers/graphicshelpergl2_p.h @@ -104,6 +104,7 @@ public: GLint maxClipPlaneCount() Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3.cpp b/src/render/graphicshelpers/graphicshelpergl3.cpp index f4a296c30..0f48348e4 100644 --- a/src/render/graphicshelpers/graphicshelpergl3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3.cpp @@ -896,6 +896,16 @@ void GraphicsHelperGL3::disablePrimitiveRestart() m_funcs->glDisable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL3::pointSize(bool programmable, GLfloat value) +{ + if (programmable) { + m_funcs->glEnable(GL_PROGRAM_POINT_SIZE); + } else { + m_funcs->glDisable(GL_PROGRAM_POINT_SIZE); + m_funcs->glPointSize(value); + } +} + QSize GraphicsHelperGL3::getRenderBufferDimensions(GLuint renderBufferId) { GLint width = 0; diff --git a/src/render/graphicshelpers/graphicshelpergl3_3.cpp b/src/render/graphicshelpers/graphicshelpergl3_3.cpp index 9000889b9..3cc06482f 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3.cpp +++ b/src/render/graphicshelpers/graphicshelpergl3_3.cpp @@ -893,6 +893,16 @@ void GraphicsHelperGL3_3::disablePrimitiveRestart() m_funcs->glDisable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL3_3::pointSize(bool programmable, GLfloat value) +{ + if (programmable) { + m_funcs->glEnable(GL_PROGRAM_POINT_SIZE); + } else { + m_funcs->glDisable(GL_PROGRAM_POINT_SIZE); + m_funcs->glPointSize(value); + } +} + QSize GraphicsHelperGL3_3::getRenderBufferDimensions(GLuint renderBufferId) { GLint width = 0; diff --git a/src/render/graphicshelpers/graphicshelpergl3_3_p.h b/src/render/graphicshelpers/graphicshelpergl3_3_p.h index 8dc0749a9..11344db63 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_3_p.h @@ -105,6 +105,7 @@ public: GLint maxClipPlaneCount() Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl3_p.h b/src/render/graphicshelpers/graphicshelpergl3_p.h index 92e921cfc..9297998fa 100644 --- a/src/render/graphicshelpers/graphicshelpergl3_p.h +++ b/src/render/graphicshelpers/graphicshelpergl3_p.h @@ -105,6 +105,7 @@ public: GLint maxClipPlaneCount() Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelpergl4.cpp b/src/render/graphicshelpers/graphicshelpergl4.cpp index fa95bfc8f..dfd09cafd 100644 --- a/src/render/graphicshelpers/graphicshelpergl4.cpp +++ b/src/render/graphicshelpers/graphicshelpergl4.cpp @@ -880,6 +880,16 @@ void GraphicsHelperGL4::disablePrimitiveRestart() m_funcs->glDisable(GL_PRIMITIVE_RESTART); } +void GraphicsHelperGL4::pointSize(bool programmable, GLfloat value) +{ + if (programmable) { + m_funcs->glEnable(GL_PROGRAM_POINT_SIZE); + } else { + m_funcs->glDisable(GL_PROGRAM_POINT_SIZE); + m_funcs->glPointSize(value); + } +} + QSize GraphicsHelperGL4::getRenderBufferDimensions(GLuint renderBufferId) { GLint width = 0; diff --git a/src/render/graphicshelpers/graphicshelpergl4_p.h b/src/render/graphicshelpers/graphicshelpergl4_p.h index 13c806629..b91653775 100644 --- a/src/render/graphicshelpers/graphicshelpergl4_p.h +++ b/src/render/graphicshelpers/graphicshelpergl4_p.h @@ -104,6 +104,7 @@ public: GLint maxClipPlaneCount() Q_DECL_OVERRIDE; void enablePrimitiveRestart(int primitiveRestartIndex) Q_DECL_OVERRIDE; void disablePrimitiveRestart() Q_DECL_OVERRIDE; + void pointSize(bool programmable, GLfloat value) Q_DECL_OVERRIDE; QSize getRenderBufferDimensions(GLuint renderBufferId) Q_DECL_OVERRIDE; QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) Q_DECL_OVERRIDE; diff --git a/src/render/graphicshelpers/graphicshelperinterface_p.h b/src/render/graphicshelpers/graphicshelperinterface_p.h index 4a538274e..6fca95516 100644 --- a/src/render/graphicshelpers/graphicshelperinterface_p.h +++ b/src/render/graphicshelpers/graphicshelperinterface_p.h @@ -112,6 +112,7 @@ public: virtual GLint maxClipPlaneCount() = 0; virtual void enablePrimitiveRestart(int primitiveRestartIndex) = 0; virtual void disablePrimitiveRestart() = 0; + virtual void pointSize(bool programmable, GLfloat value) = 0; virtual QSize getRenderBufferDimensions(GLuint renderBufferId) = 0; virtual QSize getTextureDimensions(GLuint textureId, GLenum target, uint level = 0) = 0; }; -- cgit v1.2.3