libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Typedefs | Enumerations | Variables
donut::graphics Namespace Reference

Classes

class  Buffer
 Unique resource handle with exclusive ownership of a GPU memory buffer. More...
 
struct  CameraOrthographicOptions
 Configuration options for a Camera with an orthographic projection. More...
 
struct  CameraPerspectiveOptions
 Configuration options for a Camera with a perspective projection. More...
 
class  Camera
 Combined view-projection matrix, defining the perspective for a Renderer to render from. More...
 
struct  Error
 Exception type for domain-specific errors originating from the donut::graphics module. More...
 
struct  FontOptions
 Configuration options for a Font. More...
 
class  Font
 Typeface describing an assortment of character glyphs that may be rendered on-demand into an expanding texture atlas, for use in Text rendering. More...
 
class  Framebuffer
 Unique resource handle with exclusive ownership of a GPU framebuffer. More...
 
class  ImageView
 Read-only non-owning view over a 2D image. More...
 
struct  ImageSavePNGOptions
 Options for saving an image in PNG format. More...
 
struct  ImageSaveBMPOptions
 Options for saving an image in Windows Bitmap format. More...
 
struct  ImageSaveTGAOptions
 Options for saving an image in Truevision TARGA format. More...
 
struct  ImageSaveJPGOptions
 Options for saving an image in JPEG format. More...
 
struct  ImageSaveHDROptions
 Options for saving an image in Radiance HDR RGBE format. More...
 
struct  ImageSaveOptions
 Options for saving an image in any format. More...
 
struct  ImageOptions
 Options for loading an image. More...
 
class  Image
 Container for a 2D image. More...
 
struct  NoIndex
 Tag type for specifying that a Mesh does not have an index buffer. More...
 
struct  NoInstance
 Tag type for specifying that a Mesh does not have an instance buffer. More...
 
class  Mesh
 Generic abstraction of a GPU vertex array object and its associated buffers. More...
 
struct  Model
 Container for a set of 3D triangle meshes stored on the GPU, combined with associated materials. More...
 
struct  RendererOptions
 Configuration options for a Renderer. More...
 
class  Renderer
 Persistent system for rendering the batched draw commands of a RenderPass onto a Framebuffer, such as the user's screen. More...
 
struct  ModelInstance
 Configuration of a 3D Model instance, for drawing as part of a RenderPass. More...
 
struct  QuadInstance
 Configuration of an arbitrarily shaded/transformed 2D quad instance, optionally textured, for drawing as part of a RenderPass. More...
 
struct  TextureInstance
 Configuration of a 2D textured quad instance, for drawing as part of a RenderPass. More...
 
struct  RectangleInstance
 Configuration of a 2D rectangle instance, optionally textured, for drawing as part of a RenderPass. More...
 
struct  SpriteInstance
 Configuration of a 2D sprite instance from a SpriteAtlas, for drawing as part of a RenderPass. More...
 
struct  TextInstance
 Configuration of a 2D instance of Text shaped from a Font, for drawing as part of a RenderPass. More...
 
struct  TextCopyInstance
 Configuration of a copied 2D instance of Text shaped from a Font, for drawing as part of a RenderPass. More...
 
struct  TextUTF8StringInstance
 Configuration of a 2D instance of a UTF-8 string of text with a Font, for drawing as part of a RenderPass. More...
 
struct  TextStringInstance
 Configuration of a 2D instance of a string of text with a Font, for drawing as part of a RenderPass. More...
 
class  RenderPass
 Graphics drawing queue for batch rendering using a Renderer. More...
 
struct  Shader2DOptions
 Configuration options for a Shader2D. More...
 
class  Shader2D
 ShaderProgram specialized for rendering TexturedQuad instances in 2D. More...
 
struct  Shader3DOptions
 Configuration options for a Shader3D. More...
 
class  Shader3D
 ShaderProgram specialized for rendering Model instances in 3D. More...
 
struct  ShaderConfiguration
 Base configuration options for a shader. More...
 
class  ShaderParameter
 Identifier for a uniform shader variable inside a ShaderProgram. More...
 
class  ShaderArray
 Fixed-size array of uniform shader variable identifiers representing an array inside a ShaderProgram. More...
 
struct  ShaderProgramOptions
 Configuration options for a ShaderProgram. More...
 
class  ShaderProgram
 Compiled and linked GPU shader program. More...
 
class  ShaderStage
 Compiled GPU code for a specific stage of a ShaderProgram. More...
 
struct  SpriteAtlasOptions
 Configuration options for a SpriteAtlas. More...
 
class  SpriteAtlas
 Expandable texture atlas for packing 2D images into a spritesheet to enable batch rendering. More...
 
class  Text
 Facility for shaping text, according to a Font, into renderable glyphs. More...
 
struct  TextureOptions
 Configuration options for a Texture and its assocated sampler. More...
 
class  Texture
 Storage for multidimensional data, such as 2D images, on the GPU, combined with a sampler configuration that defines how to render the stored data. More...
 
struct  TexturedQuad
 Square 2D mesh for textured rendering. More...
 
class  VertexArray
 Unique resource handle with exclusive ownership of a GPU vertex array. More...
 
struct  Viewport
 Rectangular region of a framebuffer. More...
 
struct  WindowOptions
 Configuration options for a Window. More...
 
class  Window
 Graphical window that can be rendered to. More...
 

Typedefs

using Handle = std::uint32_t
 Generic GPU resource handle. More...
 

Enumerations

enum class  PixelFormat : std::uint32_t { R , RG , RGB , RGBA }
 Description of the number and meaning of the pixel component channels of an image. More...
 
enum class  PixelComponentType : std::uint32_t { U8 , F16 , F32 }
 Description of the data type of the pixel components of an image. More...
 
enum class  MeshBufferUsage : std::uint32_t {
  STATIC_COPY , STATIC_DRAW , STATIC_READ , DYNAMIC_COPY ,
  DYNAMIC_DRAW , DYNAMIC_READ , STREAM_COPY , STREAM_DRAW ,
  STREAM_READ
}
 Hint to the graphics driver implementation regarding the intended access pattern of a particular GPU memory buffer in a Mesh, for optimization purposes. More...
 
enum class  MeshPrimitiveType : std::uint32_t {
  POINTS , LINES , LINE_LOOP , LINE_STRIP ,
  TRIANGLES , TRIANGLE_STRIP
}
 Specification of which kind of graphical primitive is defined by an associated sequence of vertices in a Mesh. More...
 
enum class  MeshIndexType : std::uint32_t { U8 , U16 , U32 }
 Specification of which type of indices is used in the index buffer of a particular Mesh. More...
 
enum class  DepthBufferMode : std::uint8_t { IGNORE , USE_DEPTH_TEST }
 Depth buffer mode used in a ShaderConfiguration. More...
 
enum class  DepthTestPredicate : std::uint32_t {
  NEVER_PASS = 0x0200 , LESS = 0x0201 , LESS_OR_EQUAL = 0x0203 , GREATER = 0x0204 ,
  GREATER_OR_EQUAL = 0x0206 , EQUAL = 0x0202 , NOT_EQUAL = 0x0205 , ALWAYS_PASS = 0x0207
}
 Depth test predicate used in a ShaderConfiguration. More...
 
enum class  StencilBufferMode : std::uint8_t { IGNORE , USE_STENCIL_TEST }
 Stencil buffer mode used in a ShaderConfiguration. More...
 
enum class  StencilTestPredicate : std::uint32_t {
  NEVER_PASS = 0x0200 , LESS = 0x0201 , LESS_OR_EQUAL = 0x0203 , GREATER = 0x0204 ,
  GREATER_OR_EQUAL = 0x0206 , EQUAL = 0x0202 , NOT_EQUAL = 0x0205 , ALWAYS_PASS = 0x0207
}
 Stencil test predicate used in a ShaderConfiguration. More...
 
enum class  StencilBufferOperation : std::uint32_t {
  KEEP = 0x1E00 , SET_TO_ZERO = 0 , REPLACE = 0x1E01 , INCREMENT_CLAMP = 0x1E02 ,
  INCREMENT_WRAP = 0x8507 , DECREMENT_CLAMP = 0x1E03 , DECREMENT_WRAP = 0x8508 , BITWISE_INVERT = 0x150A
}
 Operation to perform after evaluating the stencil test in a ShaderConfiguration. More...
 
enum class  FaceCullingMode : std::uint8_t { IGNORE , CULL_BACK_FACES , CULL_FRONT_FACES , CULL_FRONT_AND_BACK_FACES }
 Face culling mode used in a ShaderConfiguration. More...
 
enum class  FrontFace : std::uint32_t { CLOCKWISE = 0x0900 , COUNTERCLOCKWISE = 0x0901 }
 Front face used in a ShaderConfiguration. More...
 
enum class  AlphaMode : std::uint8_t { IGNORE , USE_ALPHA_BLENDING }
 Alpha mode used in a ShaderConfiguration. More...
 
enum class  ShaderStageType : unsigned { VERTEX_SHADER , FRAGMENT_SHADER }
 Type of a ShaderStage in a ShaderProgram. More...
 
enum class  TextureFormat : std::int32_t {
  R8_UNORM , R16_FLOAT , R32_FLOAT , R8G8_UNORM ,
  R16G16_FLOAT , R32G32_FLOAT , R8G8B8_UNORM , R16G16B16_FLOAT ,
  R32G32B32_FLOAT , R8G8B8A8_UNORM , R16G16B16A16_FLOAT , R32G32B32A32_FLOAT
}
 Description of the internal texel format of a Texture, including the number of component channels, their meaning and their data type. More...
 

Variables

template<typename T >
concept vertex_attribute
 Concept that checks if a type is a valid vertex attribute. More...
 
template<typename T >
concept mesh_vertex
 Concept that checks if a type is a valid vertex type. More...
 
template<typename T >
concept mesh_index
 Concept that checks if a type is a valid index type. More...
 
template<typename T >
concept mesh_instance
 Concept that checks if a type is a valid instance type. More...
 

Typedef Documentation

◆ Handle

typedef std::uint32_t donut::graphics::Handle

Generic GPU resource handle.

Enumeration Type Documentation

◆ PixelFormat

enum donut::graphics::PixelFormat : std::uint32_t
strong

Description of the number and meaning of the pixel component channels of an image.

Enumerator

Each pixel comprises 1 component: red.

RG 

Each pixel comprises 2 components: red, green.

RGB 

Each pixel comprises 3 components: red, green, blue.

RGBA 

Each pixel comprises 4 components: red, green, blue, alpha.

◆ PixelComponentType

enum donut::graphics::PixelComponentType : std::uint32_t
strong

Description of the data type of the pixel components of an image.

Enumerator
U8 

Each pixel component is an 8-bit unsigned integer.

F16 

Each pixel component is a 16-bit floating-point number.

F32 

Each pixel component is a 32-bit floating-point number.

◆ MeshBufferUsage

enum donut::graphics::MeshBufferUsage : std::uint32_t
strong

Hint to the graphics driver implementation regarding the intended access pattern of a particular GPU memory buffer in a Mesh, for optimization purposes.

See https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBufferData.xhtml for details.

Enumerator
STATIC_COPY 
STATIC_DRAW 
STATIC_READ 
DYNAMIC_COPY 
DYNAMIC_DRAW 
DYNAMIC_READ 
STREAM_COPY 
STREAM_DRAW 
STREAM_READ 

◆ MeshPrimitiveType

enum donut::graphics::MeshPrimitiveType : std::uint32_t
strong

Specification of which kind of graphical primitive is defined by an associated sequence of vertices in a Mesh.

Enumerator
POINTS 

Individual points.

LINES 

Each consecutive pair of points forms an individual line segment.

LINE_LOOP 

Each point forms a line segment to the previous point, where the last point connects back to the first in a circular fashion.

LINE_STRIP 

Each point, except the first, forms a line segment to the previous point.

TRIANGLES 

Each consecutive triple of points forms an individual filled triangle.

TRIANGLE_STRIP 

Each point, except the first two, forms a filled triangle with the previous two points.

◆ MeshIndexType

enum donut::graphics::MeshIndexType : std::uint32_t
strong

Specification of which type of indices is used in the index buffer of a particular Mesh.

Enumerator
U8 

Unsigned 8-bit integer.

U16 

Unsigned 16-bit integer.

U32 

Unsigned 32-bit integer.

◆ DepthBufferMode

enum donut::graphics::DepthBufferMode : std::uint8_t
strong

Depth buffer mode used in a ShaderConfiguration.

See also
ShaderConfiguration::depthBufferMode
Enumerator
IGNORE 

Ignore the depth buffer.

USE_DEPTH_TEST 

Evaluate the depth test defined by the DepthTestPredicate to determine whether the pixel should be rendered or discarded.

If the test fails, the new pixel is discarded and will not be rendered.

Note
In 3D, using the depth test with DepthTestPredicate::LESS is necessary to avoid 3D objects and faces being incorrectly rendered on top of each other. However, for 2D shaders, the depth test should typically be disabled in favor of using the painter's algorithm instead.

◆ DepthTestPredicate

enum donut::graphics::DepthTestPredicate : std::uint32_t
strong

Depth test predicate used in a ShaderConfiguration.

See also
ShaderConfiguration::depthTestPredicate
Enumerator
NEVER_PASS 

The depth test always fails.

LESS 

The depth test passes if and only if the new depth value is less than the old depth value.

LESS_OR_EQUAL 

The depth test passes if and only if the new depth value is less than or equal to the old depth value.

GREATER 

The depth test passes if and only if the new depth value is greater than the old depth value.

GREATER_OR_EQUAL 

The depth test passes if and only if the new depth value is greater than or equal to the old depth value.

EQUAL 

The depth test passes if and only if the new depth value is equal to the old depth value.

NOT_EQUAL 

The depth test passes if and only if the new depth value is not equal to the old depth value.

ALWAYS_PASS 

The depth test always passes.

◆ StencilBufferMode

enum donut::graphics::StencilBufferMode : std::uint8_t
strong

Stencil buffer mode used in a ShaderConfiguration.

See also
ShaderConfiguration::stencilBufferMode
Enumerator
IGNORE 

Ignore the stencil buffer.

USE_STENCIL_TEST 

Evaluate the stencil test defined by the StencilTestPredicate to determine whether the pixel should be rendered or discarded, then perform the corresponding StencilBufferOperation on the stencil buffer value.

If the test fails, the new pixel is discarded and will not be rendered.

◆ StencilTestPredicate

enum donut::graphics::StencilTestPredicate : std::uint32_t
strong

Stencil test predicate used in a ShaderConfiguration.

See also
ShaderConfiguration::stencilTestPredicate
Enumerator
NEVER_PASS 

The stencil test always fails.

LESS 

The stencil test passes if and only if the given reference value is less than the current value in the stencil buffer.

The stencil value and the reference value are both masked with the given mask before performing the check.

LESS_OR_EQUAL 

The stencil test passes if and only if the given reference value is less than or equal to the current value in the stencil buffer.

The stencil value and the reference value are both masked with the given mask before performing the check.

GREATER 

The stencil test passes if and only if the given reference value is greater than the current value in the stencil buffer.

The stencil value and the reference value are both masked with the given mask before performing the check.

GREATER_OR_EQUAL 

The stencil test passes if and only if the given reference value is greater than or equal to the current value in the stencil buffer.

The stencil value and the reference value are both masked with the given mask before performing the check.

EQUAL 

The stencil test passes if and only if the given reference value is equal to the current value in the stencil buffer.

The stencil value and the reference value are both masked with the given mask before performing the check.

NOT_EQUAL 

The stencil test passes if and only if the given reference value is not equal to the current value in the stencil buffer.

The stencil value and the reference value are both masked with the given mask before performing the check.

ALWAYS_PASS 

The stencil test always passes.

◆ StencilBufferOperation

enum donut::graphics::StencilBufferOperation : std::uint32_t
strong

Operation to perform after evaluating the stencil test in a ShaderConfiguration.

See also
ShaderConfiguration::stencilBufferOperationOnStencilTestFail
ShaderConfiguration::stencilBufferOperationOnDepthTestFail
ShaderConfiguration::stencilBufferOperationOnPass
Enumerator
KEEP 

Keep the current value in the stencil buffer.

SET_TO_ZERO 

Set the stencil buffer value to 0.

REPLACE 

Set the stencil buffer value to the given reference value.

INCREMENT_CLAMP 

Increment the stencil buffer value by 1, unless it is already maxed out.

INCREMENT_WRAP 

Increment the stencil buffer value by 1, or wrap around to 0 if it was maxed out.

DECREMENT_CLAMP 

Decrement the stencil buffer value by 1, unless it is already 0.

DECREMENT_WRAP 

Decrement the stencil buffer value by 1, or wrap around to the maximum value if it was 0.

BITWISE_INVERT 

Toggle each bit in the stencil buffer value.

◆ FaceCullingMode

enum donut::graphics::FaceCullingMode : std::uint8_t
strong

Face culling mode used in a ShaderConfiguration.

See also
ShaderConfiguration::faceCullingMode
Enumerator
IGNORE 

Ignore facing.

CULL_BACK_FACES 

Discard back-facing faces.

CULL_FRONT_FACES 

Discard front-facing faces.

CULL_FRONT_AND_BACK_FACES 

Discard all faces, only render primitives without faces, such as lines and points.

◆ FrontFace

enum donut::graphics::FrontFace : std::uint32_t
strong

Front face used in a ShaderConfiguration.

See also
ShaderConfiguration::frontFace
Enumerator
CLOCKWISE 

Consider faces with clockwise winding order as front-facing.

COUNTERCLOCKWISE 

Consider faces with counterclockwise winding order as front-facing.

◆ AlphaMode

enum donut::graphics::AlphaMode : std::uint8_t
strong

Alpha mode used in a ShaderConfiguration.

See also
ShaderConfiguration::alphaMode
Enumerator
IGNORE 

Ignore the alpha channel value of the rendered pixel color.

USE_ALPHA_BLENDING 

Blend the old and new pixel colors depending on the alpha value of the new pixel according to the standard "over" compositing operator for transparency.

◆ ShaderStageType

enum donut::graphics::ShaderStageType : unsigned
strong

Type of a ShaderStage in a ShaderProgram.

Enumerator
VERTEX_SHADER 

Vertex shader.

FRAGMENT_SHADER 

Fragment/pixel shader.

◆ TextureFormat

enum donut::graphics::TextureFormat : std::int32_t
strong

Description of the internal texel format of a Texture, including the number of component channels, their meaning and their data type.

Enumerator
R8_UNORM 

Each texel comprises 1 normalized 8-bit unsigned integer component: red.

R16_FLOAT 

Each texel comprises 1 16-bit floating-point component: red.

R32_FLOAT 

Each texel comprises 1 32-bit floating-point component: red.

R8G8_UNORM 

Each texel comprises 2 normalized 8-bit unsigned integer components: red, green.

R16G16_FLOAT 

Each texel comprises 2 16-bit floating-point components: red, green.

R32G32_FLOAT 

Each texel comprises 2 32-bit floating-point components: red, green.

R8G8B8_UNORM 

Each texel comprises 3 normalized 8-bit unsigned integer components: red, green, blue.

R16G16B16_FLOAT 

Each texel comprises 3 16-bit floating-point components: red, green, blue.

R32G32B32_FLOAT 

Each texel comprises 3 32-bit floating-point components: red, green, blue.

R8G8B8A8_UNORM 

Each texel comprises 4 normalized 8-bit unsigned integer components: red, green, blue, alpha.

R16G16B16A16_FLOAT 

Each texel comprises 4 16-bit floating-point components: red, green, blue, alpha.

R32G32B32A32_FLOAT 

Each texel comprises 4 32-bit floating-point components: red, green, blue, alpha.

Variable Documentation

◆ vertex_attribute

template<typename T >
concept donut::graphics::vertex_attribute
Initial value:
=
std::is_same_v<T, u32> ||
std::is_same_v<T, float> ||
std::is_same_v<T, vec2> ||
std::is_same_v<T, vec3> ||
std::is_same_v<T, vec4> ||
std::is_same_v<T, mat2> ||
std::is_same_v<T, mat3> ||
std::is_same_v<T, mat4>

Concept that checks if a type is a valid vertex attribute.

Template Parameters
Tthe type to check.

◆ mesh_vertex

template<typename T >
concept donut::graphics::mesh_vertex
Initial value:
=
std::is_aggregate_v<T> &&
std::is_standard_layout_v<T> &&
detail::is_vertex_attributes_v<decltype(reflection::fields(std::declval<T>()))>

Concept that checks if a type is a valid vertex type.

Template Parameters
Tthe type to check.

◆ mesh_index

template<typename T >
concept donut::graphics::mesh_index
Initial value:
=
std::is_same_v<T, NoIndex> ||
std::is_same_v<T, u8> ||
std::is_same_v<T, u16> ||
std::is_same_v<T, u32>

Concept that checks if a type is a valid index type.

Template Parameters
Tthe type to check.

◆ mesh_instance

template<typename T >
concept donut::graphics::mesh_instance
Initial value:
=
std::is_aggregate_v<T> &&
std::is_standard_layout_v<T> &&
detail::is_vertex_attributes_v<decltype(reflection::fields(std::declval<T>()))>

Concept that checks if a type is a valid instance type.

Template Parameters
Tthe type to check.