Update of /cvsroot/plib/plib/src/ssg
In directory usw-pr-cvs1:/tmp/cvs-serv24269
Modified Files:
ssgVtxTable.cxx
Log Message:
Changed ssgVtxTable to use vertex arrays.
Index: ssgVtxTable.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgVtxTable.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- ssgVtxTable.cxx 25 Jan 2002 16:28:00 -0000 1.27
+++ ssgVtxTable.cxx 27 Mar 2002 13:51:20 -0000 1.28
@@ -489,32 +489,41 @@
void ssgVtxTable::draw_geometry ()
{
+ int num_vertices = getNumVertices () ;
int num_colours = getNumColours () ;
int num_normals = getNumNormals () ;
- int num_vertices = getNumVertices () ;
int num_texcoords = getNumTexCoords () ;
- sgVec3 *vx = (sgVec3 *) vertices -> get(0) ;
- sgVec3 *nm = (sgVec3 *) normals -> get(0) ;
- sgVec2 *tx = (sgVec2 *) texcoords -> get(0) ;
- sgVec4 *cl = (sgVec4 *) colours -> get(0) ;
-
- glBegin ( gltype ) ;
-
if ( num_colours == 0 ) glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ;
- if ( num_colours == 1 ) glColor4fv ( cl [ 0 ] ) ;
- if ( num_normals == 1 ) glNormal3fv ( nm [ 0 ] ) ;
+ if ( num_colours == 1 ) glColor4fv ( colours -> get(0) ) ;
+ if ( num_normals == 1 ) glNormal3fv ( normals -> get(0) ) ;
- for ( int i = 0 ; i < num_vertices ; i++ )
+ glPushClientAttrib ( GL_CLIENT_VERTEX_ARRAY_BIT ) ;
+
+ if ( num_colours > 1 )
{
- if ( num_colours > 1 ) glColor4fv ( cl [ i ] ) ;
- if ( num_normals > 1 ) glNormal3fv ( nm [ i ] ) ;
- if ( num_texcoords > 1 ) glTexCoord2fv ( tx [ i ] ) ;
+ glEnableClientState ( GL_COLOR_ARRAY ) ;
+ glColorPointer ( 4, GL_FLOAT, 0, colours->get(0) ) ;
+ }
- glVertex3fv ( vx [ i ] ) ;
+ if ( num_normals > 1 )
+ {
+ glEnableClientState ( GL_NORMAL_ARRAY ) ;
+ glNormalPointer ( GL_FLOAT, 0, normals->get(0) ) ;
}
- glEnd () ;
+ if ( num_texcoords > 1 )
+ {
+ glEnableClientState ( GL_TEXTURE_COORD_ARRAY ) ;
+ glTexCoordPointer ( 2, GL_FLOAT, 0, texcoords->get(0) ) ;
+ }
+
+ glEnableClientState ( GL_VERTEX_ARRAY ) ;
+ glVertexPointer ( 3, GL_FLOAT, 0, vertices->get(0) ) ;
+
+ glDrawArrays ( gltype, 0, num_vertices ) ;
+
+ glPopClientAttrib () ;
}
|