From 5f1fd50f6aa1505ed1ded834cef92131c42a53a4 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 20 Aug 1998 15:12:03 +0000 Subject: [PATCH] Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate the need for "void" pointers and casts. Quick hack to count the number of scenery polygons that are being drawn. --- Scenery/obj.cxx | 9 +++++++-- Scenery/texload.c | 8 ++++++++ Scenery/tile.cxx | 7 ++++++- Scenery/tile.hxx | 14 ++++++++++++-- Scenery/tilemgr.cxx | 19 ++++++++++++++++--- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/Scenery/obj.cxx b/Scenery/obj.cxx index 5f7ba36a1..60fbea0b5 100644 --- a/Scenery/obj.cxx +++ b/Scenery/obj.cxx @@ -221,7 +221,7 @@ int fgObjLoad(char *path, fgTILE *t) { sscanf(line, "usemtl %s\n", material); // give the fragment a pointer back to the tile - (fgTILE *)(fragment.tile_ptr) = t; + fragment.tile_ptr = t; // find this material in the properties list map < string, fgMATERIAL, less > :: iterator myfind = @@ -231,7 +231,7 @@ int fgObjLoad(char *path, fgTILE *t) { "Ack! unknown usemtl name = %s in %s\n", material, path); } else { - fragment.material_ptr = (void *)(&(*myfind).second); + fragment.material_ptr = &(*myfind).second; } // initialize the fragment transformation matrix @@ -490,6 +490,11 @@ int fgObjLoad(char *path, fgTILE *t) { // $Log$ +// Revision 1.22 1998/08/20 15:12:03 curt +// Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate +// the need for "void" pointers and casts. +// Quick hack to count the number of scenery polygons that are being drawn. +// // Revision 1.21 1998/08/12 21:13:04 curt // material.cxx: don't load textures if they are disabled // obj.cxx: optimizations from Norman Vine diff --git a/Scenery/texload.c b/Scenery/texload.c index 034c1f3ff..c3e62c1ec 100644 --- a/Scenery/texload.c +++ b/Scenery/texload.c @@ -3,6 +3,14 @@ /* texload is a simplistic routine for reading an SGI .rgb image file. */ +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef HAVE_WINDOWS_H +# include +#endif + #include #include #include diff --git a/Scenery/tile.cxx b/Scenery/tile.cxx index 0af9089b5..b5a87245f 100644 --- a/Scenery/tile.cxx +++ b/Scenery/tile.cxx @@ -178,7 +178,7 @@ int fgFRAGMENT::intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag, list < fgFACE > :: iterator last; // find the associated tile - t = (fgTILE *)tile_ptr; + t = tile_ptr; // printf("Intersecting\n"); @@ -448,6 +448,11 @@ fgTILE::~fgTILE ( void ) { // $Log$ +// Revision 1.7 1998/08/20 15:12:05 curt +// Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate +// the need for "void" pointers and casts. +// Quick hack to count the number of scenery polygons that are being drawn. +// // Revision 1.6 1998/08/12 21:13:05 curt // material.cxx: don't load textures if they are disabled // obj.cxx: optimizations from Norman Vine diff --git a/Scenery/tile.hxx b/Scenery/tile.hxx index 516997ad2..455316c4b 100644 --- a/Scenery/tile.hxx +++ b/Scenery/tile.hxx @@ -61,6 +61,11 @@ using namespace std; #define MAX_NODES 1000 +// Forward declarations +class fgTILE; +class fgMATERIAL; + + class fgFACE { public: int n1, n2, n3; @@ -92,10 +97,10 @@ public: // material property this fragment is assigned to. // material property pointer - void *material_ptr; + fgMATERIAL *material_ptr; // tile pointer - void *tile_ptr; + fgTILE *tile_ptr; // OpenGL display list for fragment data GLint display_list; @@ -166,6 +171,11 @@ public: // $Log$ +// Revision 1.15 1998/08/20 15:12:06 curt +// Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate +// the need for "void" pointers and casts. +// Quick hack to count the number of scenery polygons that are being drawn. +// // Revision 1.14 1998/08/12 21:13:06 curt // material.cxx: don't load textures if they are disabled // obj.cxx: optimizations from Norman Vine diff --git a/Scenery/tilemgr.cxx b/Scenery/tilemgr.cxx index 7d5d82ea5..3f715114c 100644 --- a/Scenery/tilemgr.cxx +++ b/Scenery/tilemgr.cxx @@ -343,6 +343,7 @@ void fgTileMgrRender( void ) { int index; int culled = 0; int drawn = 0; + int total_faces = 0; c = &global_tile_cache; f = current_aircraft.flight; @@ -467,7 +468,7 @@ void fgTileMgrRender( void ) { // frag_ptr->tile_offset.y = t->offset.y; // frag_ptr->tile_offset.z = t->offset.z; - mtl_ptr = (fgMATERIAL *)(frag_ptr->material_ptr); + mtl_ptr = frag_ptr->material_ptr; // printf(" lookup = %s\n", mtl_ptr->texture_name); if ( mtl_ptr->list_size < FG_MAX_MATERIAL_FRAGS ) { mtl_ptr->list[mtl_ptr->list_size] = frag_ptr; @@ -539,12 +540,16 @@ void fgTileMgrRender( void ) { for ( i = 0; i < size; i++ ) { frag_ptr = mtl_ptr->list[i]; + // count up the number of polygons we are drawing in + // case someone is interested. + total_faces += frag_ptr->num_faces; + if ( frag_ptr->tile_ptr == last_tile_ptr ) { // same tile as last time, no transform necessary } else { // new tile, new translate // xglLoadMatrixf( frag_ptr->matrix ); - t = (fgTILE *)(frag_ptr->tile_ptr); + t = frag_ptr->tile_ptr; xglLoadMatrixd(t->model_view ); } @@ -552,7 +557,7 @@ void fgTileMgrRender( void ) { // printf(" display_list = %d\n", frag_ptr->display_list); xglCallList(frag_ptr->display_list); - last_tile_ptr = (fgTILE *)(frag_ptr->tile_ptr); + last_tile_ptr = frag_ptr->tile_ptr; } } @@ -560,10 +565,18 @@ void fgTileMgrRender( void ) { } xglPopMatrix(); + + fgPrintf( FG_TERRAIN, FG_DEBUG, "Rendered %d polygons this frame.\n", + total_faces); } // $Log$ +// Revision 1.29 1998/08/20 15:12:06 curt +// Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate +// the need for "void" pointers and casts. +// Quick hack to count the number of scenery polygons that are being drawn. +// // Revision 1.28 1998/08/12 21:13:06 curt // material.cxx: don't load textures if they are disabled // obj.cxx: optimizations from Norman Vine -- 2.39.2