GLC_Light : OpenGL Point Light. More...
#include <glc_light.h>
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. | |
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. | |
| GLuint | m_ListID |
| OpenGL Display list ID. | |
| bool | m_ListIsValid |
| OpenGL list validity. | |
| 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. | |
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. | |
OpenGL Functions | |
|
| |
| void | enable () |
| Enable the light. | |
| void | disable () |
| virtual void | glExecute (GLenum Mode=GL_COMPILE_AND_EXECUTE) |
| Execute OpenGL light. | |
| void | glDraw () |
| OpenGL light set up. | |
| void | creationList (GLenum Mode) |
| Display List creation. | |
| void | deleteList () |
| Delete OpenGL Display list. | |
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.
| enum GLC_Light::LightType |
Light Type enum.
Definition at line 51 of file glc_light.h.
| 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 37 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 | ) |
| GLC_Light::~GLC_Light | ( | void | ) | [virtual] |
Delete OpenGL list.
Definition at line 103 of file glc_light.cpp.
References deleteList(), and removeThisLight().
| void GLC_Light::addNewLight | ( | ) | [private] |
Add context new light.
Definition at line 396 of file glc_light.cpp.
References initForThisContext(), m_ContextToFreeLightSet, m_LightID, and m_pContext.
Referenced by enable(), and GLC_Light().
| 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 118 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.
| void GLC_Light::creationList | ( | GLenum | Mode | ) | [private] |
Display List creation.
Definition at line 217 of file glc_light.cpp.
References glDraw(), m_ListID, and m_ListIsValid.
Referenced by glExecute().
| void GLC_Light::deleteList | ( | void | ) | [private] |
Delete OpenGL Display list.
Definition at line 383 of file glc_light.cpp.
References disable(), and m_ListID.
Referenced by ~GLC_Light().
| 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 262 of file glc_light.cpp.
References m_LightID, and m_pContext.
Referenced by deleteList().
| void GLC_Light::enable | ( | ) |
Enable the light.
Definition at line 250 of file glc_light.cpp.
References addNewLight(), m_LightID, and m_pContext.
| void GLC_Light::glDraw | ( | void | ) | [private] |
OpenGL light set up.
Definition at line 302 of file glc_light.cpp.
References LightDirection, LightSpot, m_AmbientColor, m_ConstantAttenuation, m_DiffuseColor, m_LightID, m_LightType, m_LinearAttenuation, m_Position, m_QuadraticAttenuation, m_SpecularColor, m_SpotCutoffAngle, m_SpotDirection, m_SpotExponent, m_TwoSided, GLC_Vector3d::x(), GLC_Vector3d::y(), and GLC_Vector3d::z().
Referenced by creationList().
| void GLC_Light::glExecute | ( | GLenum | Mode = GL_COMPILE_AND_EXECUTE |
) | [virtual] |
Execute OpenGL light.
Definition at line 271 of file glc_light.cpp.
References creationList(), m_ListID, and m_ListIsValid.
| void GLC_Light::initForThisContext | ( | ) |
Init Max number of light for this light context.
Definition at line 130 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 113 of file glc_light.cpp.
References m_MaxLight.
| 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 410 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 150 of file glc_light.cpp.
References m_AmbientColor, and m_ListIsValid.
| void GLC_Light::setConstantAttenuation | ( | GLfloat | constantAttenuation | ) |
Set this light constant attenuation.
Definition at line 177 of file glc_light.cpp.
References m_ConstantAttenuation, and m_ListIsValid.
| void GLC_Light::setDiffuseColor | ( | const QColor & | color | ) |
Set light's diffuse color by a QColor.
Definition at line 156 of file glc_light.cpp.
References m_DiffuseColor, and m_ListIsValid.
| void GLC_Light::setLinearAttenuation | ( | GLfloat | linearAttenuation | ) |
Set this light linear attenuation.
Definition at line 183 of file glc_light.cpp.
References m_LinearAttenuation, and m_ListIsValid.
| void GLC_Light::setPosition | ( | GLfloat | x, | |
| GLfloat | y, | |||
| GLfloat | z | |||
| ) |
Set lihgt's position by a 3 GLfloat.
Definition at line 144 of file glc_light.cpp.
References m_ListIsValid, m_Position, and GLC_Vector3d::setVect().
| void GLC_Light::setPosition | ( | const GLC_Point3d & | pos | ) |
Set lihgt's position by a point.
Definition at line 138 of file glc_light.cpp.
References m_ListIsValid, and m_Position.
| void GLC_Light::setQuadraticAttenuation | ( | GLfloat | quadraticAttenuation | ) |
Set this light quadratic attenuation.
Definition at line 189 of file glc_light.cpp.
References m_ListIsValid, and m_QuadraticAttenuation.
| void GLC_Light::setSpecularColor | ( | const QColor & | color | ) |
Set light's specular color by a QColor.
Definition at line 162 of file glc_light.cpp.
References m_ListIsValid, and m_SpecularColor.
| void GLC_Light::setSpotCutoffAngle | ( | GLfloat | cutoffAngle | ) |
Set this light spot cutoff angle.
Definition at line 201 of file glc_light.cpp.
References m_ListIsValid, and m_SpotCutoffAngle.
| void GLC_Light::setSpotDirection | ( | const GLC_Vector3d & | direction | ) |
Set this light spot direction.
Definition at line 195 of file glc_light.cpp.
References m_ListIsValid, and m_SpotDirection.
| void GLC_Light::setSpotEponent | ( | GLfloat | exponent | ) |
Set this light spot exponent.
Definition at line 207 of file glc_light.cpp.
References m_ListIsValid, and m_SpotExponent.
| void GLC_Light::setTwoSided | ( | const bool | mode | ) |
| 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.
QColor GLC_Light::m_AmbientColor [private] |
Light ambiant color.
Definition at line 246 of file glc_light.h.
Referenced by glDraw(), and setAmbientColor().
GLfloat GLC_Light::m_ConstantAttenuation [private] |
Constant attenation.
Definition at line 265 of file glc_light.h.
Referenced by glDraw(), and setConstantAttenuation().
QHash< const QGLContext *, QSet< GLenum > > GLC_Light::m_ContextToFreeLightSet [static, private] |
Mapping between context and light set.
Definition at line 284 of file glc_light.h.
Referenced by addNewLight(), builtAbleLightCount(), initForThisContext(), and removeThisLight().
QColor GLC_Light::m_DiffuseColor [private] |
Light diffuse color.
Definition at line 248 of file glc_light.h.
Referenced by glDraw(), and setDiffuseColor().
GLenum GLC_Light::m_LightID [private] |
OpenGL light ID.
Definition at line 234 of file glc_light.h.
Referenced by addNewLight(), disable(), enable(), glDraw(), and removeThisLight().
LightType GLC_Light::m_LightType [private] |
GLfloat GLC_Light::m_LinearAttenuation [private] |
Linear attenuation.
Definition at line 268 of file glc_light.h.
Referenced by glDraw(), and setLinearAttenuation().
GLuint GLC_Light::m_ListID [private] |
OpenGL Display list ID.
Definition at line 240 of file glc_light.h.
Referenced by creationList(), deleteList(), and glExecute().
bool GLC_Light::m_ListIsValid [private] |
OpenGL list validity.
Definition at line 243 of file glc_light.h.
Referenced by creationList(), glExecute(), setAmbientColor(), setConstantAttenuation(), setDiffuseColor(), setLinearAttenuation(), setPosition(), setQuadraticAttenuation(), setSpecularColor(), setSpotCutoffAngle(), setSpotDirection(), setSpotEponent(), and setTwoSided().
GLint GLC_Light::m_MaxLight = 8 [static, private] |
Maximum number of light.
Definition at line 278 of file glc_light.h.
Referenced by builtAbleLightCount(), initForThisContext(), maxLightCount(), and removeThisLight().
QGLContext* GLC_Light::m_pContext [private] |
The context of this light.
Definition at line 281 of file glc_light.h.
Referenced by addNewLight(), disable(), enable(), initForThisContext(), and removeThisLight().
GLC_Point3d GLC_Light::m_Position [private] |
Light position.
Definition at line 253 of file glc_light.h.
Referenced by glDraw(), and setPosition().
GLfloat GLC_Light::m_QuadraticAttenuation [private] |
Quadratic attenuation.
Definition at line 271 of file glc_light.h.
Referenced by glDraw(), and setQuadraticAttenuation().
QColor GLC_Light::m_SpecularColor [private] |
Light specular color.
Definition at line 250 of file glc_light.h.
Referenced by glDraw(), and setSpecularColor().
GLfloat GLC_Light::m_SpotCutoffAngle [private] |
The spot cutoff angle.
Definition at line 262 of file glc_light.h.
Referenced by glDraw(), and setSpotCutoffAngle().
GLC_Vector3d GLC_Light::m_SpotDirection [private] |
The spot light direction.
Definition at line 256 of file glc_light.h.
Referenced by glDraw(), and setSpotDirection().
GLfloat GLC_Light::m_SpotExponent [private] |
The spot exponent.
Definition at line 259 of file glc_light.h.
Referenced by glDraw(), and setSpotEponent().
bool GLC_Light::m_TwoSided [private] |
Lighting mode.
Definition at line 274 of file glc_light.h.
Referenced by glDraw(), and setTwoSided().