libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Public Member Functions | List of all members
donut::graphics::ShaderStage Class Reference

Compiled GPU code for a specific stage of a ShaderProgram. More...

#include <donut/graphics/ShaderStage.hpp>

Public Member Functions

constexpr ShaderStage () noexcept=default
 Construct an empty shader stage without a value. More...
 
 ShaderStage (ShaderStageType type, const char *definitions, const char *sourceCode)
 Compile a shader stage. More...
 
 operator bool () const noexcept
 Check if the shader stage has a value. More...
 
Handle get () const noexcept
 Get an opaque handle to the GPU representation of the shader stage. More...
 

Detailed Description

Compiled GPU code for a specific stage of a ShaderProgram.

Constructor & Destructor Documentation

◆ ShaderStage() [1/2]

constexpr donut::graphics::ShaderStage::ShaderStage ( )
explicitconstexprdefaultnoexcept

Construct an empty shader stage without a value.

◆ ShaderStage() [2/2]

donut::graphics::ShaderStage::ShaderStage ( ShaderStageType  type,
const char *  definitions,
const char *  sourceCode 
)
explicit

Compile a shader stage.

Parameters
typetype of shader stage, see ShaderStageType.
definitionsnon-owning pointer to the GLSL source code for constant definitions to add to the beginning of the source code, or nullptr to not add any definitions.
sourceCodenon-owning pointer to the GLSL source code to compile, or nullptr to create an empty shader stage without a value.
Exceptions
graphics::Erroron failure to create the shader object or compile the shader code.
std::bad_allocon allocation failure.

Member Function Documentation

◆ operator bool()

donut::graphics::ShaderStage::operator bool ( ) const
inlineexplicitnoexcept

Check if the shader stage has a value.

Returns
true if the shader stage has a value, false otherwise.

◆ get()

Handle donut::graphics::ShaderStage::get ( ) const
inlinenoexcept

Get an opaque handle to the GPU representation of the shader stage.

Returns
a non-owning resource handle to the GPU representation of the shader stage.
Note
This function is used internally by the implementations of various abstractions and is not intended to be used outside of the graphics module. The returned handle has no meaning to application code.

The documentation for this class was generated from the following file: