X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterial.cpp;h=12d15010e579a39af819fdb557f8669d2eadd1dc;hb=48b1ab4fff00c49cc15d70a354eedb3d7a2f3e87;hp=b5ec6a5cd913209940acdd68558f1dc072fda8aa;hpb=927a1aa0a3a27e463ec0efc08bd08e7c4e969909;p=libs%2Fgl.git diff --git a/source/material.cpp b/source/material.cpp index b5ec6a5c..12d15010 100644 --- a/source/material.cpp +++ b/source/material.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include "gl.h" #include "material.h" @@ -21,49 +14,41 @@ Material::Material(): void Material::set_ambient(const Color &a) { - ambient=a; + ambient = a; } void Material::set_diffuse(const Color &d) { - diffuse=d; + diffuse = d; } void Material::set_specular(const Color &s) { - specular=s; + specular = s; } void Material::set_emission(const Color &e) { - emission=e; + emission = e; } void Material::set_shininess(float s) { - shininess=s; + shininess = s; } void Material::bind() const { - if(current!=this) + if(set_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) @@ -77,22 +62,22 @@ Material::Loader::Loader(Material &m): void Material::Loader::ambient(float r, float g, float b, float a) { - obj.ambient=GL::Color(r, g, b, 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); + 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); + 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); + obj.emission = GL::Color(r, g, b, a); } } // namespace GL