From d5614a2f2c0ecfb666a80df9553562bf60ec633a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 7 Sep 2012 02:25:29 +0200 Subject: [PATCH] Mesh: added support for polygon offset. --- src/Mesh.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/Mesh.h b/src/Mesh.h index 532902454..d4bd94987 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -123,6 +123,50 @@ class MAGNUM_EXPORT Mesh { } #endif + /** + * @brief Mode affected by polygon offset + * + * @see setPolygonOffsetMode(), setPolygonOffset() + */ + enum class PolygonOffsetMode: GLenum { + /** Offset filled polygons. */ + Fill = GL_POLYGON_OFFSET_FILL, + + /** + * Offset lines. + * @requires_gl Only PolygonOffset::%Fill is supported. + */ + Line = GL_POLYGON_OFFSET_LINE, + + /** + * Offset points. + * @requires_gl Only PolygonOffset::%Fill is supported. + */ + Point = GL_POLYGON_OFFSET_POINT + }; + + /** + * @brief Enable/disable polygon offset for given mode + * + * Initially disabled for all modes. + * @see setPolygonOffset() + */ + inline static void setPolygonOffsetMode(PolygonOffsetMode mode, bool enabled) { + enabled ? glEnable(static_cast(mode)) : glDisable(static_cast(mode)); + } + + /** + * @brief Set polygon offset + * @param factor Scale factor + * @param units Offset units + * + * @attention You have to call setPolygonOffsetMode() to enable + * polygon offset for desired polygon modes. + */ + inline static void setPolygonOffset(GLfloat factor, GLfloat units) { + glPolygonOffset(factor, units); + } + /** * @brief Set line width *