50 color[0], color[1], color[2],
51 origin[0], origin[1], origin[2],
67 if (i == MAX_GL_LIGHTS)
89 for (i = 0, s = r_sustainArray; i <
MAX_GL_LIGHTS; i++, s++) {
132 for (;i < maxLights ;i++)
153 vec4_t blackColor = {0.0, 0.0, 0.0, 1.0};
154 const vec4_t whiteColor = {1.0, 1.0, 1.0, 1.0};
155 const vec4_t defaultLight0Position = {0.0, 0.0, 1.0, 0.0};
161 glEnable(GL_LIGHTING);
163 glEnable(GL_COLOR_MATERIAL);
164 #ifndef GL_VERSION_ES_CM_1_0
165 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
168 glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.0);
169 glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0);
170 glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0);
172 glLightfv(GL_LIGHT0, GL_SPECULAR, blackColor);
180 glLightfv(GL_LIGHT0, GL_DIFFUSE, blackColor);
187 glDisable(GL_LIGHTING);
188 glDisable(GL_COLOR_MATERIAL);
190 glLightfv(GL_LIGHT0, GL_POSITION, defaultLight0Position);
191 glLightfv(GL_LIGHT0, GL_AMBIENT, blackColor);
192 glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteColor);
193 glLightfv(GL_LIGHT0, GL_SPECULAR, whiteColor);
205 for (i = 0; i < maxLights; i++)
219 if (numLights > maxLights)
220 numLights = maxLights;
239 for (i = 0; i < numLights; i++) {
248 for (; i < maxLights; i++)
264 Com_Printf(
"Failed to add lightsource: MAX_STATIC_LIGHTS exceeded\n");
269 color[0], color[1], color[2],
270 origin[0], origin[1], origin[2],
277 light->
color[3] = 1.0;
284 vec4_t blackColor = {0.0, 0.0, 0.0, 1.0};
288 glLightfv(GL_LIGHT0 +
i, GL_DIFFUSE, blackColor);
289 glLightfv(GL_LIGHT0 +
i, GL_AMBIENT, blackColor);
290 glLightfv(GL_LIGHT0 +
i, GL_SPECULAR, blackColor);
291 glDisable(GL_LIGHT0 +
i);
293 glDisable(GL_LIGHTING);
361 if (i + 1 == maxLights) {
367 while (i < ltng->numLights) {
406 for (rootEnt = ent; rootEnt->tagent; rootEnt = ent->tagent)
409 ltng = ent->lighting = rootEnt->lighting;
425 pos = ent->transform.matrix + 12;
427 ent->eBox.getDiagonal(diametralVec);
460 if (distSqr > (diameter + light->
radius) * (diameter + light->
radius))
484 if (distSqr > (diameter + light->
radius) * (diameter + light->
radius))
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
void R_DisableAttribute(const char *name)
#define VectorCopy(src, dest)
#define CACHE_CLEAR_TRESHOLD
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb)
static sustain_t r_sustainArray[MAX_GL_LIGHTS]
light_t staticLights[MAX_STATIC_LIGHTS]
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) ...
void R_UpdateLightList(entity_t *ent)
Recalculate active lights list for the given entity; R_CalcTransform(ent) should be called before thi...
void R_DisableLights(void)
local graphics definitions
cvar_t * r_dynamic_lights
#define MIN_GL_CONSTANT_ATTENUATION
void GLPositionTransform(const float m[16], const vec3_t in, vec3_t out)
Transform position (xyz) vector by OpenGL rules.
const light_t * lights[MAX_ENTITY_LIGHTS]
void Com_Printf(const char *const fmt,...)
#define VectorScale(in, scale, out)
lighting structure which contains static and dynamic lighting info for entities
static void R_AddLightToEntity(const vec_t *pos, lighting_t *ltng, const light_t *light, const float distSqr)
Adds light to the entity's lights list, sorted by distance.
static light_t * lights[LIGHTMAP_MAX]
void R_ClearStaticLights(void)
Remove all static light data.
#define Vector4Set(v, r, g, b, a)
void R_ProgramParameter3fv(const char *name, GLfloat *value)
light_t dynamicLights[MAX_GL_LIGHTS]
material_t defaultMaterial
const light_t * cachedLights[MAX_ENTITY_LIGHTS]
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void R_AddSustainedLight(const vec3_t org, float radius, const vec3_t color, float sustain)
bool dynamic_lighting_enabled
void R_Trace(const Line &trLine, float size, int contentmask)
Moves the given mins/maxs volume through the world from start to end.
void R_ProgramParameter4fvs(const char *name, GLint size, GLfloat *value)
void R_UpdateSustainedLights(void)
Updates state of sustained lights; should be called once per frame right before world rendering...
void R_EnableAttribute(const char *name)
void R_UseMaterial(const material_t *material)
static lighting_t fakeLightingData
void R_ProgramParameter3fvs(const char *name, GLint size, GLfloat *value)
void R_EnableWorldLights(void)
Set up lighting data for the GLSL world shader.
sustains are light flashes which slowly decay
#define VectorDistSqr(a, b)
void R_EnableModelLights(const light_t **lights, int numLights, bool inShadow, bool enable)
Enable or disable realtime dynamic lighting for models.
#define MAX_STATIC_LIGHTS
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)