Newer
Older
cg / sources / material.cpp
@glproj03 glproj03 on 1 Feb 2006 915 bytes added material
#include "material.h"

#include <GL/gl.h>
#include <GL/glu.h>

Material::Material() {
  ambient = new Color(0,0,0);
  specular = new Color(0.1,0.1,0.1);
  ptdump("m0");
}

Material::Material(Color _ambient) {
  ambient = _ambient.clone();
  specular = new Color(0,0,0);
  ptdump("m1");
}

Material::Material(Color _ambient, Color _specular) {
  ambient = _ambient.clone();
  specular = _specular.clone();
  ptdump("m2");
}

void Material::drawMaterial() {
  ambient->drawColor();
  specular->drawColor(GL_SPECULAR);
}

Material* Material::clone() {  
  Color a = *ambient;
  Color s = *specular;
  return new Material(a, s);
}

void Material::ptdump(std::string id) {
  printf("M::%s %p %p %p\n", id.c_str(), this, ambient, specular);
}

void Material::vardump(std::string whitespace) {
  printf("%sMaterial:\n", whitespace.c_str());
  ambient->vardump(whitespace + "  ");
  specular->vardump(whitespace + "  ");
}