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

ShaderProgram specialized for rendering TexturedQuad instances in 2D. More...

#include <donut/graphics/Shader2D.hpp>

Public Member Functions

 Shader2D (const ShaderProgramOptions &programOptions, const Shader2DOptions &options={})
 Compile and link a 2D shader program. More...
 

Public Attributes

Shader2DOptions options
 Shader configuration that was supplied in the constructor. More...
 
ShaderProgram program
 Shader program. More...
 
ShaderParameter projectionMatrix {program, "projectionMatrix"}
 Identifier for the uniform shader variable for the projection matrix. More...
 
ShaderParameter viewMatrix {program, "viewMatrix"}
 Identifier for the uniform shader variable for the view matrix. More...
 
ShaderParameter viewProjectionMatrix {program, "viewProjectionMatrix"}
 Identifier for the uniform shader variable for the combined view-projection matrix. More...
 
ShaderParameter textureUnit {program, "textureUnit"}
 Identifier for the uniform shader variable for the main texture unit. More...
 

Static Public Attributes

static const char *const VERTEX_SHADER_SOURCE_CODE_INSTANCED_TEXTURED_QUAD
 Pointer to a statically allocated string containing the GLSL source code for a plain vertex shader. More...
 
static const char *const FRAGMENT_SHADER_SOURCE_CODE_PLAIN
 Pointer to a statically allocated string containing the GLSL source code for a plain fragment shader. More...
 
static const char *const FRAGMENT_SHADER_SOURCE_CODE_ALPHA
 Pointer to a statically allocated string containing the GLSL source code for a fragment shader that interprets the red channel as alpha with a white base color. More...
 
static Shader2D *const PLAIN
 Pointer to the statically allocated storage for the built-in plain shader. More...
 
static Shader2D *const ALPHA
 Pointer to the statically allocated storage for the built-in alpha shader. More...
 

Detailed Description

ShaderProgram specialized for rendering TexturedQuad instances in 2D.

Examples
example_game.cpp.

Constructor & Destructor Documentation

◆ Shader2D()

donut::graphics::Shader2D::Shader2D ( const ShaderProgramOptions programOptions,
const Shader2DOptions options = {} 
)
inline

Compile and link a 2D shader program.

Parameters
programOptionsbase options for the ShaderProgram, see ShaderProgramOptions.
optionsadditional options for the shader, see Shader2DOptions.
Exceptions
graphics::Erroron failure to create a shader object, create the shader program object, compile the shader code or link the shader program.
std::bad_allocon allocation failure.

Member Data Documentation

◆ VERTEX_SHADER_SOURCE_CODE_INSTANCED_TEXTURED_QUAD

const char* const donut::graphics::Shader2D::VERTEX_SHADER_SOURCE_CODE_INSTANCED_TEXTURED_QUAD
static

Pointer to a statically allocated string containing the GLSL source code for a plain vertex shader.

Examples
example_game.cpp.

◆ FRAGMENT_SHADER_SOURCE_CODE_PLAIN

const char* const donut::graphics::Shader2D::FRAGMENT_SHADER_SOURCE_CODE_PLAIN
static

Pointer to a statically allocated string containing the GLSL source code for a plain fragment shader.

◆ FRAGMENT_SHADER_SOURCE_CODE_ALPHA

const char* const donut::graphics::Shader2D::FRAGMENT_SHADER_SOURCE_CODE_ALPHA
static

Pointer to a statically allocated string containing the GLSL source code for a fragment shader that interprets the red channel as alpha with a white base color.

◆ PLAIN

Shader2D* const donut::graphics::Shader2D::PLAIN
static

Pointer to the statically allocated storage for the built-in plain shader.

Warning
This pointer must not be dereferenced in application code. It is not guaranteed that the underlying shader will be present at all times.

◆ ALPHA

Shader2D* const donut::graphics::Shader2D::ALPHA
static

Pointer to the statically allocated storage for the built-in alpha shader.

Warning
This pointer must not be dereferenced in application code. It is not guaranteed that the underlying shader will be present at all times.

◆ options

Shader2DOptions donut::graphics::Shader2D::options

Shader configuration that was supplied in the constructor.

◆ program

ShaderProgram donut::graphics::Shader2D::program

Shader program.

◆ projectionMatrix

ShaderParameter donut::graphics::Shader2D::projectionMatrix {program, "projectionMatrix"}

Identifier for the uniform shader variable for the projection matrix.

◆ viewMatrix

ShaderParameter donut::graphics::Shader2D::viewMatrix {program, "viewMatrix"}

Identifier for the uniform shader variable for the view matrix.

◆ viewProjectionMatrix

ShaderParameter donut::graphics::Shader2D::viewProjectionMatrix {program, "viewProjectionMatrix"}

Identifier for the uniform shader variable for the combined view-projection matrix.

◆ textureUnit

ShaderParameter donut::graphics::Shader2D::textureUnit {program, "textureUnit"}

Identifier for the uniform shader variable for the main texture unit.


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