VIZ++ Class: OpenGLMaterial

 VIZ++ Class Library  VIZ++ Samples  VIZ++ ClassTree 

Source code

/*
 * OpenGLMaterial.h 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


#pragma once

#include <viz++/opengl/OpenGLObject.h>

namespace VIZ {

class OpenGLMaterial :public OpenGLObject {
private:
  GLenum face;

public:
  OpenGLMaterial(GLenum face)
  :face(face)
  {
    //The parameter face will take CL_FRONT, CL_BACK, CL_FRONT_AND_BACK 
  }

  void ambient(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_AMBIENT , values); 
  }

  void ambient(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  {
    GLfloat values[] = {r, g, b, a};
    glMaterialfv(this -> face , GL_AMBIENT , values); 
  }

  void diffuse(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_DIFFUSE, values); 
  }

  void diffuse(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  {
    GLfloat values[] = {r, g, b, a};
    glMaterialfv(this -> face , GL_DIFFUSE, values); 
  }

  void specular(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_SPECULAR, values); 
  }

  void specular(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  {
    GLfloat values[] = {r, g, b, a};
    glMaterialfv(this -> face , GL_SPECULAR, values); 
  }

  void shininess(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_SHININESS, values); 
  }

  void shininess(GLfloat shine)
  {
    GLfloat values[] = {shine};
    glMaterialfv(this -> face , GL_SHININESS, values); 
  }

  void emission(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_EMISSION, values); 
  }

  void emission(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  {
    GLfloat values[] = {r, g, b, a};
    glMaterialfv(this -> face , GL_EMISSION, values); 
  }
  
  
  void ambientAndDiffuse(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_AMBIENT_AND_DIFFUSE, values); 
  }

  void colorIndexes(const GLfloat* values)
  {
    assert(values);
    glMaterialfv(this -> face , GL_COLOR_INDEXES, values); 
  }

  void colorIndexes(GLfloat r, GLfloat g, GLfloat b)
  {
    GLfloat values[] = {r, g, b}; 
    glMaterialfv(this -> face , GL_COLOR_INDEXES, values); 
  }

};

}

  

Last modified: 10 Feb 2017

Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.