Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gfx_light Class Reference

#include <gl_light.h>

Inheritance diagram for gfx_light:
GFXLight

Public Member Functions

 gfx_light ()
 
GFXLight operator= (const GFXLight &tmp)
 assigns a GFXLight to a gfx_light More...
 
int lightNum ()
 Returns the number this light is in the _llights list. More...
 
bool LocalLight () const
 Returns if this light was saved as a local light. More...
 
bool enabled () const
 Retursn if this light is enabled. More...
 
intTarget ()
 Returns the target OpenGL light of this light. -1 is unassigned to a "real" light. More...
 
bool Create (const GFXLight &, bool global)
 
void Kill ()
 Disables it (may remove from table), trashes it from GLlights. sets target to -2 (dead) More...
 
void SendGLPosition (const GLenum target) const
 properly utilizes union to send to OGL More...
 
void ClobberGLLight (const int target)
 replaces target GL light in the implementation. Sets this->target! Checks for -1 and calls ContextSwitch to clobber completely More...
 
void FinesseClobberLight (const GLenum target, const int original)
 replaces target GL light, copying all state sets this->target! More...
 
void ContextSwitchClobberLight (const GLenum target, const int original) const
 replaces target GL light, copying all state sets this->target! More...
 
void Enable ()
 
void Disable ()
 
void ResetProperties (const enum LIGHT_TARGET, const GFXColor &color)
 
void AddToTable ()
 Adds this light to table (assume local) More...
 
bool RemoveFromTable (bool shouldremove=true, const GFXLight &t=GFXLight())
 Removes this light from light table. More...
 
void TrashFromGLLights ()
 Trash this light from active GLLights. More...
 
LineCollide CalculateBounds (bool &err)
 calculates bounds for the table given cutoffs! More...
 
- Public Member Functions inherited from GFXLight
 GFXLight ()
 
 GFXLight (const bool enabled, const GFXColor &vect, const GFXColor &diffuse=GFXColor(0, 0, 0, 1), const GFXColor &specular=GFXColor(0, 0, 0, 1), const GFXColor &ambient=GFXColor(0, 0, 0, 1), const GFXColor &attenuate=GFXColor(1, 0, 0), const GFXColor &direction=GFXColor(0, 0, 0), float exp=0.0f, float cutoff=180.0f, float size=0.0f)
 
void SetProperties (enum LIGHT_TARGET, const GFXColor &color)
 
GFXColor GetProperties (enum LIGHT_TARGET) const
 
void setSize (float size_)
 
float getSize () const
 
Vector getPosition () const
 
void disable ()
 
void enable ()
 
bool attenuated () const
 
void apply_attenuate (bool attenuated)
 

Static Public Member Functions

static void dopickenables ()
 Do all enables from picking. More...
 

Additional Inherited Members

- Public Attributes inherited from GFXLight
int target
 physical GL light its saved in More...
 
float vect [3]
 last is w for positional, otherwise 3 for spec More...
 
int options
 
float diffuse [4]
 
float specular [4]
 
float ambient [4]
 
float attenuate [3]
 
float direction [3]
 
float exp
 
float cutoff
 
float size
 

Detailed Description

This stores the state of a given GL Light in its fullness It inherits all values a light may have, and gains a number of functions that assist it in maintaining the virtual OpenGL state amidst the limited Number of lights, etc

Definition at line 23 of file gl_light.h.

Constructor & Destructor Documentation

gfx_light::gfx_light ( )
inline

Definition at line 25 of file gl_light.h.

25 : gfx_light() : GFXLight() {}

Member Function Documentation

void gfx_light::AddToTable ( )

Adds this light to table (assume local)

Definition at line 388 of file gl_light_state.cpp.

References CalculateBounds(), LineCollideStar::lc, and Hashtable3d< T, COLLIDETABLESIZE, COLLIDETABLEACCURACY, HUGEOBJECT >::Put().

Referenced by Enable(), and ResetProperties().

389 {
390  LineCollideStar tmp;
391  bool err;
392  LineCollide *coltarg = new LineCollide( CalculateBounds( err ) ); //leak??
393  if (err)
394  return;
395  tmp.lc = coltarg;
396  lighttable.Put( coltarg, tmp );
397 }
LineCollide gfx_light::CalculateBounds ( bool err)

calculates bounds for the table given cutoffs!

Definition at line 472 of file gl_light_state.cpp.

References GFXLight::ambient, GFXLight::attenuate, GFXLight::diffuse, intensity_cutoff, lightNum(), LineCollide::object, QVector, GFXLight::specular, UniverseUtil::sqrt(), LineCollide::UNIT, and GFXLight::vect.

Referenced by AddToTable(), and RemoveFromTable().

473 {
474  error = false;
475  float tot_intensity = ( (specular[0]+specular[1]+specular[2])*specular[3]
476  +(diffuse[0]+diffuse[1]+diffuse[2])*diffuse[3]
477  +(ambient[0]+ambient[1]+ambient[2])*ambient[3] )*.33;
478  //double d = (-(double)attenuate[1]+sqrt((double)attenuate[1]*(double)attenuate[1]+4*(double)attenuate[2]*(((double)tot_intensity/(double)intensity_cutoff) - (double)attenuate[0])))/(2*(double)attenuate[2]);
479  //simplistic calculation above causes floating point inaccuracies
480  double ffastmathreallysucksd;
481  double ffastmathreallysucksq;
482 
483  ffastmathreallysucksd = sqrt( tot_intensity/intensity_cutoff-ambient[0] );
484 
485  ffastmathreallysucksq = sqrt( attenuate[2]+attenuate[1] );
486  //VSFileSystem::Fprintf (stderr,"q%lf d%lf",ffastmathreallysucksq,ffastmathreallysucksd);
487  if (ffastmathreallysucksq == 0 || ffastmathreallysucksd <= 0)
488  error = true;
489  ffastmathreallysucksd /= ffastmathreallysucksq;
490 
491  QVector st( vect[0]-ffastmathreallysucksd, vect[1]-ffastmathreallysucksd, vect[2]-ffastmathreallysucksd );
492  QVector end( vect[0]+ffastmathreallysucksd, vect[1]+ffastmathreallysucksd, vect[2]+ffastmathreallysucksd );
493  LineCollide retval( NULL, LineCollide::UNIT, st, end );
494  *( (int*) (&retval.object) ) = lightNum(); //put in a lightNum
495  return retval;
496 }
void gfx_light::ClobberGLLight ( const int  target)

replaces target GL light in the implementation. Sets this->target! Checks for -1 and calls ContextSwitch to clobber completely

Definition at line 280 of file gl_light_state.cpp.

References ContextSwitchClobberLight(), enabled(), FinesseClobberLight(), OpenGLL::GL_ENABLED, OpenGLL::GLL_LOCAL, OpenGLL::GLL_ON, GLLights, OpenGLLights::index, index, lightNum(), LocalLight(), OpenGLLights::options, GFXLight::options, and GFXLight::target.

Referenced by Create(), and Enable().

281 {
282  this->target = target;
283  if ( enabled() != ( (GLLights[target].options&OpenGLL::GL_ENABLED) != 0 ) ) {
284  if ( enabled() ) {
285  glEnable( GL_LIGHT0+target );
287  } else {
288  GLLights[target].options &= (~OpenGLL::GL_ENABLED);
289  glDisable( GL_LIGHT0+target );
290  }
291  }
292  GLLights[target].options &= (OpenGLL::GL_ENABLED); //turn off options
293 #ifdef GFX_HARDWARE_LIGHTING
294  if (GLLights[target].index == -1) {
295 #endif
297 #ifdef GFX_HARDWARE_LIGHTING
298  } else {
300  }
301 #endif
302  this->target = target;
303  //VSFileSystem::Fprintf (stderr,"Target %d had light %d",target, GLLights[target].index);
305  //VSFileSystem::Fprintf (stderr," Clobbered with %d\n",lightNum());
307 }
void gfx_light::ContextSwitchClobberLight ( const GLenum  target,
const int  original 
) const
inline

replaces target GL light, copying all state sets this->target!

Definition at line 231 of file gl_light_state.cpp.

References GFXLight::ambient, atten0scale, atten1scale, atten2scale, GFXLight::attenuate, GFXLight::diffuse, GLLights, OpenGLLights::index, SendGLPosition(), GFXLight::specular, and GFXLight::target.

Referenced by ClobberGLLight(), and GFXUploadLightState().

232 {
233  glLightf( gltarg, GL_CONSTANT_ATTENUATION, attenuate[0]*atten0scale );
234  glLightf( gltarg, GL_LINEAR_ATTENUATION, attenuate[1]*atten1scale );
235  glLightf( gltarg, GL_QUADRATIC_ATTENUATION, attenuate[2]*atten2scale );
236 
237  SendGLPosition( gltarg );
238  glLightfv( gltarg, GL_DIFFUSE, diffuse );
239  glLightfv( gltarg, GL_SPECULAR, specular );
240  glLightfv( gltarg, GL_AMBIENT, ambient );
241  if (original != -1) {
242  gfx_light *orig = &( (*_llights)[GLLights[original].index] );
243  orig->target = -1;
244  GLLights[original].index = -1;
245  }
246 }
bool gfx_light::Create ( const GFXLight temp,
bool  global 
)

if global, puts it into GLlights (if space ||enabled) <clobber?> for local lights, if enabled, call Enable().

Definition at line 190 of file gl_light_state.cpp.

References _GLLightsEnabled, ClobberGLLight(), GFXLight::disable(), Enable(), enabled(), findGlobalClobberable(), findLocalClobberable(), GFX_LOCAL_LIGHT, and GFXLight::options.

191 {
192  int foundclobberable = 0;
193  *this = temp;
194  if (!global) {
196  if ( enabled() ) {
197  disable();
198  this->Enable(); //upon creation need to call enable script with disabled light
199  }
200  } else {
201  options &= (~GFX_LOCAL_LIGHT);
202  foundclobberable = enabled() ? findGlobalClobberable() : findLocalClobberable();
203  if (foundclobberable != -1) {
204  _GLLightsEnabled += (enabled() != 0);
205  ClobberGLLight( foundclobberable );
206  }
207  }
208  return (foundclobberable != -1) || ( !enabled() );
209 }
void gfx_light::Disable ( )

for global lights, GLdisables it. for local lights, removes it from the table. and trashes it form GLlights.

Definition at line 449 of file gl_light_state.cpp.

References _GLLightsEnabled, GFXLight::disable(), enabled(), OpenGLL::GL_ENABLED, OpenGLL::GLL_ON, GLLights, LocalLight(), OpenGLLights::options, GFXLight::options, RemoveFromTable(), GFXLight::target, and TrashFromGLLights().

Referenced by Kill().

450 {
451  if ( enabled() ) {
452  disable();
453  if (target >= 0) {
456  glDisable( GL_LIGHT0+this->target );
457  }
458  GLLights[this->target].options &= ( ~(OpenGLL::GL_ENABLED|OpenGLL::GLL_ON) );
459  }
460  if ( LocalLight() && enabled() ) {
461  RemoveFromTable();
462  if (target >= 0)
464  }
465  }
466 }
void gfx_light::dopickenables ( )
static

Do all enables from picking.

Definition at line 187 of file gl_light_pick.cpp.

References _llights, findLocalClobberable(), OpenGLL::GL_ENABLED, OpenGLL::GLL_LOCAL, GLLights, OpenGLLights::index, newpicked, oldpicked, OpenGLLights::options, GFXLight::options, and VSFileSystem::vs_fprintf().

Referenced by GFXPickLights().

188 {
189  //sort it to find minimum num lights changed from last time.
190  sort( newpicked->begin(), newpicked->end() );
191  //newpicked->sort();
192  std::vector< int >::iterator traverse = newpicked->begin();
193  std::vector< int >::iterator oldtrav;
194  while ( traverse != newpicked->end() && ( !oldpicked->empty() ) ) {
195  oldtrav = oldpicked->begin();
196  while (oldtrav != oldpicked->end() && *oldtrav < *traverse)
197  oldtrav++;
198  if ( ( (*traverse) == (*oldtrav) ) && ( (*_llights)[*oldtrav].target >= 0 ) )
199  //BOGUS ASSERT... just like this light wasn't on if it was somehow clobberedassert (GLLights[(*_llights)[oldpicked->front()].target].index == oldpicked->front());
200  oldpicked->erase( oldtrav ); //already taken care of. main screen turn on ;-)
201  traverse++;
202  }
203  oldtrav = oldpicked->begin();
204  while ( oldtrav != oldpicked->end() ) {
205  if ( GLLights[(*_llights)[(*oldtrav)].target].index != (*oldtrav) ) {
206  oldtrav++;
207  continue; //don't clobber what's not yours
208  }
209  GLLights[(*_llights)[(*oldtrav)].target].index = -1;
210  GLLights[(*_llights)[(*oldtrav)].target].options &= (OpenGLL::GL_ENABLED&OpenGLL::GLL_LOCAL); //set it to be desirable to kill
211  oldtrav++;
212  }
213  traverse = newpicked->begin();
214  while ( traverse != newpicked->end() ) {
215  if (*traverse>=(int)_llights->size()) {
216  VSFileSystem::vs_fprintf (stderr,"GFXLIGHT FAILURE %d is beyond array of size %d",(int)*traverse,(int)_llights->size());
217  traverse++;
218  continue;
219  }
220  if ( (*_llights)[*traverse].target == -1 ) {
221  int gltarg = findLocalClobberable();
222  if (gltarg == -1) {
223  newpicked->erase( traverse, newpicked->end() ); //erase everything on the picked list. Nothing can fit;
224  break;
225  }
226  (*_llights)[(*traverse)].ClobberGLLight( gltarg );
227  }
228  traverse++;
229  }
230  /*while (!oldpicked->empty()) {
231  * int glind=(*_llights)[oldpicked->front()].target;
232  * if ((GLLights[glind].options&OpenGLL::GL_ENABLED)&&GLLights[glind].index==-1) {//if hasn't been duly clobbered
233  * glDisable (GL_LIGHT0+glind);
234  * GLLights[glind].options &= (~OpenGLL::GL_ENABLED);
235  * }
236  * (*_llights)[oldpicked->front()].target=-1;//make sure it doesn't think it owns any gl lights!
237  * oldpicked->pop_front();
238  * }*/
239  for (oldtrav = oldpicked->begin(); oldtrav != oldpicked->end(); oldtrav++) {
240  if (*oldtrav>=(int)_llights->size()) {
241  VSFileSystem::vs_fprintf (stderr,"GFXLIGHT FAILURE %d is beyond array of size %d",(int)*oldtrav,(int)_llights->size());
242  continue;
243  }
244 
245  int glind = (*_llights)[*oldtrav].target;
246  if ( (GLLights[glind].options&OpenGLL::GL_ENABLED) && GLLights[glind].index == -1 ) {
247  //if hasn't been duly clobbered
248  glDisable( GL_LIGHT0+glind );
249  GLLights[glind].options &= (~OpenGLL::GL_ENABLED);
250  }
251  (*_llights)[*oldtrav].target = -1; //make sure it doesn't think it owns any gl lights!
252  }
253  oldpicked->clear();
254 }
void gfx_light::Enable ( )

for global lights, clobbers SOMETHING for sure, calls GLenable for local lights, puts it into the light table

Definition at line 428 of file gl_light_state.cpp.

References _GLLightsEnabled, AddToTable(), ClobberGLLight(), GFXLight::enable(), enabled(), findGlobalClobberable(), OpenGLL::GL_ENABLED, OpenGLL::GLL_ON, GLLights, LocalLight(), OpenGLLights::options, and GFXLight::target.

Referenced by Create().

429 {
430  if ( !enabled() ) {
431  if ( LocalLight() ) {
432  AddToTable();
433  } else {
434  if (target == -1) {
435  int newtarg = findGlobalClobberable();
436  if (newtarg == -1)
437  return;
439  ClobberGLLight( newtarg );
440  }
441  glEnable( GL_LIGHT0+this->target );
443  }
444  enable();
445  }
446 }
bool gfx_light::enabled ( ) const
inline

Retursn if this light is enabled.

Definition at line 36 of file gl_light.h.

References GFX_LIGHT_ENABLED, and GFXLight::options.

Referenced by ClobberGLLight(), Create(), Disable(), Enable(), and GFXUploadLightState().

37  {
38  return (options&GFX_LIGHT_ENABLED) != 0;
39  }
void gfx_light::FinesseClobberLight ( const GLenum  target,
const int  original 
)
inline

replaces target GL light, copying all state sets this->target!

Definition at line 248 of file gl_light_state.cpp.

References GFXLight::ambient, atten0scale, atten1scale, atten2scale, GFXLight::attenuate, GFXLight::attenuated(), GFXLight::diffuse, GLLights, OpenGLLights::index, SendGLPosition(), GFXLight::specular, GFXLight::target, and GFXLight::vect.

Referenced by ClobberGLLight().

249 {
250  gfx_light *orig = &( (*_llights)[GLLights[original].index] );
251  if ( attenuated() ) {
252  if ( orig->attenuated() ) {
253  if (orig->attenuate[0] != attenuate[0])
254  glLightf( gltarg, GL_CONSTANT_ATTENUATION, attenuate[0]*atten0scale );
255  if (orig->attenuate[1] != attenuate[1])
256  glLightf( gltarg, GL_LINEAR_ATTENUATION, attenuate[1]*atten1scale );
257  if (orig->attenuate[2] != attenuate[2])
258  glLightf( gltarg, GL_QUADRATIC_ATTENUATION, attenuate[2]*atten2scale );
259  } else {
260  glLightf( gltarg, GL_CONSTANT_ATTENUATION, attenuate[0]*atten0scale );
261  glLightf( gltarg, GL_LINEAR_ATTENUATION, attenuate[1]*atten1scale );
262  glLightf( gltarg, GL_QUADRATIC_ATTENUATION, attenuate[2]*atten2scale );
263  }
264  }
265  if ( vect[0] != orig->vect[0] || vect[1] != orig->vect[1] || vect[2] != orig->vect[2] || attenuated() != orig->attenuated() )
266  SendGLPosition( gltarg );
267  if (diffuse[0] != orig->diffuse[0] || diffuse[1] != orig->diffuse[1] || diffuse[2] != orig->diffuse[2] || diffuse[3]
268  != orig->diffuse[3])
269  glLightfv( gltarg, GL_DIFFUSE, diffuse );
270  if (specular[0] != orig->specular[0] || specular[1] != orig->specular[1] || specular[2] != orig->specular[2]
271  || specular[3] != orig->specular[3])
272  glLightfv( gltarg, GL_SPECULAR, specular );
273  if (ambient[0] != orig->ambient[0] || ambient[1] != orig->ambient[1] || ambient[2] != orig->ambient[2] || ambient[3]
274  != orig->ambient[3])
275  glLightfv( gltarg, GL_AMBIENT, ambient );
276  orig->target = -1;
277  GLLights[original].index = -1;
278 }
void gfx_light::Kill ( )

Disables it (may remove from table), trashes it from GLlights. sets target to -2 (dead)

Definition at line 211 of file gl_light_state.cpp.

References Disable(), GFXLight::options, GFXLight::target, and TrashFromGLLights().

212 {
213  Disable(); //first disables it...which _will_ remove it from the light table.
214  if (target >= 0)
215  TrashFromGLLights(); //then if not already done, trash from GLlights;
216  target = -2;
217  options = 0;
218 }
int gfx_light::lightNum ( )

Returns the number this light is in the _llights list.

Definition at line 153 of file gl_light_state.cpp.

References _llights.

Referenced by CalculateBounds(), and ClobberGLLight().

154 {
155  int tmp = ( this-&_llights->front() );
156  assert( tmp >= 0 && tmp < (int) _llights->size() );
157  //assert (&(*_llights)[GLLights[target].index]==this);
158  return tmp;
159 } //which number it is in the main scheme of things
bool gfx_light::LocalLight ( ) const
inline

Returns if this light was saved as a local light.

Definition at line 31 of file gl_light.h.

References GFX_LOCAL_LIGHT, and GFXLight::options.

Referenced by ClobberGLLight(), Disable(), Enable(), and ResetProperties().

32  {
33  return (options&GFX_LOCAL_LIGHT) != 0;
34  }
GFXLight gfx_light::operator= ( const GFXLight tmp)

assigns a GFXLight to a gfx_light

Definition at line 147 of file gl_light_state.cpp.

References VsnetOSS::memcpy().

148 {
149  memcpy( this, &tmp, sizeof (GFXLight) );
150  return tmp;
151 }
bool gfx_light::RemoveFromTable ( bool  shouldremove = true,
const GFXLight t = GFXLight() 
)

Removes this light from light table.

Definition at line 399 of file gl_light_state.cpp.

References CalculateBounds(), Hashtable3d< T, COLLIDETABLESIZE, COLLIDETABLEACCURACY, HUGEOBJECT >::hash_int(), LineCollideStar::lc, LineCollide::Maxi, LineCollide::Mini, and Hashtable3d< T, COLLIDETABLESIZE, COLLIDETABLEACCURACY, HUGEOBJECT >::Remove().

Referenced by Disable(), and ResetProperties().

400 {
401  LineCollideStar tmp;
402  bool err;
403  LineCollide coltarg( CalculateBounds( err ) );
404  if (!shouldremove) {
405  bool err2;
406  LineCollide coltarg2( CalculateBounds( err2 ) );
407  if ( lighttable.hash_int( coltarg2.Mini.i ) == lighttable.hash_int( coltarg.Mini.i )
408  && lighttable.hash_int( coltarg2.Mini.j ) == lighttable.hash_int( coltarg.Mini.j )
409  && lighttable.hash_int( coltarg2.Mini.k ) == lighttable.hash_int( coltarg.Mini.k )
410  && lighttable.hash_int( coltarg2.Maxi.i ) == lighttable.hash_int( coltarg.Maxi.i )
411  && lighttable.hash_int( coltarg2.Maxi.j ) == lighttable.hash_int( coltarg.Maxi.j )
412  && lighttable.hash_int( coltarg2.Maxi.k ) == lighttable.hash_int( coltarg.Maxi.k ) )
413  return false;
414  }
415  if (err)
416  return false;
417  tmp.lc = &coltarg;
418  if ( lighttable.Remove( &coltarg, tmp ) ) {
419  if (tmp.lc)
420  delete tmp.lc;
421  else
422  assert( tmp.lc );
423  }
424  return true;
425 }
void gfx_light::ResetProperties ( const enum LIGHT_TARGET  light_targ,
const GFXColor color 
)

sets properties, making minimum GL state changes for global, for local lights, removes it from table, trashes it from GLlights, if enabled, puts it bakc in table.

Definition at line 309 of file gl_light_state.cpp.

References GFXColor::a, AddToTable(), AMBIENT, GFXLight::ambient, GFXLight::apply_attenuate(), atten0scale, atten1scale, atten2scale, ATTENUATE, GFXLight::attenuate, GFXLight::attenuated(), GFXColor::b, changed, DIFFUSE, GFXLight::diffuse, GFXColor::g, LocalLight(), VsnetOSS::memcpy(), POSITION, GFXColor::r, RemoveFromTable(), SendGLPosition(), GFXLight::SetProperties(), SPECULAR, GFXLight::specular, GFXLight::target, TrashFromGLLights(), and GFXLight::vect.

310 {
311  bool changed = false;
312  if ( LocalLight() ) {
313  GFXLight t;
314  memcpy( &t, this, sizeof (GFXLight) );
315  t.SetProperties( light_targ, color );
316  changed = RemoveFromTable( false, t );
317  memcpy( this, &t, sizeof (GFXLight) );
318  if (changed)
319  AddToTable();
320  if (target >= 0)
322  return;
323  }
324  switch (light_targ)
325  {
326  case DIFFUSE:
327  diffuse[0] = color.r;
328  diffuse[1] = color.g;
329  diffuse[2] = color.b;
330  diffuse[3] = color.a;
331  if (target < 0)
332  break;
333  glLightfv( GL_LIGHT0+target, GL_DIFFUSE, diffuse );
334  break;
335  case SPECULAR:
336  specular[0] = color.r;
337  specular[1] = color.g;
338  specular[2] = color.b;
339  specular[3] = color.a;
340  if (target < 0)
341  break;
342  glLightfv( GL_LIGHT0+target, GL_SPECULAR, specular );
343  break;
344  case AMBIENT:
345  ambient[0] = color.r;
346  ambient[1] = color.g;
347  ambient[2] = color.b;
348  ambient[3] = color.a;
349  if (target < 0)
350  break;
351  glLightfv( GL_LIGHT0+target, GL_AMBIENT, ambient );
352  break;
353  case POSITION:
354  vect[0] = color.r;
355  vect[1] = color.g;
356  vect[2] = color.b;
357  if (target < 0)
358  break;
359  SendGLPosition( GL_LIGHT0+target );
360  break;
361  default:
362  case ATTENUATE:
363  attenuate[0] = color.r;
364  attenuate[1] = color.g;
365  attenuate[2] = color.b;
367  if (target < 0)
368  break;
369  SendGLPosition( GL_LIGHT0+target );
370  glLightf( GL_LIGHT0+target, GL_CONSTANT_ATTENUATION, attenuate[0]*atten0scale );
371  glLightf( GL_LIGHT0+target, GL_LINEAR_ATTENUATION, attenuate[1]*atten1scale );
372  glLightf( GL_LIGHT0+target, GL_QUADRATIC_ATTENUATION, attenuate[2]*atten2scale );
373  break;
374  }
375 }
void gfx_light::SendGLPosition ( const GLenum  target) const

properly utilizes union to send to OGL

ClobberGLLight **** most OpenGL implementation dirty lighting if any info is changed at all having two different lights with the same stats and pos is unlikely at best

Definition at line 225 of file gl_light_state.cpp.

References v, and GFXLight::vect.

Referenced by ContextSwitchClobberLight(), FinesseClobberLight(), and ResetProperties().

226 {
227  float v[4] = {vect[0], vect[1], vect[2], 1};
228  glLightfv( target, GL_POSITION, v );
229 }
int& gfx_light::Target ( )
inline

Returns the target OpenGL light of this light. -1 is unassigned to a "real" light.

Definition at line 41 of file gl_light.h.

References GFXLight::target.

42  {
43  return target;
44  }
void gfx_light::TrashFromGLLights ( )

Trash this light from active GLLights.

Definition at line 377 of file gl_light_state.cpp.

References _llights, OpenGLL::GLL_LOCAL, OpenGLL::GLL_ON, GLLights, OpenGLLights::index, index, OpenGLLights::options, GFXLight::options, removelightfromnewpick(), and GFXLight::target.

Referenced by Disable(), Kill(), and ResetProperties().

378 {
379  assert( target >= 0 );
380  assert( (GLLights[target].options&OpenGLL::GLL_ON) == 0 ); //better be disabled so we know it's not in the table, etc
381  assert( (&(*_llights)[GLLights[target].index]) == this );
383  GLLights[target].index = -1;
385  target = -1;
386 }

The documentation for this class was generated from the following files: