GLC_Light Class Reference

GLC_Light : OpenGL Point Light. More...

#include <glc_light.h>

Inheritance diagram for GLC_Light:
GLC_Object

List of all members.

Public Types

enum  LightType { LightPosition = 0, LightDirection = 1, LightSpot = 2 }
 

Light Type enum.

More...

Public Member Functions

Constructor / Destructor

 GLC_Light (const QGLContext *pContext=NULL, const QColor &color=Qt::white)
 Construct a default GLC_Light.
 GLC_Light (LightType lightType, const QGLContext *pContext=NULL, const QColor &color=Qt::white)
 Construct a default GLC_Light.
 GLC_Light (const GLC_Light &light)
 Copy constructor.
virtual ~GLC_Light (void)
 Delete OpenGL list.
Set Functions

void initForThisContext ()
 Init Max number of light for this light context.
void setPosition (const GLC_Point3d &pos)
 Set lihgt's position by a point.
void setPosition (GLfloat x, GLfloat y, GLfloat z)
 Set lihgt's position by a 3 GLfloat.
void setAmbientColor (const QColor &color)
 Set light's ambiant color by a QColor.
void setDiffuseColor (const QColor &color)
 Set light's diffuse color by a QColor.
void setSpecularColor (const QColor &color)
 Set light's specular color by a QColor.
void setTwoSided (const bool mode)
 Set Mode.
void setConstantAttenuation (GLfloat constantAttenuation)
 Set this light constant attenuation.
void setLinearAttenuation (GLfloat linearAttenuation)
 Set this light linear attenuation.
void setQuadraticAttenuation (GLfloat quadraticAttenuation)
 Set this light quadratic attenuation.
void setSpotDirection (const GLC_Vector3d &direction)
 Set this light spot direction.
void setSpotCutoffAngle (GLfloat cutoffAngle)
 Set this light spot cutoff angle.
void setSpotEponent (GLfloat exponent)
 Set this light spot exponent.
OpenGL Functions

void disable ()
virtual void glExecute ()
 Execute OpenGL light.

Private Member Functions

void addNewLight ()
 Add context new light.
void removeThisLight ()
 Remove contetx light.

Private Attributes

GLenum m_LightID
 OpenGL light ID.
LightType m_LightType
 The Light type.
QColor m_AmbientColor
 Light ambiant color.
QColor m_DiffuseColor
 Light diffuse color.
QColor m_SpecularColor
 Light specular color.
GLC_Point3d m_Position
 Light position.
GLC_Vector3d m_SpotDirection
 The spot light direction.
GLfloat m_SpotExponent
 The spot exponent.
GLfloat m_SpotCutoffAngle
 The spot cutoff angle.
GLfloat m_ConstantAttenuation
 Constant attenation.
GLfloat m_LinearAttenuation
 Linear attenuation.
GLfloat m_QuadraticAttenuation
 Quadratic attenuation.
bool m_TwoSided
 Lighting mode.
QGLContext * m_pContext
 The context of this light.
bool m_IsValid
 Flag to know if this light is valid.

Static Private Attributes

static GLint m_MaxLight = 8
 Maximum number of light.
static QHash< const QGLContext
*, QSet< GLenum > > 
m_ContextToFreeLightSet
 Mapping between context and light set.

Get Functions



GLC_Point3d position (void) const
 Return a GLC_Point3d representing light position.
QColor ambientColor () const
 Return the QColor of the light's ambient color.
QColor diffuseColor () const
 Return the QColor of the light's Diffuse color.
QColor specularColor () const
 Return the QColor of the light's Specular color.
bool isTwoSided () const
 Return true if the light used two sided ilumination.
LightType type () const
 Return the type of this light.
GLenum openglID () const
 Return the OpenGL ID of this light.
GLfloat constantAttenuation () const
 Return this light const attenuation.
GLfloat linearAttenuation () const
 Return this light linear attenuation.
GLfloat quadraticAttenuation () const
 Return this light quadratic attenuation.
GLC_Vector3d spotDirection () const
 Return this light spot direction.
GLfloat spotCutoffAngle () const
 Return this light spot cutoff angle.
GLfloat spotEponent () const
 Return this light spot exponent.
static int maxLightCount ()
 Return the maximum number light.
static int builtAbleLightCount (QGLContext *pContext)
 Return the number of builtable light.

Detailed Description

GLC_Light : OpenGL Point Light.

An GLC_Light is an OpenGL point Light source at a 3D location
Point light is omnidirectional and have color

Definition at line 47 of file glc_light.h.


Member Enumeration Documentation

Light Type enum.

Enumerator:
LightPosition 
LightDirection 
LightSpot 

Definition at line 51 of file glc_light.h.


Constructor & Destructor Documentation

GLC_Light::GLC_Light ( const QGLContext *  pContext = NULL,
const QColor &  color = Qt::white 
)

Construct a default GLC_Light.

By default, ambient color is black, diffuse Color is white and specular color is white

Definition at line 38 of file glc_light.cpp.

References addNewLight().

GLC_Light::GLC_Light ( LightType  lightType,
const QGLContext *  pContext = NULL,
const QColor &  color = Qt::white 
)

Construct a default GLC_Light.

By default, ambient color is black, diffuse Color is white and specular color is white

Definition at line 59 of file glc_light.cpp.

References addNewLight().

GLC_Light::GLC_Light ( const GLC_Light light  ) 

Copy constructor.

Definition at line 80 of file glc_light.cpp.

References addNewLight().

GLC_Light::~GLC_Light ( void   )  [virtual]

Delete OpenGL list.

Definition at line 101 of file glc_light.cpp.

References removeThisLight().


Member Function Documentation

void GLC_Light::addNewLight (  )  [private]

Add context new light.

Definition at line 328 of file glc_light.cpp.

References initForThisContext(), m_ContextToFreeLightSet, m_LightID, m_MaxLight, and m_pContext.

Referenced by GLC_Light(), and glExecute().

QColor GLC_Light::ambientColor (  )  const [inline]

Return the QColor of the light's ambient color.

Definition at line 93 of file glc_light.h.

int GLC_Light::builtAbleLightCount ( QGLContext *  pContext  )  [static]

Return the number of builtable light.

Definition at line 115 of file glc_light.cpp.

References m_ContextToFreeLightSet, and m_MaxLight.

GLfloat GLC_Light::constantAttenuation (  )  const [inline]

Return this light const attenuation.

Definition at line 117 of file glc_light.h.

QColor GLC_Light::diffuseColor (  )  const [inline]

Return the QColor of the light's Diffuse color.

Definition at line 97 of file glc_light.h.

void GLC_Light::disable (  ) 

Definition at line 210 of file glc_light.cpp.

References m_LightID, and m_pContext.

void GLC_Light::glExecute (  )  [virtual]
void GLC_Light::initForThisContext (  ) 

Init Max number of light for this light context.

Definition at line 127 of file glc_light.cpp.

References m_ContextToFreeLightSet, m_MaxLight, and m_pContext.

Referenced by addNewLight().

bool GLC_Light::isTwoSided (  )  const [inline]

Return true if the light used two sided ilumination.

Definition at line 105 of file glc_light.h.

GLfloat GLC_Light::linearAttenuation (  )  const [inline]

Return this light linear attenuation.

Definition at line 121 of file glc_light.h.

int GLC_Light::maxLightCount (  )  [static]

Return the maximum number light.

Definition at line 110 of file glc_light.cpp.

References m_MaxLight.

Referenced by GLC_Shader::createAndCompileProgrammShader(), and GLC_Shader::initLightsUniformId().

GLenum GLC_Light::openglID (  )  const [inline]

Return the OpenGL ID of this light.

Definition at line 113 of file glc_light.h.

GLC_Point3d GLC_Light::position ( void   )  const [inline]

Return a GLC_Point3d representing light position.

Definition at line 89 of file glc_light.h.

GLfloat GLC_Light::quadraticAttenuation (  )  const [inline]

Return this light quadratic attenuation.

Definition at line 125 of file glc_light.h.

void GLC_Light::removeThisLight (  )  [private]

Remove contetx light.

Definition at line 352 of file glc_light.cpp.

References m_ContextToFreeLightSet, m_LightID, m_MaxLight, and m_pContext.

Referenced by ~GLC_Light().

void GLC_Light::setAmbientColor ( const QColor &  color  ) 

Set light's ambiant color by a QColor.

Definition at line 145 of file glc_light.cpp.

References m_AmbientColor, and m_IsValid.

void GLC_Light::setConstantAttenuation ( GLfloat  constantAttenuation  ) 

Set this light constant attenuation.

Definition at line 169 of file glc_light.cpp.

References m_ConstantAttenuation, and m_IsValid.

void GLC_Light::setDiffuseColor ( const QColor &  color  ) 

Set light's diffuse color by a QColor.

Definition at line 151 of file glc_light.cpp.

References m_DiffuseColor, and m_IsValid.

void GLC_Light::setLinearAttenuation ( GLfloat  linearAttenuation  ) 

Set this light linear attenuation.

Definition at line 175 of file glc_light.cpp.

References m_IsValid, and m_LinearAttenuation.

void GLC_Light::setPosition ( GLfloat  x,
GLfloat  y,
GLfloat  z 
)

Set lihgt's position by a 3 GLfloat.

Definition at line 140 of file glc_light.cpp.

References m_Position, and GLC_Vector3d::setVect().

void GLC_Light::setPosition ( const GLC_Point3d pos  ) 

Set lihgt's position by a point.

Definition at line 135 of file glc_light.cpp.

References m_Position.

void GLC_Light::setQuadraticAttenuation ( GLfloat  quadraticAttenuation  ) 

Set this light quadratic attenuation.

Definition at line 181 of file glc_light.cpp.

References m_IsValid, and m_QuadraticAttenuation.

void GLC_Light::setSpecularColor ( const QColor &  color  ) 

Set light's specular color by a QColor.

Definition at line 157 of file glc_light.cpp.

References m_IsValid, and m_SpecularColor.

void GLC_Light::setSpotCutoffAngle ( GLfloat  cutoffAngle  ) 

Set this light spot cutoff angle.

Definition at line 193 of file glc_light.cpp.

References m_IsValid, and m_SpotCutoffAngle.

void GLC_Light::setSpotDirection ( const GLC_Vector3d direction  ) 

Set this light spot direction.

Definition at line 187 of file glc_light.cpp.

References m_IsValid, and m_SpotDirection.

void GLC_Light::setSpotEponent ( GLfloat  exponent  ) 

Set this light spot exponent.

Definition at line 199 of file glc_light.cpp.

References m_IsValid, and m_SpotExponent.

void GLC_Light::setTwoSided ( const bool  mode  ) 

Set Mode.

Definition at line 163 of file glc_light.cpp.

References m_IsValid, and m_TwoSided.

QColor GLC_Light::specularColor (  )  const [inline]

Return the QColor of the light's Specular color.

Definition at line 101 of file glc_light.h.

GLfloat GLC_Light::spotCutoffAngle (  )  const [inline]

Return this light spot cutoff angle.

Definition at line 133 of file glc_light.h.

GLC_Vector3d GLC_Light::spotDirection (  )  const [inline]

Return this light spot direction.

Definition at line 129 of file glc_light.h.

GLfloat GLC_Light::spotEponent (  )  const [inline]

Return this light spot exponent.

Definition at line 137 of file glc_light.h.

LightType GLC_Light::type (  )  const [inline]

Return the type of this light.

Definition at line 109 of file glc_light.h.


Member Data Documentation

QColor GLC_Light::m_AmbientColor [private]

Light ambiant color.

Definition at line 231 of file glc_light.h.

Referenced by glExecute(), and setAmbientColor().

Constant attenation.

Definition at line 250 of file glc_light.h.

Referenced by glExecute(), and setConstantAttenuation().

QHash< const QGLContext *, QSet< GLenum > > GLC_Light::m_ContextToFreeLightSet [static, private]

Mapping between context and light set.

Definition at line 272 of file glc_light.h.

Referenced by addNewLight(), builtAbleLightCount(), initForThisContext(), and removeThisLight().

QColor GLC_Light::m_DiffuseColor [private]

Light diffuse color.

Definition at line 233 of file glc_light.h.

Referenced by glExecute(), and setDiffuseColor().

bool GLC_Light::m_IsValid [private]
GLenum GLC_Light::m_LightID [private]

OpenGL light ID.

Definition at line 225 of file glc_light.h.

Referenced by addNewLight(), disable(), glExecute(), and removeThisLight().

The Light type.

Definition at line 228 of file glc_light.h.

Referenced by glExecute().

GLfloat GLC_Light::m_LinearAttenuation [private]

Linear attenuation.

Definition at line 253 of file glc_light.h.

Referenced by glExecute(), and setLinearAttenuation().

GLint GLC_Light::m_MaxLight = 8 [static, private]

Maximum number of light.

Definition at line 263 of file glc_light.h.

Referenced by addNewLight(), builtAbleLightCount(), initForThisContext(), maxLightCount(), and removeThisLight().

QGLContext* GLC_Light::m_pContext [private]

The context of this light.

Definition at line 266 of file glc_light.h.

Referenced by addNewLight(), disable(), glExecute(), initForThisContext(), and removeThisLight().

Light position.

Definition at line 238 of file glc_light.h.

Referenced by glExecute(), and setPosition().

Quadratic attenuation.

Definition at line 256 of file glc_light.h.

Referenced by glExecute(), and setQuadraticAttenuation().

QColor GLC_Light::m_SpecularColor [private]

Light specular color.

Definition at line 235 of file glc_light.h.

Referenced by glExecute(), and setSpecularColor().

GLfloat GLC_Light::m_SpotCutoffAngle [private]

The spot cutoff angle.

Definition at line 247 of file glc_light.h.

Referenced by glExecute(), and setSpotCutoffAngle().

The spot light direction.

Definition at line 241 of file glc_light.h.

Referenced by glExecute(), and setSpotDirection().

GLfloat GLC_Light::m_SpotExponent [private]

The spot exponent.

Definition at line 244 of file glc_light.h.

Referenced by glExecute(), and setSpotEponent().

bool GLC_Light::m_TwoSided [private]

Lighting mode.

Definition at line 259 of file glc_light.h.

Referenced by glExecute(), and setTwoSided().


The documentation for this class was generated from the following files:

SourceForge.net Logo

©2005-2011 Laurent Ribon