diff options
author | Karl Berry <karl@freefriends.org> | 2019-03-27 22:27:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-03-27 22:27:57 +0000 |
commit | 9121faed0cf54a08882acf41120cf28fc3a32998 (patch) | |
tree | fe7f0c5e9ed02fe4a1fc389c27c88750c2807e43 /Build/source/utils/asymptote/material.h | |
parent | b8e24fbf964b4030f68a8484a53d405869693266 (diff) |
asy 2.48 sources
git-svn-id: svn://tug.org/texlive/trunk@50622 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/material.h')
-rw-r--r-- | Build/source/utils/asymptote/material.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/material.h b/Build/source/utils/asymptote/material.h new file mode 100644 index 00000000000..8ae0c067b45 --- /dev/null +++ b/Build/source/utils/asymptote/material.h @@ -0,0 +1,69 @@ +#ifndef MATERIAL_STRUCT +#define MATERIAL_STRUCT +#ifdef HAVE_GL + +#include <glm/glm.hpp> + +namespace camp { + +inline bool operator < (const glm::vec4& m1, const glm::vec4& m2) { + return m1[0] < m2[0] || + (m1[0] == m2[0] && + (m1[1] < m2[1] || + (m1[1] == m2[1] && + (m1[2] < m2[2] || + (m1[2] == m2[2] && + (m1[3] < m2[3])))))); +} + +struct Material { +public: + glm::vec4 diffuse, ambient, emissive, specular; + GLfloat shininess; + GLfloat padding[3]; + + Material() {} + + Material(const glm::vec4& diffuse, const glm::vec4& ambient, + const glm::vec4& emissive, const glm::vec4& specular, + double shininess) : + diffuse(diffuse), ambient(ambient), emissive(emissive), specular(specular), + shininess(128*shininess) {} + + Material(Material const& m): + diffuse(m.diffuse), ambient(m.ambient), emissive(m.emissive), + specular(m.specular), shininess(m.shininess) {} + ~Material() {} + + Material& operator=(Material const& m) + { + diffuse=m.diffuse; + ambient=m.ambient; + emissive=m.emissive; + specular=m.specular; + shininess=m.shininess; + return *this; + } + + friend bool operator < (const Material& m1, const Material& m2) { + return m1.diffuse < m2.diffuse || + (m1.diffuse == m2.diffuse && + (m1.ambient < m2.ambient || + (m1.ambient == m2.ambient && + (m1.emissive < m2.emissive || + (m1.emissive == m2.emissive && + (m1.specular < m2.specular || + (m1.specular == m2.specular && + (m1.shininess < m2.shininess)))))))); + } + +}; + +extern size_t Nmaterials; // Number of materials compiled in shader +extern size_t nmaterials; // Current size of materials buffer +extern size_t Maxmaterials; // Maxinum size of materials buffer +void clearMaterialBuffer(bool draw=false); + +} +#endif +#endif |