Repository navigation
Expand file tree
/
Copy pathShaderMaterial.h
More file actions
48 lines (38 loc) · 1.52 KB
/
Copy pathShaderMaterial.h
File metadata and controls
48 lines (38 loc) · 1.52 KB
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
#pragma once
#include <map>
#include "Material.h"
#include "Pixmap.h"
#include "Scene3D.h"
#include "types.h"
namespace dawn
{
class ShaderMaterial : public Material
{
public:
ShaderMaterial(std::string path) : m_path(path) { }
CONSTANTS::MaterialType type() const { return CONSTANTS::ShaderMaterial; }
std::string path() const { return m_path; }
void path(std::string path) { setChanged(m_path != path); m_path = path; } // TODO Should it exist?
UniformMap uniforms() const { return m_uniforms; }
// TODO make read const
uniform_t uniform(std::string key) { return m_uniforms[key]; }
void uniform(std::string key, uniform_t value) { setChanged(); m_uniforms[key] = value; }
virtual bool isChanged(etag_t *etag, bool recursive) {
bool changed = Material::isChanged(etag, recursive);
if (recursive) {
for (UniformMap::const_iterator itr = m_uniforms.begin(); itr != m_uniforms.end(); itr++) {
uniform_t u = itr->second;
if (u.type() == typeid(Pixmap *)) {
changed |= boost::any_cast<Pixmap *>(u)->isChanged(etag, recursive);
} else if (u.type() == typeid(Scene3D *)) {
changed |= boost::any_cast<Pixmap *>(u)->isChanged(etag, recursive);
}
}
}
return changed;
}
private:
std::string m_path;
UniformMap m_uniforms;
};
}