YAGE  1.0
Yet Another Game Engine
Light Class Reference

A light is a special class of Game Object that mostly just sends uniform data to the shaders. Lights are fundamental to the shading pipeline! Without a light, nothing will show up in the scene. More...

#include <Light.h>

Inheritance diagram for Light:
IGameObject AmbientLight DirectionalLight PointLight SpotLight

Classes

struct  LightUniformLocations
 Holds the various uniform location ID's of the Light. More...
 

Public Member Functions

 Light ()
 
 ~Light ()
 
virtual void Draw (GLuint) override
 Sets up the light uniform location id's from the program. Each subclass must then send their corresponding params to the shader. More...
 
virtual void DrawShadow (GLuint) override
 Sends shadow information. Each subclass must implement this functionality! More...
 
virtual void Update () override
 Updates the light. This currently does nothing! Draw() does update the light. More...
 
virtual void Destroy () override
 Destroys the light. This currently only turns off the enabled flag! More...
 
virtual void SetTexture (const std::string &, const TextureType &, const GLuint &) override
 Adds a texture to an object. More...
 
virtual const GLuint GetTexture (const std::string &) const override
 Gets a texture. More...
 
bool EnableShadows ()
 Enables shadow generation for this light. More...
 
bool DisableShadows ()
 Disables shadow generation for this light. More...
 
void SetAttenuation (float constant=0.0f, float linear=1.0f, float quadratic=0.0f)
 Sets the attenutation parameters. See this wiki article for more information about attenuation: https://developer.valvesoftware.com/wiki/Constant-Linear-Quadratic_Falloff. More...
 
- Public Member Functions inherited from IGameObject
virtual ~IGameObject ()
 Destructor that deletes the unique shader program and shadow program belonging to the object. More...
 
virtual void SetProgram (GLuint shaderName)
 Sets the main shader program corresponding to this object. More...
 
virtual void SetShadowProgram (GLuint shaderName)
 Sets the shadow pass shader program corresponding to this object. More...
 
virtual GLuint GetProgram ()
 Gets the object's main shader program. More...
 
virtual GLuint GetShadowProgram ()
 Gets the object's shadow program. More...
 

Public Attributes

glm::vec3 ambient
 light's contribution to ambient light. More...
 
glm::vec3 color
 The color/intensity of the light. More...
 
glm::vec3 position
 location of light if isLocal is true. For directional light, it is the direction More...
 
glm::vec3 halfVector
 ?? direction of headlights for directional light ?? More...
 
glm::vec3 coneDirection
 spotlight cone direction. More...
 
float spotCosCutoff
 how wide the spotlight is [0-1]. More...
 
float spotExponent
 control light fall-off in the spotlight. More...
 
float constantAttenuation
 constant light fall-out More...
 
float linearAttenuation
 linear light fall-off More...
 
float quadraticAttenuation
 quadratic light fall-out More...
 
bool isEnabled
 true if this object is enabled. More...
 

Protected Attributes

GLuint texture
 
unsigned int _id
 
bool castsShadow
 
int type
 
struct Light::LightUniformLocations ids
 
- Protected Attributes inherited from IGameObject
GLuint program = 0
 
GLuint shadowProgram = 0
 

Detailed Description

A light is a special class of Game Object that mostly just sends uniform data to the shaders. Lights are fundamental to the shading pipeline! Without a light, nothing will show up in the scene.

Constructor & Destructor Documentation

Light::Light ( )
Light::~Light ( )
inline

Member Function Documentation

void Light::Destroy ( )
overridevirtual

Destroys the light. This currently only turns off the enabled flag!

Implements IGameObject.

bool Light::DisableShadows ( )

Disables shadow generation for this light.

Returns
true if it succeeds, false if it fails.
void Light::Draw ( GLuint  program)
overridevirtual

Sets up the light uniform location id's from the program. Each subclass must then send their corresponding params to the shader.

Parameters
programThe shader program.

Implements IGameObject.

Reimplemented in SpotLight, PointLight, AmbientLight, and DirectionalLight.

void Light::DrawShadow ( GLuint  )
overridevirtual

Sends shadow information. Each subclass must implement this functionality!

Parameters
programThe shader program.

Implements IGameObject.

Reimplemented in DirectionalLight.

bool Light::EnableShadows ( )

Enables shadow generation for this light.

Returns
true if it succeeds, false if it fails.
const GLuint Light::GetTexture ( const std::string &  textureName) const
overridevirtual

Gets a texture.

Parameters
textureNameThe name of the texture.
Returns
The texture.

Implements IGameObject.

void Light::SetAttenuation ( float  constant = 0.0f,
float  linear = 1.0f,
float  quadratic = 0.0f 
)

Sets the attenutation parameters. See this wiki article for more information about attenuation: https://developer.valvesoftware.com/wiki/Constant-Linear-Quadratic_Falloff.

Author
Harry
Date
4/14/2016
Parameters
constantThe constant attenuation factor.
linearThe linear attenuation factor.
quadraticThe quadratic attenuation factor.
void Light::SetTexture ( const std::string &  textureName,
const TextureType textureType,
const GLuint &  texture 
)
overridevirtual

Adds a texture to an object.

Parameters
textureNameName of the texture.
textureTypeType of the texture.
textureThe texture id.

Implements IGameObject.

void Light::Update ( )
overridevirtual

Updates the light. This currently does nothing! Draw() does update the light.

Implements IGameObject.

Member Data Documentation

unsigned int Light::_id
protected
glm::vec3 Light::ambient

light's contribution to ambient light.

bool Light::castsShadow
protected
glm::vec3 Light::color

The color/intensity of the light.

glm::vec3 Light::coneDirection

spotlight cone direction.

float Light::constantAttenuation

constant light fall-out

glm::vec3 Light::halfVector

?? direction of headlights for directional light ??

struct Light::LightUniformLocations Light::ids
protected
bool Light::isEnabled

true if this object is enabled.

float Light::linearAttenuation

linear light fall-off

glm::vec3 Light::position

location of light if isLocal is true. For directional light, it is the direction

float Light::quadraticAttenuation

quadratic light fall-out

float Light::spotCosCutoff

how wide the spotlight is [0-1].

float Light::spotExponent

control light fall-off in the spotlight.

GLuint Light::texture
protected
int Light::type
protected