Unravel Engine C++ Reference
Loading...
Searching...
No Matches
shader.cpp
Go to the documentation of this file.
1#include "shader.h"
2#include "utils/bgfx_utils.h"
3
4namespace gfx
5{
6shader::shader(const std::string& path)
7 : shader(loadShader(bx::FilePath(path.c_str())))
8{
9}
10
12{
13}
14
19
20shader::shader(handle_type_t hndl)
21{
22 handle_ = hndl;
23
24 populate_uniforms();
25}
26
27void shader::populate_uniforms()
28{
29 auto uniform_count = get_shader_uniforms(handle_);
30 if(uniform_count > 0)
31 {
32 std::vector<uniform::handle_type_t> uniforms_handles(uniform_count);
33 get_shader_uniforms(handle_, &uniforms_handles[0], uniform_count);
34 uniforms.reserve(uniform_count);
35 for(auto& uni : uniforms_handles)
36 {
37 auto uniform_var = std::make_shared<uniform>(uni);
38 uniforms.emplace_back(uniform_var);
39 }
40 }
41}
42
43} // namespace gfx
static bgfx::ShaderHandle loadShader(bx::FileReaderI *_reader, const bx::StringView &_name)
std::string name
Definition hub.cpp:33
Definition imgui.h:25
renderer_type get_renderer_type()
Definition graphics.cpp:440
shader_handle create_embedded_shader(const embedded_shader *_es, renderer_type _type, const char *_name)
Definition graphics.cpp:402
shader_handle create_shader(const memory_view *_mem)
Definition graphics.cpp:616
uint16_t get_shader_uniforms(shader_handle _handle, uniform_handle *_uniforms, uint16_t _max)
Definition graphics.cpp:621
bgfx::EmbeddedShader embedded_shader
Definition graphics.h:55
bgfx::Memory memory_view
Definition graphics.h:23
std::vector< std::shared_ptr< uniform > > uniforms
Uniforms for this shader.
Definition shader.h:18
shader()=default