X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterial.cpp;h=0b888ef519404e164ac32be278f3593fb85edc0e;hb=a4ec5410595ddf37bfbc0e85ad87d31a9cbf94f1;hp=25c21ff21988b3aed6a00419cb4dcc9ec2450a9f;hpb=4c89817d6e060323ec1ddd275f3265cea688c650;p=libs%2Fgl.git diff --git a/source/material.cpp b/source/material.cpp index 25c21ff2..0b888ef5 100644 --- a/source/material.cpp +++ b/source/material.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include "gl.h" #include "material.h" namespace Msp { @@ -43,7 +44,7 @@ void Material::set_shininess(float s) shininess=s; } -void Material::apply() +void Material::apply() const { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r); @@ -52,5 +53,36 @@ void Material::apply() glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); } + +Material::Loader::Loader(Material &m): + mat(m) +{ + add("ambient", &Loader::ambient); + add("diffuse", &Loader::diffuse); + add("specular", &Loader::specular); + add("emission", &Loader::emission); + add("shininess", &Material::shininess); +} + +void Material::Loader::ambient(float r, float g, float b, float a) +{ + mat.ambient=GL::Color(r, g, b, a); +} + +void Material::Loader::diffuse(float r, float g, float b, float a) +{ + mat.diffuse=GL::Color(r, g, b, a); +} + +void Material::Loader::specular(float r, float g, float b, float a) +{ + mat.specular=GL::Color(r, g, b, a); +} + +void Material::Loader::emission(float r, float g, float b, float a) +{ + mat.emission=GL::Color(r, g, b, a); +} + } // namespace GL } // namespace Msp