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
GFXVertexList Class Reference

#include <gfxlib_struct.h>

Inheritance diagram for GFXVertexList:
GFXSphereVertexList

Classes

union  INDEX
 
union  VDAT
 Vertices and colors stored. More...
 

Public Member Functions

void RefreshDisplayList ()
 Propagates modifications to the display list. More...
 
 GFXVertexList (enum POLYTYPE poly, int numVertices, const GFXVertex *vertices, int numindices, bool Mutable=false, unsigned int *index=0)
 creates a vertex list with 1 polytype and a given number of vertices More...
 
 GFXVertexList (enum POLYTYPE *poly, int numVertices, const GFXVertex *vertices, int numlists, int *offsets, bool Mutable=false, unsigned int *index=0)
 Creates a vertex list with an arbitrary number of poly types and given vertices, num list and offsets (see above) More...
 
 GFXVertexList (enum POLYTYPE poly, int numVertices, const GFXColorVertex *colors, int numindices, bool Mutable=false, unsigned int *index=0)
 Creates a vertex list with 1 poly type and color information to boot. More...
 
 GFXVertexList (enum POLYTYPE *poly, int numVertices, const GFXColorVertex *colors, int numlists, int *offsets, bool Mutable=false, unsigned int *index=0)
 Creates a vertex list with an arbitrary number of poly types and color. More...
 
virtual ~GFXVertexList ()
 
virtual int numTris () const
 Returns number of Triangles in vertex list (counts tri strips) More...
 
virtual int numQuads () const
 Returns number of Quads in vertex list (counts quad strips) More...
 
unsigned int GetIndex (int offset) const
 Looks up the index in the appropriate short, char or int array. More...
 
POLYTYPEGetPolyType () const
 
intGetOffsets () const
 
int GetNumLists () const
 
bool hasColor () const
 
int GetNumVertices () const
 
virtual VDATMap (bool read, bool write)
 
void UnMap ()
 
virtual VDATBeginMutate (int offset)
 Returns the array of vertices to be mutated. More...
 
virtual void EndMutate (int newsize=0)
 Ends mutation and refreshes display list. More...
 
void LoadDrawState ()
 Loads the draw state (what is active) of a given vlist for mass drawing. More...
 
virtual void BeginDrawState (GFXBOOL lock=GFXTRUE)
 Specifies array pointers and loads the draw state of a given vlist for mass drawing. More...
 
virtual void Draw ()
 Draws a single copy of the mass-loaded vlist. More...
 
void Draw (enum POLYTYPE poly, int numV)
 
void Draw (enum POLYTYPE poly, int numV, unsigned char *index)
 
void Draw (enum POLYTYPE poly, int numV, unsigned short *index)
 
void Draw (enum POLYTYPE poly, int numV, unsigned int *index)
 
void DrawOnce ()
 Loads draw state and prepares to draw only once. More...
 
virtual void EndDrawState (GFXBOOL lock=GFXTRUE)
 
virtual void GetPolys (GFXVertex **vert, int *numPolys, int *numTris)
 returns a packed vertex list with number of polys and number of tries to passed in arguments. Useful for getting vertex info from a mesh More...
 

Protected Member Functions

const GFXVertexGetVertex (int index) const
 Num vertices allocated. More...
 
const GFXColorVertexGetColorVertex (int index) const
 
void Init (enum POLYTYPE *poly, int numVertices, const GFXVertex *vert, const GFXColorVertex *colors, int numlists, int *offsets, bool Mutable, unsigned int *indices)
 Init function (call from construtor) More...
 
virtual void Draw (enum POLYTYPE *poly, const INDEX index, const int numLists, const int *offsets)
 
void RenormalizeNormals ()
 
 GFXVertexList ()
 

Static Protected Member Functions

static void VtxCopy (GFXVertexList *thus, GFXVertex *dst, int offset, int howmany)
 copies nonindexed vertices to dst vertex array More...
 
static void ColVtxCopy (GFXVertexList *thus, GFXVertex *dst, int offset, int howmany)
 Copies nonindex colored vertices to dst vertex array. More...
 
static void ColIndVtxCopy (GFXVertexList *thus, GFXVertex *dst, int offset, int howmany)
 Copies indexed colored vertices to dst vertex array. More...
 
static void IndVtxCopy (GFXVertexList *thus, GFXVertex *dst, int offset, int howmany)
 Copies indexed vertices to dst vertex array. More...
 

Protected Attributes

int numVertices
 
union GFXVertexList::VDAT data
 
union GFXVertexList::INDEX index
 
enum POLYTYPEmode
 Array of modes that vertices will be drawn with. More...
 
bool unique_mode
 
int display_list
 Display list number if list is indeed active. 0 otherwise. More...
 
int vbo_data
 
int numlists
 number of different mode, drawn lists More...
 
intoffsets
 
char changed
 If vertex list has been mutated since last draw. Low 3 bits store the stride of the index list (if avail). another bit for if color is presnet. More...
 

Friends

class GFXSphereVertexList
 

Detailed Description

A vertex list is a list of any conglomeration of POLY TYPES. It is held for storage in an array of GFXVertex but attempts to use a display list to hold information if possible

Definition at line 491 of file gfxlib_struct.h.

Constructor & Destructor Documentation

GFXVertexList::GFXVertexList ( )
protected

Definition at line 602 of file gfxlib_struct.cpp.

Referenced by GFXSphereVertexList::GFXSphereVertexList().

602  :
603  numVertices(0),
604  mode(0),
605  unique_mode(0),
606  display_list(0),
607  vbo_data(0),
608  numlists(0),
609  offsets(0),
610  changed(0)
611 {
612  // ctor
613 }
GFXVertexList::GFXVertexList ( enum POLYTYPE  poly,
int  numVertices,
const GFXVertex vertices,
int  numindices,
bool  Mutable = false,
unsigned int index = 0 
)
inline

creates a vertex list with 1 polytype and a given number of vertices

Definition at line 558 of file gfxlib_struct.h.

References index, and Init().

564  {
565  Init( &poly, numVertices, vertices, 0, 1, &numindices, Mutable, index );
566  }
GFXVertexList::GFXVertexList ( enum POLYTYPE poly,
int  numVertices,
const GFXVertex vertices,
int  numlists,
int offsets,
bool  Mutable = false,
unsigned int index = 0 
)
inline

Creates a vertex list with an arbitrary number of poly types and given vertices, num list and offsets (see above)

Definition at line 568 of file gfxlib_struct.h.

References index, and Init().

575  {
576  Init( poly, numVertices, vertices, 0, numlists, offsets, Mutable, index );
577  }
GFXVertexList::GFXVertexList ( enum POLYTYPE  poly,
int  numVertices,
const GFXColorVertex colors,
int  numindices,
bool  Mutable = false,
unsigned int index = 0 
)
inline

Creates a vertex list with 1 poly type and color information to boot.

Definition at line 579 of file gfxlib_struct.h.

References index, and Init().

585  {
586  Init( &poly, numVertices, 0, colors, 1, &numindices, Mutable, index );
587  }
GFXVertexList::GFXVertexList ( enum POLYTYPE poly,
int  numVertices,
const GFXColorVertex colors,
int  numlists,
int offsets,
bool  Mutable = false,
unsigned int index = 0 
)
inline

Creates a vertex list with an arbitrary number of poly types and color.

Definition at line 589 of file gfxlib_struct.h.

References index, and Init().

596  {
597  Init( poly, numVertices, 0, colors, numlists, offsets, Mutable, index );
598  }
GFXVertexList::~GFXVertexList ( )
virtual

Definition at line 506 of file gfxlib_struct.cpp.

References changed, GFXVertexList::VDAT::colors, data, display_list, GFXDeleteList(), HAS_COLOR, mode, offsets, vbo_data, and GFXVertexList::VDAT::vertices.

507 {
508 #ifndef NO_VBO_SUPPORT
509  if (vbo_data) {
510  (*glDeleteBuffersARB_p)(1, (GLuint*) &vbo_data);
511  if (display_list)
512  (*glDeleteBuffersARB_p)(1, (GLuint*) &display_list);
513  } else
514 #endif
515  if (display_list)
516  GFXDeleteList( display_list ); //delete dis
517  if (offsets)
518  delete[] offsets;
519  if (mode)
520  delete[] mode;
521  if (changed&HAS_COLOR) {
522  if (data.colors)
523  free( data.colors );
524  } else if (data.vertices) {
525  free( data.vertices );
526  }
527 }

Member Function Documentation

void GFXVertexList::BeginDrawState ( GFXBOOL  lock = GFXTRUE)
virtual

Specifies array pointers and loads the draw state of a given vlist for mass drawing.

Reimplemented in GFXSphereVertexList.

Definition at line 164 of file gfxlib_struct.cpp.

References BindBuf(), BindInd(), changed, clear_gl_error(), GFXVertexList::VDAT::colors, data, display_list, gl_options, glClientActiveTextureARB_p, glLockArraysEXT_p, HAS_COLOR, HAS_INDEX, gl_options_t::Multitexture, numVertices, print_gl_error(), GFXVertex::s, GFXColorVertex::s, GFXVertex::tx, GFXColorVertex::tx, vbo_data, and GFXVertexList::VDAT::vertices.

Referenced by PointStarVlist::BeginDrawState(), SpriteStarVlist::BeginDrawState(), GFXSphereVertexList::BeginDrawState(), Bolt::Draw(), DrawOnce(), Logo::ProcessDrawQueue(), and quadsquare::Render().

165 {
166  if (!numVertices)
167  return; //don't do anything if there are no vertices
168 
169 #ifndef NO_VBO_SUPPORT
170  if (vbo_data) {
171  clear_gl_error();
172 
173  BindBuf( vbo_data );
174  print_gl_error("VBO18.5a Error %d\n");
175 
176  if (changed&HAS_INDEX) {
178  print_gl_error("VBO18.5b Error %d\n");
179  }
180 
181  if (changed&HAS_COLOR) {
183  glClientActiveTextureARB_p( GL_TEXTURE0 );
184  glInterleavedArrays( GL_T2F_C4F_N3F_V3F, sizeof (GFXColorVertex), 0 );
185  if (gl_options.Multitexture) {
186  glClientActiveTextureARB_p( GL_TEXTURE1 );
187  glTexCoordPointer( 2, GL_FLOAT, sizeof (GFXColorVertex),
188  (void*) ( (char*) &data.colors[0].s-(char*) data.vertices ) );
189  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
190  glClientActiveTextureARB_p( GL_TEXTURE2 );
191  glTexCoordPointer( 4, GL_FLOAT, sizeof (GFXColorVertex),
192  (void*) ( (char*) &data.colors[0].tx-(char*) data.vertices ) );
193  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
194  glClientActiveTextureARB_p( GL_TEXTURE0 );
195  }
196  } else {
198  glClientActiveTextureARB_p( GL_TEXTURE0 );
199  glInterleavedArrays( GL_T2F_N3F_V3F, sizeof (GFXVertex), 0 );
200  if (gl_options.Multitexture) {
201  glClientActiveTextureARB_p( GL_TEXTURE1 );
202  glTexCoordPointer( 2, GL_FLOAT, sizeof (GFXVertex),
203  (void*) ( (char*) &data.vertices[0].s-(char*) data.vertices ) );
204  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
205  glClientActiveTextureARB_p( GL_TEXTURE2 );
206  glTexCoordPointer( 4, GL_FLOAT, sizeof (GFXVertex),
207  (void*) ( (char*) &data.vertices[0].tx-(char*) data.vertices ) );
208  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
209  glClientActiveTextureARB_p( GL_TEXTURE0 );
210  }
211  }
212  } else
213 #endif
214  if (display_list != 0) {} else {
215  if (changed&HAS_COLOR) {
217  glClientActiveTextureARB_p( GL_TEXTURE0 );
218  glInterleavedArrays( GL_T2F_C4F_N3F_V3F, sizeof (GFXColorVertex), &data.colors[0] );
219  if (gl_options.Multitexture) {
220  glClientActiveTextureARB_p( GL_TEXTURE1 );
221  glTexCoordPointer( 2, GL_FLOAT, sizeof (GFXColorVertex), &data.colors[0].s );
222  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
223  glClientActiveTextureARB_p( GL_TEXTURE2 );
224  glTexCoordPointer( 4, GL_FLOAT, sizeof (GFXColorVertex), &data.colors[0].tx );
225  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
226  glClientActiveTextureARB_p( GL_TEXTURE0 );
227  }
228  } else {
230  glClientActiveTextureARB_p( GL_TEXTURE0 );
231  glInterleavedArrays( GL_T2F_N3F_V3F, sizeof (GFXVertex), &data.vertices[0] );
232  if (gl_options.Multitexture) {
233  glClientActiveTextureARB_p( GL_TEXTURE1 );
234  glTexCoordPointer( 2, GL_FLOAT, sizeof (GFXVertex), &data.vertices[0].s );
235  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
236  glClientActiveTextureARB_p( GL_TEXTURE2 );
237  glTexCoordPointer( 4, GL_FLOAT, sizeof (GFXVertex), &data.vertices[0].tx );
238  glEnableClientState( GL_TEXTURE_COORD_ARRAY );
239  glClientActiveTextureARB_p( GL_TEXTURE0 );
240  }
241  }
242 #ifndef NO_COMPILEDVERTEXARRAY_SUPPORT
243  if (lock && glLockArraysEXT_p)
244  (*glLockArraysEXT_p)(0, numVertices);
245 #endif
246  }
247 }
union GFXVertexList::VDAT * GFXVertexList::BeginMutate ( int  offset)
virtual

Returns the array of vertices to be mutated.

Reimplemented in GFXSphereVertexList.

Definition at line 575 of file gfxlib_struct.cpp.

References Map().

Referenced by quadsquare::AddHeightMapAux(), PointStarVlist::BeginDrawState(), GFXSphereVertexList::ProceduralModification(), quadsquare::quadsquare(), quadsquare::RecomputeErrorAndLighting(), and quadsquare::Render().

576 {
577  return this->Map( false, true );
578 }
void GFXVertexList::ColIndVtxCopy ( GFXVertexList thus,
GFXVertex dst,
int  offset,
int  howmany 
)
staticprotected

Copies indexed colored vertices to dst vertex array.

Definition at line 320 of file gl_vertex_list.cpp.

References GFXVertexList::VDAT::colors, data, GetIndex(), GFXColorVertex::i, i, j, GFXColorVertex::j, GFXColorVertex::k, GFXColorVertex::s, GFXColorVertex::t, GFXColorVertex::tw, GFXColorVertex::tx, GFXColorVertex::ty, GFXColorVertex::tz, Vector, GFXColorVertex::x, GFXColorVertex::y, and GFXColorVertex::z.

Referenced by GetPolys().

321 {
322  for (int i = 0; i < howmany; i++) {
323  unsigned int j = thus->GetIndex( i+offset );
324  dst[i].
325  SetTexCoord( thus->data.colors[j].s, thus->data.colors[j].t ).
326  SetNormal( Vector( thus->data.colors[j].i, thus->data.colors[j].j, thus->data.colors[j].k ) ).
327  SetVertex( Vector( thus->data.colors[j].x, thus->data.colors[j].y, thus->data.colors[j].z ) ).
328  SetTangent( Vector( thus->data.colors[j].tx,
329  thus->data.colors[j].ty,
330  thus->data.colors[j].tz ), thus->data.colors[j].tw );
331  }
332 }
void GFXVertexList::ColVtxCopy ( GFXVertexList thus,
GFXVertex dst,
int  offset,
int  howmany 
)
staticprotected

Copies nonindex colored vertices to dst vertex array.

Definition at line 261 of file gl_vertex_list.cpp.

References GFXVertexList::VDAT::colors, data, GFXColorVertex::i, i, GFXColorVertex::j, GFXColorVertex::k, GFXColorVertex::s, GFXColorVertex::t, GFXColorVertex::tw, GFXColorVertex::tx, GFXColorVertex::ty, GFXColorVertex::tz, Vector, GFXColorVertex::x, GFXColorVertex::y, and GFXColorVertex::z.

Referenced by GetPolys().

262 {
263  for (int i = 0; i < howmany; i++)
264  dst[i].
265  SetTexCoord( thus->data.colors[i+offset].s, thus->data.colors[i+offset].t ).
266  SetNormal( Vector( thus->data.colors[i+offset].i, thus->data.colors[i+offset].j, thus->data.colors[i+offset].k ) ).
267  SetVertex( Vector( thus->data.colors[i+offset].x, thus->data.colors[i+offset].y, thus->data.colors[i+offset].z ) ).
268  SetTangent( Vector( thus->data.colors[i+offset].tx,
269  thus->data.colors[i+offset].ty,
270  thus->data.colors[i+offset].tz ), thus->data.colors[i+offset].tw );
271 }
void GFXVertexList::Draw ( enum POLYTYPE poly,
const INDEX  index,
const int  numLists,
const int offsets 
)
protectedvirtual

Reimplemented in GFXSphereVertexList.

Definition at line 312 of file gfxlib_struct.cpp.

References GFXVertexList::INDEX::b, BindInd(), changed, display_list, GFXBlendMode(), GFXCallList(), GFXDisable(), GFXEnable(), GFXGetBlendMode(), GFXLINE, GFXLINESTRIP, GFXPOINT, GFXPOLY, GFXPopBlendMode(), GFXPushBlendMode(), gl_batches_this_frame, gl_options, gl_vertices_this_frame, glMultiDrawArrays_p, glMultiDrawElements_p, HAS_INDEX, i, INDEX_BYTE, INDEX_SHORT, j, numlists, ONE, PolyLookup(), SMOOTH, gl_options_t::smooth_lines, gl_options_t::smooth_points, SRCALPHA, unique_mode, vbo_data, and ZERO.

Referenced by Bolt::Draw(), PointStarVlist::Draw(), SpriteStarVlist::Draw(), GFXSphereVertexList::Draw(), Logo::ProcessDrawQueue(), and quadsquare::Render().

313 {
314  //Hardware support for this seems... sketchy
315  if (vbo_data == 0 && display_list != 0) {
316  //Big issue: display lists cannot discriminate between lines/points/triangles,
317  //so, for now, we'll limit smoothing to single-mode GFXVertexLists, which, by the way,
318  //are the only ones being used, AFAIK.
319  bool blendchange = false;
320  if ( unique_mode && (numlists > 0) ) {
321  switch (*mode)
322  {
323  case GFXLINE:
324  case GFXLINESTRIP:
325  case GFXPOLY:
326  case GFXPOINT:
327  if ( ( (*mode == GFXPOINT)
329  BLENDFUNC src, dst;
330  GFXGetBlendMode( src, dst );
331  if ( (dst != ZERO) && ( (src == ONE) || (src == SRCALPHA) ) ) {
333  GFXBlendMode( SRCALPHA, dst );
334  GFXEnable( SMOOTH );
335  blendchange = true;
336  }
337  }
338  break;
339  default:
340  break;
341  }
342  }
344  if (blendchange) {
345  GFXPopBlendMode();
346  GFXDisable( SMOOTH );
347  }
348 
350  } else {
351  int totoffset = 0;
352  if (changed&HAS_INDEX) {
353  char stride = changed&HAS_INDEX;
354  GLenum indextype = (changed&INDEX_BYTE)
355  ? GL_UNSIGNED_BYTE
356  : ( (changed&INDEX_SHORT)
357  ? GL_UNSIGNED_SHORT
358  : GL_UNSIGNED_INT );
359  bool use_vbo = vbo_data != 0;
360  use_vbo = use_vbo && memcmp( &index, &this->index, sizeof (INDEX) ) == 0;
361  if (use_vbo) {
362  #ifndef NO_VBO_SUPPORT
364  #else
365  use_vbo = false;
366  #endif
367  } else {
368  #ifndef NO_VBO_SUPPORT
369  if (vbo_data)
370  BindInd( 0 );
371  #endif
372  }
373  if (glMultiDrawElements_p != NULL && numlists > 1) {
374  static std::vector< bool > drawn;
375  static std::vector< const GLvoid* >glindices;
376  static std::vector< GLsizei >glcounts;
377 
378  drawn.clear();
379  drawn.resize( numlists, false );
380  for (int i = 0; i < numlists; totoffset += offsets[i++])
381  if (!drawn[i]) {
382  glindices.clear();
383  glcounts.clear();
384  int totcount = 0;
385  for (int j = i, offs = totoffset; j < numlists; offs += offsets[j++]) {
386  totcount += offsets[j];
387  if ( !drawn[j] && (mode[j] == mode[i]) ) {
388  glindices.push_back( use_vbo ? (GLvoid*) (stride*offs)
389  : (GLvoid*) &index.b[stride*offs] );
390  glcounts.push_back( offsets[j] );
391  drawn[j] = true;
392  }
393  }
394  if (glindices.size() == 1)
395  glDrawElements( PolyLookup( mode[i] ), glcounts[0], indextype, glindices[0] );
396 
397  else
399  mode[i] ), &glcounts[0], indextype, &glindices[0], glindices.size() );
401  gl_vertices_this_frame += totcount;
402  }
403  } else {
404  for (int i = 0; i < numlists; i++) {
405  glDrawElements( PolyLookup( mode[i] ), offsets[i], indextype,
406  use_vbo ? (void*) (stride*totoffset)
407  : &index.b[stride*totoffset] ); //changed&INDEX_BYTE == stride!
408  totoffset += offsets[i];
411  }
412  }
413  } else {
414  if (glMultiDrawArrays_p) {
415  static std::vector< bool > drawn;
416  static std::vector< GLint > gloffsets;
417  static std::vector< GLsizei >glcounts;
418 
419  drawn.clear();
420  drawn.resize( numlists, false );
421  for (int i = 0; i < numlists; totoffset += offsets[i++])
422  if (!drawn[i]) {
423  gloffsets.clear();
424  glcounts.clear();
425  int totcount = 0;
426  for (int j = i, offs = totoffset; j < numlists; offs += offsets[j++]) {
427  totcount += offsets[j];
428  if ( !drawn[j] && (mode[j] == mode[i]) ) {
429  gloffsets.push_back( offs );
430  glcounts.push_back( offsets[j] );
431  drawn[j] = true;
432  }
433  }
434  bool blendchange = false;
435  switch (mode[i])
436  {
437  case GFXLINE:
438  case GFXLINESTRIP:
439  case GFXPOLY:
440  case GFXPOINT:
441  if ( ( (mode[i] == GFXPOINT)
442  && gl_options.smooth_points ) || ( (mode[i] != GFXPOINT) && gl_options.smooth_lines ) ) {
443  BLENDFUNC src, dst;
444  GFXGetBlendMode( src, dst );
445  if ( (dst != ZERO) && ( (src == ONE) || (src == SRCALPHA) ) ) {
447  GFXBlendMode( SRCALPHA, dst );
448  GFXEnable( SMOOTH );
449  blendchange = true;
450  }
451  }
452  break;
453  default:
454  break;
455  }
456  if (gloffsets.size() == 1)
457  glDrawArrays( PolyLookup( mode[i] ), gloffsets[0], glcounts[0] );
458 
459  else
460  glMultiDrawArrays_p( PolyLookup( mode[i] ), &gloffsets[0], &glcounts[0], gloffsets.size() );
461  if (blendchange) {
462  GFXPopBlendMode();
463  GFXDisable( SMOOTH );
464  }
466  gl_vertices_this_frame += totcount;
467  }
468  } else {
469  for (int i = 0; i < numlists; i++) {
470  bool blendchange = false;
471  switch (mode[i])
472  {
473  case GFXLINE:
474  case GFXLINESTRIP:
475  case GFXPOLY:
476  case GFXPOINT:
477  if ( ( (mode[i] == GFXPOINT)
478  && gl_options.smooth_points ) || ( (mode[i] != GFXPOINT) && gl_options.smooth_lines ) ) {
479  BLENDFUNC src, dst;
480  GFXGetBlendMode( src, dst );
481  if ( (dst != ZERO) && ( (src == ONE) || (src == SRCALPHA) ) ) {
483  GFXBlendMode( SRCALPHA, dst );
484  GFXEnable( SMOOTH );
485  blendchange = true;
486  }
487  }
488  break;
489  default:
490  break;
491  }
492  glDrawArrays( PolyLookup( mode[i] ), totoffset, offsets[i] );
493  totoffset += offsets[i];
494  if (blendchange) {
495  GFXPopBlendMode();
496  GFXDisable( SMOOTH );
497  }
500  }
501  }
502  }
503  }
504 }
void GFXVertexList::Draw ( )
virtual

Draws a single copy of the mass-loaded vlist.

Reimplemented in GFXSphereVertexList.

Definition at line 306 of file gfxlib_struct.cpp.

References index, mode, numlists, and offsets.

Referenced by Draw(), and DrawOnce().

307 {
309 }
void GFXVertexList::Draw ( enum POLYTYPE  poly,
int  numV 
)

Definition at line 264 of file gfxlib_struct.cpp.

References GFXVertexList::INDEX::b, Draw(), and index.

265 {
266  INDEX index;
267  index.b = NULL;
268  Draw( &poly, index, 1, &numV );
269 }
void GFXVertexList::Draw ( enum POLYTYPE  poly,
int  numV,
unsigned char *  index 
)

Definition at line 270 of file gfxlib_struct.cpp.

References GFXVertexList::INDEX::b, changed, Draw(), HAS_INDEX, and index.

271 {
272  char tmpchanged = changed;
273  changed = sizeof (unsigned char)|( (~HAS_INDEX)&changed );
274  INDEX tmp;
275  tmp.b = (index);
276  Draw( &poly, tmp, 1, &numV );
277  changed = tmpchanged;
278 }
void GFXVertexList::Draw ( enum POLYTYPE  poly,
int  numV,
unsigned short *  index 
)

Definition at line 279 of file gfxlib_struct.cpp.

References changed, Draw(), HAS_INDEX, index, and GFXVertexList::INDEX::s.

280 {
281  char tmpchanged = changed;
282  changed = sizeof (unsigned short)|( (~HAS_INDEX)&changed );
283  INDEX tmp;
284  tmp.s = (index);
285  Draw( &poly, tmp, 1, &numV );
286  changed = tmpchanged;
287 }
void GFXVertexList::Draw ( enum POLYTYPE  poly,
int  numV,
unsigned int index 
)

Definition at line 288 of file gfxlib_struct.cpp.

References changed, Draw(), HAS_INDEX, GFXVertexList::INDEX::i, index, and int.

289 {
290  char tmpchanged = changed;
291  changed = sizeof (unsigned int)|( (~HAS_INDEX)&changed );
292  INDEX tmp;
293  tmp.i = (index);
294  Draw( &poly, tmp, 1, &numV );
295  changed = tmpchanged;
296 }
void GFXVertexList::DrawOnce ( )

Loads draw state and prepares to draw only once.

Definition at line 298 of file gfxlib_struct.cpp.

References BeginDrawState(), Draw(), EndDrawState(), GFXFALSE, and LoadDrawState().

Referenced by Mesh::DrawNow(), and Beam::ProcessDrawQueue().

299 {
300  LoadDrawState();
302  Draw();
304 }
void GFXVertexList::EndDrawState ( GFXBOOL  lock = GFXTRUE)
virtual

Reimplemented in GFXSphereVertexList.

Definition at line 250 of file gfxlib_struct.cpp.

References changed, display_list, GFXColor4f(), glUnlockArraysEXT_p, HAS_COLOR, numVertices, and vbo_data.

Referenced by Bolt::Draw(), DrawOnce(), PointStarVlist::EndDrawState(), SpriteStarVlist::EndDrawState(), GFXSphereVertexList::EndDrawState(), Logo::ProcessDrawQueue(), and quadsquare::Render().

251 {
252  if (vbo_data) {} else if (display_list != 0) {} else {
253 #ifndef NO_COMPILEDVERTEXARRAY_SUPPORT
254  if (lock && glUnlockArraysEXT_p && numVertices)
255  (*glUnlockArraysEXT_p)();
256 #endif
257  }
258  if (changed&HAS_COLOR)
259  GFXColor4f( 1, 1, 1, 1 );
260 }
void GFXVertexList::EndMutate ( int  newsize = 0)
virtual

Ends mutation and refreshes display list.

Reimplemented in GFXSphereVertexList.

Definition at line 581 of file gfxlib_struct.cpp.

References CHANGE_CHANGE, CHANGE_MUTABLE, changed, numlists, numVertices, offsets, RefreshDisplayList(), RenormalizeNormals(), UnMap(), and vbo_data.

Referenced by quadsquare::AddHeightMapAux(), PointStarVlist::BeginDrawState(), GFXSphereVertexList::ProceduralModification(), quadsquare::quadsquare(), quadsquare::RecomputeErrorAndLighting(), and quadsquare::Render().

582 {
583  this->UnMap();
584  if ( !(changed&CHANGE_MUTABLE) )
586  if (newvertexsize) {
587  numVertices = newvertexsize;
588  //Must keep synchronized - we'll only permit changing vertex count on single-list objects
589  if (numlists == 1) *offsets = numVertices;
590  }
591  if (!vbo_data) {
594  } else {
596  }
598  changed &= (~CHANGE_CHANGE);
599 }
const GFXColorVertex * GFXVertexList::GetColorVertex ( int  index) const
protected

Definition at line 358 of file gl_vertex_list.cpp.

References GFXVertexList::VDAT::colors, data, and index.

359 {
360  return data.colors+index;
361 }
unsigned int GFXVertexList::GetIndex ( int  offset) const

Looks up the index in the appropriate short, char or int array.

Definition at line 311 of file gl_vertex_list.cpp.

References GFXVertexList::INDEX::b, changed, GFXVertexList::INDEX::i, index, int, and GFXVertexList::INDEX::s.

Referenced by ColIndVtxCopy(), IndVtxCopy(), and RefreshDisplayList().

312 {
313  return ( changed&sizeof (unsigned char) )
314  ? (unsigned int) (index.b[offset])
315  : ( ( changed&sizeof (unsigned short) )
316  ? (unsigned int) (index.s[offset])
317  : index.i[offset] );
318 }
int GFXVertexList::GetNumLists ( ) const

Definition at line 625 of file gfxlib_struct.cpp.

References numlists.

626 {
627  return numlists;
628 }
int GFXVertexList::GetNumVertices ( ) const
inline

Definition at line 611 of file gfxlib_struct.h.

References numVertices.

Referenced by PointStarVlist::BeginDrawState(), PointStarVlist::Draw(), and MeshAnimation::Init().

612  {
613  return numVertices;
614  }
int * GFXVertexList::GetOffsets ( ) const

Definition at line 620 of file gfxlib_struct.cpp.

References offsets.

621 {
622  return offsets;
623 }
void GFXVertexList::GetPolys ( GFXVertex **  vert,
int numPolys,
int numTris 
)
virtual

returns a packed vertex list with number of polys and number of tries to passed in arguments. Useful for getting vertex info from a mesh

Reimplemented in GFXSphereVertexList.

Definition at line 363 of file gl_vertex_list.cpp.

References changed, ColIndVtxCopy(), ColVtxCopy(), GFXPOLY, GFXQUAD, GFXQUADSTRIP, GFXTRI, GFXTRIFAN, GFXTRISTRIP, HAS_COLOR, HAS_INDEX, i, IndVtxCopy(), j, Map(), mode, numlists, numQuads(), numTris(), numVertices, offsets, UnMap(), and VtxCopy().

Referenced by Mesh::Fork(), Mesh::GetPolys(), and GFXSphereVertexList::GetPolys().

364 {
365  if (numVertices == 0) {
366  *numpolys = 0;
367  *numtris = 0;
368  *vert = 0;
369  return;
370  }
371  this->Map( true, false );
372  void (*vtxcpy)( GFXVertexList *thus, GFXVertex *dst, int offset, int howmany );
373  vtxcpy = (changed&HAS_COLOR)
374  ? ( (changed&HAS_INDEX)
375  ? ColIndVtxCopy
376  : ColVtxCopy )
377  : ( (changed&HAS_INDEX)
378  ? IndVtxCopy
379  : VtxCopy );
380  //int offst = (changed&HAS_COLOR)?sizeof(GFXColorVertex):sizeof(GFXVertex);
381  int i;
382  int cur = 0;
383  GFXVertex *res;
384  *numtris = numTris();
385  *numpolys = *numtris+numQuads();
386  int curtri = 0;
387  int curquad = 3*(*numtris);
388  res = (GFXVertex*) malloc( ( (*numtris)*3+4*( *numpolys-(*numtris) ) )*sizeof (GFXVertex) );
389  *vert = res;
390  for (i = 0; i < numlists; i++) {
391  int j;
392  switch (mode[i])
393  {
394  case GFXTRI:
395  (*vtxcpy)(this, &res[curtri], cur, offsets[i]);
396  curtri += offsets[i];
397  break;
398  case GFXTRIFAN:
399  case GFXPOLY:
400  for (j = 1; j < offsets[i]-1; j++) {
401  (*vtxcpy)(this, &res[curtri++], cur, 1);
402  (*vtxcpy)(this, &res[curtri++], (cur+j), 1);
403  (*vtxcpy)(this, &res[curtri++], (cur+j+1), 1);
404  }
405  break;
406  case GFXTRISTRIP:
407  for (j = 2; j < offsets[i]; j += 2) {
408  (*vtxcpy)(this, &res[curtri++], (cur+j-2), 1);
409  (*vtxcpy)(this, &res[curtri++], (cur+j-1), 1);
410  (*vtxcpy)(this, &res[curtri++], (cur+j), 1);
411  if (j+1 < offsets[i]) {
412  //copy reverse
413  (*vtxcpy)(this, &res[curtri++], (cur+j), 1);
414  (*vtxcpy)(this, &res[curtri++], (cur+j-1), 1);
415  (*vtxcpy)(this, &res[curtri++], (cur+j+1), 1);
416  }
417  }
418  break;
419  case GFXQUAD:
420  (*vtxcpy)(this, &res[curquad], (cur), offsets[i]);
421  curquad += offsets[i];
422  break;
423  case GFXQUADSTRIP:
424  for (j = 2; j < offsets[i]-1; j += 2) {
425  (*vtxcpy)(this, &res[curquad++], (cur+j-2), 1);
426  (*vtxcpy)(this, &res[curquad++], (cur+j-1), 1);
427  (*vtxcpy)(this, &res[curquad++], (cur+j+1), 1);
428  (*vtxcpy)(this, &res[curquad++], (cur+j), 1);
429  }
430  break;
431  default:
432  break;
433  }
434  cur += offsets[i];
435  }
436  this->UnMap();
437 }
POLYTYPE * GFXVertexList::GetPolyType ( ) const

Definition at line 615 of file gfxlib_struct.cpp.

References mode.

616 {
617  return mode;
618 }
const GFXVertex * GFXVertexList::GetVertex ( int  index) const
protected

Num vertices allocated.

Definition at line 353 of file gl_vertex_list.cpp.

References data, index, and GFXVertexList::VDAT::vertices.

354 {
355  return data.vertices+index;
356 }
bool GFXVertexList::hasColor ( ) const

Definition at line 348 of file gl_vertex_list.cpp.

References changed, and HAS_COLOR.

349 {
350  return (changed&HAS_COLOR) != 0;
351 }
void GFXVertexList::IndVtxCopy ( GFXVertexList thus,
GFXVertex dst,
int  offset,
int  howmany 
)
staticprotected

Copies indexed vertices to dst vertex array.

Definition at line 334 of file gl_vertex_list.cpp.

References data, GetIndex(), GFXVertex::i, i, GFXVertex::j, j, GFXVertex::k, GFXVertex::s, GFXVertex::t, GFXVertex::tw, GFXVertex::tx, GFXVertex::ty, GFXVertex::tz, Vector, GFXVertexList::VDAT::vertices, GFXVertex::x, GFXVertex::y, and GFXVertex::z.

Referenced by GetPolys().

335 {
336  for (int i = 0; i < howmany; i++) {
337  unsigned int j = thus->GetIndex( i+offset );
338  dst[i].
339  SetTexCoord( thus->data.vertices[j].s, thus->data.vertices[j].t ).
340  SetNormal( Vector( thus->data.vertices[j].i, thus->data.vertices[j].j, thus->data.vertices[j].k ) ).
341  SetVertex( Vector( thus->data.vertices[j].x, thus->data.vertices[j].y, thus->data.vertices[j].z ) ).
342  SetTangent( Vector( thus->data.vertices[j].tx,
343  thus->data.vertices[j].ty,
344  thus->data.vertices[j].tz ), thus->data.vertices[j].tw );
345  }
346 }
void GFXVertexList::Init ( enum POLYTYPE poly,
int  numVertices,
const GFXVertex vert,
const GFXColorVertex colors,
int  numlists,
int offsets,
bool  Mutable,
unsigned int indices 
)
protected

Init function (call from construtor)

Definition at line 99 of file gl_vertex_list.cpp.

References GFXVertexList::INDEX::b, CHANGE_CHANGE, CHANGE_MUTABLE, changed, colors, GFXVertexList::VDAT::colors, data, display_list, GFX_BUFFER_MAP_UNMAP, HAS_COLOR, i, GFXVertexList::INDEX::i, index, INDEX_BYTE, INDEX_INT, INDEX_SHORT, VsnetOSS::memcpy(), mode, numlists, numVertices, RefreshDisplayList(), RenormalizeNormals(), GFXVertexList::INDEX::s, sizeof(), unique_mode, vbo_data, GFXVertexList::VDAT::vertices, and VSFileSystem::vs_dprintf().

Referenced by GFXVertexList().

107 {
108  vbo_data = 0;
109 
110  int stride = 0;
111 
112  changed = HAS_COLOR*( (colors != NULL) ? 1 : 0 );
113  if (numlists > 0) {
114  mode = new POLYTYPE[numlists];
115  unique_mode = true;
116  POLYTYPE umode = *poly;
117  for (int pol = 0; pol < numlists; pol++) {
118  mode[pol] = poly[pol]; //PolyLookup (poly[pol]);
119  if ( unique_mode && (poly[pol] != umode) ) unique_mode = false;
120  }
121  } else {
122  mode = NULL;
123  unique_mode = false;
124  }
125  this->numlists = numlists;
126  this->numVertices = numVertices;
127  if (numVertices) {
128  if (vertices) {
129  if (!GFX_BUFFER_MAP_UNMAP) {
130  data.vertices = (GFXVertex*) malloc( sizeof (GFXVertex)*numVertices );
132  } else {
133  data.vertices = const_cast< GFXVertex* > (vertices); //will *not* modify
134  }
135  } else if (colors) {
136  if (!GFX_BUFFER_MAP_UNMAP) {
137  data.colors = (GFXColorVertex*) malloc( sizeof (GFXColorVertex)*numVertices );
139  } else {
140  data.colors = const_cast< GFXColorVertex* > (colors);
141  }
142  }
143  } else {
144  data.vertices = NULL;
145  data.colors = NULL;
146  }
147  this->offsets = new int[numlists];
148  memcpy( this->offsets, offsets, sizeof (int)*numlists );
149  int i;
150  unsigned int numindices = 0;
151  for (i = 0; i < numlists; i++)
152  numindices += offsets[i];
153  display_list = 0;
154  if (Mutable)
156  else
158  if (indices) {
159  stride = INDEX_BYTE;
160  if (numVertices > 255)
161  stride = INDEX_SHORT;
162  if (numVertices > 65535)
163  stride = INDEX_INT;
164 
165  index.b = (unsigned char*) malloc( stride*numindices );
166  switch (stride)
167  {
168  case INDEX_BYTE:
169  VSFileSystem::vs_dprintf(3, "Optimized vertex list - using 8-bit indices\n");
170  for (unsigned int i = 0; i < numindices; i++)
171  index.b[i] = indices[i];
172  break;
173  case INDEX_SHORT:
174  VSFileSystem::vs_dprintf(3, "Optimized vertex list - using 16-bit indices\n");
175  for (unsigned int i = 0; i < numindices; i++)
176  index.s[i] = indices[i];
177  break;
178  case INDEX_INT:
179  VSFileSystem::vs_dprintf(2, "Optimized vertex list - using 32-bit indices\n");
180  for (unsigned int i = 0; i < numindices; i++)
181  index.i[i] = indices[i];
182  break;
183  }
184  } else {
185  index.b = NULL;
186  }
187  changed |= stride;
190  if (GFX_BUFFER_MAP_UNMAP) {
191  if (!vbo_data) {
192  //backstore required
193  if (numVertices) {
194  if (vertices) {
195  data.vertices = (GFXVertex*) malloc( sizeof (GFXVertex)*numVertices );
197  } else if (colors) {
198  data.colors = (GFXColorVertex*) malloc( sizeof (GFXColorVertex)*numVertices );
200  }
201  }
202  } else {
203  if (index.b)
204  free( index.b );
205  index.b = NULL;
206  data.vertices = NULL;
207  data.colors = NULL;
208  }
209  }
210  if (Mutable)
211  changed |= CHANGE_MUTABLE; //for display lists
212  else
213  changed &= (~CHANGE_CHANGE);
214 }
void GFXVertexList::LoadDrawState ( )

Loads the draw state (what is active) of a given vlist for mass drawing.

Definition at line 439 of file gl_vertex_list.cpp.

Referenced by PointStarVlist::BeginDrawState(), SpriteStarVlist::BeginDrawState(), Bolt::Draw(), DrawOnce(), Logo::ProcessDrawQueue(), and quadsquare::Render().

440 {
441 }
GFXVertexList::VDAT * GFXVertexList::Map ( bool  read,
bool  write 
)
virtual

Definition at line 529 of file gfxlib_struct.cpp.

References GFXVertexList::INDEX::b, BindBuf(), BindInd(), changed, GFXVertexList::VDAT::colors, data, display_list, GFX_BUFFER_MAP_UNMAP, glMapBufferARB_p, HAS_COLOR, index, vbo_data, and GFXVertexList::VDAT::vertices.

Referenced by BeginMutate(), and GetPolys().

530 {
531 #ifndef NO_VBO_SUPPORT
533  if (vbo_data) {
534  if (display_list) {
536  index.b =
537  (unsigned char*) (*glMapBufferARB_p)(GL_ELEMENT_ARRAY_BUFFER_ARB,
538  read ? (write ? GL_READ_WRITE_ARB : GL_READ_ONLY_ARB)
539  : GL_WRITE_ONLY_ARB);
540  }
541  BindBuf( vbo_data );
542  void *ret =
543  (*glMapBufferARB_p)(GL_ARRAY_BUFFER_ARB,
544  read ? (write ? GL_READ_WRITE_ARB : GL_READ_ONLY_ARB) : GL_WRITE_ONLY_ARB);
545  if (changed&HAS_COLOR)
546  data.colors = (GFXColorVertex*) ret;
547  else
548  data.vertices = (GFXVertex*) ret;
549  }
550 
551 #endif
552 
553 
554  return &data;
555 }
int GFXVertexList::numQuads ( ) const
virtual

Returns number of Quads in vertex list (counts quad strips)

Definition at line 237 of file gl_vertex_list.cpp.

References GFXQUAD, GFXQUADSTRIP, i, mode, numlists, and offsets.

Referenced by GetPolys().

238 {
239  int tot = 0;
240  for (int i = 0; i < numlists; i++) {
241  switch (mode[i])
242  {
243  case GFXQUAD:
244  tot += offsets[i]/4;
245  break;
246  case GFXQUADSTRIP:
247  tot += (offsets[i]-2)/2;
248  break;
249  default:
250  break;
251  }
252  }
253  return tot;
254 }
int GFXVertexList::numTris ( ) const
virtual

Returns number of Triangles in vertex list (counts tri strips)

Definition at line 216 of file gl_vertex_list.cpp.

References GFXPOLY, GFXTRI, GFXTRIFAN, GFXTRISTRIP, i, mode, numlists, and offsets.

Referenced by GetPolys(), and GFXSphereVertexList::GetPolys().

217 {
218  int tot = 0;
219  for (int i = 0; i < numlists; i++) {
220  switch (mode[i])
221  {
222  case GFXTRI:
223  tot += offsets[i]/3;
224  break;
225  case GFXTRISTRIP:
226  case GFXTRIFAN:
227  case GFXPOLY:
228  tot += offsets[i]-2;
229  break;
230  default:
231  break;
232  }
233  }
234  return tot;
235 }
void GFXVertexList::RefreshDisplayList ( )

Propagates modifications to the display list.

Definition at line 72 of file gfxlib_struct.cpp.

References a, GFXVertexList::INDEX::b, BindBuf(), BindInd(), CHANGE_CHANGE, CHANGE_MUTABLE, changed, GFXVertexList::VDAT::colors, data, display_list, gl_options_t::display_lists, GetIndex(), GFXCreateList(), GFXDeleteList(), GFXEndList(), GFXTexCoord224f(), gl_options, glBindBufferARB_p, glBufferDataARB_p, glGenBuffersARB_p, glMapBufferARB_p, glUnmapBufferARB_p, HAS_COLOR, HAS_INDEX, GFXVertex::i, GFXColorVertex::i, i, index, INDEX_BYTE, INDEX_SHORT, int, mode, numlists, numVertices, offsets, PolyLookup(), GFXColorVertex::r, GFXVertex::s, GFXColorVertex::s, GFXVertex::t, GFXColorVertex::t, GFXVertex::tw, GFXColorVertex::tw, GFXVertex::tx, GFXColorVertex::tx, GFXVertex::ty, GFXColorVertex::ty, GFXVertex::tz, GFXColorVertex::tz, vs_options::vbo, vbo_data, GFXVertexList::VDAT::vertices, GFXVertex::x, and GFXColorVertex::x.

Referenced by EndMutate(), and Init().

73 {
74 #ifndef NO_VBO_SUPPORT
75  if (game_options.vbo && !vbo_data) {
77  || glUnmapBufferARB_p == 0) {
78  game_options.vbo = 0;
79  } else {
80  (*glGenBuffersARB_p)(1, (GLuint*) &vbo_data);
81  if (changed&HAS_INDEX)
82  (*glGenBuffersARB_p)(1, (GLuint*) &display_list);
83  }
84  }
85  if (vbo_data) {
86  BindBuf( vbo_data );
87  (*glBufferDataARB_p)(GL_ARRAY_BUFFER_ARB, numVertices
88  *( (changed&HAS_COLOR) ? sizeof (GFXColorVertex) : sizeof (GFXVertex) ), data.vertices,
89  (changed&CHANGE_MUTABLE) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB);
90  if (changed&HAS_INDEX) {
92  unsigned int tot = 0;
93  for (int i = 0; i < numlists; ++i)
94  tot += offsets[i];
95  unsigned int indexsize = (changed&INDEX_BYTE)
96  ? sizeof (char)
97  : ( (changed&INDEX_SHORT)
98  ? sizeof (unsigned short)
99  : sizeof (unsigned int) );
100  (*glBufferDataARB_p)(GL_ELEMENT_ARRAY_BUFFER_ARB, tot*indexsize, &index.b[0],
101  (changed&CHANGE_MUTABLE) ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB);
102  }
103  return;
104  }
105 #endif
107  return; //don't used lists if they're mutable
108  if (display_list)
110  int a;
111  int offset = 0;
113  if (changed&HAS_COLOR) {
114  for (int i = 0; i < numlists; i++) {
115  glBegin( PolyLookup( mode[i] ) );
116  if (changed&HAS_INDEX) {
117  for (a = 0; a < offsets[i]; a++) {
118  const GFXColorVertex &vtx = data.colors[GetIndex( offset+a )];
119  GFXTexCoord224f( vtx.s, vtx.t, vtx.s, vtx.t, vtx.tx, vtx.ty, vtx.tz, vtx.tw );
120  glColor4fv( &vtx.r );
121  glNormal3fv( &vtx.i );
122  glVertex3fv( &vtx.x );
123  }
124  } else {
125  for (a = 0; a < offsets[i]; a++) {
126  const GFXColorVertex &vtx = data.colors[offset+a];
127  GFXTexCoord224f( vtx.s, vtx.t, vtx.s, vtx.t, vtx.tx, vtx.ty, vtx.tz, vtx.tw );
128  glColor4fv( &vtx.r );
129  glNormal3fv( &vtx.i );
130  glVertex3fv( &vtx.x );
131  }
132  }
133  offset += offsets[i];
134  glEnd();
135  }
136  } else {
137  for (int i = 0; i < numlists; i++) {
138  glBegin( PolyLookup( mode[i] ) );
139  if (changed&HAS_INDEX) {
140  for (a = 0; a < offsets[i]; a++) {
141  const GFXVertex &vtx = data.vertices[GetIndex( offset+a )];
142  glNormal3fv( &vtx.i );
143  GFXTexCoord224f( vtx.s, vtx.t, vtx.s, vtx.t, vtx.tx, vtx.ty, vtx.tz, vtx.tw );
144  glVertex3fv( &vtx.x );
145  }
146  } else {
147  for (a = 0; a < offsets[i]; a++) {
148  const GFXVertex &vtx = data.vertices[offset+a];
149  glNormal3fv( &vtx.i );
150  GFXTexCoord224f( vtx.s, vtx.t, vtx.s, vtx.t, vtx.tx, vtx.ty, vtx.tz, vtx.tw );
151  glVertex3fv( &vtx.x );
152  }
153  }
154  offset += offsets[i];
155  glEnd();
156  }
157  }
158  if ( !GFXEndList() ) {
160  display_list = 0;
161  }
162 }
void GFXVertexList::RenormalizeNormals ( )
protected

Definition at line 273 of file gl_vertex_list.cpp.

References changed, GFXVertexList::VDAT::colors, data, GFXVertex::GetNormal(), GFXColorVertex::GetNormal(), GFX_SCALE, HAS_COLOR, GFXVertex::i, GFXColorVertex::i, i, GFXVertex::j, GFXColorVertex::j, GFXVertex::k, GFXColorVertex::k, numVertices, GFXVertex::SetNormal(), GFXColorVertex::SetNormal(), Vector, and GFXVertexList::VDAT::vertices.

Referenced by EndMutate(), and Init().

274 {
275  if (data.colors == 0 && data.vertices == 0)
276  return; //
277  if (numVertices > 0) {
278  Vector firstNormal;
279  if (changed&HAS_COLOR)
280  firstNormal = data.colors[0].GetNormal();
281  else
282  firstNormal = data.vertices[0].GetNormal();
283  float mag = firstNormal.Magnitude();
284  if (mag > GFX_SCALE/1.5 && mag < GFX_SCALE*1.5)
285  return;
286  if (mag < GFX_SCALE/100 && mag < .00001)
287  firstNormal.Set( 1, 0, 0 );
288  firstNormal.Normalize();
289  if (changed&HAS_COLOR)
290  data.colors[0].SetNormal( firstNormal );
291  else
292  data.vertices[0].SetNormal( firstNormal );
293  if (changed&HAS_COLOR) {
294  for (int i = 0; i < numVertices; i++) {
295  //data.colors[i].SetNormal(data.colors[i].GetNormal().Normalize());
296  data.colors[i].i *= GFX_SCALE;
297  data.colors[i].j *= GFX_SCALE;
298  data.colors[i].k *= GFX_SCALE;
299  }
300  } else {
301  for (int i = 0; i < numVertices; i++) {
302  //data.vertices[i].SetNormal(data.vertices[i].GetNormal().Normalize());
303  data.vertices[i].i *= GFX_SCALE;
304  data.vertices[i].j *= GFX_SCALE;
305  data.vertices[i].k *= GFX_SCALE;
306  }
307  }
308  }
309 }
void GFXVertexList::UnMap ( )

Definition at line 556 of file gfxlib_struct.cpp.

References BindBuf(), BindInd(), GFXVertexList::VDAT::colors, data, display_list, GFX_BUFFER_MAP_UNMAP, vbo_data, and GFXVertexList::VDAT::vertices.

Referenced by EndMutate(), and GetPolys().

557 {
558 #ifndef NO_VBO_SUPPORT
560  if (vbo_data) {
561  if (display_list) {
563  (*glUnmapBufferARB_p)(GL_ELEMENT_ARRAY_BUFFER_ARB);
564  }
565  BindBuf( vbo_data );
566  (*glUnmapBufferARB_p)(GL_ARRAY_BUFFER_ARB);
567  data.colors = NULL;
568  data.vertices = NULL;
569  }
570 
571 #endif
572 
573 }
void GFXVertexList::VtxCopy ( GFXVertexList thus,
GFXVertex dst,
int  offset,
int  howmany 
)
staticprotected

copies nonindexed vertices to dst vertex array

Definition at line 256 of file gl_vertex_list.cpp.

References data, VsnetOSS::memcpy(), sizeof(), and GFXVertexList::VDAT::vertices.

Referenced by GetPolys().

257 {
258  memcpy( dst, &thus->data.vertices[offset], sizeof (GFXVertex)*howmany );
259 }

Friends And Related Function Documentation

friend class GFXSphereVertexList
friend

Definition at line 493 of file gfxlib_struct.h.

Member Data Documentation

char GFXVertexList::changed
protected

If vertex list has been mutated since last draw. Low 3 bits store the stride of the index list (if avail). another bit for if color is presnet.

Definition at line 531 of file gfxlib_struct.h.

Referenced by BeginDrawState(), Draw(), EndDrawState(), EndMutate(), GetIndex(), GetPolys(), hasColor(), Init(), Map(), RefreshDisplayList(), RenormalizeNormals(), and ~GFXVertexList().

int GFXVertexList::display_list
protected
enum POLYTYPE* GFXVertexList::mode
protected
int GFXVertexList::numlists
protected
int* GFXVertexList::offsets
protected

number of vertices in each individual mode. 2 triangles 3 quads and 2 lines would be {6,12,4} as the offsets

Definition at line 529 of file gfxlib_struct.h.

Referenced by Draw(), EndMutate(), GetOffsets(), GetPolys(), GFXSphereVertexList::GFXSphereVertexList(), numQuads(), numTris(), RefreshDisplayList(), GFXSphereVertexList::~GFXSphereVertexList(), and ~GFXVertexList().

bool GFXVertexList::unique_mode
protected

Definition at line 519 of file gfxlib_struct.h.

Referenced by Draw(), and Init().


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