Unravel Engine C++ Reference
Loading...
Searching...
No Matches
program.h
Go to the documentation of this file.
1#pragma once
2
3#include "frame_buffer.h"
4#include "shader.h"
5#include "texture.h"
6#include "uniform.h"
7
8#include "handle_impl.h"
9#include <hpp/string_view.hpp>
10#include <limits>
11#include <map>
12#include <memory>
13
14namespace gfx
15{
16
17struct program : public handle_impl<program, program_handle>
18{
19 using uniform_ptr = std::shared_ptr<uniform>;
20 //-----------------------------------------------------------------------------
21 // Name : program ()
27 //-----------------------------------------------------------------------------
28 program() = default;
29
30 //-----------------------------------------------------------------------------
31 // Name : program ()
37 //-----------------------------------------------------------------------------
38 program(const shader& compute_shader);
39
40 //-----------------------------------------------------------------------------
41 // Name : program ()
47 //-----------------------------------------------------------------------------
48 program(const shader& vertex_shader, const shader& fragment_shader);
49
50 //-----------------------------------------------------------------------------
51 // Name : set_texture ()
57 //-----------------------------------------------------------------------------
58 void set_texture(uint8_t _stage,
59 const hpp::string_view& _sampler,
60 const gfx::frame_buffer* _handle,
61 uint8_t _attachment = 0,
62 uint32_t _flags = std::numeric_limits<uint32_t>::max());
63
64 //-----------------------------------------------------------------------------
65 // Name : set_texture ()
71 //-----------------------------------------------------------------------------
72 void set_texture(uint8_t _stage,
73 const hpp::string_view& _sampler,
74 const gfx::texture* _texture,
75 uint32_t _flags = std::numeric_limits<uint32_t>::max());
76
77 //-----------------------------------------------------------------------------
78 // Name : set_uniform ()
84 //-----------------------------------------------------------------------------
85 void set_uniform(const hpp::string_view& _name, const void* _value, uint16_t _num = 1);
86
87 //-----------------------------------------------------------------------------
88 // Name : get_uniform ()
94 //-----------------------------------------------------------------------------
95 auto get_uniform(const hpp::string_view& _name, uint8_t stage = uint8_t(-1)) -> uniform_ptr;
96
98 std::map<std::string, uniform_ptr, std::less<>> uniforms;
99 std::array<uniform_ptr, 64> textures_uniforms;
100};
101
102} // namespace gfx
std::map< std::string, uniform_ptr, std::less<> > uniforms
All uniforms for this program.
Definition program.h:98
std::array< uniform_ptr, 64 > textures_uniforms
Definition program.h:99
void set_texture(uint8_t _stage, const hpp::string_view &_sampler, const gfx::frame_buffer *_handle, uint8_t _attachment=0, uint32_t _flags=std::numeric_limits< uint32_t >::max())
Definition program.cpp:46
std::shared_ptr< uniform > uniform_ptr
Definition program.h:19
auto get_uniform(const hpp::string_view &_name, uint8_t stage=uint8_t(-1)) -> uniform_ptr
Definition program.cpp:97
program()=default
void set_uniform(const hpp::string_view &_name, const void *_value, uint16_t _num=1)
Definition program.cpp:87