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.
This commit is contained in:
parent
f1b0e32e37
commit
5f1fd50f6a
5 changed files with 49 additions and 8 deletions
|
@ -221,7 +221,7 @@ int fgObjLoad(char *path, fgTILE *t) {
|
||||||
sscanf(line, "usemtl %s\n", material);
|
sscanf(line, "usemtl %s\n", material);
|
||||||
|
|
||||||
// give the fragment a pointer back to the tile
|
// 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
|
// find this material in the properties list
|
||||||
map < string, fgMATERIAL, less<string> > :: iterator myfind =
|
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",
|
"Ack! unknown usemtl name = %s in %s\n",
|
||||||
material, path);
|
material, path);
|
||||||
} else {
|
} else {
|
||||||
fragment.material_ptr = (void *)(&(*myfind).second);
|
fragment.material_ptr = &(*myfind).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the fragment transformation matrix
|
// initialize the fragment transformation matrix
|
||||||
|
@ -490,6 +490,11 @@ int fgObjLoad(char *path, fgTILE *t) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $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
|
// Revision 1.21 1998/08/12 21:13:04 curt
|
||||||
// material.cxx: don't load textures if they are disabled
|
// material.cxx: don't load textures if they are disabled
|
||||||
// obj.cxx: optimizations from Norman Vine
|
// obj.cxx: optimizations from Norman Vine
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
|
|
||||||
/* texload is a simplistic routine for reading an SGI .rgb image file. */
|
/* 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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -178,7 +178,7 @@ int fgFRAGMENT::intersect( fgPoint3d *end0, fgPoint3d *end1, int side_flag,
|
||||||
list < fgFACE > :: iterator last;
|
list < fgFACE > :: iterator last;
|
||||||
|
|
||||||
// find the associated tile
|
// find the associated tile
|
||||||
t = (fgTILE *)tile_ptr;
|
t = tile_ptr;
|
||||||
|
|
||||||
// printf("Intersecting\n");
|
// printf("Intersecting\n");
|
||||||
|
|
||||||
|
@ -448,6 +448,11 @@ fgTILE::~fgTILE ( void ) {
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $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
|
// Revision 1.6 1998/08/12 21:13:05 curt
|
||||||
// material.cxx: don't load textures if they are disabled
|
// material.cxx: don't load textures if they are disabled
|
||||||
// obj.cxx: optimizations from Norman Vine
|
// obj.cxx: optimizations from Norman Vine
|
||||||
|
|
|
@ -61,6 +61,11 @@ using namespace std;
|
||||||
#define MAX_NODES 1000
|
#define MAX_NODES 1000
|
||||||
|
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class fgTILE;
|
||||||
|
class fgMATERIAL;
|
||||||
|
|
||||||
|
|
||||||
class fgFACE {
|
class fgFACE {
|
||||||
public:
|
public:
|
||||||
int n1, n2, n3;
|
int n1, n2, n3;
|
||||||
|
@ -92,10 +97,10 @@ public:
|
||||||
// material property this fragment is assigned to.
|
// material property this fragment is assigned to.
|
||||||
|
|
||||||
// material property pointer
|
// material property pointer
|
||||||
void *material_ptr;
|
fgMATERIAL *material_ptr;
|
||||||
|
|
||||||
// tile pointer
|
// tile pointer
|
||||||
void *tile_ptr;
|
fgTILE *tile_ptr;
|
||||||
|
|
||||||
// OpenGL display list for fragment data
|
// OpenGL display list for fragment data
|
||||||
GLint display_list;
|
GLint display_list;
|
||||||
|
@ -166,6 +171,11 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $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
|
// Revision 1.14 1998/08/12 21:13:06 curt
|
||||||
// material.cxx: don't load textures if they are disabled
|
// material.cxx: don't load textures if they are disabled
|
||||||
// obj.cxx: optimizations from Norman Vine
|
// obj.cxx: optimizations from Norman Vine
|
||||||
|
|
|
@ -343,6 +343,7 @@ void fgTileMgrRender( void ) {
|
||||||
int index;
|
int index;
|
||||||
int culled = 0;
|
int culled = 0;
|
||||||
int drawn = 0;
|
int drawn = 0;
|
||||||
|
int total_faces = 0;
|
||||||
|
|
||||||
c = &global_tile_cache;
|
c = &global_tile_cache;
|
||||||
f = current_aircraft.flight;
|
f = current_aircraft.flight;
|
||||||
|
@ -467,7 +468,7 @@ void fgTileMgrRender( void ) {
|
||||||
// frag_ptr->tile_offset.y = t->offset.y;
|
// frag_ptr->tile_offset.y = t->offset.y;
|
||||||
// frag_ptr->tile_offset.z = t->offset.z;
|
// 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);
|
// printf(" lookup = %s\n", mtl_ptr->texture_name);
|
||||||
if ( mtl_ptr->list_size < FG_MAX_MATERIAL_FRAGS ) {
|
if ( mtl_ptr->list_size < FG_MAX_MATERIAL_FRAGS ) {
|
||||||
mtl_ptr->list[mtl_ptr->list_size] = frag_ptr;
|
mtl_ptr->list[mtl_ptr->list_size] = frag_ptr;
|
||||||
|
@ -539,12 +540,16 @@ void fgTileMgrRender( void ) {
|
||||||
for ( i = 0; i < size; i++ ) {
|
for ( i = 0; i < size; i++ ) {
|
||||||
frag_ptr = mtl_ptr->list[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 ) {
|
if ( frag_ptr->tile_ptr == last_tile_ptr ) {
|
||||||
// same tile as last time, no transform necessary
|
// same tile as last time, no transform necessary
|
||||||
} else {
|
} else {
|
||||||
// new tile, new translate
|
// new tile, new translate
|
||||||
// xglLoadMatrixf( frag_ptr->matrix );
|
// xglLoadMatrixf( frag_ptr->matrix );
|
||||||
t = (fgTILE *)(frag_ptr->tile_ptr);
|
t = frag_ptr->tile_ptr;
|
||||||
xglLoadMatrixd(t->model_view );
|
xglLoadMatrixd(t->model_view );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +557,7 @@ void fgTileMgrRender( void ) {
|
||||||
// printf(" display_list = %d\n", frag_ptr->display_list);
|
// printf(" display_list = %d\n", frag_ptr->display_list);
|
||||||
xglCallList(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();
|
xglPopMatrix();
|
||||||
|
|
||||||
|
fgPrintf( FG_TERRAIN, FG_DEBUG, "Rendered %d polygons this frame.\n",
|
||||||
|
total_faces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// $Log$
|
// $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
|
// Revision 1.28 1998/08/12 21:13:06 curt
|
||||||
// material.cxx: don't load textures if they are disabled
|
// material.cxx: don't load textures if they are disabled
|
||||||
// obj.cxx: optimizations from Norman Vine
|
// obj.cxx: optimizations from Norman Vine
|
||||||
|
|
Loading…
Add table
Reference in a new issue