Browse Source

Shaders: clarify that object ID features need GL 3.0 extensions.

Important for Zink, which has neither of them.
pull/427/merge
Vladimír Vondruš 6 years ago
parent
commit
881a50f7fa
  1. 4
      src/Magnum/Shaders/Flat.frag
  2. 33
      src/Magnum/Shaders/Flat.h
  3. 4
      src/Magnum/Shaders/Flat.vert
  4. 12
      src/Magnum/Shaders/Generic.h
  5. 20
      src/Magnum/Shaders/MeshVisualizer.h
  6. 4
      src/Magnum/Shaders/MeshVisualizer.vert
  7. 4
      src/Magnum/Shaders/Phong.frag
  8. 33
      src/Magnum/Shaders/Phong.h
  9. 4
      src/Magnum/Shaders/Phong.vert

4
src/Magnum/Shaders/Flat.frag

@ -23,6 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#if defined(OBJECT_ID) && !defined(GL_ES) && !defined(NEW_GLSL)
#extension GL_EXT_gpu_shader4: require
#endif
#ifndef NEW_GLSL #ifndef NEW_GLSL
#define fragmentColor gl_FragColor #define fragmentColor gl_FragColor
#define texture texture2D #define texture texture2D

33
src/Magnum/Shaders/Flat.h

@ -198,9 +198,9 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public GL::Ab
* *
* @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt. * @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt.
* Used only if @ref Flag::InstancedObjectId is set. * Used only if @ref Flag::InstancedObjectId is set.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or WebGL * @requires_gles30 Object ID output requires integer support in
* 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
*/ */
typedef typename Generic<dimensions>::ObjectId ObjectId; typedef typename Generic<dimensions>::ObjectId ObjectId;
#endif #endif
@ -251,9 +251,10 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public GL::Ab
* single-component unsigned integral attachment. Writes the value * single-component unsigned integral attachment. Writes the value
* set in @ref setObjectId() there, see * set in @ref setObjectId() there, see
* @ref Shaders-Phong-object-id for more information. * @ref Shaders-Phong-object-id for more information.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,texture_integer}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since{2019,10} * @m_since{2019,10}
*/ */
ObjectIdOutput = Generic<dimensions>::ObjectIdOutput ObjectIdOutput = Generic<dimensions>::ObjectIdOutput
@ -305,9 +306,10 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public GL::Ab
/** /**
* Enable object ID output. See @ref Shaders-Flat-object-id for * Enable object ID output. See @ref Shaders-Flat-object-id for
* more information. * more information.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since{2019,10} * @m_since{2019,10}
*/ */
ObjectId = 1 << 4, ObjectId = 1 << 4,
@ -318,9 +320,10 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public GL::Ab
* the per-vertex ID and ID coming from @ref setObjectId(). * the per-vertex ID and ID coming from @ref setObjectId().
* Implicitly enables @ref Flag::ObjectId. See * Implicitly enables @ref Flag::ObjectId. See
* @ref Shaders-Flat-object-id for more information. * @ref Shaders-Flat-object-id for more information.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since_latest * @m_since_latest
*/ */
InstancedObjectId = (1 << 5)|ObjectId, InstancedObjectId = (1 << 5)|ObjectId,
@ -473,9 +476,9 @@ template<UnsignedInt dimensions> class MAGNUM_SHADERS_EXPORT Flat: public GL::Ab
* @ref Shaders-Flat-object-id for more information. Default is * @ref Shaders-Flat-object-id for more information. Default is
* @cpp 0 @ce. If @ref Flag::InstancedObjectId is enabled as well, this * @cpp 0 @ce. If @ref Flag::InstancedObjectId is enabled as well, this
* value is combined with ID coming from the @ref ObjectId attribute. * value is combined with ID coming from the @ref ObjectId attribute.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or WebGL * @requires_gles30 Object ID output requires integer support in
* 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
*/ */
Flat<dimensions>& setObjectId(UnsignedInt id); Flat<dimensions>& setObjectId(UnsignedInt id);
#endif #endif

4
src/Magnum/Shaders/Flat.vert

@ -23,6 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#if defined(INSTANCED_OBJECT_ID) && !defined(GL_ES) && !defined(NEW_GLSL)
#extension GL_EXT_gpu_shader4: require
#endif
#ifndef NEW_GLSL #ifndef NEW_GLSL
#define in attribute #define in attribute
#define out varying #define out varying

12
src/Magnum/Shaders/Generic.h

@ -247,9 +247,9 @@ template<UnsignedInt dimensions> struct Generic {
/** /**
* Object ID shader output. Expects a single-component unsigned * Object ID shader output. Expects a single-component unsigned
* integral attachment. * integral attachment.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,texture_integer}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
*/ */
ObjectIdOutput = 1 ObjectIdOutput = 1
#endif #endif
@ -339,9 +339,9 @@ template<UnsignedInt dimensions> struct Generic {
* This attribute conflicts with @ref Bitangent, if you want to use both * This attribute conflicts with @ref Bitangent, if you want to use both
* instanced object ID and bitangents, you need to reconstruct them from * instanced object ID and bitangents, you need to reconstruct them from
* @ref Tangent4 instead. * @ref Tangent4 instead.
* * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* @requires_gles30 Object ID output requires integer attributes, which are * @requires_gles30 Object ID output requires integer support in shaders,
* not available in OpenGL ES 2.0 or WebGL 1.0. * which is not available in OpenGL ES 2.0 or WebGL 1.0.
*/ */
typedef GL::Attribute<4, UnsignedInt> ObjectId; typedef GL::Attribute<4, UnsignedInt> ObjectId;
#endif #endif

20
src/Magnum/Shaders/MeshVisualizer.h

@ -145,10 +145,9 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer2D: public Implementation::MeshVisuali
* *
* @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt. * @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt.
* Used only if @ref Flag::InstancedObjectId is set. * Used only if @ref Flag::InstancedObjectId is set.
* @requires_gles30 Object ID input requires integer attributes, which * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* are not available in OpenGL ES 2.0. * @requires_gles30 Object ID output requires integer support in
* @requires_webgl20 Object ID input requires integer attributes, which * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
* are not available in WebGL 1.0.
*/ */
typedef Generic3D::ObjectId ObjectId; typedef Generic3D::ObjectId ObjectId;
#endif #endif
@ -558,10 +557,9 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer3D: public Implementation::MeshVisuali
* *
* @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt. * @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt.
* Used only if @ref Flag::InstancedObjectId is set. * Used only if @ref Flag::InstancedObjectId is set.
* @requires_gles30 Object ID input requires integer attributes, which * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* are not available in OpenGL ES 2.0. * @requires_gles30 Object ID output requires integer support in
* @requires_webgl20 Object ID input requires integer attributes, which * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
* are not available in WebGL 1.0.
*/ */
typedef Generic3D::ObjectId ObjectId; typedef Generic3D::ObjectId ObjectId;
#endif #endif
@ -609,8 +607,10 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizer3D: public Implementation::MeshVisuali
* Visualize instanced object ID. You need to provide the * Visualize instanced object ID. You need to provide the
* @ref ObjectId attribute in the mesh. Mutually exclusive with * @ref ObjectId attribute in the mesh. Mutually exclusive with
* @ref Flag::PrimitiveId. * @ref Flag::PrimitiveId.
* @requires_gles30 Object ID input requires integer attributes, * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* which are not available in OpenGL ES 2.0 or WebGL 1.0. * @requires_gles30 Object ID output requires integer support in
* shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since_latest * @m_since_latest
*/ */
InstancedObjectId = 1 << 2, InstancedObjectId = 1 << 2,

4
src/Magnum/Shaders/MeshVisualizer.vert

@ -23,6 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#if defined(INSTANCED_OBJECT_ID) && !defined(GL_ES) && !defined(NEW_GLSL)
#extension GL_EXT_gpu_shader4: require
#endif
#ifndef NEW_GLSL #ifndef NEW_GLSL
#define in attribute #define in attribute
#define out varying #define out varying

4
src/Magnum/Shaders/Phong.frag

@ -23,6 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#if defined(OBJECT_ID) && !defined(GL_ES) && !defined(NEW_GLSL)
#extension GL_EXT_gpu_shader4: require
#endif
#ifndef NEW_GLSL #ifndef NEW_GLSL
#define in varying #define in varying
#define fragmentColor gl_FragColor #define fragmentColor gl_FragColor

33
src/Magnum/Shaders/Phong.h

@ -214,9 +214,9 @@ class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram {
* *
* @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt. * @ref shaders-generic "Generic attribute", @ref Magnum::UnsignedInt.
* Used only if @ref Flag::InstancedObjectId is set. * Used only if @ref Flag::InstancedObjectId is set.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or WebGL * @requires_gles30 Object ID output requires integer support in
* 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
*/ */
typedef Generic3D::ObjectId ObjectId; typedef Generic3D::ObjectId ObjectId;
#endif #endif
@ -282,9 +282,10 @@ class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram {
* single-component unsigned integral attachment. Writes the value * single-component unsigned integral attachment. Writes the value
* set in @ref setObjectId() there, see * set in @ref setObjectId() there, see
* @ref Shaders-Phong-object-id for more information. * @ref Shaders-Phong-object-id for more information.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,texture_integer}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since{2019,10} * @m_since{2019,10}
*/ */
ObjectIdOutput = Generic3D::ObjectIdOutput ObjectIdOutput = Generic3D::ObjectIdOutput
@ -357,9 +358,10 @@ class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram {
/** /**
* Enable object ID output. See @ref Shaders-Phong-object-id * Enable object ID output. See @ref Shaders-Phong-object-id
* for more information. * for more information.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since{2019,10} * @m_since{2019,10}
*/ */
ObjectId = 1 << 7, ObjectId = 1 << 7,
@ -370,9 +372,10 @@ class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram {
* the per-vertex ID and ID coming from @ref setObjectId(). * the per-vertex ID and ID coming from @ref setObjectId().
* Implicitly enables @ref Flag::ObjectId. See * Implicitly enables @ref Flag::ObjectId. See
* @ref Shaders-Phong-object-id for more information. * @ref Shaders-Phong-object-id for more information.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or * @requires_gles30 Object ID output requires integer support in
* WebGL 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL
* 1.0.
* @m_since_latest * @m_since_latest
*/ */
InstancedObjectId = (1 << 8)|ObjectId, InstancedObjectId = (1 << 8)|ObjectId,
@ -593,9 +596,9 @@ class MAGNUM_SHADERS_EXPORT Phong: public GL::AbstractShaderProgram {
* enabled. Value set here is written to the @ref ObjectIdOutput, see * enabled. Value set here is written to the @ref ObjectIdOutput, see
* @ref Shaders-Phong-object-id for more information. Default is * @ref Shaders-Phong-object-id for more information. Default is
* @cpp 0 @ce. * @cpp 0 @ce.
* @requires_gles30 Object ID output requires integer buffer * @requires_gl30 Extension @gl_extension{EXT,gpu_shader4}
* attachments, which are not available in OpenGL ES 2.0 or WebGL * @requires_gles30 Object ID output requires integer support in
* 1.0. * shaders, which is not available in OpenGL ES 2.0 or WebGL 1.0.
*/ */
Phong& setObjectId(UnsignedInt id); Phong& setObjectId(UnsignedInt id);
#endif #endif

4
src/Magnum/Shaders/Phong.vert

@ -23,6 +23,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#if defined(INSTANCED_OBJECT_ID) && !defined(GL_ES) && !defined(NEW_GLSL)
#extension GL_EXT_gpu_shader4: require
#endif
#ifndef NEW_GLSL #ifndef NEW_GLSL
#define in attribute #define in attribute
#define out varying #define out varying

Loading…
Cancel
Save