Unravel Engine C++ Reference
|
Class representing a GPU program. More...
#include <gpu_program.h>
Public Types | |
using | ptr = std::shared_ptr<gpu_program> |
using | wptr = std::weak_ptr<gpu_program> |
using | uptr = std::unique_ptr<gpu_program> |
Public Member Functions | |
gpu_program ()=default | |
Default constructor. | |
gpu_program (asset_handle< gfx::shader > compute_shader) | |
Constructor to create a program from a compute shader asset. | |
gpu_program (asset_handle< gfx::shader > vertex_shader, asset_handle< gfx::shader > fragment_shader) | |
Constructor to create a program from vertex and fragment shader assets. | |
auto | begin () -> bool |
Begins usage of the program. Checks validity of attached shaders and recreates the internal program if necessary. | |
void | end () |
Indicates the end of working with a program. | |
void | set_texture (std::uint8_t stage, const hpp::string_view &sampler, const gfx::frame_buffer *handle, uint8_t attachment=0, std::uint32_t flags=std::numeric_limits< std::uint32_t >::max()) |
Sets the texture for a specific stage using a frame buffer. | |
void | set_texture (std::uint8_t stage, const hpp::string_view &sampler, const gfx::texture *texture, std::uint32_t flags=std::numeric_limits< std::uint32_t >::max()) |
Sets the texture for a specific stage using a texture. | |
void | set_uniform (const hpp::string_view &name, const void *value, std::uint16_t num=1) |
Sets a uniform value in the shader program. | |
void | set_uniform (const hpp::string_view &name, const math::vec4 &value, std::uint16_t num=1) |
Sets a uniform value in the shader program. | |
void | set_uniform (const hpp::string_view &name, const math::vec3 &value, std::uint16_t num=1) |
Sets a uniform value in the shader program. | |
void | set_uniform (const hpp::string_view &name, const math::vec2 &value, std::uint16_t num=1) |
Sets a uniform value in the shader program. | |
auto | get_uniform (const hpp::string_view &name) -> gfx::program::uniform_ptr |
Retrieves a uniform from the shader program. | |
auto | native_handle () const -> gfx::program::handle_type_t |
Retrieves the native handle of the internal shader program. | |
auto | get_shaders () const -> const std::vector< asset_handle< gfx::shader > > & |
Retrieves the shader assets that created the shader program. | |
auto | is_valid () const -> bool |
Checks if the GPU program is valid. | |
void | populate () |
Populates the GPU program. | |
void | attach_shader (asset_handle< gfx::shader > shader) |
Attaches a shader to the GPU program. | |
Class representing a GPU program.
Definition at line 16 of file gpu_program.h.
using unravel::gpu_program::ptr = std::shared_ptr<gpu_program> |
Definition at line 19 of file gpu_program.h.
using unravel::gpu_program::uptr = std::unique_ptr<gpu_program> |
Definition at line 21 of file gpu_program.h.
using unravel::gpu_program::wptr = std::weak_ptr<gpu_program> |
Definition at line 20 of file gpu_program.h.
|
default |
Default constructor.
unravel::gpu_program::gpu_program | ( | asset_handle< gfx::shader > | compute_shader | ) |
Constructor to create a program from a compute shader asset.
compute_shader | The compute shader asset. |
Definition at line 6 of file gpu_program.cpp.
unravel::gpu_program::gpu_program | ( | asset_handle< gfx::shader > | vertex_shader, |
asset_handle< gfx::shader > | fragment_shader ) |
Constructor to create a program from vertex and fragment shader assets.
vertex_shader | The vertex shader asset. |
fragment_shader | The fragment shader asset. |
Definition at line 12 of file gpu_program.cpp.
void unravel::gpu_program::attach_shader | ( | asset_handle< gfx::shader > | shader | ) |
Attaches a shader to the GPU program.
shader | The shader to attach. |
Definition at line 19 of file gpu_program.cpp.
auto unravel::gpu_program::begin | ( | ) | -> bool |
Begins usage of the program. Checks validity of attached shaders and recreates the internal program if necessary.
Definition at line 122 of file gpu_program.cpp.
void unravel::gpu_program::end | ( | ) |
Indicates the end of working with a program.
Definition at line 148 of file gpu_program.cpp.
auto unravel::gpu_program::get_shaders | ( | ) | const -> const std::vector<asset_handle<gfx::shader>>& |
Retrieves the shader assets that created the shader program.
Definition at line 112 of file gpu_program.cpp.
auto unravel::gpu_program::get_uniform | ( | const hpp::string_view & | name | ) | -> gfx::program::uniform_ptr |
Retrieves a uniform from the shader program.
_name | The name of the uniform. |
Definition at line 102 of file gpu_program.cpp.
auto unravel::gpu_program::is_valid | ( | ) | const -> bool |
Checks if the GPU program is valid.
Definition at line 117 of file gpu_program.cpp.
auto unravel::gpu_program::native_handle | ( | ) | const -> gfx::program::handle_type_t |
Retrieves the native handle of the internal shader program.
Definition at line 107 of file gpu_program.cpp.
void unravel::gpu_program::populate | ( | ) |
Populates the GPU program.
Definition at line 30 of file gpu_program.cpp.
void unravel::gpu_program::set_texture | ( | std::uint8_t | stage, |
const hpp::string_view & | sampler, | ||
const gfx::frame_buffer * | handle, | ||
uint8_t | attachment = 0, | ||
std::uint32_t | flags = std::numeric_limits< std::uint32_t >::max() ) |
Sets the texture for a specific stage using a frame buffer.
_stage | The stage number. |
_sampler | The sampler name. |
_handle | The frame buffer handle. |
_attachment | The attachment point. |
_flags | The texture flags. |
void unravel::gpu_program::set_texture | ( | std::uint8_t | stage, |
const hpp::string_view & | sampler, | ||
const gfx::texture * | texture, | ||
std::uint32_t | flags = std::numeric_limits< std::uint32_t >::max() ) |
Sets the texture for a specific stage using a texture.
_stage | The stage number. |
_sampler | The sampler name. |
_texture | The texture handle. |
_flags | The texture flags. |
void unravel::gpu_program::set_uniform | ( | const hpp::string_view & | name, |
const math::vec2 & | value, | ||
std::uint16_t | num = 1 ) |
Sets a uniform value in the shader program.
_name | The name of the uniform. |
_value | The vec2 value to set. |
_num | The number of elements (default is 1). |
void unravel::gpu_program::set_uniform | ( | const hpp::string_view & | name, |
const math::vec3 & | value, | ||
std::uint16_t | num = 1 ) |
Sets a uniform value in the shader program.
_name | The name of the uniform. |
_value | The vec3 value to set. |
_num | The number of elements (default is 1). |
void unravel::gpu_program::set_uniform | ( | const hpp::string_view & | name, |
const math::vec4 & | value, | ||
std::uint16_t | num = 1 ) |
Sets a uniform value in the shader program.
_name | The name of the uniform. |
_value | The vec4 value to set. |
_num | The number of elements (default is 1). |
void unravel::gpu_program::set_uniform | ( | const hpp::string_view & | name, |
const void * | value, | ||
std::uint16_t | num = 1 ) |
Sets a uniform value in the shader program.
_name | The name of the uniform. |
_value | The value to set. |
_num | The number of elements (default is 1). |