Browse Source

Implement NV_polygon_mode ES extension.

pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
4720a8db96
  1. 1
      doc/opengl-support.dox
  2. 1
      src/Magnum/Context.cpp
  3. 1
      src/Magnum/Extensions.h
  4. 14
      src/Magnum/Renderer.cpp
  5. 51
      src/Magnum/Renderer.h
  6. 1
      src/MagnumExternal/OpenGL/GLES2/extensions.txt
  7. 3
      src/MagnumExternal/OpenGL/GLES2/flextGL.cpp
  8. 14
      src/MagnumExternal/OpenGL/GLES2/flextGL.h
  9. 3
      src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp
  10. 1
      src/MagnumExternal/OpenGL/GLES3/extensions.txt
  11. 3
      src/MagnumExternal/OpenGL/GLES3/flextGL.cpp
  12. 14
      src/MagnumExternal/OpenGL/GLES3/flextGL.h
  13. 3
      src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp

1
doc/opengl-support.dox

@ -368,6 +368,7 @@ Extension | Status
@es_extension2{NV,read_stencil,NV_read_depth_stencil} | done @es_extension2{NV,read_stencil,NV_read_depth_stencil} | done
@es_extension{NV,read_depth_stencil} | done @es_extension{NV,read_depth_stencil} | done
@es_extension{NV,texture_border_clamp} | done @es_extension{NV,texture_border_clamp} | done
@es_extension{NV,polygon_mode} | done
@es_extension{OES,depth32} | done @es_extension{OES,depth32} | done
@es_extension{OES,mapbuffer} | done @es_extension{OES,mapbuffer} | done
@es_extension{OES,stencil1} | done @es_extension{OES,stencil1} | done

1
src/Magnum/Context.cpp

@ -267,6 +267,7 @@ const std::vector<Extension>& Extension::extensions(Version version) {
_extension(GL,NV,read_stencil), _extension(GL,NV,read_stencil),
_extension(GL,NV,read_depth_stencil), _extension(GL,NV,read_depth_stencil),
_extension(GL,NV,texture_border_clamp), _extension(GL,NV,texture_border_clamp),
_extension(GL,NV,polygon_mode),
_extension(GL,OES,depth32), _extension(GL,OES,depth32),
_extension(GL,OES,mapbuffer), _extension(GL,OES,mapbuffer),
_extension(GL,OES,stencil1), _extension(GL,OES,stencil1),

1
src/Magnum/Extensions.h

@ -357,6 +357,7 @@ namespace GL {
_extension(GL,NV,shadow_samplers_cube, GLES200, GLES300) // #147 _extension(GL,NV,shadow_samplers_cube, GLES200, GLES300) // #147
#endif #endif
_extension(GL,NV,texture_border_clamp, GLES200, None) // #149 _extension(GL,NV,texture_border_clamp, GLES200, None) // #149
_extension(GL,NV,polygon_mode, GLES200, None) // #238
} namespace OES { } namespace OES {
#ifdef MAGNUM_TARGET_GLES2 #ifdef MAGNUM_TARGET_GLES2
_extension(GL,OES,depth24, GLES200, GLES300) // #24 _extension(GL,OES,depth24, GLES200, GLES300) // #24

14
src/Magnum/Renderer.cpp

@ -81,9 +81,21 @@ void Renderer::setFaceCullingMode(const PolygonFacing mode) {
void Renderer::setProvokingVertex(const ProvokingVertex mode) { void Renderer::setProvokingVertex(const ProvokingVertex mode) {
glProvokingVertex(GLenum(mode)); glProvokingVertex(GLenum(mode));
} }
#endif
#ifndef MAGNUM_TARGET_WEBGL
void Renderer::setPolygonMode(const PolygonMode mode) { 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<void>(mode);
CORRADE_ASSERT_UNREACHABLE();
#endif
} }
#endif #endif

51
src/Magnum/Renderer.h

@ -182,25 +182,37 @@ class MAGNUM_EXPORT Renderer {
*/ */
PolygonOffsetFill = GL_POLYGON_OFFSET_FILL, PolygonOffsetFill = GL_POLYGON_OFFSET_FILL,
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_WEBGL
/** /**
* Offset lines * Offset lines
* @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetPoint, * @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetPoint,
* @ref setPolygonOffset() * @ref setPolygonOffset()
* @requires_gl Only @ref Feature::PolygonOffsetFill is available * @requires_es_extension Extension @es_extension{NV,polygon_offset}
* in OpenGL ES and WebGL. * @requires_gles Only @ref Feature::PolygonOffsetFill is available
* in WebGL.
*/ */
#ifndef MAGNUM_TARGET_GLES
PolygonOffsetLine = GL_POLYGON_OFFSET_LINE, PolygonOffsetLine = GL_POLYGON_OFFSET_LINE,
#else
PolygonOffsetLine = GL_POLYGON_OFFSET_LINE_NV,
#endif
/** /**
* Offset points * Offset points
* @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetLine, * @see @ref Feature::PolygonOffsetFill, @ref Feature::PolygonOffsetLine,
* @ref setPolygonOffset() * @ref setPolygonOffset()
* @requires_gl Only @ref Feature::PolygonOffsetFill is available * @requires_es_extension Extension @es_extension{NV,polygon_offset}
* in OpenGL ES and WebGL. * @requires_gles Only @ref Feature::PolygonOffsetFill is available
* in WebGL.
*/ */
#ifndef MAGNUM_TARGET_GLES
PolygonOffsetPoint = GL_POLYGON_OFFSET_POINT, 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 * Programmable point size. If enabled, the point size is taken
* from vertex/geometry shader builtin `gl_PointSize`. * 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. * @requires_gl OpenGL ES and WebGL behave always like the default.
*/ */
static void setProvokingVertex(ProvokingVertex mode); static void setProvokingVertex(ProvokingVertex mode);
#endif
#ifndef MAGNUM_TARGET_WEBGL
/** /**
* @brief Polygon mode * @brief Polygon mode
* *
* @see @ref setPolygonMode() * @see @ref setPolygonMode()
* @requires_gl OpenGL ES and WebGL behaves always like * @requires_es_extension Extension @es_extension{NV,polygon_mode}.
* @ref PolygonMode::Fill. See @ref Mesh::setPrimitive() for * Otherwise behaves always like @ref PolygonMode::Fill. See
* possible workaround. * @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 { enum class PolygonMode: GLenum {
/** /**
* Interior of the polygon is filled (default). * Interior of the polygon is filled (default).
*/ */
#ifndef MAGNUM_TARGET_GLES
Fill = GL_FILL, Fill = GL_FILL,
#else
Fill = GL_FILL_NV,
#endif
/** /**
* Boundary edges are filled. See also @ref setLineWidth(). * Boundary edges are filled. See also @ref setLineWidth().
*/ */
#ifndef MAGNUM_TARGET_GLES
Line = GL_LINE, Line = GL_LINE,
#else
Line = GL_LINE_NV,
#endif
/** /**
* Starts of boundary edges are drawn as points. See also * Starts of boundary edges are drawn as points. See also
* @ref setPointSize(). * @ref setPointSize().
*/ */
#ifndef MAGNUM_TARGET_GLES
Point = GL_POINT Point = GL_POINT
#else
Point = GL_POINT_NV
#endif
}; };
/** /**
@ -450,8 +478,11 @@ class MAGNUM_EXPORT Renderer {
* *
* Initial value is @ref PolygonMode::Fill. * Initial value is @ref PolygonMode::Fill.
* @see @fn_gl{PolygonMode} * @see @fn_gl{PolygonMode}
* @requires_gl OpenGL ES and WebGL behaves always like the default. * @requires_es_extension Extension @es_extension{NV,polygon_mode}.
* See @ref Mesh::setPrimitive() for possible workaround. * 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); static void setPolygonMode(PolygonMode mode);
#endif #endif

1
src/MagnumExternal/OpenGL/GLES2/extensions.txt vendored

@ -66,6 +66,7 @@ extension NV_read_depth optional
extension NV_read_stencil optional extension NV_read_stencil optional
extension NV_read_depth_stencil optional extension NV_read_depth_stencil optional
extension NV_texture_border_clamp optional extension NV_texture_border_clamp optional
extension NV_polygon_mode optional
extension OES_depth32 optional extension OES_depth32 optional
extension OES_mapbuffer optional extension OES_mapbuffer optional
extension OES_stencil1 optional extension OES_stencil1 optional

3
src/MagnumExternal/OpenGL/GLES2/flextGL.cpp vendored

@ -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 *flextglGetObjectPtrLabelKHR)(const void *, GLsizei, GLsizei *, GLchar *) = nullptr;
FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **) = nullptr;
/* GL_NV_polygon_mode */
FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum) = nullptr;
/* GL_OES_mapbuffer */ /* GL_OES_mapbuffer */
FLEXTGL_EXPORT void *(APIENTRY *flextglMapBufferOES)(GLenum, GLenum) = nullptr; FLEXTGL_EXPORT void *(APIENTRY *flextglMapBufferOES)(GLenum, GLenum) = nullptr;
FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapBufferOES)(GLenum) = nullptr; FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapBufferOES)(GLenum) = nullptr;

14
src/MagnumExternal/OpenGL/GLES2/flextGL.h vendored

@ -880,6 +880,15 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 #define GL_TEXTURE_BORDER_COLOR_NV 0x1004
#define GL_CLAMP_TO_BORDER_NV 0x812D #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 */ /* GL_OES_depth32 */
#define GL_DEPTH_COMPONENT32_OES 0x81A7 #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_texture_border_clamp */
/* GL_NV_polygon_mode */
GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum);
#define glPolygonModeNV flextglPolygonModeNV
/* GL_OES_depth32 */ /* GL_OES_depth32 */

3
src/MagnumExternal/OpenGL/GLES2/flextGLPlatform.cpp vendored

@ -265,6 +265,9 @@ void flextGLInit() {
/* GL_NV_texture_border_clamp */ /* GL_NV_texture_border_clamp */
/* GL_NV_polygon_mode */
flextglPolygonModeNV = reinterpret_cast<void(APIENTRY*)(GLenum, GLenum)>(loader.load("glPolygonModeNV"));
/* GL_OES_depth32 */ /* GL_OES_depth32 */
/* GL_OES_mapbuffer */ /* GL_OES_mapbuffer */

1
src/MagnumExternal/OpenGL/GLES3/extensions.txt vendored

@ -21,6 +21,7 @@ extension NV_read_depth optional
extension NV_read_stencil optional extension NV_read_stencil optional
extension NV_read_depth_stencil optional extension NV_read_depth_stencil optional
extension NV_texture_border_clamp optional extension NV_texture_border_clamp optional
extension NV_polygon_mode optional
extension OES_depth32 optional extension OES_depth32 optional
extension OES_mapbuffer optional extension OES_mapbuffer optional
extension OES_stencil1 optional extension OES_stencil1 optional

3
src/MagnumExternal/OpenGL/GLES3/flextGL.cpp vendored

@ -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 *flextglGetObjectPtrLabelKHR)(const void *, GLsizei, GLsizei *, GLchar *) = nullptr;
FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **) = nullptr; FLEXTGL_EXPORT void(APIENTRY *flextglGetPointervKHR)(GLenum, void **) = nullptr;
/* GL_NV_polygon_mode */
FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum) = nullptr;
/* GL_OES_mapbuffer */ /* GL_OES_mapbuffer */
FLEXTGL_EXPORT void *(APIENTRY *flextglMapBufferOES)(GLenum, GLenum) = nullptr; FLEXTGL_EXPORT void *(APIENTRY *flextglMapBufferOES)(GLenum, GLenum) = nullptr;
FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapBufferOES)(GLenum) = nullptr; FLEXTGL_EXPORT GLboolean(APIENTRY *flextglUnmapBufferOES)(GLenum) = nullptr;

14
src/MagnumExternal/OpenGL/GLES3/flextGL.h vendored

@ -1064,6 +1064,15 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 #define GL_TEXTURE_BORDER_COLOR_NV 0x1004
#define GL_CLAMP_TO_BORDER_NV 0x812D #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 */ /* GL_OES_depth32 */
#define GL_DEPTH_COMPONENT32_OES 0x81A7 #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_texture_border_clamp */
/* GL_NV_polygon_mode */
GLAPI FLEXTGL_EXPORT void(APIENTRY *flextglPolygonModeNV)(GLenum, GLenum);
#define glPolygonModeNV flextglPolygonModeNV
/* GL_OES_depth32 */ /* GL_OES_depth32 */

3
src/MagnumExternal/OpenGL/GLES3/flextGLPlatform.cpp vendored

@ -209,6 +209,9 @@ void flextGLInit() {
/* GL_NV_texture_border_clamp */ /* GL_NV_texture_border_clamp */
/* GL_NV_polygon_mode */
flextglPolygonModeNV = reinterpret_cast<void(APIENTRY*)(GLenum, GLenum)>(loader.load("glPolygonModeNV"));
/* GL_OES_depth32 */ /* GL_OES_depth32 */
/* GL_OES_mapbuffer */ /* GL_OES_mapbuffer */

Loading…
Cancel
Save