Source code
/*
* OpenGLLight.h
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
#pragma once
#include <viz++/opengl/OpenGLObject.h>
namespace VIZ {
class OpenGLLight :public OpenGLObject {
private:
GLenum light;
public:
OpenGLLight(GLenum light=GL_LIGHT0)
:light(light)
{
//The light parameter will take GL_LIGHT0 to GL_LIGHT7
glEnable(GL_LIGHTING);
glEnable(light);
}
void enable()
{
glEnable(light);
}
void ambient(const GLfloat* values)
{
assert(values);
glLightfv(light, GL_AMBIENT, values);
}
void ambient(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
GLfloat values[] = {r, g, b, a};
glLightfv(light, GL_AMBIENT, values);
}
void specular(const GLfloat* values)
{
assert(values);
glLightfv(this -> light,GL_SPECULAR, values);
}
void specular(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
GLfloat values[] = {r, g, b, a};
glLightfv(this -> light,GL_SPECULAR, values);
}
void diffuse(const GLfloat* values)
{
assert(values);
glLightfv(this -> light, GL_DIFFUSE, values);
}
void diffuse(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
GLfloat values[] = {r, g, b, a};
glLightfv(this -> light, GL_DIFFUSE, values);
}
void position(const GLfloat* values)
{
glLightfv(this -> light,GL_POSITION, values);
}
void position(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
GLfloat values[] = {x, y, z, w};
glLightfv(this -> light,GL_POSITION, values);
}
void spotDirection(const GLfloat* values)
{
assert(values);
glLightfv(this -> light , GL_SPOT_DIRECTION , values);
}
void spotDirection(GLfloat x, GLfloat y, GLfloat z)
{
GLfloat values[] = {x, y, z};
glLightfv(this -> light , GL_SPOT_DIRECTION , values);
}
void spotExponent(const GLfloat* values)
{
assert(values);
glLightfv(this -> light , GL_SPOT_EXPONENT , values);
}
void spotExponent(GLfloat v)
{
GLfloat values[] = {v};
glLightfv(this -> light , GL_SPOT_EXPONENT , values);
}
void spotCutoff(const GLfloat* value)
{
assert(value);
glLightfv(this -> light , GL_SPOT_CUTOFF, value);
}
void spotCutoff(GLfloat v)
{
GLfloat value[] = {v};
glLightfv(this -> light , GL_SPOT_CUTOFF, value);
}
void constantAttenuation(const GLfloat* value)
{
assert(value);
glLightfv(this -> light , GL_CONSTANT_ATTENUATION, value);
}
void constantAttenuation(GLfloat v)
{
GLfloat value[] = {v};
glLightfv(this -> light , GL_CONSTANT_ATTENUATION, value);
}
void linearAttenuation(const GLfloat* value)
{
assert(value);
glLightfv(this -> light , GL_LINEAR_ATTENUATION, value);
}
void linearAttenuation(GLfloat v)
{
GLfloat value[] = {v};
glLightfv(this -> light , GL_LINEAR_ATTENUATION, value);
}
void quadraticAttenuation(const GLfloat* value)
{
assert(value);
glLightfv(this -> light , GL_QUADRATIC_ATTENUATION, value);
}
void quadraticAttenuation(GLfloat v)
{
GLfloat value[] = {v};
glLightfv(this -> light , GL_QUADRATIC_ATTENUATION, value);
}
};
}
Last modified: 10 Feb 2017
Copyright (c) 2009-2017 Antillia.com ALL RIGHTS RESERVED.