DeferredRenderer 1.0
|
Deferred PointLight class using simple geometry to send to the GPU for per-pixel lighting. More...
#include <PointLight.h>
Public Member Functions | |
PointLight () | |
ctor | |
PointLight (const ngl::Vector &_centre, const float &_radius, const ngl::Vector &_intensity) | |
ctor taking the radius, centre and intensity colour of light | |
~PointLight () | |
dtor | |
void | draw (unsigned int &_vao, const std::string &_shaderName) |
method for drawing the pointlight | |
bool | collidesWithSphere (const ngl::Vector &_pos, const float &_radius) |
check for collision with sphere | |
Public Attributes | |
ngl::Vector | m_pos |
the light position, public for easier access | |
Private Attributes | |
float | m_radius |
the light radius | |
ngl::Vector | m_intensity |
the light colour intensity |
Deferred PointLight class using simple geometry to send to the GPU for per-pixel lighting.
Definition at line 13 of file PointLight.h.
PointLight::PointLight | ( | ) |
PointLight::PointLight | ( | const ngl::Vector & | _centre, |
const float & | _radius, | ||
const ngl::Vector & | _intensity | ||
) |
ctor taking the radius, centre and intensity colour of light
[in] | _centre | the world space position of light |
[in] | _radius | the extent of lights influence |
[in] | _intensity | the colour value of the light |
Definition at line 9 of file PointLight.cpp.
References m_intensity, m_pos, and m_radius.
{ m_pos.set(_centre.m_x,_centre.m_y,_centre.m_z); m_radius = _radius; m_intensity = _intensity; }
PointLight::~PointLight | ( | ) |
bool PointLight::collidesWithSphere | ( | const ngl::Vector & | _pos, |
const float & | _radius | ||
) |
check for collision with sphere
[in] | _pos | sphere position |
[in] | _radius | sphere radius |
Definition at line 17 of file PointLight.cpp.
void PointLight::draw | ( | unsigned int & | _vao, |
const std::string & | _shaderName | ||
) |
method for drawing the pointlight
[in] | _vao | the vao id of pointlight geometry |
[in] | _shaderName | the name of the shader to draw with |
Definition at line 27 of file PointLight.cpp.
References m_intensity, m_pos, and m_radius.
{ ngl::ShaderManager *shader = ngl::ShaderManager::instance(); (*shader)[_shaderName]->use(); shader->setShaderParam3f(_shaderName, "u_RGBIntensity", m_intensity.m_x, m_intensity.m_y, m_intensity.m_z); shader->setShaderParam4f(_shaderName, "u_WSCentreRadius", m_pos.m_x, m_pos.m_y, m_pos.m_z, m_radius ); // now we bind back our vertex array object and draw glBindVertexArray(_vao); glDrawArrays(GL_QUADS, 0, 24); //go back to default just incase glEnableVertexAttribArray(0); glBindVertexArray(0); }
ngl::Vector PointLight::m_intensity [private] |
the light colour intensity
Definition at line 45 of file PointLight.h.
ngl::Vector PointLight::m_pos |
the light position, public for easier access
Definition at line 39 of file PointLight.h.
float PointLight::m_radius [private] |
the light radius
Definition at line 42 of file PointLight.h.