NGL
6.5
The NCCA Graphics Library
|
Simple class to encapsulate OpenGL Light functions this will fill in the following structure. More...
#include <Light.h>
Public Member Functions | |
void | setPosition (const Vec3 &_p) noexcept |
set the light position More... | |
void | setColour (const Colour &_c) noexcept |
set the light colour More... | |
void | setSpecColour (const Colour &_c) noexcept |
set the specular colour More... | |
Light () noexcept | |
default constructor this set nothing so the light will not illuminate More... | |
Light (const Light &_l) noexcept | |
copy ctor this set nothing so the light will not illuminate More... | |
Light (const Vec3 &_pos, const Colour &_col, LightModes _lightmode) noexcept | |
ctor to create the light More... | |
Light (const Vec3 &_pos, const Colour &_col, const Colour &_specColour, LightModes _lightmode) noexcept | |
ctor to create the light More... | |
virtual | ~Light () noexcept |
destructor when light is destroyed we turn it off More... | |
void | disable () noexcept |
Disable the light by calling glDisable(GL_LIGHT0+LightNo);. More... | |
virtual void | enable () noexcept |
Enables the light and automatically allocates an OpenGL light ID. More... | |
Vec4 | getPos () const noexcept |
returns the current light position as a Vector More... | |
Colour | getColour () const noexcept |
returns the current light colour More... | |
Colour | getSpecColour () const noexcept |
returns the current light Specular colour More... | |
void | setAttenuation (Real _constant=1.0, Real _linear=0.0, Real _quadratic=0.0) noexcept |
set the light attenuation More... | |
void | loadToShader (std::string _uniformName) const noexcept |
method to load the current light values to the shader that is active at present More... | |
void | setTransform (Mat4 &_t) noexcept |
set a transform so that the light position is multiplied by this value (default is identity matrix) More... | |
Protected Attributes | |
Vec4 | m_position |
m_pos is used to store the light position w used for point / dir light values More... | |
Colour | m_diffuse |
Colour used to give the light a colour. More... | |
Colour | m_specular |
specular highlight colour used for the lights More... | |
Colour | m_ambient |
ambient light colour used for the lights More... | |
LightModes | m_lightMode |
used to hold the current lights mode More... | |
Real | m_constantAtten |
attenuation value for constant falloff More... | |
Real | m_linearAtten |
attenuation value for linear falloff More... | |
Real | m_quadraticAtten |
attenuation value for Quadratic falloff More... | |
bool | m_active |
active if true else off More... | |
Real | m_cutoffAngle |
the spot cutoff angle for directional and point lights this is set to 180 by default, and other values are cos(radians(angle)) More... | |
Mat4 | m_transform |
the transform applied to the light before loading to the shader this is usually the inverse projection matrix for normal OpenGL style eye-cord calculations but is left for the Application to calculate and pass for easier implementation of different light models More... | |
Simple class to encapsulate OpenGL Light functions this will fill in the following structure.
struct Lights { vec4 position; vec4 ambient; vec4 diffuse; vec4 specular; };
|
inlinenoexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
inlinevirtualnoexcept |
|
noexcept |
|
virtualnoexcept |
Enables the light and automatically allocates an OpenGL light ID.
Reimplemented in ngl::SpotLight.
Definition at line 84 of file Light.cpp.
References m_active.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
noexcept |
method to load the current light values to the shader that is active at present
[in] | _uniformName | name of the uniform to set |
Definition at line 105 of file Light.cpp.
References ngl::Singleton< ShaderLib >::instance(), ngl::Colour::m_a, m_active, m_ambient, ngl::Colour::m_b, m_constantAtten, m_cutoffAngle, m_diffuse, ngl::Colour::m_g, m_lightMode, m_linearAtten, m_position, m_quadraticAtten, ngl::Colour::m_r, m_specular, m_transform, ngl::Vec4::m_x, ngl::Vec4::m_y, ngl::Vec4::m_z, ngl::ShaderLib::setShaderParam1f(), and ngl::ShaderLib::setShaderParam4f().
|
noexcept |
set the light attenuation
[in] | _constant | the constant attenuation |
[in] | _linear | attenuation |
[in] | _quadratic | attenuation |
Definition at line 96 of file Light.cpp.
References m_constantAtten, m_linearAtten, and m_quadraticAtten.
set a transform so that the light position is multiplied by this value (default is identity matrix)
[in] | _t | the transform matrix |
Definition at line 141 of file Light.cpp.
References m_transform.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
the transform applied to the light before loading to the shader this is usually the inverse projection matrix for normal OpenGL style eye-cord calculations but is left for the Application to calculate and pass for easier implementation of different light models