13 #define WIN32_LEAN_AND_MEAN
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 };
94 switch (FSLight->
type) {
212 if ( la_value < lb_value )
214 else if ( la_value > lb_value )
230 static vec3d last_view_pos;
231 static matrix last_view_orient;
233 static bool use_last_view =
false;
250 use_last_view =
true;
255 use_last_view =
false;
258 if ( !use_last_view ) {
277 GLdouble Sx = (fwdy * upz) - (fwdz * upy);
278 GLdouble Sy = (fwdz * upx) - (fwdx * upz);
279 GLdouble Sz = (fwdx * upy) - (fwdy * upx);
282 mag = 1.0 / sqrt( (Sx*Sx) + (Sy*Sy) + (Sz*Sz) );
289 GLdouble Ux = (Sy * fwdz) - (Sz * fwdy);
290 GLdouble Uy = (Sz * fwdx) - (Sx * fwdz);
291 GLdouble Uz = (Sx * fwdy) - (Sy * fwdx);
294 mag = 1.0 / sqrt( (Ux*Ux) + (Uy*Uy) + (Uz*Uz) );
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;
315 if(!Deferred_lighting)
323 if (opengl_lights[offset+i].occupied) {
368 opengl_lights[Num_active_gl_lights++].
occupied =
true;
440 opengl_lights[Num_active_gl_lights++].
occupied =
true;
447 memcpy( &opengl_lights[Num_active_gl_lights], &glight,
sizeof(
opengl_light) );
448 opengl_lights[Num_active_gl_lights++].
occupied =
true;
479 float amb_user = 0.0f;
488 GL_light_ambient[0] += amb_user;
489 GL_light_ambient[1] += amb_user;
490 GL_light_ambient[2] += amb_user;
492 CLAMP( GL_light_ambient[0], 0.02
f, 1.0
f );
493 CLAMP( GL_light_ambient[1], 0.02
f, 1.0
f );
494 CLAMP( GL_light_ambient[2], 0.02
f, 1.0
f );
496 GL_light_ambient[3] = 1.0f;
501 if (opengl_lights != NULL) {
503 opengl_lights = NULL;
523 if ( opengl_lights == NULL )
526 if (opengl_lights == NULL)
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;
#define vm_malloc_q(size)
#define GL_LIGHT_MODEL_TWO_SIDE
WINGDIAPI void APIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
void opengl_calculate_ambient_factor()
#define GL_LIGHT_MODEL_AMBIENT
WINGDIAPI void APIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
int gr_opengl_make_light(light *fs_light, int idx, int priority)
opengl_light * opengl_lights
void gr_opengl_set_lighting(bool set, bool state)
void opengl_set_light(int light_num, opengl_light *ltp)
struct vec3d::@225::@227 xyz
void gr_opengl_destroy_light(int idx)
bool opengl_sort_active_lights(const opengl_light &la, const opengl_light &lb)
#define GL_SPOT_DIRECTION
void gr_opengl_reset_lighting()
#define GL_LIGHT_MODEL_LOCAL_VIEWER
int Cmdline_ambient_factor
#define GL_AMBIENT_AND_DIFFUSE
void gr_opengl_center_alpha(int type)
float static_light_factor
WINGDIAPI void APIENTRY glPopMatrix(void)
void FSLight2GLLight(light *FSLight, opengl_light *GLLight)
void gr_opengl_modify_light(light *fs_light, int idx, int priority)
#define CLAMP(x, min, max)
void gr_opengl_set_light_factor(float factor)
#define GR_ALPHABLEND_FILTER
struct matrix::@228::@230 vec
double specular_exponent_value
GLboolean GLboolean GLboolean GLboolean a
GLboolean Light(GLint num, GLint state=-1)
void gr_opengl_set_center_alpha(int type)
void opengl_light_shutdown()
WINGDIAPI void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
WINGDIAPI void APIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z)
WINGDIAPI void APIENTRY glGetIntegerv(GLenum pname, GLint *params)
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
WINGDIAPI void APIENTRY glLoadMatrixd(const GLdouble *m)
void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1)
WINGDIAPI void APIENTRY glLightModelfv(GLenum pname, const GLfloat *params)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void opengl_pre_render_init_lights()
WINGDIAPI void APIENTRY glPushMatrix(void)
void gr_opengl_set_ambient_light(int red, int green, int blue)
#define GL_LINEAR_ATTENUATION
int current_alphablend_mode
WINGDIAPI void APIENTRY glLightf(GLenum light, GLenum pname, GLfloat param)
WINGDIAPI void APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
WINGDIAPI void APIENTRY glLightModeli(GLenum pname, GLint param)
void opengl_change_active_lights(int pos, int d_offset)
bool is_minimum_GLSL_version()
float static_point_factor
void opengl_default_light_settings(int ambient, int emission, int specular)
void gr_opengl_set_light(light *fs_light)
float vm_vec_normalize(vec3d *v)
GLboolean Lighting(GLint state=-1)