class
AbstractShaderProgramBase for shader program implementations.
Contents
Subclassing workflow
This class is designed to be used via subclassing. Subclasses define these functions and properties:
Attribute definitions with location and type for configuring meshes, for example:
typedef GL::Attribute<0, Vector3> Position; typedef GL::Attribute<1, Vector3> Normal; typedef GL::Attribute<2, Vector2> TextureCoordinates;
Output attribute locations, if desired, for example:
enum: UnsignedInt { ColorOutput = 0, NormalOutput = 1 };
Constructor, which loads, compiles and attaches particular shaders and links the program together, for example:
explicit MyShader() { /* Load shader sources */ GL::Shader vert{GL::Version::GL430, GL::Shader::Type::Vertex}; GL::Shader frag{GL::Version::GL430, GL::Shader::Type::Fragment}; vert.addFile("MyShader.vert"); frag.addFile("MyShader.frag"); /* Invoke parallel compilation for best performance */ CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag})); /* Attach the shaders */ attachShaders({vert, frag}); /* Link the program together */ CORRADE_INTERNAL_ASSERT_OUTPUT(link()); }
Uniform setting functions, which will provide public interface for protected setUniform() functions. For usability purposes you can implement also method chaining. Example:
MyShader& setProjectionMatrix(const Matrix4& matrix) { setUniform(0, matrix); return *this; } MyShader& setTransformationMatrix(const Matrix4& matrix) { setUniform(1, matrix); return *this; } MyShader& setNormalMatrix(const Matrix3x3& matrix) { setUniform(2, matrix); return *this; }
Texture and texture image binding functions in which you bind the textures/images to particular texture/image units using *Texture::
bind() / *Texture:: bindImage() and similar, for example: MyShader& bindDiffuseTexture(GL::Texture2D& texture) { texture.bind(0); return *this; } MyShader& bindSpecularTexture(GL::Texture2D& texture) { texture.bind(1); return *this; }
Transform feedback setup function, if needed, in which you bind buffers to particular indices using TransformFeedback::
attachBuffer() and similar, possibly with overloads based on desired use cases, e.g.: MyShader& setTransformFeedback(GL::TransformFeedback& feedback, GL::Buffer& positions, GL::Buffer& data) { feedback.attachBuffers(0, {&positions, &data}); return *this; } MyShader& setTransformFeedback(GL::TransformFeedback& feedback, Int totalCount, GL::Buffer& positions, GLintptr positionsOffset, GL::Buffer& data, GLintptr dataOffset) { feedback.attachBuffers(0, { std::make_tuple(&positions, positionsOffset, totalCount*sizeof(Vector3)), std::make_tuple(&data, dataOffset, totalCount*sizeof(Vector2ui)) }); return *this; }
Binding attribute location
The preferred workflow is to specify attribute location for vertex shader input attributes and fragment shader output attributes explicitly in the shader code, e.g.:
// GLSL 3.30, GLSL ES 3.00 or #extension GL_ARB_explicit_attrib_location: require layout(location = 0) in vec4 position; layout(location = 1) in vec3 normal; layout(location = 2) in vec2 textureCoordinates;
Similarly for ouput attributes, you can also specify blend equation color index for them (see Renderer::
layout(location = 0, index = 0) out vec4 color; layout(location = 1, index = 1) out vec3 normal;
If you don't have the required version/extension, declare the attributes without layout()
qualifier and use functions bindAttributeLocation() and bindFragmentDataLocation() / bindFragmentDataLocationIndexed() between attaching the shaders and linking the program. Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES.
in vec4 position; in vec3 normal; in vec2 textureCoordinates;
out vec4 color; out vec3 normal;
// Shaders attached... bindAttributeLocation(Position::Location, "position"); bindAttributeLocation(Normal::Location, "normal"); bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates"); bindFragmentDataLocationIndexed(ColorOutput, 0, "color"); bindFragmentDataLocationIndexed(NormalOutput, 1, "normal"); // Link...
Uniform locations
The preferred workflow is to specify uniform locations directly in the shader code, e.g.:
// GLSL 4.30, GLSL ES 3.10 or #extension GL_ARB_explicit_uniform_location: require layout(location = 0) uniform mat4 projectionMatrix; layout(location = 1) uniform mat4 transformationMatrix; layout(location = 2) uniform mat3 normalMatrix;
If you don't have the required version/extension, declare the uniforms without the layout()
qualifier, get uniform location using uniformLocation() after linking stage and then use the queried location in uniform setting functions. Note that additional syntax changes may be needed for GLSL 1.20 and GLSL ES.
uniform mat4 projectionMatrix; uniform mat4 transformationMatrix; uniform mat3 normalMatrix;
Int projectionMatrixUniform = uniformLocation("projectionMatrix"); Int transformationMatrixUniform = uniformLocation("transformationMatrix"); Int normalMatrixUniform = uniformLocation("normalMatrix");
Uniform block bindings
The preferred workflow is to specify uniform block binding directly in the shader code, e.g.:
// GLSL 4.20, GLSL ES 3.10 or #extension GL_ARB_shading_language_420pack: require layout(std140, binding = 0) uniform matrices { mat4 projectionMatrix; mat4 transformationMatrix; }; layout(std140, binding = 1) uniform material { vec4 diffuse; vec4 specular; };
If you don't have the required version/extension, declare the uniform blocks without the layout()
qualifier, get uniform block index using uniformBlockIndex() and then map it to the uniform buffer binding using setUniformBlockBinding(). Note that additional syntax changes may be needed for GLSL ES.
layout(std140) uniform matrices { mat4 projectionMatrix; mat4 transformationMatrix; }; layout(std140) uniform material { vec4 diffuse; vec4 specular; };
setUniformBlockBinding(uniformBlockIndex("matrices"), 0); setUniformBlockBinding(uniformBlockIndex("material"), 1);
Shader storage block bindings
The workflow is to specify shader storage block binding directly in the shader code, e.g.:
// GLSL 4.30 or GLSL ES 3.10 layout(std430, binding = 0) buffer vertices { vec3 position; vec3 color; }; layout(std430, binding = 1) buffer normals { vec3 normal; };
Specifying texture and image binding units
The preferred workflow is to specify texture/image binding unit directly in the shader code, e.g.:
// GLSL 4.20, GLSL ES 3.10 or #extension GL_ARB_shading_language_420pack: require layout(binding = 0) uniform sampler2D diffuseTexture; layout(binding = 1) uniform sampler2D specularTexture;
If you don't have the required version/extension, declare the uniforms without the binding
qualifier and set the texture binding unit using setUniform(Int, Int). Note that additional syntax changes may be needed for GLSL ES.
uniform sampler2D diffuseTexture; uniform sampler2D specularTexture;
setUniform(uniformLocation("diffuseTexture"), 0); setUniform(uniformLocation("specularTexture"), 1);
Specifying transform feedback binding points
The preferred workflow is to specify output binding points directly in the shader code, e.g.:
// GLSL 4.40, or #extension GL_ARB_enhanced_layouts: require layout(xfb_buffer = 0, xfb_stride = 32) out block { layout(xfb_offset = 0) vec3 position; layout(xfb_offset = 16) vec3 normal; }; layout(xfb_buffer = 1) out vec3 velocity;
If you don't have the required version/extension, declare the uniforms without the xfb_*
qualifier and set the binding points using setTransformFeedbackOutputs(). Equivalent setup for the previous code would be the following:
out block { vec3 position; vec3 normal; }; out vec3 velocity;
setTransformFeedbackOutputs({ // Buffer 0 "position", "gl_SkipComponents1", "normal", "gl_SkipComponents1", // Buffer 1 "gl_NextBuffer", "velocity" }, TransformFeedbackBufferMode::InterleavedAttributes);
Rendering workflow
Basic workflow with AbstractShaderProgram subclasses is: instance shader class, configure attribute binding in meshes (see Mesh documentation for more information) and map shader outputs to framebuffer attachments if needed (see Framebuffer documentation for more information). In each draw event set all required shader parameters, bind specific framebuffer (if needed) and then call Mesh::
shader.setTransformationMatrix(transformation) .setProjectionMatrix(projection) .bindDiffuseTexture(diffuseTexture) .bindSpecularTexture(specularTexture); mesh.draw(shader);
Compute workflow
Add just the Shader::
Mapping between GLSL and Magnum types
See Type system for more information, only types with GLSL equivalent can be used (and their super- or subclasses with the same size and underlying type). See also Attribute::
Performance optimizations
The engine tracks currently used shader program to avoid unnecessary calls to glUseProgram(). Shader limits (such as maxVertexAttributes()) are cached, so repeated queries don't result in repeated glGet() calls. See also Context::
If extension ARB_
To achieve least state changes, set all uniforms in one run — method chaining comes in handy.
Base classes
- class AbstractObject
- Base for all OpenGL objects.
Derived classes
-
template<UnsignedInt dimensions>class Magnum::Shaders::AbstractVector
- Base for vector shaders.
-
template<UnsignedInt dimensions>class Magnum::Shaders::Flat
- Flat shader.
- class Magnum::Shaders::MeshVisualizer
- Mesh visualization shader.
- class Magnum::Shaders::Phong
- Phong shader.
-
template<UnsignedInt dimensions>class Magnum::Shaders::VertexColor
- Vertex color shader.
- class Magnum::Ui::AbstractUiShader
- Base for UI shaders.
Public types
- enum class TransformFeedbackBufferMode: GLenum { InterleavedAttributes = GL_INTERLEAVED_ATTRIBS, SeparateAttributes = GL_SEPARATE_ATTRIBS }
- Buffer mode for transform feedback.
Public static functions
- static auto maxVertexAttributes() -> Int
- Max supported vertex attribute count.
- static auto maxAtomicCounterBufferSize() -> Int
- Max supported atomic counter buffer size.
- static auto maxComputeSharedMemorySize() -> Int
- Max supported compute shared memory size.
- static auto maxComputeWorkGroupInvocations() -> Int
- Max supported compute work group invocation count.
- static auto maxComputeWorkGroupCount() -> Vector3i
- Max supported compute work group count.
- static auto maxComputeWorkGroupSize() -> Vector3i
- Max supported compute work group size.
- static auto maxImageUnits() -> Int
- Max supported image unit count.
- static auto maxImageSamples() -> Int
- Max supported image sample count.
- static auto maxCombinedShaderOutputResources() -> Int
- Max supported combined shader output resource count.
- static auto maxShaderStorageBlockSize() -> Long
- Max supported shader storage block size.
- static auto maxUniformBlockSize() -> Int
- Max supported uniform block size.
- static auto maxUniformLocations() -> Int
- Max supported explicit uniform location count.
- static auto minTexelOffset() -> Int
- Min supported program texel offset.
- static auto maxTexelOffset() -> Int
- Max supported program texel offset.
Constructors, destructors, conversion operators
- AbstractShaderProgram() explicit
- Constructor.
- AbstractShaderProgram(NoCreateT) explicit noexcept
- Construct without creating the underlying OpenGL object.
- AbstractShaderProgram(const AbstractShaderProgram&) deleted
- Copying is not allowed.
- AbstractShaderProgram(AbstractShaderProgram&& other) noexcept
- Move constructor.
- ~AbstractShaderProgram() pure virtual
- Destructor.
Public functions
- auto operator=(const AbstractShaderProgram&) -> AbstractShaderProgram& deleted
- Copying is not allowed.
- auto operator=(AbstractShaderProgram&& other) -> AbstractShaderProgram& noexcept
- Move assignment.
- auto id() const -> GLuint
- OpenGL program ID.
-
auto label() const -> std::
string - Shader program label.
-
auto setLabel(const std::
string& label) -> AbstractShaderProgram& - Set shader program label.
-
template<std::auto setLabel(const char(&label)[size]) -> AbstractShaderProgram&
size_t size> -
auto validate() -> std::
pair<bool, std:: string> - Validate program.
- void dispatchCompute(const Vector3ui& workgroupCount)
- Dispatch compute.
Protected static functions
-
static auto link(std::
initializer_list<std:: reference_wrapper<AbstractShaderProgram>> shaders) -> bool - Link the shader.
Protected functions
- void setRetrievableBinary(bool enabled)
- Allow retrieving program binary.
- void setSeparable(bool enabled)
- Allow the program to be bound to individual pipeline stages.
- void attachShader(Shader& shader)
- Attach shader.
-
void attachShaders(std::
initializer_list<std:: reference_wrapper<Shader>> shaders) - Attach shaders.
-
void bindAttributeLocation(UnsignedInt location,
const std::
string& name) - Bind attribute to given location.
-
template<std::void bindAttributeLocation(UnsignedInt location, const char(&name)[size])
size_t size> -
void bindFragmentDataLocationIndexed(UnsignedInt location,
UnsignedInt index,
const std::
string& name) - Bind fragment data to given location and color input index.
-
template<std::void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const char(&name)[size])
size_t size> -
void bindFragmentDataLocation(UnsignedInt location,
const std::
string& name) - Bind fragment data to given location and first color input index.
-
template<std::void bindFragmentDataLocation(UnsignedInt location, const char(&name)[size])
size_t size> -
void setTransformFeedbackOutputs(std::
initializer_list<std:: string> outputs, TransformFeedbackBufferMode bufferMode) - Specify shader outputs to be recorded in transform feedback.
- auto link() -> bool
- Link the shader.
-
auto uniformLocation(const std::
string& name) -> Int - Get uniform location.
-
template<std::auto uniformLocation(const char(&name)[size]) -> Int
size_t size> -
auto uniformBlockIndex(const std::
string& name) -> UnsignedInt - Get uniform block index.
-
template<std::auto uniformBlockIndex(const char(&name)[size]) -> UnsignedInt
size_t size> -
template<class T>void setUniform(Int location, const T& value)
- Set uniform value.
-
void setUniform(Int location,
Containers::
ArrayView<const Float> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<2, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<3, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<4, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Int> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<2, Int>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<3, Int>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<4, Int>> values) -
void setUniform(Int location,
Containers::
ArrayView<const UnsignedInt> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<2, UnsignedInt>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<3, UnsignedInt>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<4, UnsignedInt>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Double> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<2, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<3, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: Vector<4, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<2, 2, Float>> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<3, 3, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<4, 4, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<2, 3, Float>> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<3, 2, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<2, 4, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<4, 2, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<3, 4, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<4, 3, Float>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<2, 2, Double>> values) - Set uniform values.
-
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<3, 3, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<4, 4, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<2, 3, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<3, 2, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<2, 4, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<4, 2, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<3, 4, Double>> values) -
void setUniform(Int location,
Containers::
ArrayView<const Math:: RectangularMatrix<4, 3, Double>> values) - void setUniformBlockBinding(UnsignedInt index, UnsignedInt binding)
- Set uniform block binding.
Enum documentation
enum class Magnum:: GL:: AbstractShaderProgram:: TransformFeedbackBufferMode: GLenum
Buffer mode for transform feedback.
Enumerators | |
---|---|
InterleavedAttributes |
Attributes will be interleaved at one buffer binding point |
SeparateAttributes |
Each attribute will be put into separate buffer binding point |
Function documentation
static Int Magnum:: GL:: AbstractShaderProgram:: maxVertexAttributes()
Max supported vertex attribute count.
The result is cached, repeated queries don't result in repeated OpenGL calls.
static Int Magnum:: GL:: AbstractShaderProgram:: maxAtomicCounterBufferSize()
Max supported atomic counter buffer size.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxComputeSharedMemorySize()
Max supported compute shared memory size.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxComputeWorkGroupInvocations()
Max supported compute work group invocation count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Vector3i Magnum:: GL:: AbstractShaderProgram:: maxComputeWorkGroupCount()
Max supported compute work group count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_
static Vector3i Magnum:: GL:: AbstractShaderProgram:: maxComputeWorkGroupSize()
Max supported compute work group size.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_
static Int Magnum:: GL:: AbstractShaderProgram:: maxImageUnits()
Max supported image unit count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxImageSamples()
Max supported image sample count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxCombinedShaderOutputResources()
Max supported combined shader output resource count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Long Magnum:: GL:: AbstractShaderProgram:: maxShaderStorageBlockSize()
Max supported shader storage block size.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxUniformBlockSize()
Max supported uniform block size.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxUniformLocations()
Max supported explicit uniform location count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: minTexelOffset()
Min supported program texel offset.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension EXT_0
.
static Int Magnum:: GL:: AbstractShaderProgram:: maxTexelOffset()
Max supported program texel offset.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension EXT_0
.
Magnum:: GL:: AbstractShaderProgram:: AbstractShaderProgram() explicit
Constructor.
Creates one OpenGL shader program.
Magnum:: GL:: AbstractShaderProgram:: AbstractShaderProgram(NoCreateT) explicit noexcept
Construct without creating the underlying OpenGL object.
The constructed instance is equivalent to moved-from state. Useful in cases where you will overwrite the instance later anyway. Move another object over it to make it useful.
This function can be safely used for constructing (and later destructing) objects even without any OpenGL context being active.
Magnum:: GL:: AbstractShaderProgram:: ~AbstractShaderProgram() pure virtual
Destructor.
Deletes associated OpenGL shader program.
std:: string Magnum:: GL:: AbstractShaderProgram:: label() const
Shader program label.
The result is not cached, repeated queries will result in repeated OpenGL calls. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_
AbstractShaderProgram& Magnum:: GL:: AbstractShaderProgram:: setLabel(const std:: string& label)
Set shader program label.
Returns | Reference to self (for method chaining) |
---|
Default is empty string. If OpenGL 4.3 / OpenGL ES 3.2 is not supported and neither KHR_
template<std:: size_t size>
AbstractShaderProgram& Magnum:: GL:: AbstractShaderProgram:: setLabel(const char(&label)[size])
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std:: pair<bool, std:: string> Magnum:: GL:: AbstractShaderProgram:: validate()
Validate program.
Returns validation status and optional validation message.
void Magnum:: GL:: AbstractShaderProgram:: dispatchCompute(const Vector3ui& workgroupCount)
Dispatch compute.
Parameters | |
---|---|
workgroupCount | Workgroup count in given dimension |
Valid only on programs with compute shader attached.
static bool Magnum:: GL:: AbstractShaderProgram:: link(std:: initializer_list<std:: reference_wrapper<AbstractShaderProgram>> shaders) protected
Link the shader.
Returns false
if linking of any shader failed, true
if everything succeeded. Linker message (if any) is printed to error output. All attached shaders must be compiled with Shader::
void Magnum:: GL:: AbstractShaderProgram:: setRetrievableBinary(bool enabled) protected
Allow retrieving program binary.
Initially disabled.
void Magnum:: GL:: AbstractShaderProgram:: setSeparable(bool enabled) protected
Allow the program to be bound to individual pipeline stages.
Initially disabled.
void Magnum:: GL:: AbstractShaderProgram:: attachShader(Shader& shader) protected
Attach shader.
void Magnum:: GL:: AbstractShaderProgram:: attachShaders(std:: initializer_list<std:: reference_wrapper<Shader>> shaders) protected
Attach shaders.
Convenience overload to the above, allowing the user to specify more than one shader at once. Other than that there is no other (performance) difference when using this function.
void Magnum:: GL:: AbstractShaderProgram:: bindAttributeLocation(UnsignedInt location,
const std:: string& name) protected
Bind attribute to given location.
Parameters | |
---|---|
location | Location |
name | Attribute name |
Binds attribute to location which is used later for binding vertex buffers.
template<std:: size_t size>
void Magnum:: GL:: AbstractShaderProgram:: bindAttributeLocation(UnsignedInt location,
const char(&name)[size]) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: bindFragmentDataLocationIndexed(UnsignedInt location,
UnsignedInt index,
const std:: string& name) protected
Bind fragment data to given location and color input index.
Parameters | |
---|---|
location | Location |
index | Blend equation color input index (0 or 1 ) |
name | Fragment output variable name |
Binds fragment data to location which is used later for framebuffer operations. See also Renderer::
template<std:: size_t size>
void Magnum:: GL:: AbstractShaderProgram:: bindFragmentDataLocationIndexed(UnsignedInt location,
UnsignedInt index,
const char(&name)[size]) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: bindFragmentDataLocation(UnsignedInt location,
const std:: string& name) protected
Bind fragment data to given location and first color input index.
Parameters | |
---|---|
location | Location |
name | Fragment output variable name |
The same as bindFragmentDataLocationIndexed(), but with index
set to 0
.
template<std:: size_t size>
void Magnum:: GL:: AbstractShaderProgram:: bindFragmentDataLocation(UnsignedInt location,
const char(&name)[size]) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setTransformFeedbackOutputs(std:: initializer_list<std:: string> outputs,
TransformFeedbackBufferMode bufferMode) protected
Specify shader outputs to be recorded in transform feedback.
Parameters | |
---|---|
outputs | Names of output variables |
bufferMode | Buffer mode |
Binds given output variables from vertex, geometry or tessellation shader to transform feedback buffer binding points. If TransformFeedbackBufferMode::gl_NextBuffer
causes the following output to be recorded into next buffer binding point and gl_SkipComponents#
causes the transform feedback to offset the following output variable by #
components.
bool Magnum:: GL:: AbstractShaderProgram:: link() protected
Link the shader.
Links single shader. If possible, prefer to link multiple shaders at once using link(std::
Int Magnum:: GL:: AbstractShaderProgram:: uniformLocation(const std:: string& name) protected
Get uniform location.
Parameters | |
---|---|
name | Uniform name |
If given uniform is not found in the linked shader, a warning is printed and -1
is returned.
template<std:: size_t size>
Int Magnum:: GL:: AbstractShaderProgram:: uniformLocation(const char(&name)[size]) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
UnsignedInt Magnum:: GL:: AbstractShaderProgram:: uniformBlockIndex(const std:: string& name) protected
Get uniform block index.
Parameters | |
---|---|
name | Uniform block name |
If given uniform block name is not found in the linked shader, a warning is printed and 0xffffffffu
is returned.
template<std:: size_t size>
UnsignedInt Magnum:: GL:: AbstractShaderProgram:: uniformBlockIndex(const char(&name)[size]) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
const T& value) protected
Set uniform value.
Parameters | |
---|---|
location | Uniform location |
value | Value |
Convenience alternative for setting one value, see setUniform(Int, Containers::
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Float> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<2, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<3, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<4, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Int> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<2, Int>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<3, Int>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<4, Int>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const UnsignedInt> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<2, UnsignedInt>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<3, UnsignedInt>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<4, UnsignedInt>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Double> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<2, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<3, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: Vector<4, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<2, 2, Float>> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<3, 3, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<4, 4, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<2, 3, Float>> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<3, 2, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<2, 4, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<4, 2, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<3, 4, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<4, 3, Float>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<2, 2, Double>> values) protected
Set uniform values.
Parameters | |
---|---|
location | Uniform location |
values | Values |
If neither ARB_
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<3, 3, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<4, 4, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<2, 3, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<3, 2, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<2, 4, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<4, 2, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<3, 4, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniform(Int location,
Containers:: ArrayView<const Math:: RectangularMatrix<4, 3, Double>> values) protected
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Magnum:: GL:: AbstractShaderProgram:: setUniformBlockBinding(UnsignedInt index,
UnsignedInt binding) protected
Set uniform block binding.
Parameters | |
---|---|
index | Uniform block index |
binding | Uniform block binding |