16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 12:49:18 +02:00

material changes, shader params, texture binding changes, more changes, ...

This commit is contained in:
milek7
2018-07-18 21:53:12 +02:00
parent a1d11cb03b
commit ee16821509
12 changed files with 486 additions and 165 deletions

View File

@@ -9,6 +9,11 @@
namespace gl
{
class shader_exception : public std::runtime_error
{
using runtime_error::runtime_error;
};
class shader : public object
{
public:
@@ -17,29 +22,56 @@ namespace gl
enum class components_e
{
R,
RG,
RGB,
RGBA,
sRGB,
sRGB_A
R = GL_R,
RG = GL_RG,
RGB = GL_RGB,
RGBA = GL_RGBA,
sRGB = GL_SRGB,
sRGB_A = GL_SRGB_ALPHA
};
struct texture_entry
{
std::string name;
size_t id;
components_e components;
};
std::vector<texture_entry> texture_conf;
enum class defaultparam_e
{
required,
nan,
zero,
one,
ambient,
diffuse,
specular
};
struct param_entry
{
size_t location;
size_t offset;
size_t size;
defaultparam_e defaultparam;
};
std::unordered_map<std::string, texture_entry> texture_conf;
std::unordered_map<std::string, param_entry> param_conf;
std::string name;
private:
void process_source(std::string &str);
void expand_includes(std::string &str);
void parse_config(std::string &str);
void parse_texture_entries(std::string &str);
void parse_param_entries(std::string &str);
std::string read_file(const std::string &filename);
static std::unordered_map<std::string, components_e> components_mapping;
static std::unordered_map<std::string, defaultparam_e> defaultparams_mapping;
void log_error(const std::string &str);
};
class program : public object, public bindable<program>
@@ -55,7 +87,8 @@ namespace gl
void attach(const shader &);
void link();
std::vector<shader::texture_entry> texture_conf;
std::unordered_map<std::string, shader::texture_entry> texture_conf;
std::unordered_map<std::string, shader::param_entry> param_conf;
private:
void init();