FS2_Open
Open source remastering of the Freespace 2 engine
gropengllight.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifdef _WIN32
13 #define WIN32_LEAN_AND_MEAN
14 #include <windows.h>
15 #endif
16 
17 #include <algorithm>
18 
19 #include "cmdline/cmdline.h"
20 #include "globalincs/pstypes.h"
21 #include <globalincs/systemvars.h>
22 #include "graphics/2d.h"
24 #include "graphics/gropengllight.h"
25 #include "graphics/gropenglstate.h"
26 #include "lighting/lighting.h"
27 #include "render/3d.h"
28 
29 
30 
31 // Variables
33 bool lighting_is_enabled = true;
36 float GL_light_factor = 1.0f;
37 
38 extern float static_point_factor;
39 extern float static_light_factor;
40 extern float static_tube_factor;
41 extern double specular_exponent_value;
42 extern float Cmdline_ogl_spec;
43 
44 
46 
47 // OGL defaults
48 static const float GL_light_color[4] = { 0.8f, 0.8f, 0.8f, 1.0f };
49 static const float GL_light_spec[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
50 static const float GL_light_zero[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
51 static const float GL_light_emission[4] = { 0.09f, 0.09f, 0.09f, 1.0f };
52 static const float GL_light_true_zero[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
53 static float GL_light_ambient[4] = { 0.47f, 0.47f, 0.47f, 1.0f };
54 
55 void FSLight2GLLight(light *FSLight, opengl_light *GLLight)
56 {
57  GLLight->Ambient[0] = 0.0f;
58  GLLight->Ambient[1] = 0.0f;
59  GLLight->Ambient[2] = 0.0f;
60  GLLight->Ambient[3] = 1.0f;
61 
62  GLLight->Diffuse[0] = FSLight->r * FSLight->intensity;
63  GLLight->Diffuse[1] = FSLight->g * FSLight->intensity;
64  GLLight->Diffuse[2] = FSLight->b * FSLight->intensity;
65  GLLight->Diffuse[3] = 1.0f;
66 
67  GLLight->Specular[0] = FSLight->spec_r * FSLight->intensity;
68  GLLight->Specular[1] = FSLight->spec_g * FSLight->intensity;
69  GLLight->Specular[2] = FSLight->spec_b * FSLight->intensity;
70  GLLight->Specular[3] = 1.0f;
71 
72  GLLight->type = FSLight->type;
73 
74  // GL default values...
75  // spot direction
76  GLLight->SpotDir[0] = 0.0f;
77  GLLight->SpotDir[1] = 0.0f;
78  GLLight->SpotDir[2] = -1.0f;
79  // spot exponent
80  GLLight->SpotExp = Cmdline_ogl_spec * 0.5f;
81  // spot cutoff
82  GLLight->SpotCutOff = 180.0f; // special value, light in all directions
83  // defaults to disable attenuation
84  GLLight->ConstantAtten = 1.0f;
85  GLLight->LinearAtten = 0.0f;
86  GLLight->QuadraticAtten = 0.0f;
87  // position
88  GLLight->Position[0] = FSLight->vec.xyz.x;
89  GLLight->Position[1] = FSLight->vec.xyz.y;
90  GLLight->Position[2] = FSLight->vec.xyz.z; // flipped axis for FS2
91  GLLight->Position[3] = 1.0f;
92 
93 
94  switch (FSLight->type) {
95  case LT_POINT: {
96  // this crap still needs work...
97  GLLight->ConstantAtten = 1.0f;
98  GLLight->LinearAtten = (1.0f / MAX(FSLight->rada, FSLight->radb)) * 1.25f;
99 
100  GLLight->Specular[0] *= static_point_factor;
101  GLLight->Specular[1] *= static_point_factor;
102  GLLight->Specular[2] *= static_point_factor;
103 
104  break;
105  }
106 
107  case LT_TUBE: {
108  GLLight->ConstantAtten = 1.0f;
109  GLLight->LinearAtten = (1.0f / MAX(FSLight->rada, FSLight->radb)) * 1.25f;
110  GLLight->QuadraticAtten = (1.0f / MAX(FSLight->rada_squared, FSLight->radb_squared)) * 1.25f;
111 
112  GLLight->Specular[0] *= static_tube_factor;
113  GLLight->Specular[1] *= static_tube_factor;
114  GLLight->Specular[2] *= static_tube_factor;
115 
116  GLLight->Position[0] = FSLight->vec2.xyz.x; // Valathil: Use endpoint of tube as light position
117  GLLight->Position[1] = FSLight->vec2.xyz.y;
118  GLLight->Position[2] = FSLight->vec2.xyz.z;
119  GLLight->Position[3] = 1.0f;
120 
121  if ( is_minimum_GLSL_version() ) {
122  // Valathil: When using shaders pass the beam direction (not normalized IMPORTANT for calculation of tube)
123  vec3d a;
124  vm_vec_sub(&a, &FSLight->vec2, &FSLight->vec);
125  GLLight->SpotDir[0] = a.xyz.x;
126  GLLight->SpotDir[1] = a.xyz.y;
127  GLLight->SpotDir[2] = a.xyz.z;
128  GLLight->SpotCutOff = 90.0f; // Valathil: So shader dectects tube light
129  } else {
130  GLLight->SpotDir[0] = 1.0f; // Valathil: When not using shaders pass a fake spotdir
131  GLLight->SpotDir[1] = 0.0f;
132  GLLight->SpotDir[2] = 0.0f;
133  GLLight->SpotCutOff = 180.0f; // Valathil: Should be a point light not a spot; using tube only for the light sorting
134  }
135  break;
136  }
137 
138  case LT_DIRECTIONAL: {
139  GLLight->Position[0] = -FSLight->vec.xyz.x;
140  GLLight->Position[1] = -FSLight->vec.xyz.y;
141  GLLight->Position[2] = -FSLight->vec.xyz.z;
142  GLLight->Position[3] = 0.0f; // Directional lights in OpenGL have w set to 0
143 
144  GLLight->Specular[0] *= static_light_factor;
145  GLLight->Specular[1] *= static_light_factor;
146  GLLight->Specular[2] *= static_light_factor;
147 
148  break;
149  }
150 
151  case LT_CONE:
152  break;
153 
154  default:
155  Int3();
156  break;
157  }
158 }
159 
160 void opengl_set_light(int light_num, opengl_light *ltp)
161 {
162  Assert(light_num < GL_max_lights);
163 
164  GLfloat diffuse[4];
165  memcpy(diffuse, ltp->Diffuse, sizeof(GLfloat) * 4);
166 
167  if ( !is_minimum_GLSL_version() && (ltp->type == LT_DIRECTIONAL) && (GL_light_factor < 1.0f) ) {
168  // if we're not using shaders, manually adjust the diffuse light factor.
169  diffuse[0] *= GL_light_factor;
170  diffuse[1] *= GL_light_factor;
171  diffuse[2] *= GL_light_factor;
172  }
173 
174  glLightfv(GL_LIGHT0+light_num, GL_POSITION, ltp->Position);
175  glLightfv(GL_LIGHT0+light_num, GL_AMBIENT, ltp->Ambient);
176  glLightfv(GL_LIGHT0+light_num, GL_DIFFUSE, diffuse);
177  glLightfv(GL_LIGHT0+light_num, GL_SPECULAR, ltp->Specular);
178  glLightfv(GL_LIGHT0+light_num, GL_SPOT_DIRECTION, ltp->SpotDir);
179  //glLightf(GL_LIGHT0+light_num, GL_CONSTANT_ATTENUATION, ltp->ConstantAtten); Default is 1.0 and we only use 1.0 - Valathil
181  //glLightf(GL_LIGHT0+light_num, GL_QUADRATIC_ATTENUATION, ltp->QuadraticAtten); Default is 0.0 and we only use 0.0 - Valathil
182  glLightf(GL_LIGHT0+light_num, GL_SPOT_EXPONENT, ltp->SpotExp);
183  glLightf(GL_LIGHT0+light_num, GL_SPOT_CUTOFF, ltp->SpotCutOff);
184 }
185 
187 {
188  // directional lights always go first
189  if ( (la.type != LT_DIRECTIONAL) && (lb.type == LT_DIRECTIONAL) )
190  return false;
191  else if ( (la.type == LT_DIRECTIONAL) && (lb.type != LT_DIRECTIONAL) )
192  return true;
193 
194  // tube lights go next, they are generally large and intense
195  if ( (la.type != LT_TUBE) && (lb.type == LT_TUBE) )
196  return false;
197  else if ( (la.type == LT_TUBE) && (lb.type != LT_TUBE) )
198  return true;
199 
200  // everything else is sorted by linear atten (light size)
201  // NOTE: smaller atten is larger light radius!
202  if ( la.LinearAtten > lb.LinearAtten )
203  return false;
204  else if ( la.LinearAtten < lb.LinearAtten )
205  return true;
206 
207  // as one extra check, if we're still here, go with overall brightness of light
208 
209  float la_value = la.Diffuse[0] + la.Diffuse[1] + la.Diffuse[2];
210  float lb_value = lb.Diffuse[0] + lb.Diffuse[1] + lb.Diffuse[2];
211 
212  if ( la_value < lb_value )
213  return false;
214  else if ( la_value > lb_value )
215  return true;
216 
217  // the two are equal
218  return false;
219 }
220 
222 {
223  // sort the lights to try and get the most visible lights on the first pass
224  std::sort(opengl_lights, opengl_lights + Num_active_gl_lights, opengl_sort_active_lights);
225 }
226 
227 static GLdouble eyex, eyey, eyez;
228 static GLdouble vmatrix[16];
229 
230 static vec3d last_view_pos;
231 static matrix last_view_orient;
232 
233 static bool use_last_view = false;
234 
235 void opengl_change_active_lights(int pos, int d_offset)
236 {
237  int i, offset;
238 
239  if ( !lighting_is_enabled ) {
240  return;
241  }
242 
243  Assert( d_offset < GL_max_lights );
244 
245  offset = (pos * GL_max_lights) + d_offset;
246 
247  glPushMatrix();
248 
249  if ( !memcmp(&Eye_position, &last_view_pos, sizeof(vec3d)) && !memcmp(&Eye_matrix, &last_view_orient, sizeof(matrix)) ) {
250  use_last_view = true;
251  } else {
252  memcpy(&last_view_pos, &Eye_position, sizeof(vec3d));
253  memcpy(&last_view_orient, &Eye_matrix, sizeof(matrix));
254 
255  use_last_view = false;
256  }
257 
258  if ( !use_last_view ) {
259  // should already be normalized
260  eyex = (GLdouble)Eye_position.xyz.x;
261  eyey = (GLdouble)Eye_position.xyz.y;
262  eyez = -(GLdouble)Eye_position.xyz.z;
263 
264  // should already be normalized
265  GLdouble fwdx = (GLdouble)Eye_matrix.vec.fvec.xyz.x;
266  GLdouble fwdy = (GLdouble)Eye_matrix.vec.fvec.xyz.y;
267  GLdouble fwdz = -(GLdouble)Eye_matrix.vec.fvec.xyz.z;
268 
269  // should already be normalized
270  GLdouble upx = (GLdouble)Eye_matrix.vec.uvec.xyz.x;
271  GLdouble upy = (GLdouble)Eye_matrix.vec.uvec.xyz.y;
272  GLdouble upz = -(GLdouble)Eye_matrix.vec.uvec.xyz.z;
273 
274  GLdouble mag;
275 
276  // setup Side vector (crossprod of forward and up vectors)
277  GLdouble Sx = (fwdy * upz) - (fwdz * upy);
278  GLdouble Sy = (fwdz * upx) - (fwdx * upz);
279  GLdouble Sz = (fwdx * upy) - (fwdy * upx);
280 
281  // normalize Side
282  mag = 1.0 / sqrt( (Sx*Sx) + (Sy*Sy) + (Sz*Sz) );
283 
284  Sx *= mag;
285  Sy *= mag;
286  Sz *= mag;
287 
288  // setup Up vector (crossprod of s and forward vectors)
289  GLdouble Ux = (Sy * fwdz) - (Sz * fwdy);
290  GLdouble Uy = (Sz * fwdx) - (Sx * fwdz);
291  GLdouble Uz = (Sx * fwdy) - (Sy * fwdx);
292 
293  // normalize Up
294  mag = 1.0 / sqrt( (Ux*Ux) + (Uy*Uy) + (Uz*Uz) );
295 
296  Ux *= mag;
297  Uy *= mag;
298  Uz *= mag;
299 
300  // store the result in our matrix
301  memset( vmatrix, 0, sizeof(GLdouble) * 16 );
302  vmatrix[0] = Sx; vmatrix[1] = Ux; vmatrix[2] = -fwdx;
303  vmatrix[4] = Sy; vmatrix[5] = Uy; vmatrix[6] = -fwdy;
304  vmatrix[8] = Sz; vmatrix[9] = Uz; vmatrix[10] = -fwdz;
305  vmatrix[15] = 1.0;
306  }
307 
308  glLoadMatrixd(vmatrix);
309 
310  glTranslated(-eyex, -eyey, -eyez);
311  glScalef(1.0f, 1.0f, -1.0f);
312 
313  //Valathil: Sort lights by priority
314  extern bool Deferred_lighting;
315  if(!Deferred_lighting)
317 
318  for (i = 0; i < GL_max_lights; i++) {
319  if ( (offset + i) >= Num_active_gl_lights ) {
320  break;
321  }
322 
323  if (opengl_lights[offset+i].occupied) {
324  opengl_set_light(i, &opengl_lights[offset+i]);
325 
326  GL_state.Light(i, GL_TRUE);
327  }
328  }
329  opengl_light zero;
330  memset(&zero,0,sizeof(opengl_light));
331  zero.Position[0] = 1.0f;
332 
333  // make sure that we turn off any lights that we aren't using right now
334  for ( ; i < GL_max_lights; i++) {
335  GL_state.Light(i, GL_FALSE);
336  opengl_set_light(i, &zero);
337  }
338 
339  glPopMatrix();
340 }
341 
342 int gr_opengl_make_light(light *fs_light, int idx, int priority)
343 {
344  return idx;
345 }
346 
347 void gr_opengl_modify_light(light *fs_light, int idx, int priority)
348 {
349 }
350 
352 {
353 }
354 
355 void gr_opengl_set_light(light *fs_light)
356 {
357  if (Cmdline_nohtl)
358  return;
359 
361  return;
362 
363 //if (fs_light->type == LT_POINT)
364 // return;
365 
366  // init the light
367  FSLight2GLLight(fs_light, &opengl_lights[Num_active_gl_lights]);
368  opengl_lights[Num_active_gl_lights++].occupied = true;
369 }
370 
371 // this sets up a light to be pointinf from the eye to the object,
372 // the point being to make the object ether center or edge alphaed with THL
373 // this effect is used mostly on shockwave models
374 // -1 == edge
375 // 1 == center
376 // 0 == none
377 // should be called after lighting has been set up,
378 // currently not designed for use with lit models
380 {
382 }
383 
385 {
386  if (!type || Cmdline_nohtl)
387  return;
388 
390  return;
391  opengl_light glight;
392 
393  vec3d dir;
395  vm_vec_normalize(&dir);
396 
397  if (type == 1) {
398  glight.Diffuse[0] = 0.0f;
399  glight.Diffuse[1] = 0.0f;
400  glight.Diffuse[2] = 0.0f;
401  glight.Ambient[0] = gr_screen.current_alpha;
402  glight.Ambient[1] = gr_screen.current_alpha;
403  glight.Ambient[2] = gr_screen.current_alpha;
404  } else {
405  glight.Diffuse[0] = gr_screen.current_alpha;
406  glight.Diffuse[1] = gr_screen.current_alpha;
407  glight.Diffuse[2] = gr_screen.current_alpha;
408  glight.Ambient[0] = 0.0f;
409  glight.Ambient[1] = 0.0f;
410  glight.Ambient[2] = 0.0f;
411  }
412  glight.type = type;
413 
414  glight.Specular[0] = 0.0f;
415  glight.Specular[1] = 0.0f;
416  glight.Specular[2] = 0.0f;
417  glight.Specular[3] = 0.0f;
418 
419  glight.Ambient[3] = 1.0f;
420  glight.Diffuse[3] = 1.0f;
421 
422  glight.Position[0] = -dir.xyz.x;
423  glight.Position[1] = -dir.xyz.y;
424  glight.Position[2] = -dir.xyz.z;
425  glight.Position[3] = 0.0f;
426 
427  // defaults
428  glight.SpotDir[0] = 0.0f;
429  glight.SpotDir[1] = 0.0f;
430  glight.SpotDir[2] = -1.0f;
431  glight.SpotExp = Cmdline_ogl_spec * 0.5f;
432  glight.SpotCutOff = 180.0f;
433  glight.ConstantAtten = 1.0f;
434  glight.LinearAtten = 0.0f;
435  glight.QuadraticAtten = 0.0f;
436  glight.occupied = false;
437 
438  // first light
439  memcpy( &opengl_lights[Num_active_gl_lights], &glight, sizeof(opengl_light) );
440  opengl_lights[Num_active_gl_lights++].occupied = true;
441 
442  // second light
443  glight.Position[0] = dir.xyz.x;
444  glight.Position[1] = dir.xyz.y;
445  glight.Position[2] = dir.xyz.z;
446 
447  memcpy( &opengl_lights[Num_active_gl_lights], &glight, sizeof(opengl_light) );
448  opengl_lights[Num_active_gl_lights++].occupied = true;
449 
450  // reset center alpha
451  GL_center_alpha = 0;
452 }
453 
455 {
457 }
458 
460 {
461  int i;
462 
463  if (Cmdline_nohtl)
464  return;
465 
466 // memset( opengl_lights, 0, sizeof(opengl_light) * MAX_LIGHTS );
467 
468  for (i = 0; i < GL_max_lights; i++) {
469  GL_state.Light(i, GL_FALSE);
470  opengl_lights[i].occupied = false;
471  }
472 
474  GL_center_alpha = 0;
475 }
476 
478 {
479  float amb_user = 0.0f;
480 
481  // assuming that the default is "128", just skip this if not a user setting
482  if (Cmdline_ambient_factor == 128)
483  return;
484 
485  amb_user = (float)((Cmdline_ambient_factor * 2) - 255) / 255.0f;
486 
487  // set the ambient light
488  GL_light_ambient[0] += amb_user;
489  GL_light_ambient[1] += amb_user;
490  GL_light_ambient[2] += amb_user;
491 
492  CLAMP( GL_light_ambient[0], 0.02f, 1.0f );
493  CLAMP( GL_light_ambient[1], 0.02f, 1.0f );
494  CLAMP( GL_light_ambient[2], 0.02f, 1.0f );
495 
496  GL_light_ambient[3] = 1.0f;
497 }
498 
500 {
501  if (opengl_lights != NULL) {
502  vm_free(opengl_lights);
503  opengl_lights = NULL;
504  }
505 }
506 
508 {
510 
512 
514 
515  // more realistic lighting model
517 
518  glGetIntegerv(GL_MAX_LIGHTS, &GL_max_lights); // Get the max number of lights supported
519 
520  // allocate memory for enabled lights
521  Verify(GL_max_lights > 0);
522 
523  if ( opengl_lights == NULL )
524  opengl_lights = (opengl_light *) vm_malloc_q(MAX_LIGHTS * sizeof(opengl_light));
525 
526  if (opengl_lights == NULL)
527  Error( LOCATION, "Unable to allocate memory for lights!\n");
528 
529  memset( opengl_lights, 0, MAX_LIGHTS * sizeof(opengl_light) );
530 }
531 
532 extern int Cmdline_no_emissive;
533 bool ambient_state = false;
534 bool emission_state = false;
535 bool specular_state = false;
536 void opengl_default_light_settings(int ambient, int emission, int specular)
537 {
538  if (!lighting_is_enabled)
539  return;
540 
541  if (ambient) {
542  if (!ambient_state) {
544  glMaterialfv( GL_FRONT, GL_AMBIENT, GL_light_ambient );
545  ambient_state = true;
546  }
547  } else {
548  if (ambient_state) {
549  if (GL_center_alpha) {
550  glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, GL_light_true_zero );
551  } else {
552  glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, GL_light_zero );
553  }
554  ambient_state = false;
555  }
556  }
557 
558  if (emission && !Cmdline_no_emissive) {
559  // emissive light is just a general glow but without it things are *terribly* dark if there is no light on them
560  if (!emission_state) {
561  glMaterialfv( GL_FRONT, GL_EMISSION, GL_light_emission );
562  emission_state = true;
563  }
564  } else {
565  if (emission_state) {
566  glMaterialfv( GL_FRONT, GL_EMISSION, GL_light_zero );
567  emission_state = false;
568  }
569  }
570 
571  if (specular) {
572  if (!specular_state) {
573  glMaterialfv( GL_FRONT, GL_SPECULAR, GL_light_spec );
574  specular_state = true;
575  }
576  } else {
577  if (specular_state) {
578  glMaterialfv( GL_FRONT, GL_SPECULAR, GL_light_zero );
579  specular_state = false;
580  }
581  }
582 }
583 
584 void gr_opengl_set_lighting(bool set, bool state)
585 {
586  if (Cmdline_nohtl) {
587  return;
588  }
589 
590  lighting_is_enabled = set;
591 
593 
597  } else {
598  glLightModelfv( GL_LIGHT_MODEL_AMBIENT, GL_light_ambient );
599  }
600 
601  for (int i = 0; i < GL_max_lights; i++) {
603  }
604 
605  GL_state.Lighting( (state) ? GL_TRUE : GL_FALSE );
606 }
607 
608 void gr_opengl_set_ambient_light(int red, int green, int blue)
609 {
610  GL_light_ambient[0] = i2fl(red)/255.0f;
611  GL_light_ambient[1] = i2fl(green)/255.0f;
612  GL_light_ambient[2] = i2fl(blue)/255.0f;
613  GL_light_ambient[3] = 1.0f;
614 
616 }
#define vm_malloc_q(size)
Definition: pstypes.h:554
bool specular_state
int i
Definition: multi_pxo.cpp:466
#define vm_free(ptr)
Definition: pstypes.h:548
float current_alpha
Definition: 2d.h:400
float static_tube_factor
Definition: lighting.cpp:745
#define GL_DIFFUSE
Definition: Gl.h:656
bool lighting_is_enabled
#define Verify(x)
Definition: pstypes.h:272
bool ambient_state
#define GL_LIGHT_MODEL_TWO_SIDE
Definition: Gl.h:401
WINGDIAPI void APIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
void opengl_calculate_ambient_factor()
#define GL_LIGHT_MODEL_AMBIENT
Definition: Gl.h:402
#define GL_FRONT
Definition: Gl.h:219
WINGDIAPI void APIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
#define MAX_LIGHTS
Definition: globals.h:86
int gr_opengl_make_light(light *fs_light, int idx, int priority)
opengl_light * opengl_lights
Assert(pm!=NULL)
int GL_center_alpha
double GLdouble
Definition: Gl.h:55
Definition: pstypes.h:88
void gr_opengl_set_lighting(bool set, bool state)
matrix Eye_matrix
Definition: 3dsetup.cpp:26
void opengl_set_light(int light_num, opengl_light *ltp)
struct vec3d::@225::@227 xyz
bool Deferred_lighting
GLclampf f
Definition: Glext.h:7097
float GL_light_factor
float LinearAtten
Definition: gropengllight.h:35
void gr_opengl_destroy_light(int idx)
float factor
Definition: lua.cpp:440
bool opengl_sort_active_lights(const opengl_light &la, const opengl_light &lb)
#define GL_SPOT_DIRECTION
Definition: Gl.h:659
void gr_opengl_reset_lighting()
float rada_squared
Definition: lighting.h:39
vec3d Object_position
Definition: 3dsetup.cpp:42
#define GL_LIGHT_MODEL_LOCAL_VIEWER
Definition: Gl.h:400
#define Int3()
Definition: pstypes.h:292
int Cmdline_ambient_factor
Definition: cmdline.cpp:322
#define GL_AMBIENT_AND_DIFFUSE
Definition: Gl.h:744
void gr_opengl_center_alpha(int type)
float static_light_factor
Definition: lighting.cpp:744
WINGDIAPI void APIENTRY glPopMatrix(void)
void FSLight2GLLight(light *FSLight, opengl_light *GLLight)
GLenum type
Definition: Gl.h:1492
void gr_opengl_modify_light(light *fs_light, int idx, int priority)
#define CLAMP(x, min, max)
Definition: pstypes.h:488
float spec_b
Definition: lighting.h:42
#define GL_SPOT_CUTOFF
Definition: Gl.h:661
#define GL_SPECULAR
Definition: Gl.h:657
#define GL_FALSE
Definition: Gl.h:139
GLintptr offset
Definition: Glext.h:5497
void gr_opengl_set_light_factor(float factor)
int Cmdline_nohtl
Definition: cmdline.cpp:438
#define GR_ALPHABLEND_FILTER
Definition: 2d.h:349
vec3d vec2
Definition: lighting.h:35
float b
Definition: lighting.h:41
struct matrix::@228::@230 vec
bool emission_state
#define GL_SHININESS
Definition: Gl.h:743
float g
Definition: lighting.h:41
double specular_exponent_value
Definition: lighting.cpp:747
GLboolean GLboolean GLboolean GLboolean a
Definition: Glext.h:5781
GLclampf GLclampf blue
Definition: Glext.h:5177
#define GL_AMBIENT
Definition: Gl.h:655
GLboolean Light(GLint num, GLint state=-1)
void gr_opengl_set_center_alpha(int type)
float rada
Definition: lighting.h:39
float spec_r
Definition: lighting.h:42
float Cmdline_ogl_spec
Definition: cmdline.cpp:321
void opengl_light_shutdown()
#define LT_TUBE
Definition: lighting.h:27
WINGDIAPI void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
WINGDIAPI void APIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z)
#define GL_TRUE
Definition: Gl.h:138
int idx
Definition: multiui.cpp:761
GLclampf green
Definition: Glext.h:5177
#define GL_LIGHT0
Definition: Gl.h:645
WINGDIAPI void APIENTRY glGetIntegerv(GLenum pname, GLint *params)
int Num_active_gl_lights
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
int Cmdline_no_emissive
Definition: cmdline.cpp:330
int type
Definition: lighting.h:33
Definition: lighting.h:32
GLint GL_max_lights
WINGDIAPI void APIENTRY glLoadMatrixd(const GLdouble *m)
float radb_squared
Definition: lighting.h:40
#define LT_POINT
Definition: lighting.h:26
float ConstantAtten
Definition: gropengllight.h:35
void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1)
Definition: vecmat.cpp:168
vec3d Eye_position
Definition: 3dsetup.cpp:27
float GL_light_color[]
WINGDIAPI void APIENTRY glLightModelfv(GLenum pname, const GLfloat *params)
#define LT_CONE
Definition: lighting.h:28
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
float spec_g
Definition: lighting.h:42
void opengl_pre_render_init_lights()
opengl_state GL_state
WINGDIAPI void APIENTRY glPushMatrix(void)
screen gr_screen
Definition: 2d.cpp:46
void gr_opengl_set_ambient_light(int red, int green, int blue)
#define GL_MAX_LIGHTS
Definition: Gl.h:522
#define GL_LINEAR_ATTENUATION
Definition: Gl.h:663
#define LOCATION
Definition: pstypes.h:245
vec3d vec
Definition: lighting.h:34
float radb
Definition: lighting.h:40
float SpotCutOff
Definition: gropengllight.h:34
hull_check pos
Definition: lua.cpp:5050
void opengl_light_init()
GLfloat Diffuse[4]
Definition: gropengllight.h:26
int current_alphablend_mode
Definition: 2d.h:392
WINGDIAPI void APIENTRY glLightf(GLenum light, GLenum pname, GLfloat param)
#define i2fl(i)
Definition: floating.h:32
GLfloat SpotDir[3]
Definition: gropengllight.h:32
WINGDIAPI void APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
WINGDIAPI void APIENTRY glLightModeli(GLenum pname, GLint param)
float intensity
Definition: lighting.h:38
void opengl_change_active_lights(int pos, int d_offset)
bool is_minimum_GLSL_version()
Definition: gropengl.cpp:2064
#define MAX(a, b)
Definition: pstypes.h:299
GLfloat Ambient[4]
Definition: gropengllight.h:26
float static_point_factor
Definition: lighting.cpp:746
#define GL_SPOT_EXPONENT
Definition: Gl.h:660
void opengl_default_light_settings(int ambient, int emission, int specular)
#define GL_EMISSION
Definition: Gl.h:742
void gr_opengl_set_light(light *fs_light)
float r
Definition: lighting.h:41
#define LT_DIRECTIONAL
Definition: lighting.h:25
GLfloat Position[4]
Definition: gropengllight.h:29
float QuadraticAtten
Definition: gropengllight.h:35
GLfloat Specular[4]
Definition: gropengllight.h:26
#define GL_POSITION
Definition: Gl.h:658
int GLint
Definition: Gl.h:48
float vm_vec_normalize(vec3d *v)
Definition: vecmat.cpp:460
float GLfloat
Definition: Gl.h:53
GLboolean Lighting(GLint state=-1)