GLShader class
#include <nCine/Graphics/GL/GLShader.h>
Wraps an OpenGL shader object.
Manages the lifetime of a single shader object of a given stage (e.g. vertex or fragment), loads its source from strings and/or a file, compiles it, and tracks the compilation status. Compilation errors can be checked immediately or deferred.
Public types
- enum class Status { NotCompiled, CompilationFailed, Compiled, CompiledWithDeferredChecks }
- Compilation status of the shader.
- enum class ErrorChecking { Immediate, Deferred }
- When the compilation status is checked.
Constructors, destructors, conversion operators
- GLShader(GLenum type) explicit
- GLShader(GLenum type, StringView filename)
- ~GLShader()
- GLShader(const GLShader&) deleted
Public functions
- auto operator=(const GLShader&) -> GLShader& deleted
- auto GetGLHandle() const -> GLuint
- Returns the OpenGL handle of the shader object.
- auto GetStatus() const -> Status
- Returns the current compilation status.
- auto LoadFromString(StringView string) -> bool
- Loads the shader source from the given string.
- auto LoadFromStringAndFile(StringView string, StringView filename) -> bool
- Loads the shader source from the given string, then appends the specified file.
- auto LoadFromStrings(ArrayView<const StringView> strings) -> bool
- Loads the shader source by concatenating the given strings in order.
- auto LoadFromStringsAndFile(ArrayView<const StringView> strings, StringView filename) -> bool
- Loads the shader source by concatenating the given strings in order, then appends the specified file.
- auto LoadFromFile(StringView filename) -> bool
- Loads the shader source from the specified file.
- auto Compile(ErrorChecking errorChecking, bool logOnErrors) -> bool
- Compiles the shader.
- auto CheckCompilation(bool logOnErrors) -> bool
- Checks the result of a deferred compilation.
- void SetObjectLabel(StringView label)
- Sets an OpenGL object label for the shader, for debugging.
Enum documentation
enum class nCine:: GLShader:: Status
Compilation status of the shader.
| Enumerators | |
|---|---|
| NotCompiled |
The shader has not been compiled yet |
| CompilationFailed |
Compilation failed |
| Compiled |
Compiled successfully |
| CompiledWithDeferredChecks |
Compiled, but the success status has not been checked yet |
enum class nCine:: GLShader:: ErrorChecking
When the compilation status is checked.
| Enumerators | |
|---|---|
| Immediate |
The compilation status is checked right after compiling |
| Deferred |
The compilation status check is postponed |
Function documentation
bool nCine:: GLShader:: Compile(ErrorChecking errorChecking,
bool logOnErrors)
Compiles the shader.
| Parameters | |
|---|---|
| errorChecking | Whether to check the compilation status immediately or defer it |
| logOnErrors | Whether to log the information log when compilation fails |
| Returns | true on success, or when the status check is deferred |
bool nCine:: GLShader:: CheckCompilation(bool logOnErrors)
Checks the result of a deferred compilation.
| Parameters | |
|---|---|
| logOnErrors | Whether to log the information log when compilation failed |
| Returns | true if the shader compiled successfully |