diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 0b4fdd65e..5ee15968c 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -368,6 +368,7 @@ Extension | Status @es_extension2{NV,read_stencil,NV_read_depth_stencil} | done @es_extension{NV,read_depth_stencil} | done @es_extension{NV,texture_border_clamp} | done +@es_extension{NV,polygon_mode} | done @es_extension{OES,depth32} | done @es_extension{OES,mapbuffer} | done @es_extension{OES,stencil1} | done diff --git a/src/Magnum/Context.cpp b/src/Magnum/Context.cpp index c4214d05c..edcc40ab3 100644 --- a/src/Magnum/Context.cpp +++ b/src/Magnum/Context.cpp @@ -267,6 +267,7 @@ const std::vector& Extension::extensions(Version version) { _extension(GL,NV,read_stencil), _extension(GL,NV,read_depth_stencil), _extension(GL,NV,texture_border_clamp), + _extension(GL,NV,polygon_mode), _extension(GL,OES,depth32), _extension(GL,OES,mapbuffer), _extension(GL,OES,stencil1), diff --git a/src/Magnum/Extensions.h b/src/Magnum/Extensions.h index 037839f9b..4c57d4bce 100644 --- a/src/Magnum/Extensions.h +++ b/src/Magnum/Extensions.h @@ -357,6 +357,7 @@ namespace GL { _extension(GL,NV,shadow_samplers_cube, GLES200, GLES300) // #147 #endif _extension(GL,NV,texture_border_clamp, GLES200, None) // #149 + _extension(GL,NV,polygon_mode, GLES200, None) // #238 } namespace OES { #ifdef MAGNUM_TARGET_GLES2 _extension(GL,OES,depth24, GLES200, GLES300) // #24 diff --git a/src/Magnum/Renderer.cpp b/src/Magnum/Renderer.cpp index 0f3c46e26..9c7bb2b96 100644 --- a/src/Magnum/Renderer.cpp +++ b/src/Magnum/Renderer.cpp @@ -81,9 +81,21 @@ void Renderer::setFaceCullingMode(const PolygonFacing mode) { void Renderer::setProvokingVertex(const ProvokingVertex mode) { glProvokingVertex(GLenum(mode)); } +#endif +#ifndef MAGNUM_TARGET_WEBGL void Renderer::setPolygonMode(const PolygonMode mode) { - glPolygonMode(GL_FRONT_AND_BACK, GLenum(mode)); + #ifndef CORRADE_TARGET_NACL + #ifndef MAGNUM_TARGET_GLES + glPolygonMode + #else + glPolygonModeNV + #endif + (GL_FRONT_AND_BACK, GLenum(mode)); + #else + static_cast(mode); + CORRADE_ASSERT_UNREACHABLE(); + #endif } #endif diff --git a/src/Magnum/Renderer.h b/src/Magnum/Renderer.h index 5b2e3b1cb..d358604f7 100644 --- a/src/Magnum/Renderer.h +++ b/src/Magnum/Renderer.h @@ -182,25 +182,37 @@ class MAGNUM_EXPORT Renderer { */ PolygonOffsetFill = GL_POLYGON_OFFSET_FILL, - #ifndef MAGNUM_TARGET_GLES + #ifndef MAGNUM_TARGET_WEBGL /** * Offset lines * @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetPoint, * @ref setPolygonOffset() - * @requires_gl Only @ref Feature::PolygonOffsetFill is available - * in OpenGL ES and WebGL. + * @requires_es_extension Extension @es_extension{NV,polygon_offset} + * @requires_gles Only @ref Feature::PolygonOffsetFill is available + * in WebGL. */ + #ifndef MAGNUM_TARGET_GLES PolygonOffsetLine = GL_POLYGON_OFFSET_LINE, + #else + PolygonOffsetLine = GL_POLYGON_OFFSET_LINE_NV, + #endif /** * Offset points * @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetLine, * @ref setPolygonOffset() - * @requires_gl Only @ref Feature::PolygonOffsetFill is available - * in OpenGL ES and WebGL. + * @requires_es_extension Extension @es_extension{NV,polygon_offset} + * @requires_gles Only @ref Feature::PolygonOffsetFill is available + * in WebGL. */ + #ifndef MAGNUM_TARGET_GLES PolygonOffsetPoint = GL_POLYGON_OFFSET_POINT, + #else + PolygonOffsetPoint = GL_POLYGON_OFFSET_POINT_NV, + #endif + #endif + #ifndef MAGNUM_TARGET_GLES /** * Programmable point size. If enabled, the point size is taken * from vertex/geometry shader builtin `gl_PointSize`. @@ -418,31 +430,47 @@ class MAGNUM_EXPORT Renderer { * @requires_gl OpenGL ES and WebGL behave always like the default. */ static void setProvokingVertex(ProvokingVertex mode); + #endif + #ifndef MAGNUM_TARGET_WEBGL /** * @brief Polygon mode * * @see @ref setPolygonMode() - * @requires_gl OpenGL ES and WebGL behaves always like - * @ref PolygonMode::Fill. See @ref Mesh::setPrimitive() for - * possible workaround. + * @requires_es_extension Extension @es_extension{NV,polygon_mode}. + * Otherwise behaves always like @ref PolygonMode::Fill. See + * @ref Mesh::setPrimitive() for possible workaround. + * @requires_gles WebGL behaves always like @ref PolygonMode::Fill. See + * @ref Mesh::setPrimitive() for possible workaround. */ enum class PolygonMode: GLenum { /** * Interior of the polygon is filled (default). */ + #ifndef MAGNUM_TARGET_GLES Fill = GL_FILL, + #else + Fill = GL_FILL_NV, + #endif /** * Boundary edges are filled. See also @ref setLineWidth(). */ + #ifndef MAGNUM_TARGET_GLES Line = GL_LINE, + #else + Line = GL_LINE_NV, + #endif /** * Starts of boundary edges are drawn as points. See also * @ref setPointSize(). */ + #ifndef MAGNUM_TARGET_GLES Point = GL_POINT + #else + Point = GL_POINT_NV + #endif }; /** @@ -450,8 +478,11 @@ class MAGNUM_EXPORT Renderer { * * Initial value is @ref PolygonMode::Fill. * @see @fn_gl{PolygonMode} - * @requires_gl OpenGL ES and WebGL behaves always like the default. - * See @ref Mesh::setPrimitive() for possible workaround. + * @requires_es_extension Extension @es_extension{NV,polygon_mode}. + * Otherwise behaves always like the default. See + * @ref Mesh::setPrimitive() for possible workaround. + * @requires_gles WebGL behaves always like the default. See + * @ref Mesh::setPrimitive() for possible workaround. */ static void setPolygonMode(PolygonMode mode); #endif diff --git a/src/MagnumExternal/OpenGL/GLES2/extensions.txt b/src/MagnumExternal/OpenGL/GLES2/extensions.txt index 82193082c..1d703ee03 100644 --- a/src/MagnumExternal/OpenGL/GLES2/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES2/extensions.txt @@ -66,6 +66,7 @@ extension NV_read_depth optional extension NV_read_stencil optional extension NV_read_depth_stencil optional extension NV_texture_border_clamp optional +extension NV_polygon_mode optional extension OES_depth32 optional extension OES_mapbuffer optional extension OES_stencil1 optional diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGL.cpp b/src/MagnumExternal/OpenGL/GLES2/flextGL.cpp index bb66db1ed..204dc3c00 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGL.cpp +++ b/src/MagnumExternal/OpenGL/GLES2/flextGL.cpp @@ -189,6 +189,9 @@ FLEXTGL_EXPORT void(APIENTRY *flextglObjectPtrLabelKHR)(const void *, GLsizei, c FLEXTGL_EXPORT void(APIENTRY *flextglGetObjectPtrLabelKHR)(const void *, GLsizei, GLsizei *, GLchar *) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **) = nullptr; +/* GL_NV_polygon_mode */ +FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum) = nullptr; + /* GL_OES_mapbuffer */ FLEXTGL_EXPORT void *(APIENTRY *flextglMapBufferOES)(GLenum, GLenum) = nullptr; FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapBufferOES)(GLenum) = nullptr; diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGL.h b/src/MagnumExternal/OpenGL/GLES2/flextGL.h index cb0accec1..2801f2ba4 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGL.h +++ b/src/MagnumExternal/OpenGL/GLES2/flextGL.h @@ -880,6 +880,15 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 #define GL_CLAMP_TO_BORDER_NV 0x812D +/* GL_NV_polygon_mode */ + +#define GL_POLYGON_MODE_NV 0x0B40 +#define GL_POLYGON_OFFSET_POINT_NV 0x2A01 +#define GL_POLYGON_OFFSET_LINE_NV 0x2A02 +#define GL_POINT_NV 0x1B00 +#define GL_LINE_NV 0x1B01 +#define GL_FILL_NV 0x1B02 + /* GL_OES_depth32 */ #define GL_DEPTH_COMPONENT32_OES 0x81A7 @@ -1497,6 +1506,11 @@ GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **); /* GL_NV_texture_border_clamp */ +/* GL_NV_polygon_mode */ + +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum); +#define glPolygonModeNV flextglPolygonModeNV + /* GL_OES_depth32 */ diff --git a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp index d82919f1c..7241fdda7 100644 --- a/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp @@ -265,6 +265,9 @@ void flextGLInit() { /* GL_NV_texture_border_clamp */ + /* GL_NV_polygon_mode */ + flextglPolygonModeNV = reinterpret_cast(loader.load("glPolygonModeNV")); + /* GL_OES_depth32 */ /* GL_OES_mapbuffer */ diff --git a/src/MagnumExternal/OpenGL/GLES3/extensions.txt b/src/MagnumExternal/OpenGL/GLES3/extensions.txt index 41247b237..d8fd27211 100644 --- a/src/MagnumExternal/OpenGL/GLES3/extensions.txt +++ b/src/MagnumExternal/OpenGL/GLES3/extensions.txt @@ -21,6 +21,7 @@ extension NV_read_depth optional extension NV_read_stencil optional extension NV_read_depth_stencil optional extension NV_texture_border_clamp optional +extension NV_polygon_mode optional extension OES_depth32 optional extension OES_mapbuffer optional extension OES_stencil1 optional diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGL.cpp b/src/MagnumExternal/OpenGL/GLES3/flextGL.cpp index 7b922e19d..38410be9e 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGL.cpp +++ b/src/MagnumExternal/OpenGL/GLES3/flextGL.cpp @@ -183,6 +183,9 @@ FLEXTGL_EXPORT void(APIENTRY *flextglObjectPtrLabelKHR)(const void *, GLsizei, c FLEXTGL_EXPORT void(APIENTRY *flextglGetObjectPtrLabelKHR)(const void *, GLsizei, GLsizei *, GLchar *) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **) = nullptr; +/* GL_NV_polygon_mode */ +FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum) = nullptr; + /* GL_OES_mapbuffer */ FLEXTGL_EXPORT void *(APIENTRY *flextglMapBufferOES)(GLenum, GLenum) = nullptr; FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapBufferOES)(GLenum) = nullptr; diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGL.h b/src/MagnumExternal/OpenGL/GLES3/flextGL.h index 2c9653f97..a4f41d691 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGL.h +++ b/src/MagnumExternal/OpenGL/GLES3/flextGL.h @@ -1064,6 +1064,15 @@ typedef khronos_ssize_t GLsizeiptr; #define GL_TEXTURE_BORDER_COLOR_NV 0x1004 #define GL_CLAMP_TO_BORDER_NV 0x812D +/* GL_NV_polygon_mode */ + +#define GL_POLYGON_MODE_NV 0x0B40 +#define GL_POLYGON_OFFSET_POINT_NV 0x2A01 +#define GL_POLYGON_OFFSET_LINE_NV 0x2A02 +#define GL_POINT_NV 0x1B00 +#define GL_LINE_NV 0x1B01 +#define GL_FILL_NV 0x1B02 + /* GL_OES_depth32 */ #define GL_DEPTH_COMPONENT32_OES 0x81A7 @@ -1719,6 +1728,11 @@ GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **); /* GL_NV_texture_border_clamp */ +/* GL_NV_polygon_mode */ + +GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum); +#define glPolygonModeNV flextglPolygonModeNV + /* GL_OES_depth32 */ diff --git a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp index ffb11853f..b0fd298cd 100644 --- a/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp +++ b/src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp @@ -209,6 +209,9 @@ void flextGLInit() { /* GL_NV_texture_border_clamp */ + /* GL_NV_polygon_mode */ + flextglPolygonModeNV = reinterpret_cast(loader.load("glPolygonModeNV")); + /* GL_OES_depth32 */ /* GL_OES_mapbuffer */