Antkeeper  0.0.1
Public Member Functions | Friends | List of all members
gl::pipeline Class Reference

Graphics pipeline interface. More...

#include <pipeline.hpp>

Public Member Functions

 pipeline ()
 Constructs a pipeline. More...
 
Vertex input state
void bind_framebuffer (const gl::framebuffer *framebuffer)
 Sets the vertex input. More...
 
void bind_shader_program (const gl::shader_program *shader_program)
 Sets the vertex input. More...
 
void bind_vertex_array (const vertex_array *array)
 Binds a vertex array. More...
 
void bind_vertex_buffers (std::uint32_t first_binding, std::span< const vertex_buffer *const > buffers, std::span< const std::size_t > offsets, std::span< const std::size_t > strides)
 Binds vertex buffers. More...
 
Input assembly state
void set_primitive_topology (primitive_topology topology)
 Sets the primitive topology to use for drawing. More...
 
void set_primitive_restart_enabled (bool enabled)
 Controls whether a special vertex index value is treated as restarting the assembly of primitives. More...
 
Viewport state
void set_viewport (std::uint32_t first_viewport, std::span< const viewport > viewports)
 Sets one or more viewports. More...
 
void set_scissor (std::uint32_t first_scissor, std::span< const scissor_region > scissors)
 Sets one or more scissor regions. More...
 
Rasterizer state
void set_rasterizer_discard_enabled (bool enabled)
 Controls whether primitives are discarded before the rasterization stage. More...
 
void set_fill_mode (fill_mode mode)
 Sets the polygon rasterization mode. More...
 
void set_cull_mode (cull_mode mode)
 Sets the triangle culling mode. More...
 
void set_front_face (front_face face)
 Sets the front-facing triangle orientation. More...
 
void set_depth_bias_enabled (bool enabled)
 Controls whether to bias fragment depth values. More...
 
void set_depth_bias_factors (float constant_factor, float slope_factor)
 Sets depth bias factors. More...
 
void set_depth_clamp_enabled (bool enabled)
 Controls whether depth clamping is enabled. More...
 
void set_scissor_test_enabled (bool enabled)
 Enables or disables scissor testing. More...
 
void set_provoking_vertex_mode (provoking_vertex_mode mode)
 Sets the vertex to be used as the source of data for flat-shaded varyings. More...
 
void set_point_size (float size)
 Sets the the diameter of rasterized points. More...
 
void set_line_width (float width)
 Sets the width of rasterized lines. More...
 
Depth/stencil state
void set_depth_test_enabled (bool enabled)
 Controls whether depth testing is enabled. More...
 
void set_depth_write_enabled (bool enabled)
 Controls whether depth writes are enabled. More...
 
void set_depth_compare_op (gl::compare_op compare_op)
 Sets the depth comparison operator. More...
 
void set_stencil_test_enabled (bool enabled)
 Controls whether stencil testing is enabled. More...
 
void set_stencil_op (std::uint8_t face_mask, stencil_op fail_op, stencil_op pass_op, stencil_op depth_fail_op, gl::compare_op compare_op)
 Sets the stencil operations. More...
 
void set_stencil_compare_mask (std::uint8_t face_mask, std::uint32_t compare_mask)
 Sets the stencil compare mask. More...
 
void set_stencil_reference (std::uint8_t face_mask, std::uint32_t reference)
 Sets the stencil reference value. More...
 
void set_stencil_write_mask (std::uint8_t face_mask, std::uint32_t write_mask)
 Sets the stencil write mask. More...
 
Color blend state
void set_logic_op_enabled (bool enabled)
 Controls whether whether logical operations are enabled. More...
 
void set_logic_op (gl::logic_op logic_op)
 Selects which logical operation to apply. More...
 
void set_color_blend_enabled (bool enabled)
 Controls whether blending is enabled for the corresponding color attachment. More...
 
void set_color_blend_equation (const color_blend_equation &equation)
 Sets the color blend factors and operations. More...
 
void set_color_write_mask (std::uint8_t mask)
 Sets the color write mask. More...
 
void set_blend_constants (const std::array< float, 4 > &blend_constants)
 Sets the values of the blend constants. More...
 
Drawing
void draw (std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance)
 Draws primitives. More...
 
void draw_indexed (std::uint32_t index_count, std::uint32_t instance_count, std::uint32_t first_index, std::int32_t vertex_offset, std::uint32_t first_instance)
 Draws primitives with indexed vertices. More...
 
Clear
void clear_attachments (std::uint8_t mask, const clear_value &value)
 Clears the color, depth, or stencil buffers of current attachments. More...
 
Limitations
constexpr const std::array< std::uint32_t, 2 > & get_default_framebuffer_dimensions () const noexcept
 Returns the dimensions of the default framebuffer. More...
 
constexpr std::uint32_t get_max_viewports () const noexcept
 Returns the maximum number of supported viewports. More...
 
constexpr float get_max_sampler_anisotropy () const noexcept
 Returns the maximum supported degree of sampler anisotropy. More...
 

Friends

class app::sdl_window_manager
 

Detailed Description

Graphics pipeline interface.

Definition at line 47 of file pipeline.hpp.

Constructor & Destructor Documentation

◆ pipeline()

gl::pipeline::pipeline ( )

Constructs a pipeline.

Definition at line 229 of file pipeline.cpp.

Member Function Documentation

◆ bind_framebuffer()

void gl::pipeline::bind_framebuffer ( const gl::framebuffer framebuffer)

Sets the vertex input.

Parameters
vertex_bindingsVertex bindings.
vertex_attributesVertex attributes.

Definition at line 275 of file pipeline.cpp.

◆ bind_shader_program()

void gl::pipeline::bind_shader_program ( const gl::shader_program shader_program)

Sets the vertex input.

Parameters
vertex_bindingsVertex bindings.
vertex_attributesVertex attributes.

Definition at line 292 of file pipeline.cpp.

◆ bind_vertex_array()

void gl::pipeline::bind_vertex_array ( const vertex_array array)

Binds a vertex array.

Parameters
arrayVertex array to bind.

Definition at line 309 of file pipeline.cpp.

◆ bind_vertex_buffers()

void gl::pipeline::bind_vertex_buffers ( std::uint32_t  first_binding,
std::span< const vertex_buffer *const >  buffers,
std::span< const std::size_t >  offsets,
std::span< const std::size_t >  strides 
)

Binds vertex buffers.

Parameters
first_bindingIndex of the first vertex input binding.
buffersSequence of buffers to bind.
offsetsSequence of byte offsets into each buffer.
stridesSequence of byte strides between consecutive elements within each buffer.

Definition at line 326 of file pipeline.cpp.

◆ clear_attachments()

void gl::pipeline::clear_attachments ( std::uint8_t  mask,
const clear_value value 
)

Clears the color, depth, or stencil buffers of current attachments.

Parameters
maskBit mask indicating which buffers should be cleared.
valueColor, depth, and stencil values with which to fill the cleared attachments.

Definition at line 1053 of file pipeline.cpp.

◆ draw()

void gl::pipeline::draw ( std::uint32_t  vertex_count,
std::uint32_t  instance_count,
std::uint32_t  first_vertex,
std::uint32_t  first_instance 
)

Draws primitives.

Parameters
vertex_countNumber of vertices to draw.
instance_countNumber of instances to draw.
first_vertexIndex of the first vertex to draw.
first_instanceInstance ID of the first instance to draw. (WARNING: not currently supported)
Warning
first_instance currently not supported.

Definition at line 1028 of file pipeline.cpp.

◆ draw_indexed()

void gl::pipeline::draw_indexed ( std::uint32_t  index_count,
std::uint32_t  instance_count,
std::uint32_t  first_index,
std::int32_t  vertex_offset,
std::uint32_t  first_instance 
)

Draws primitives with indexed vertices.

Parameters
index_countNumber of vertices to draw.
instance_countNumber of instances to draw.
first_indexBase index within the index buffer.
vertex_offsetValue added to the vertex index before indexing into the vertex buffer.
first_instanceInstance ID of the first instance to draw. (WARNING: not currently supported)
Warning
first_instance currently not supported.

Definition at line 1040 of file pipeline.cpp.

◆ get_default_framebuffer_dimensions()

constexpr const std::array<std::uint32_t, 2>& gl::pipeline::get_default_framebuffer_dimensions ( ) const
inlineconstexprnoexcept

Returns the dimensions of the default framebuffer.

Definition at line 383 of file pipeline.hpp.

◆ get_max_sampler_anisotropy()

constexpr float gl::pipeline::get_max_sampler_anisotropy ( ) const
inlineconstexprnoexcept

Returns the maximum supported degree of sampler anisotropy.

Definition at line 395 of file pipeline.hpp.

◆ get_max_viewports()

constexpr std::uint32_t gl::pipeline::get_max_viewports ( ) const
inlineconstexprnoexcept

Returns the maximum number of supported viewports.

Definition at line 389 of file pipeline.hpp.

◆ set_blend_constants()

void gl::pipeline::set_blend_constants ( const std::array< float, 4 > &  blend_constants)

Sets the values of the blend constants.

Parameters
blend_constantsRGBA components of the blend constant that are used in blending, depending on the blend factor.

Definition at line 1019 of file pipeline.cpp.

◆ set_color_blend_enabled()

void gl::pipeline::set_color_blend_enabled ( bool  enabled)

Controls whether blending is enabled for the corresponding color attachment.

Parameters
enabledtrue if color blending should be enabled, false otherwise.

Definition at line 953 of file pipeline.cpp.

◆ set_color_blend_equation()

void gl::pipeline::set_color_blend_equation ( const color_blend_equation equation)

Sets the color blend factors and operations.

Parameters
equationColor blend factors and operations.

Definition at line 970 of file pipeline.cpp.

◆ set_color_write_mask()

void gl::pipeline::set_color_write_mask ( std::uint8_t  mask)

Sets the color write mask.

Parameters
maskBitmask indicating which of the RGBA components are enabled for writing.

Definition at line 1003 of file pipeline.cpp.

◆ set_cull_mode()

void gl::pipeline::set_cull_mode ( cull_mode  mode)

Sets the triangle culling mode.

Parameters
modeTriangle culling mode.

Definition at line 503 of file pipeline.cpp.

◆ set_depth_bias_enabled()

void gl::pipeline::set_depth_bias_enabled ( bool  enabled)

Controls whether to bias fragment depth values.

Parameters
enabledtrue if fragment depth values should be biased, false otherwise.

Definition at line 551 of file pipeline.cpp.

◆ set_depth_bias_factors()

void gl::pipeline::set_depth_bias_factors ( float  constant_factor,
float  slope_factor 
)

Sets depth bias factors.

Parameters
constant_factorScalar factor controlling the constant depth value added to each fragment.
slope_factorScalar factor applied to a fragment's slope in depth bias calculations.

Definition at line 572 of file pipeline.cpp.

◆ set_depth_clamp_enabled()

void gl::pipeline::set_depth_clamp_enabled ( bool  enabled)

Controls whether depth clamping is enabled.

Parameters
enabledtrue if depth clamping should be enabled, false otherwise.

Definition at line 585 of file pipeline.cpp.

◆ set_depth_compare_op()

void gl::pipeline::set_depth_compare_op ( gl::compare_op  compare_op)

Sets the depth comparison operator.

Parameters
compare_opComparison operator to use in the depth comparison step of the depth test.

Definition at line 675 of file pipeline.cpp.

◆ set_depth_test_enabled()

void gl::pipeline::set_depth_test_enabled ( bool  enabled)

Controls whether depth testing is enabled.

Parameters
enabledtrue if depth testing should be enabled, false otherwise.

Definition at line 649 of file pipeline.cpp.

◆ set_depth_write_enabled()

void gl::pipeline::set_depth_write_enabled ( bool  enabled)

Controls whether depth writes are enabled.

Parameters
enabledtrue if depth writes should be enabled when depth testing is enabled, false otherwise.
Note
Depth writes are always disabled when depth testing is disabled.

Definition at line 666 of file pipeline.cpp.

◆ set_fill_mode()

void gl::pipeline::set_fill_mode ( fill_mode  mode)

Sets the polygon rasterization mode.

Parameters
modePolygon rasterization mode.

Definition at line 477 of file pipeline.cpp.

◆ set_front_face()

void gl::pipeline::set_front_face ( front_face  face)

Sets the front-facing triangle orientation.

Parameters
faceFront-facing triangle orientation.

Definition at line 541 of file pipeline.cpp.

◆ set_line_width()

void gl::pipeline::set_line_width ( float  width)

Sets the width of rasterized lines.

Parameters
widthWidth of rasterized line segments.

Definition at line 639 of file pipeline.cpp.

◆ set_logic_op()

void gl::pipeline::set_logic_op ( gl::logic_op  logic_op)

Selects which logical operation to apply.

Parameters
logic_opLogical operation to apply.

Definition at line 942 of file pipeline.cpp.

◆ set_logic_op_enabled()

void gl::pipeline::set_logic_op_enabled ( bool  enabled)

Controls whether whether logical operations are enabled.

Parameters
enabledtrue if logical operations should be enabled, false otherwise.

Definition at line 925 of file pipeline.cpp.

◆ set_point_size()

void gl::pipeline::set_point_size ( float  size)

Sets the the diameter of rasterized points.

Parameters
sizePoint size.

Definition at line 629 of file pipeline.cpp.

◆ set_primitive_restart_enabled()

void gl::pipeline::set_primitive_restart_enabled ( bool  enabled)

Controls whether a special vertex index value is treated as restarting the assembly of primitives.

Parameters
enabledtrue if a special vertex index value should restart the assembly of primitives, false otherwise.

Definition at line 364 of file pipeline.cpp.

◆ set_primitive_topology()

void gl::pipeline::set_primitive_topology ( primitive_topology  topology)

Sets the primitive topology to use for drawing.

Parameters
topologyPrimitive topology to use for drawing.

Definition at line 356 of file pipeline.cpp.

◆ set_provoking_vertex_mode()

void gl::pipeline::set_provoking_vertex_mode ( provoking_vertex_mode  mode)

Sets the vertex to be used as the source of data for flat-shaded varyings.

Parameters
modeProvoking vertex mode.

Definition at line 619 of file pipeline.cpp.

◆ set_rasterizer_discard_enabled()

void gl::pipeline::set_rasterizer_discard_enabled ( bool  enabled)

Controls whether primitives are discarded before the rasterization stage.

Parameters
enabledtrue if primitives should be discarded before the rasterization stage, false otherwise.

Definition at line 460 of file pipeline.cpp.

◆ set_scissor()

void gl::pipeline::set_scissor ( std::uint32_t  first_scissor,
std::span< const scissor_region scissors 
)

Sets one or more scissor regions.

Parameters
first_scissorIndex of the first scissor region to set.
scissorsSequence of scissor regions.

@except std::out_of_range Scissor region index out of range.

Warning
Currently only a single scissor region is supported.

Definition at line 424 of file pipeline.cpp.

◆ set_scissor_test_enabled()

void gl::pipeline::set_scissor_test_enabled ( bool  enabled)

Enables or disables scissor testing.

Parameters
enabledtrue if scissor testing should be enabled, false otherwise.

Definition at line 602 of file pipeline.cpp.

◆ set_stencil_compare_mask()

void gl::pipeline::set_stencil_compare_mask ( std::uint8_t  face_mask,
std::uint32_t  compare_mask 
)

Sets the stencil compare mask.

Parameters
face_maskBit mask specifying the set of stencil states for which to update the compare mask.
compare_maskNew value to use as the stencil compare mask.

Definition at line 786 of file pipeline.cpp.

◆ set_stencil_op()

void gl::pipeline::set_stencil_op ( std::uint8_t  face_mask,
stencil_op  fail_op,
stencil_op  pass_op,
stencil_op  depth_fail_op,
gl::compare_op  compare_op 
)

Sets the stencil operations.

Parameters
face_maskBit mask specifying the set of stencil states for which to update the stencil operation.
fail_opAction performed on samples that fail the stencil test.
pass_opAction performed on samples that pass both the depth and stencil tests.
depth_fail_opAction performed on samples that pass the stencil test and fail the depth test.
compare_opComparison operator used in the stencil test.

Definition at line 702 of file pipeline.cpp.

◆ set_stencil_reference()

void gl::pipeline::set_stencil_reference ( std::uint8_t  face_mask,
std::uint32_t  reference 
)

Sets the stencil reference value.

Parameters
face_maskBit mask specifying the set of stencil states for which to update the reference value.
referenceNew value to use as the stencil reference value.

Definition at line 841 of file pipeline.cpp.

◆ set_stencil_test_enabled()

void gl::pipeline::set_stencil_test_enabled ( bool  enabled)

Controls whether stencil testing is enabled.

Parameters
enabledtrue if stencil testing should be enabled, false otherwise.

Definition at line 685 of file pipeline.cpp.

◆ set_stencil_write_mask()

void gl::pipeline::set_stencil_write_mask ( std::uint8_t  face_mask,
std::uint32_t  write_mask 
)

Sets the stencil write mask.

Parameters
face_maskBit mask specifying the set of stencil states for which to update the write mask.
write_maskNew value to use as the stencil write mask.

Definition at line 896 of file pipeline.cpp.

◆ set_viewport()

void gl::pipeline::set_viewport ( std::uint32_t  first_viewport,
std::span< const viewport viewports 
)

Sets one or more viewports.

Parameters
first_viewportIndex of the first viewport to set.
viewportsSequence of viewports.

@except std::out_of_range Viewport index out of range.

Warning
Currently only a single viewport is supported.

Definition at line 381 of file pipeline.cpp.

Friends And Related Function Documentation

◆ app::sdl_window_manager

friend class app::sdl_window_manager
friend

Definition at line 403 of file pipeline.hpp.


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