UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_light.h File Reference

Go to the source code of this file.

Data Structures

struct  light_s
 a light source More...
 
struct  sustain_s
 sustains are light flashes which slowly decay More...
 

Macros

#define MAX_STATIC_LIGHTS   1024
 

Typedefs

typedef struct light_s light_t
 
typedef struct sustain_s sustain_t
 sustains are light flashes which slowly decay More...
 

Functions

void R_AddLight (const vec3_t origin, float radius, const vec3_t color)
 Create light to be rendered in the current frame (will be removed before the next) More...
 
void R_AddSustainedLight (const vec3_t org, float radius, const vec3_t color, float sustain)
 
void R_UpdateSustainedLights (void)
 Updates state of sustained lights; should be called once per frame right before world rendering. More...
 
void R_EnableWorldLights (void)
 Set up lighting data for the GLSL world shader. More...
 
void R_EnableModelLights (const light_t **lights, int numLights, bool inShadow, bool enable)
 Enable or disable realtime dynamic lighting for models. More...
 
void R_DisableLights (void)
 
void R_AddStaticLight (const vec3_t origin, float radius, const vec3_t color)
 Add static light for model lighting (world already got them baked into lightmap) More...
 
void R_ClearStaticLights (void)
 Remove all static light data. More...
 
void R_UpdateLightList (struct entity_s *ent)
 

Macro Definition Documentation

#define MAX_STATIC_LIGHTS   1024

Definition at line 47 of file r_light.h.

Referenced by R_AddStaticLight().

Typedef Documentation

typedef struct light_s light_t
typedef struct sustain_s sustain_t

sustains are light flashes which slowly decay

Function Documentation

void R_AddLight ( const vec3_t  origin,
float  radius,
const vec3_t  color 
)

Create light to be rendered in the current frame (will be removed before the next)

Todo:
  • integrate the particle-based lights into the new dynamic light system
Note
Call before actual 3D rendering begins to avoid missing or partially rendered lights

Definition at line 36 of file r_light.cpp.

References light_s::color, Com_DPrintf(), DEBUG_RENDERER, rendererData_t::dynamicLights, i, MAX_GL_LIGHTS, rendererData_t::numDynamicLights, light_s::origin, light_s::radius, refdef, and VectorCopy.

Referenced by CL_ParticleRun2(), and R_UpdateSustainedLights().

void R_AddStaticLight ( const vec3_t  origin,
float  radius,
const vec3_t  color 
)

Add static light for model lighting (world already got them baked into lightmap)

Note
To be called from map loader only
See also
SP_light

Definition at line 261 of file r_light.cpp.

References light_s::color, Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, MAX_STATIC_LIGHTS, rendererData_t::numStaticLights, light_s::origin, light_s::radius, refdef, rendererData_t::staticLights, and VectorCopy.

Referenced by SP_light().

void R_AddSustainedLight ( const vec3_t  org,
float  radius,
const vec3_t  color,
float  sustain 
)
void R_ClearStaticLights ( void  )

Remove all static light data.

Note
To be called before loading a new map

Definition at line 300 of file r_light.cpp.

References rendererData_t::numStaticLights, and refdef.

Referenced by R_ModBeginLoading(), and R_SetDefaultState().

void R_DisableLights ( void  )

Definition at line 282 of file r_light.cpp.

References i, MAX_GL_LIGHTS, and MIN_GL_CONSTANT_ATTENUATION.

void R_EnableModelLights ( const light_t **  lights,
int  numLights,
bool  inShadow,
bool  enable 
)

Enable or disable realtime dynamic lighting for models.

Parameters
lightsThe lights to enable
numLightsThe amount of lights in the given lights list
inShadowWhether model is shadowed from the sun
enableWhether to turn realtime lighting on or off
Todo:
is it a good idea?
Todo:
assert?

Definition at line 149 of file r_light.cpp.

References light_s::color, defaultMaterial, rstate_s::dynamic_lighting_enabled, GLPositionTransform(), i, cvar_s::integer, rstate_s::lighting_enabled, MAX_GL_LIGHTS, rendererData_t::modelAmbientColor, light_s::origin, R_DisableAttribute(), r_dynamic_lights, R_EnableAttribute(), r_locals, R_ProgramParameter3fv(), R_ProgramParameter3fvs(), R_ProgramParameter4fvs(), r_programs, r_state, R_UseMaterial(), light_s::radius, refdef, rendererData_t::sunDiffuseColor, rendererData_t::sunVector, Vector4Set, VectorCopy, and rlocals_s::world_matrix.

Referenced by R_DrawAliasModel(), and R_DrawMaterialSurfaces().

void R_UpdateLightList ( struct entity_s ent)
void R_UpdateSustainedLights ( void  )

Updates state of sustained lights; should be called once per frame right before world rendering.

See also
R_RenderFrame
R_AddSustainedLight

Definition at line 83 of file r_light.cpp.

References light_s::color, i, sustain_s::light, MAX_GL_LIGHTS, light_s::origin, R_AddLight(), light_s::radius, refdef, sustain_s::sustain, sustain_s::time, rendererData_t::time, and VectorScale.

Referenced by R_RenderFrame().