]> git.mxchange.org Git - flightgear.git/commitdiff
Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate
authorcurt <curt>
Thu, 20 Aug 1998 15:12:03 +0000 (15:12 +0000)
committercurt <curt>
Thu, 20 Aug 1998 15:12:03 +0000 (15:12 +0000)
the need for "void" pointers and casts.
Quick hack to count the number of scenery polygons that are being drawn.

Scenery/obj.cxx
Scenery/texload.c
Scenery/tile.cxx
Scenery/tile.hxx
Scenery/tilemgr.cxx

index 5f7ba36a15f2c93ef2a6f8e160b1e0805b0fe586..60fbea0b575dd4108d93456f16e8a973d66fd8eb 100644 (file)
@@ -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<string> > :: 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
index 034c1f3ff216311029ff7c18ba2447d67a4fc77c..c3e62c1ecc8cc298253a91f4bc6bc1b3aa961412 100644 (file)
@@ -3,6 +3,14 @@
 
 /* texload is a simplistic routine for reading an SGI .rgb image file. */
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#  include <windows.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h> 
 #include <string.h>
index 0af9089b5e8b2a96f5811dc33db7c7d5dc60222d..b5a87245f3d14d46b9c57b64d843ed92ff09657b 100644 (file)
@@ -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
index 516997ad219cd13cf27886381f2d8e5674b62932..455316c4bcac5f2117a730972bf5dab980e791c8 100644 (file)
@@ -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
index 7d5d82ea5227cd99873f7285be922cf39a1e9658..3f715114c4946e4e465131f1c5da3f5a0f6ad787 100644 (file)
@@ -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