diff --git a/src/AbstractShaderProgram.cpp b/src/AbstractShaderProgram.cpp index 61e773700..e02831f1a 100644 --- a/src/AbstractShaderProgram.cpp +++ b/src/AbstractShaderProgram.cpp @@ -37,10 +37,12 @@ AbstractShaderProgram::Uniform1iImplementation AbstractShaderProgram::uniform1iI AbstractShaderProgram::Uniform2ivImplementation AbstractShaderProgram::uniform2ivImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform3ivImplementation AbstractShaderProgram::uniform3ivImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform4ivImplementation AbstractShaderProgram::uniform4ivImplementation = &AbstractShaderProgram::uniformImplementationDefault; +#ifndef MAGNUM_TARGET_GLES2 AbstractShaderProgram::Uniform1uiImplementation AbstractShaderProgram::uniform1uiImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform2uivImplementation AbstractShaderProgram::uniform2uivImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform3uivImplementation AbstractShaderProgram::uniform3uivImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform4uivImplementation AbstractShaderProgram::uniform4uivImplementation = &AbstractShaderProgram::uniformImplementationDefault; +#endif #ifndef MAGNUM_TARGET_GLES AbstractShaderProgram::Uniform1dImplementation AbstractShaderProgram::uniform1dImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::Uniform2dvImplementation AbstractShaderProgram::uniform2dvImplementation = &AbstractShaderProgram::uniformImplementationDefault; @@ -51,12 +53,14 @@ AbstractShaderProgram::Uniform4dvImplementation AbstractShaderProgram::uniform4d AbstractShaderProgram::UniformMatrix2fvImplementation AbstractShaderProgram::uniformMatrix2fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix3fvImplementation AbstractShaderProgram::uniformMatrix3fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix4fvImplementation AbstractShaderProgram::uniformMatrix4fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; +#ifndef MAGNUM_TARGET_GLES2 AbstractShaderProgram::UniformMatrix2x3fvImplementation AbstractShaderProgram::uniformMatrix2x3fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix3x2fvImplementation AbstractShaderProgram::uniformMatrix3x2fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix2x4fvImplementation AbstractShaderProgram::uniformMatrix2x4fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix4x2fvImplementation AbstractShaderProgram::uniformMatrix4x2fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix3x4fvImplementation AbstractShaderProgram::uniformMatrix3x4fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix4x3fvImplementation AbstractShaderProgram::uniformMatrix4x3fvImplementation = &AbstractShaderProgram::uniformImplementationDefault; +#endif #ifndef MAGNUM_TARGET_GLES AbstractShaderProgram::UniformMatrix2dvImplementation AbstractShaderProgram::uniformMatrix2dvImplementation = &AbstractShaderProgram::uniformImplementationDefault; AbstractShaderProgram::UniformMatrix3dvImplementation AbstractShaderProgram::uniformMatrix3dvImplementation = &AbstractShaderProgram::uniformImplementationDefault; @@ -153,6 +157,8 @@ GLint AbstractShaderProgram::uniformLocation(const std::string& name) { } void AbstractShaderProgram::initializeContextBasedFunctionality(Context* context) { + /** @todo OpenGL ES 2 has extension @es_extension{EXT,separate_shader_objects} for this */ + #ifndef MAGNUM_TARGET_GLES if(context->isExtensionSupported() || context->isExtensionSupported()) { Debug() << "AbstractShaderProgram: using" << (context->isExtensionSupported() ? @@ -169,12 +175,10 @@ void AbstractShaderProgram::initializeContextBasedFunctionality(Context* context uniform2uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform3uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform4uivImplementation = &AbstractShaderProgram::uniformImplementationDSA; - #ifndef MAGNUM_TARGET_GLES uniform1dImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniform4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - #endif uniformMatrix2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix3fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; @@ -185,7 +189,6 @@ void AbstractShaderProgram::initializeContextBasedFunctionality(Context* context uniformMatrix4x2fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix3x4fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix4x3fvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - #ifndef MAGNUM_TARGET_GLES uniformMatrix2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; @@ -195,8 +198,10 @@ void AbstractShaderProgram::initializeContextBasedFunctionality(Context* context uniformMatrix4x2dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix3x4dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; uniformMatrix4x3dvImplementation = &AbstractShaderProgram::uniformImplementationDSA; - #endif } + #else + static_cast(context); + #endif } void AbstractShaderProgram::uniformImplementationDefault(GLint location, GLfloat value) { @@ -204,108 +209,134 @@ void AbstractShaderProgram::uniformImplementationDefault(GLint location, GLfloat glUniform1f(location, value); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, GLfloat value) { glProgramUniform1f(_id, location, value); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<2, GLfloat>& value) { use(); glUniform2fv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<2, GLfloat>& value) { glProgramUniform2fv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<3, GLfloat>& value) { use(); glUniform3fv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<3, GLfloat>& value) { glProgramUniform3fv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<4, GLfloat>& value) { use(); glUniform4fv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<4, GLfloat>& value) { glProgramUniform4fv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, GLint value) { use(); glUniform1i(location, value); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, GLint value) { glProgramUniform1i(_id, location, value); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<2, GLint>& value) { use(); glUniform2iv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<2, GLint>& value) { glProgramUniform2iv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<3, GLint>& value) { use(); glUniform3iv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<3, GLint>& value) { glProgramUniform3iv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<4, GLint>& value) { use(); glUniform4iv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<4, GLint>& value) { glProgramUniform4iv(_id, location, 1, value.data()); } +#endif +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationDefault(GLint location, GLuint value) { use(); glUniform1ui(location, value); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, GLuint value) { glProgramUniform1ui(_id, location, value); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<2, GLuint>& value) { use(); glUniform2uiv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<2, GLuint>& value) { glProgramUniform2uiv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<3, GLuint>& value) { use(); glUniform3uiv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<3, GLuint>& value) { glProgramUniform3uiv(_id, location, 1, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Vector<4, GLuint>& value) { use(); glUniform4uiv(location, 1, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Vector<4, GLuint>& value) { glProgramUniform4uiv(_id, location, 1, value.data()); } +#endif +#endif #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDefault(GLint location, GLdouble value) { @@ -350,81 +381,101 @@ void AbstractShaderProgram::uniformImplementationDefault(GLint location, const M glUniformMatrix2fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Matrix<2, GLfloat>& value) { glProgramUniformMatrix2fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Matrix<3, GLfloat>& value) { use(); glUniformMatrix3fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Matrix<3, GLfloat>& value) { glProgramUniformMatrix3fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Matrix<4, GLfloat>& value) { use(); glUniformMatrix4fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::Matrix<4, GLfloat>& value) { glProgramUniformMatrix4fv(_id, location, 1, GL_FALSE, value.data()); } +#endif +#ifndef MAGNUM_TARGET_GLES2 void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::RectangularMatrix<2, 3, GLfloat>& value) { use(); glUniformMatrix2x3fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::RectangularMatrix<2, 3, GLfloat>& value) { glProgramUniformMatrix2x3fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::RectangularMatrix<3, 2, GLfloat>& value) { use(); glUniformMatrix3x2fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::RectangularMatrix<3, 2, GLfloat>& value) { glProgramUniformMatrix3x2fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::RectangularMatrix<2, 4, GLfloat>& value) { use(); glUniformMatrix2x4fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::RectangularMatrix<2, 4, GLfloat>& value) { glProgramUniformMatrix2x4fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::RectangularMatrix<4, 2, GLfloat>& value) { use(); glUniformMatrix4x2fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::RectangularMatrix<4, 2, GLfloat>& value) { glProgramUniformMatrix4x2fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::RectangularMatrix<3, 4, GLfloat>& value) { use(); glUniformMatrix3x4fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::RectangularMatrix<3, 4, GLfloat>& value) { glProgramUniformMatrix3x4fv(_id, location, 1, GL_FALSE, value.data()); } +#endif void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::RectangularMatrix<4, 3, GLfloat>& value) { use(); glUniformMatrix4x3fv(location, 1, GL_FALSE, value.data()); } +#ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDSA(GLint location, const Math::RectangularMatrix<4, 3, GLfloat>& value) { glProgramUniformMatrix4x3fv(_id, location, 1, GL_FALSE, value.data()); } +#endif +#endif #ifndef MAGNUM_TARGET_GLES void AbstractShaderProgram::uniformImplementationDefault(GLint location, const Math::Matrix<2, GLdouble>& value) { diff --git a/src/AbstractShaderProgram.h b/src/AbstractShaderProgram.h index e1efd315e..1ed8222bc 100644 --- a/src/AbstractShaderProgram.h +++ b/src/AbstractShaderProgram.h @@ -121,22 +121,11 @@ using color input index): layout(location = 0, index = 0) out vec4 color; layout(location = 1, index = 1) out vec4 ambient; @endcode -@requires_gl (for explicit input attribute location instead of using - bindAttributeLocation()) -@requires_gl (for using bindFragmentDataLocation() / - bindFragmentDataLocationIndexed()) -@requires_gl30 Extension @extension{EXT,gpu_shader4} (for using - bindFragmentDataLocation()) -@requires_gl33 Extension @extension{ARB,blend_func_extended} (for using - bindFragmentDataLocationIndexed()) -@requires_gl33 Extension @extension{ARB,explicit_attrib_location} (for - explicit attribute location instead of using bindAttributeLocation()) -@requires_gles30 (no extension providing this functionality) (for explicit - input and output attribute location) - -If you don't have the required extension, you can use functions bindAttributeLocation() -and bindFragmentDataLocation() / bindFragmentDataLocationIndexed() between -attaching the shaders and linking the program: + +If you don't have the required extension, you can use functions +bindAttributeLocation() and bindFragmentDataLocation() / +bindFragmentDataLocationIndexed() between attaching the shaders and linking +the program: @code // Shaders attached... @@ -150,6 +139,19 @@ bindFragmentDataLocationIndexed(1, 1, "ambient"); // Link... @endcode +@requires_gl30 %Extension @extension{EXT,gpu_shader4} for using + bindFragmentDataLocation(). +@requires_gl33 %Extension @extension{ARB,blend_func_extended} for using + bindFragmentDataLocationIndexed(). +@requires_gl33 %Extension @extension{ARB,explicit_attrib_location} for + explicit attribute location instead of using bindAttributeLocation(), + bindFragmentDataLocation() or bindFragmentDataLocationIndexed(). +@requires_gles30 Explicit location specification of input attributes is not + supported in OpenGL ES 2.0, use bindAttributeLocation() instead. +@requires_gles30 Multiple fragment shader outputs are not available in OpenGL + ES 2.0, similar functionality is available in extension + @extension{NV,draw_buffers}. + @subsection AbstractShaderProgram-uniform-location Uniform locations The preferred workflow is to specify uniform locations directly in the shader @@ -160,9 +162,6 @@ code, e.g.: layout(location = 0) uniform mat4 transformation; layout(location = 1) uniform mat4 projection; @endcode -@requires_gl (for explicit uniform location instead of using uniformLocation()) -@requires_gl43 Extension @extension{ARB,explicit_uniform_location} (for - explicit uniform location instead of using uniformLocation()) If you don't have the required extension, you can get uniform location using uniformLocation() after linking stage: @@ -171,6 +170,11 @@ GLint transformationUniform = uniformLocation("transformation"); GLint projectionUniform = uniformLocation("projection"); @endcode +@requires_gl43 Extension @extension{ARB,explicit_uniform_location} for + explicit uniform location instead of using uniformLocation(). +@requires_gl Explicit uniform location is not supported in OpenGL ES. Use + uniformLocation() instead. + @subsection AbstractShaderProgram-texture-layer Binding texture layer uniforms The preferred workflow is to specify texture layers directly in the shader @@ -181,10 +185,6 @@ code, e.g.: layout(binding = 0) uniform sampler2D diffuseTexture; layout(binding = 1) uniform sampler2D specularTexture; @endcode -@requires_gl (for explicit texture layer binding instead of using - setUniform(GLint, GLint)) -@requires_gl42 Extension @extension{ARB,shading_language_420pack} (for explicit - texture layer binding instead of using setUniform(GLint, GLint)) If you don't have the required extension (or if you want to change the layer later), you can set the texture layer uniform using setUniform(GLint, GLint): @@ -193,6 +193,11 @@ setUniform(DiffuseTextureUniform, DiffuseTextureLayer); setUniform(SpecularTextureUniform, SpecularTextureLayer); @endcode +@requires_gl42 Extension @extension{ARB,shading_language_420pack} for explicit + texture layer binding instead of using setUniform(GLint, GLint). +@requires_gl Explicit texture layer binding is not supported in OpenGL ES. Use + setUniform(GLint, GLint) instead. + @section AbstractShaderProgram-rendering-workflow Rendering workflow Basic workflow with %AbstractShaderProgram subclasses is to instance the class @@ -235,8 +240,10 @@ mesh.draw(); @ref Math::Vector "Math::Vector<2, GLuint>", @ref Math::Vector "Math::Vector<3, GLuint>" and @ref Math::Vector "Math::Vector<4, GLuint>". - @requires_gl30 %Extension @extension{EXT,gpu_shader4} (for integer attributes) - @requires_gles30 Integer attributes are not supported in OpenGL ES 2.0. + @requires_gl30 %Extension @extension{EXT,gpu_shader4} (for integer attributes + and unsigned integer uniforms) + @requires_gles30 Integer attributes and unsigned integer uniforms are not + available in OpenGL ES 2.0. - `dvec2`, `dvec3` and `dvec4` is @ref Math::Vector "Math::Vector<2, GLdouble>", @ref Math::Vector "Math::Vector<3, GLdouble>" and @@ -251,8 +258,9 @@ mesh.draw(); @ref Math::RectangularMatrix "Math::RectangularMatrix<4, 2, GLdouble>", @ref Math::RectangularMatrix "Math::RectangularMatrix<3, 4, GLdouble>" and @ref Math::RectangularMatrix "Math::RectangularMatrix<4, 3, GLdouble>". - @requires_gl41 %Extension @extension{ARB,vertex_attrib_64bit} (for double attributes) - @requires_gl Double attributes are supported only on desktop OpenGL. + @requires_gl41 %Extension @extension{ARB,vertex_attrib_64bit} (for double + attributes) + @requires_gl Double attributes are not available in OpenGL ES. Only types listed here (and their subclasses and specializations, such as @ref Matrix3 or Color4) can be used for setting uniforms and specifying @@ -388,8 +396,8 @@ class MAGNUM_EXPORT AbstractShaderProgram { * BGRA component ordering. Default is RGBA. Only for * four-component float vector attribute type. * @requires_gl32 %Extension @extension{ARB,vertex_array_bgra} - * @requires_gl Only RGBA component ordering is available - * on OpenGL ES. + * @requires_gl Only RGBA component ordering is supported + * in OpenGL ES. */ BGRA = 1 << 1 }; @@ -462,15 +470,13 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @note This function should be called after attachShader() calls and * before link(). * @see @fn_gl{ProgramParameter} with @def_gl{PROGRAM_BINARY_RETRIEVABLE_HINT} - * @requires_gl * @requires_gl41 Extension @extension{ARB,get_program_binary} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Always allowed in OpenGL ES 2.0. */ inline void setRetrievableBinary(bool enabled) { glProgramParameteri(_id, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, enabled ? GL_TRUE : GL_FALSE); } - #ifndef MAGNUM_TARGET_GLES /** * @brief Allow the program to be bound to individual pipeline stages * @@ -478,13 +484,17 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @note This function should be called after attachShader() calls and * before link(). * @see @fn_gl{ProgramParameter} with @def_gl{PROGRAM_SEPARABLE} - * @requires_gl * @requires_gl41 Extension @extension{ARB,separate_shader_objects} + * @requires_es_extension %Extension @es_extension{EXT,separate_shader_objects} */ inline void setSeparable(bool enabled) { + /** @todo Remove when extension wrangler is available for ES */ + #ifndef MAGNUM_TARGET_GLES glProgramParameteri(_id, GL_PROGRAM_SEPARABLE, enabled ? GL_TRUE : GL_FALSE); + #else + static_cast(enabled); + #endif } - #endif /** * @brief Load shader @@ -536,8 +546,9 @@ class MAGNUM_EXPORT AbstractShaderProgram { * @ref AbstractShaderProgram-attribute-location "class documentation" * for more information. * @see @fn_gl{BindFragDataLocationIndexed} - * @requires_gl * @requires_gl33 Extension @extension{ARB,blend_func_extended} + * @requires_gl Multiple blend function inputs are not available in + * OpenGL ES. */ void bindFragmentDataLocationIndexed(GLuint location, GLuint index, const std::string& name); @@ -549,8 +560,9 @@ class MAGNUM_EXPORT AbstractShaderProgram { * The same as bindFragmentDataLocationIndexed(), but with `index` set * to `0`. * @see @fn_gl{BindFragDataLocation} - * @requires_gl * @requires_gl30 Extension @extension{EXT,gpu_shader4} + * @requires_gl Use explicit location specification in OpenGL ES 3.0 + * instead. */ void bindFragmentDataLocation(GLuint location, const std::string& name); #endif @@ -628,10 +640,11 @@ class MAGNUM_EXPORT AbstractShaderProgram { (this->*uniform4ivImplementation)(location, value); } + #ifndef MAGNUM_TARGET_GLES2 /** * @copydoc setUniform(GLint, GLfloat) * @requires_gl30 Extension @extension{EXT,gpu_shader4} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, GLuint value) { (this->*uniform1uiImplementation)(location, value); @@ -640,7 +653,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) * @requires_gl30 Extension @extension{EXT,gpu_shader4} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::Vector<2, GLuint>& value) { (this->*uniform2uivImplementation)(location, value); @@ -649,7 +662,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) * @requires_gl30 Extension @extension{EXT,gpu_shader4} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::Vector<3, GLuint>& value) { (this->*uniform3uivImplementation)(location, value); @@ -658,11 +671,12 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) * @requires_gl30 Extension @extension{EXT,gpu_shader4} - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only signed integers are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::Vector<4, GLuint>& value) { (this->*uniform4uivImplementation)(location, value); } + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -717,9 +731,10 @@ class MAGNUM_EXPORT AbstractShaderProgram { (this->*uniformMatrix4fvImplementation)(location, value); } + #ifndef MAGNUM_TARGET_GLES2 /** * @copydoc setUniform(GLint, GLfloat) - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::RectangularMatrix<2, 3, GLfloat>& value) { (this->*uniformMatrix2x3fvImplementation)(location, value); @@ -727,7 +742,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::RectangularMatrix<3, 2, GLfloat>& value) { (this->*uniformMatrix3x2fvImplementation)(location, value); @@ -735,7 +750,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::RectangularMatrix<2, 4, GLfloat>& value) { (this->*uniformMatrix2x4fvImplementation)(location, value); @@ -743,7 +758,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::RectangularMatrix<4, 2, GLfloat>& value) { (this->*uniformMatrix4x2fvImplementation)(location, value); @@ -751,7 +766,7 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::RectangularMatrix<3, 4, GLfloat>& value) { (this->*uniformMatrix3x4fvImplementation)(location, value); @@ -759,11 +774,12 @@ class MAGNUM_EXPORT AbstractShaderProgram { /** * @copydoc setUniform(GLint, GLfloat) - * @requires_gles30 (no extension providing this functionality) + * @requires_gles30 Only square matrices are available in OpenGL ES 2.0. */ inline void setUniform(GLint location, const Math::RectangularMatrix<4, 3, GLfloat>& value) { (this->*uniformMatrix4x3fvImplementation)(location, value); } + #endif #ifndef MAGNUM_TARGET_GLES /** @@ -865,10 +881,12 @@ class MAGNUM_EXPORT AbstractShaderProgram { typedef void(AbstractShaderProgram::*Uniform2ivImplementation)(GLint, const Math::Vector<2, GLint>&); typedef void(AbstractShaderProgram::*Uniform3ivImplementation)(GLint, const Math::Vector<3, GLint>&); typedef void(AbstractShaderProgram::*Uniform4ivImplementation)(GLint, const Math::Vector<4, GLint>&); + #ifndef MAGNUM_TARGET_GLES2 typedef void(AbstractShaderProgram::*Uniform1uiImplementation)(GLint, GLuint); typedef void(AbstractShaderProgram::*Uniform2uivImplementation)(GLint, const Math::Vector<2, GLuint>&); typedef void(AbstractShaderProgram::*Uniform3uivImplementation)(GLint, const Math::Vector<3, GLuint>&); typedef void(AbstractShaderProgram::*Uniform4uivImplementation)(GLint, const Math::Vector<4, GLuint>&); + #endif #ifndef MAGNUM_TARGET_GLES typedef void(AbstractShaderProgram::*Uniform1dImplementation)(GLint, GLdouble); typedef void(AbstractShaderProgram::*Uniform2dvImplementation)(GLint, const Math::Vector<2, GLdouble>&); @@ -883,16 +901,17 @@ class MAGNUM_EXPORT AbstractShaderProgram { void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<2, GLint>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<3, GLint>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<4, GLint>& value); + #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLuint value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<2, GLuint>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<3, GLuint>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<4, GLuint>& value); + #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL uniformImplementationDefault(GLint location, GLdouble value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<2, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<3, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Vector<4, GLdouble>& value); - #endif void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLfloat value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<2, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<3, GLfloat>& value); @@ -905,7 +924,6 @@ class MAGNUM_EXPORT AbstractShaderProgram { void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<2, GLuint>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<3, GLuint>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<4, GLuint>& value); - #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL uniformImplementationDSA(GLint location, GLdouble value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<2, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Vector<3, GLdouble>& value); @@ -919,10 +937,12 @@ class MAGNUM_EXPORT AbstractShaderProgram { static Uniform2ivImplementation uniform2ivImplementation; static Uniform3ivImplementation uniform3ivImplementation; static Uniform4ivImplementation uniform4ivImplementation; + #ifndef MAGNUM_TARGET_GLES2 static Uniform1uiImplementation uniform1uiImplementation; static Uniform2uivImplementation uniform2uivImplementation; static Uniform3uivImplementation uniform3uivImplementation; static Uniform4uivImplementation uniform4uivImplementation; + #endif #ifndef MAGNUM_TARGET_GLES static Uniform1dImplementation uniform1dImplementation; static Uniform2dvImplementation uniform2dvImplementation; @@ -933,12 +953,14 @@ class MAGNUM_EXPORT AbstractShaderProgram { typedef void(AbstractShaderProgram::*UniformMatrix2fvImplementation)(GLint, const Math::Matrix<2, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix3fvImplementation)(GLint, const Math::Matrix<3, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix4fvImplementation)(GLint, const Math::Matrix<4, GLfloat>&); + #ifndef MAGNUM_TARGET_GLES2 typedef void(AbstractShaderProgram::*UniformMatrix2x3fvImplementation)(GLint, const Math::RectangularMatrix<2, 3, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix3x2fvImplementation)(GLint, const Math::RectangularMatrix<3, 2, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix2x4fvImplementation)(GLint, const Math::RectangularMatrix<2, 4, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix4x2fvImplementation)(GLint, const Math::RectangularMatrix<4, 2, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix3x4fvImplementation)(GLint, const Math::RectangularMatrix<3, 4, GLfloat>&); typedef void(AbstractShaderProgram::*UniformMatrix4x3fvImplementation)(GLint, const Math::RectangularMatrix<4, 3, GLfloat>&); + #endif #ifndef MAGNUM_TARGET_GLES typedef void(AbstractShaderProgram::*UniformMatrix2dvImplementation)(GLint, const Math::Matrix<2, GLdouble>&); typedef void(AbstractShaderProgram::*UniformMatrix3dvImplementation)(GLint, const Math::Matrix<3, GLdouble>&); @@ -953,12 +975,14 @@ class MAGNUM_EXPORT AbstractShaderProgram { void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Matrix<2, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Matrix<3, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Matrix<4, GLfloat>& value); + #ifndef MAGNUM_TARGET_GLES2 void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<2, 3, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<3, 2, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<2, 4, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<4, 2, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<3, 4, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<4, 3, GLfloat>& value); + #endif #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Matrix<2, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::Matrix<3, GLdouble>& value); @@ -969,7 +993,6 @@ class MAGNUM_EXPORT AbstractShaderProgram { void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<4, 2, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<3, 4, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDefault(GLint location, const Math::RectangularMatrix<4, 3, GLdouble>& value); - #endif void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Matrix<2, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Matrix<3, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Matrix<4, GLfloat>& value); @@ -979,7 +1002,6 @@ class MAGNUM_EXPORT AbstractShaderProgram { void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::RectangularMatrix<4, 2, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::RectangularMatrix<3, 4, GLfloat>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::RectangularMatrix<4, 3, GLfloat>& value); - #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Matrix<2, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Matrix<3, GLdouble>& value); void MAGNUM_LOCAL uniformImplementationDSA(GLint location, const Math::Matrix<4, GLdouble>& value); @@ -993,12 +1015,14 @@ class MAGNUM_EXPORT AbstractShaderProgram { static UniformMatrix2fvImplementation uniformMatrix2fvImplementation; static UniformMatrix3fvImplementation uniformMatrix3fvImplementation; static UniformMatrix4fvImplementation uniformMatrix4fvImplementation; + #ifndef MAGNUM_TARGET_GLES2 static UniformMatrix2x3fvImplementation uniformMatrix2x3fvImplementation; static UniformMatrix3x2fvImplementation uniformMatrix3x2fvImplementation; static UniformMatrix2x4fvImplementation uniformMatrix2x4fvImplementation; static UniformMatrix4x2fvImplementation uniformMatrix4x2fvImplementation; static UniformMatrix3x4fvImplementation uniformMatrix3x4fvImplementation; static UniformMatrix4x3fvImplementation uniformMatrix4x3fvImplementation; + #endif #ifndef MAGNUM_TARGET_GLES static UniformMatrix2dvImplementation uniformMatrix2dvImplementation; static UniformMatrix3dvImplementation uniformMatrix3dvImplementation; @@ -1029,8 +1053,12 @@ template<> struct Attribute { UnsignedInt = GL_UNSIGNED_INT, Int = GL_INT, HalfFloat = GL_HALF_FLOAT, - Float = GL_FLOAT, + Float = GL_FLOAT + + #ifndef MAGNUM_TARGET_GLES + , Double = GL_DOUBLE + #endif }; enum class DataOption: std::uint8_t { @@ -1072,23 +1100,34 @@ template<> struct Attribute> { Int = GL_INT, Half = GL_HALF_FLOAT, Float = GL_FLOAT, + #ifndef MAGNUM_TARGET_GLES Double = GL_DOUBLE, + #endif UnsignedAlpha2RGB10 = GL_UNSIGNED_INT_2_10_10_10_REV, Alpha2RGB10 = GL_INT_2_10_10_10_REV }; enum class DataOption: std::uint8_t { - Normalized = 1 << 0, + Normalized = 1 << 0 + + #ifndef MAGNUM_TARGET_GLES + , BGRA = 2 << 0 + #endif }; typedef Corrade::Containers::EnumSet DataOptions; static const DataType DefaultDataType = DataType::Float; + #ifndef MAGNUM_TARGET_GLES inline constexpr static GLint size(DataOptions options) { return options & DataOption::BGRA ? GL_BGRA : 4; } + #else + inline constexpr static GLint size(DataOptions) { return 4; } + #endif + inline constexpr static std::size_t vectorCount() { return 1; } }; @@ -1133,6 +1172,7 @@ template struct Attribute>: public Attri inline constexpr static GLint size() { return size; } }; +#ifndef MAGNUM_TARGET_GLES template<> struct Attribute { enum class DataType: GLenum { Double = GL_DOUBLE @@ -1162,6 +1202,7 @@ template struct Attribute>: public Att inline constexpr static GLint size() { return size; } inline constexpr static std::size_t vectorCount() { return size; } }; +#endif template struct Attribute>: public Attribute> {}; template struct Attribute>: public Attribute> {}; diff --git a/src/Shader.h b/src/Shader.h index 7da337718..643674b77 100644 --- a/src/Shader.h +++ b/src/Shader.h @@ -48,29 +48,29 @@ class MAGNUM_EXPORT Shader { #ifndef MAGNUM_TARGET_GLES /** * Tessellation control shader - * @requires_gl * @requires_gl40 Extension @extension{ARB,tessellation_shader} + * @requires_gl Tessellation shaders are not available in OpenGL ES. */ TessellationControl = GL_TESS_CONTROL_SHADER, /** * Tessellation evaluation shader - * @requires_gl * @requires_gl40 Extension @extension{ARB,tessellation_shader} + * @requires_gl Tessellation shaders are not available in OpenGL ES. */ TessellationEvaluation = GL_TESS_EVALUATION_SHADER, /** * Geometry shader - * @requires_gl * @requires_gl32 Extension @extension{ARB,geometry_shader4} + * @requires_gl Geometry shaders are not available in OpenGL ES. */ Geometry = GL_GEOMETRY_SHADER, /** * Compute shader - * @requires_gl * @requires_gl43 Extension @extension{ARB,compute_shader} + * @requires_gl Compute shaders are not available in OpenGL ES. */ Compute = GL_COMPUTE_SHADER, #endif