codemp/cgame/cg_light.c File Reference

#include "cg_local.h"
#include "cg_lights.h"

Go to the source code of this file.

Functions

void CG_ClearLightStyles (void)
void CG_RunLightStyles (void)
void CG_SetLightstyle (int i)


Function Documentation

void CG_ClearLightStyles void   ) 
 

Definition at line 15 of file cg_light.c.

References CG_SetLightstyle(), MAX_LIGHT_STYLES, and memset().

Referenced by CG_Init().

00016 {
00017         int     i;
00018 
00019         memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
00020         lastofs = -1;
00021 
00022         for(i=0;i<MAX_LIGHT_STYLES*3;i++)
00023         {
00024                 CG_SetLightstyle (i);
00025         }
00026 }

void CG_RunLightStyles void   ) 
 

Definition at line 33 of file cg_light.c.

References cg, MAX_LIGHT_STYLES, cg_t::time, and trap_R_SetLightStyle().

Referenced by CG_DrawActiveFrame().

00034 {
00035         int             ofs;
00036         int             i;
00037         clightstyle_t   *ls;
00038 
00039         ofs = cg.time / 50;
00040 //      if (ofs == lastofs)
00041 //              return;
00042         lastofs = ofs;
00043 
00044         for (i=0,ls=cl_lightstyle ; i<MAX_LIGHT_STYLES ; i++, ls++)
00045         {
00046                 if (!ls->length)
00047                 {
00048                         ls->value[0] = ls->value[1] = ls->value[2] = ls->value[3] = 255;
00049                 }
00050                 else if (ls->length == 1)
00051                 {
00052                         ls->value[0] = ls->map[0][0];
00053                         ls->value[1] = ls->map[0][1];
00054                         ls->value[2] = ls->map[0][2];
00055                         ls->value[3] = 255; //ls->map[0][3];
00056                 }
00057                 else
00058                 {
00059                         ls->value[0] = ls->map[ofs%ls->length][0];
00060                         ls->value[1] = ls->map[ofs%ls->length][1];
00061                         ls->value[2] = ls->map[ofs%ls->length][2];
00062                         ls->value[3] = 255; //ls->map[ofs%ls->length][3];
00063                 }
00064                 trap_R_SetLightStyle(i, *(int*)ls->value);
00065         }
00066 }

void CG_SetLightstyle int  i  ) 
 

Definition at line 68 of file cg_light.c.

References CG_ConfigString(), Com_Error(), CS_LIGHT_STYLES, ERR_DROP, clightstyle_t::length, clightstyle_t::map, MAX_QPATH, and strlen().

Referenced by CG_ClearLightStyles().

00069 {
00070         const char      *s;
00071         int                     j, k;
00072 
00073         s = CG_ConfigString( i+CS_LIGHT_STYLES );
00074         j = strlen (s);
00075         if (j >= MAX_QPATH)
00076         {
00077                 Com_Error (ERR_DROP, "svc_lightstyle length=%i", j);
00078         }
00079 
00080         cl_lightstyle[(i/3)].length = j;
00081         for (k=0 ; k<j ; k++)
00082         {
00083                 cl_lightstyle[(i/3)].map[k][(i%3)] = (float)(s[k]-'a')/(float)('z'-'a') * 255.0;
00084         }
00085 }