GL Studio C++ Runtime API
GlobalLightMgr Class Referencefinal

#include <global_light_mgr.h>

Public Types

typedef DynamicArray< GlsLightSource * > LightingState
 

Public Member Functions

void PushLightingState ()
 
void PopLightingState ()
 
void ReapplyLights ()
 
void SetLightingState (const LightingState &newState)
 
void SetLightingState (LightingState &&newState)
 
const LightingStateGetLightingState () const
 
void SetupLighting (GlsEyePoint *relativeToEyepoint=NULL)
 
void InitializeStateFromOpenGL ()
 
void RestoreOpenGLState ()
 
bool * GetActiveLightsMask ()
 
unsigned int GetActiveLightsBitMask ()
 
unsigned int GetNumActiveLights ()
 

Static Public Member Functions

static GlobalLightMgrInstance ()
 
static unsigned int GlMaxLights ()
 
static void EnableNormalize (bool enableNormalize)
 
static bool EnableNormalize ()
 

Protected Attributes

LightingState _currentOpenGLState
 The current OpenGL lighting state.
 
LightingState _currentState
 This will become the _currentOpenglState when a lit object draws.
 
DynamicArray< GlsLightSource * > _tempOpenGLLights
 Store temporary light source pointers (only used in InitializeStateFromOpenGL).
 
DynamicArray< LightingState_lightingStateStack
 As each component draws it will push it's lighting state on the stack.
 
bool _reapplyLights
 If true, the lighting state will be recalculated.
 
bool _enableNormalize
 If true, GL_NORMALIZE will be enabled during lighting.
 
bool * _activeLights
 An array storing the current on/off state for each light.
 

Static Protected Attributes

static unsigned int MAX_OPENGL_LIGHTS
 The value of glGetIntegerv(GL_MAX_LIGHTS);.
 

Friends

class GlobalLightMgrThreadMap
 

Detailed Description

This singleton class is responsible for keeping track of the GlsLightSource objects currently affecting the OpenGL lighting state and changing the state when needed.

Member Typedef Documentation

◆ LightingState

List of the currently active lights The number of the light is equal to it's array index. (i.e. The light at index 0 is GL_LIGHT0)

Member Function Documentation

◆ EnableNormalize() [1/2]

static bool EnableNormalize ( )
static

Get the state of whether GL_NORMALIZE is enabled

Returns
Whether or not GL_NORMALIZE is enabled

◆ EnableNormalize() [2/2]

static void EnableNormalize ( bool  enableNormalize)
static

Set whether or not GL_NORMALIZE is enabled

Parameters
enableNormalizeSet GL_NORMALIZE to true or false

◆ GetActiveLightsBitMask()

unsigned int GetActiveLightsBitMask ( )

Get a bitmask of the active lights

Returns
An unsigned integer with each bit representing a light turned on/off

◆ GetActiveLightsMask()

bool * GetActiveLightsMask ( )

Get a boolean mask of the active lights

Returns
A boolean array with a bitmask of the currently active lights

◆ GetLightingState()

const LightingState & GetLightingState ( ) const

Get the current lighting state

Returns
The current lighting state

◆ GetNumActiveLights()

unsigned int GetNumActiveLights ( )

Get the number of active lights. Really is the max index(+1) of lights that you need to cycle through to have taken all of them into account (in case of holes in the list created by an outside party).

Returns
An integer representing the (max) number of currently active lights

◆ GlMaxLights()

static unsigned int GlMaxLights ( )
inlinestatic
Returns
The value of GL_MAX_LIGHTS

◆ InitializeStateFromOpenGL()

void InitializeStateFromOpenGL ( )

Clear the lighting stack, create GlsLightSource objects based on the current OpenGL lighting state and store them as the current state.

◆ Instance()

static GlobalLightMgr & Instance ( )
static
Returns
The singleton to the one instance of GlobalLightMgr

◆ PopLightingState()

void PopLightingState ( )

Push the current lighting state off the stack

◆ PushLightingState()

void PushLightingState ( )

Push the current lighting state onto the stack

◆ ReapplyLights()

void ReapplyLights ( )
inline

Flags the need to reapply the lights. This may be necessary for special cases where the OpenGL matrices have changed during a traversel. This can happen when drawing multiple views of the same geometry.

◆ RestoreOpenGLState()

void RestoreOpenGLState ( )

Restore the OpenGL state to what it was at the last call to InitializeStateFromOpenGL()

◆ SetLightingState() [1/2]

void SetLightingState ( const LightingState newState)

Set the current lighting state to a new state

Parameters
newStateThe new lighting state

◆ SetLightingState() [2/2]

void SetLightingState ( LightingState &&  newState)
inline

Set the current lighting state to a new state

Parameters
newStateThe new lighting state

◆ SetupLighting()

void SetupLighting ( GlsEyePoint relativeToEyepoint = NULL)

Set OpenGL lighting state to match the current state. If relativeToEyepoint is set, the light will be applied using the modelview matrix calculated from the eyepoint to the light.

Parameters
relativeToEyepointOptional eyepoint used to calculate modelview matrix to apply with the light.

Friends And Related Function Documentation

◆ GlobalLightMgrThreadMap

friend class GlobalLightMgrThreadMap
friend

helper class for maintaining one global light mgr per calling thread


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