class
ShaderShader.
Contents
See AbstractShaderProgram for usage information.
Performance optimizations
Shader limits and implementation-defined values (such as maxUniformComponents()) are cached, so repeated queries don't result in repeated glGet() calls.
Base classes
- class AbstractObject
- Base for all OpenGL objects.
Public types
- enum class Type: GLenum { Vertex = GL_VERTEX_SHADER, TessellationControl = GL_TESS_CONTROL_SHADER, TessellationEvaluation = GL_TESS_EVALUATION_SHADER, Geometry = GL_GEOMETRY_SHADER, Compute = GL_COMPUTE_SHADER, Fragment = GL_FRAGMENT_SHADER }
- Shader type.
Public static functions
- static auto maxVertexOutputComponents() -> Int
- Max supported component count on vertex shader output.
- static auto maxTessellationControlInputComponents() -> Int
- Max supported component count of tessellation control shader input vertex.
- static auto maxTessellationControlOutputComponents() -> Int
- Max supported component count of tessellation control shader output vertex.
- static auto maxTessellationControlTotalOutputComponents() -> Int
- Max supported component count of all tessellation control shader output vertices combined.
- static auto maxTessellationEvaluationInputComponents() -> Int
- Max supported component count of tessellation evaluation shader input vertex.
- static auto maxTessellationEvaluationOutputComponents() -> Int
- Max supported component count of tessellation evaluation shader output vertex.
- static auto maxGeometryInputComponents() -> Int
- Max supported component count of geometry shader input vertex.
- static auto maxGeometryOutputComponents() -> Int
- Max supported component count of geometry shader output vertex.
- static auto maxGeometryTotalOutputComponents() -> Int
- Max supported component count of all geometry shader output vertices combined.
- static auto maxFragmentInputComponents() -> Int
- Max supported component count on fragment shader input.
- static auto maxUniformComponents(Type type) -> Int
- Max supported uniform component count in default block.
- static auto maxAtomicCounterBuffers(Type type) -> Int
- Max supported atomic counter buffer count.
- static auto maxCombinedAtomicCounterBuffers() -> Int
- Max supported atomic counter buffer count for all stages combined.
- static auto maxAtomicCounters(Type type) -> Int
- Max supported atomic counter count.
- static auto maxCombinedAtomicCounters() -> Int
- Max supported atomic counter count for all stages combined.
- static auto maxImageUniforms(Type type) -> Int
- Max supported image uniform count.
- static auto maxCombinedImageUniforms() -> Int
- Max supported image uniform count for all stages combined.
- static auto maxShaderStorageBlocks(Type type) -> Int
- Max supported shader storage block count.
- static auto maxCombinedShaderStorageBlocks() -> Int
- Max supported shader storage block count for all stages combined.
- static auto maxTextureImageUnits(Type type) -> Int
- Max supported texture image unit count.
- static auto maxCombinedTextureImageUnits() -> Int
- Max supported texture image unit count for all stages combined.
- static auto maxUniformBlocks(Type type) -> Int
- Max supported uniform block count.
- static auto maxCombinedUniformBlocks() -> Int
- Max supported uniform block count for all stages combined.
- static auto maxCombinedUniformComponents(Type type) -> Int
- Max supported uniform component count in all blocks combined.
-
static auto compile(std::
initializer_list<std:: reference_wrapper<Shader>> shaders) -> bool - Compile multiple shaders simultaneously.
Constructors, destructors, conversion operators
Public functions
- auto operator=(const Shader&) -> Shader& deleted
- Copying is not allowed.
- auto operator=(Shader&& other) -> Shader& noexcept
- Move assignment.
- auto id() const -> GLuint
- OpenGL shader ID.
-
auto label() const -> std::
string - Shader label.
-
auto setLabel(const std::
string& label) -> Shader& - Set shader label.
-
template<std::auto setLabel(const char(&label)[size]) -> Shader&
size_t size> - auto type() const -> Type
- Shader type.
-
auto sources() const -> std::
vector<std:: string> - Shader sources.
-
auto addSource(std::
string source) -> Shader& - Add shader source.
-
auto addFile(const std::
string& filename) -> Shader& - Add source file.
- auto compile() -> bool
- Compile shader.
Enum documentation
enum class Magnum:: GL:: Shader:: Type: GLenum
Shader type.
Enumerators | |
---|---|
Vertex |
Vertex shader |
TessellationControl |
Tessellation control shader |
TessellationEvaluation |
Tessellation evaluation shader |
Geometry |
Geometry shader |
Compute |
Compute shader |
Fragment |
Fragment shader |
Function documentation
static Int Magnum:: GL:: Shader:: maxVertexOutputComponents()
Max supported component count on vertex shader output.
The result is cached, repeated queries don't result in repeated OpenGL calls. In OpenGL ES 2.0 the four-component vector count is queried and multiplied with 4.
static Int Magnum:: GL:: Shader:: maxTessellationControlInputComponents()
Max supported component count of tessellation control shader input vertex.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxTessellationControlOutputComponents()
Max supported component count of tessellation control shader output vertex.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxTessellationControlTotalOutputComponents()
Max supported component count of all tessellation control shader output vertices combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxTessellationEvaluationInputComponents()
Max supported component count of tessellation evaluation shader input vertex.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxTessellationEvaluationOutputComponents()
Max supported component count of tessellation evaluation shader output vertex.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxGeometryInputComponents()
Max supported component count of geometry shader input vertex.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxGeometryOutputComponents()
Max supported component count of geometry shader output vertex.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxGeometryTotalOutputComponents()
Max supported component count of all geometry shader output vertices combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither ARB_0
.
static Int Magnum:: GL:: Shader:: maxFragmentInputComponents()
Max supported component count on fragment shader input.
The result is cached, repeated queries don't result in repeated OpenGL calls. In OpenGL ES 2.0 the four-component vector count is queried and multiplied with 4.
static Int Magnum:: GL:: Shader:: maxUniformComponents(Type type)
Max supported uniform component count in default block.
The result is cached, repeated queries don't result in repeated OpenGL calls. If particular shader stage is not available, returns 0
. In OpenGL ES 2.0 the four-component vector count is queried and multiplied with 4.
static Int Magnum:: GL:: Shader:: maxAtomicCounterBuffers(Type type)
Max supported atomic counter buffer count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxCombinedAtomicCounterBuffers()
Max supported atomic counter buffer count for all stages combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxAtomicCounters(Type type)
Max supported atomic counter count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxCombinedAtomicCounters()
Max supported atomic counter count for all stages combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxImageUniforms(Type type)
Max supported image uniform count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxCombinedImageUniforms()
Max supported image uniform count for all stages combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxShaderStorageBlocks(Type type)
Max supported shader storage block count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxCombinedShaderStorageBlocks()
Max supported shader storage block count for all stages combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If neither extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxTextureImageUnits(Type type)
Max supported texture image unit count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If particular shader stage is not available, returns 0
.
static Int Magnum:: GL:: Shader:: maxCombinedTextureImageUnits()
Max supported texture image unit count for all stages combined.
The result is cached, repeated queries don't result in repeated OpenGL calls.
static Int Magnum:: GL:: Shader:: maxUniformBlocks(Type type)
Max supported uniform block count.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxCombinedUniformBlocks()
Max supported uniform block count for all stages combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static Int Magnum:: GL:: Shader:: maxCombinedUniformComponents(Type type)
Max supported uniform component count in all blocks combined.
The result is cached, repeated queries don't result in repeated OpenGL calls. If extension ARB_0
.
static bool Magnum:: GL:: Shader:: compile(std:: initializer_list<std:: reference_wrapper<Shader>> shaders)
Compile multiple shaders simultaneously.
Returns false
if compilation of any shader failed, true
if everything succeeded. Compiler messages (if any) are printed to error output. The operation is batched in a way that allows the driver to perform multiple compilations simultaneously (i.e. in multiple threads).
Magnum:: GL:: Shader:: Shader(Version version,
Type type) explicit
Constructor.
Parameters | |
---|---|
version | Target version |
type | Shader type |
Creates empty OpenGL shader and adds #version
directive corresponding to version
parameter at the beginning. If Version::#version
directive is left to the user.
std:: string Magnum:: GL:: Shader:: label() const
Shader 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_
Shader& Magnum:: GL:: Shader:: setLabel(const std:: string& label)
Set shader 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>
Shader& Magnum:: GL:: Shader:: 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.
Shader& Magnum:: GL:: Shader:: addSource(std:: string source)
Add shader source.
Parameters | |
---|---|
source | String with shader source |
Returns | Reference to self (for method chaining) |
Adds given source to source list, preceeded with #line
directive marking first line of the source as n(1)
where n
is number of the added source. The source number 0
is #version
directive added in the constructor, if any. If passed string is empty, the function does nothing.
Shader& Magnum:: GL:: Shader:: addFile(const std:: string& filename)
Add source file.
Parameters | |
---|---|
filename | Name of source file to read from |
Returns | Reference to self (for method chaining) |
The file must exist and must be readable. Calls addSource() with the contents.
bool Magnum:: GL:: Shader:: compile()
Compile shader.
Compiles single shader. Prefer to compile multiple shaders at once using compile(std::
Debug& operator<<(Debug& debug,
Shader:: Type value)
Debug output operator.