X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterial.cpp;h=a2814cff1ad6ccfdac3347e14f5a3ce130451e45;hp=eee1ebc6152057d8799db1a118fa3dcda2bfcd2c;hb=HEAD;hpb=b617c5d7b5283ad260a77f01e42e6170cabbc03d diff --git a/source/material.cpp b/source/material.cpp deleted file mode 100644 index eee1ebc6..00000000 --- a/source/material.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - -#include "gl.h" -#include "material.h" - -namespace Msp { -namespace GL { - -Material::Material(): - ambient(0.2), - diffuse(0.8), - specular(0), - emission(0), - shininess(0) -{ } - -void Material::set_ambient(const Color &a) -{ - ambient = a; -} - -void Material::set_diffuse(const Color &d) -{ - diffuse = d; -} - -void Material::set_specular(const Color &s) -{ - specular = s; -} - -void Material::set_emission(const Color &e) -{ - emission = e; -} - -void Material::set_shininess(float s) -{ - shininess = s; -} - -void Material::bind() const -{ - if(current!=this) - { - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, &ambient.r); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, &diffuse.r); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &specular.r); - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, &emission.r); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); - current = this; - } -} - -void Material::unbind() -{ - current = 0; -} - -const Material *Material::current = 0; - - -Material::Loader::Loader(Material &m): - DataFile::ObjectLoader(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) -{ - obj.ambient = GL::Color(r, g, b, a); -} - -void Material::Loader::diffuse(float r, float g, float b, float a) -{ - obj.diffuse = GL::Color(r, g, b, a); -} - -void Material::Loader::specular(float r, float g, float b, float a) -{ - obj.specular = GL::Color(r, g, b, a); -} - -void Material::Loader::emission(float r, float g, float b, float a) -{ - obj.emission = GL::Color(r, g, b, a); -} - -} // namespace GL -} // namespace Msp