summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/bgfx/uniform.h
blob: aa4c2cc097ae10ad5fbed07f14c9a1c856132adb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// license:BSD-3-Clause
// copyright-holders:Ryan Holtz
//============================================================
//
//  uniform.h - Shader uniform abstraction for BGFX layer
//
//============================================================

#pragma once

#ifndef __DRAWBGFX_UNIFORM__
#define __DRAWBGFX_UNIFORM__

#include <bgfx/bgfx.h>

#include <string>

class bgfx_uniform
{
public:
	bgfx_uniform(std::string name, bgfx::UniformType::Enum type);
	virtual ~bgfx_uniform();

	virtual void upload();

	// Getters
	std::string name() { return m_name; }
	bgfx::UniformType::Enum type() const { return m_type; }
	bgfx::UniformHandle handle() const { return m_handle; }

	// Setters
	bgfx_uniform* set(float* value);
	bgfx_uniform* set_int(int value);
	bgfx_uniform* set_mat3(float* value);
	bgfx_uniform* set_mat4(float* value);
	bgfx_uniform* set(void* data, size_t size);

	static size_t get_size_for_type(bgfx::UniformType::Enum type);

protected:
	bgfx::UniformHandle     m_handle;
	std::string             m_name;
	bgfx::UniformType::Enum m_type;
	uint8_t*                m_data;
	size_t                  m_data_size;
};

#endif // __DRAWBGFX_UNIFORM__