From 156f35932bda5869652f366867583613a6780e65 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 27 Jan 1998 03:26:41 +0000 Subject: [PATCH] Playing with new fgPrintf command. --- Scenery/bucketutils.c | 24 ++++++++++++-------- Scenery/obj.c | 53 ++++++++++++++++++++++++------------------- Scenery/scenery.c | 15 +++++++----- Scenery/tilecache.c | 16 ++++++++----- Scenery/tilemgr.c | 24 ++++++++++++-------- 5 files changed, 78 insertions(+), 54 deletions(-) diff --git a/Scenery/bucketutils.c b/Scenery/bucketutils.c index af03c9348..2453d256f 100644 --- a/Scenery/bucketutils.c +++ b/Scenery/bucketutils.c @@ -27,8 +27,9 @@ #include #include -#include #include +#include
+#include /* Generate the unique scenery tile index containing the specified @@ -199,8 +200,9 @@ void fgBucketFind(double lon, double lat, struct fgBUCKET *p) { p->x = (lon - p->lon) * 8; p->y = (lat - p->lat) * 8; - printf("Bucket = lon,lat = %d,%d x,y index = %d,%d\n", - p->lon, p->lat, p->x, p->y); + fgPrintf( FG_TERRAIN, FG_DEBUG, + "Bucket = lon,lat = %d,%d x,y index = %d,%d\n", + p->lon, p->lat, p->x, p->y); } @@ -216,9 +218,10 @@ void fgBucketGenIdxArray(struct fgBUCKET *p1, struct fgBUCKET *tiles, for ( i = 0; i < width; i++ ) { fgBucketOffset(p1, &tiles[(j*width)+i], i - dw, j - dh); p2 = &tiles[(j*width)+i]; - printf(" bucket = %d %d %d %d index = %ld\n", - p2->lon, p2->lat, p2->x, p2->y, - fgBucketGenIndex(&tiles[(j*width)+i])); + fgPrintf( FG_TERRAIN, FG_DEBUG, + " bucket = %d %d %d %d index = %ld\n", + p2->lon, p2->lat, p2->x, p2->y, + fgBucketGenIndex(&tiles[(j*width)+i])); } } } @@ -266,10 +269,13 @@ int main() { /* $Log$ -/* Revision 1.3 1998/01/27 00:48:01 curt -/* Incorporated Paul Bleisch's new debug message -/* system and commandline/config file processing code. +/* Revision 1.4 1998/01/27 03:26:41 curt +/* Playing with new fgPrintf command. /* + * Revision 1.3 1998/01/27 00:48:01 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * * Revision 1.2 1998/01/24 00:03:28 curt * Initial revision. * diff --git a/Scenery/obj.c b/Scenery/obj.c index c480a6f03..61e7195cb 100644 --- a/Scenery/obj.c +++ b/Scenery/obj.c @@ -33,11 +33,11 @@ #include #include +#include
+#include #include #include -#include - #define MAXNODES 100000 @@ -58,23 +58,24 @@ void calc_normal(float p1[3], float p2[3], float p3[3], double normal[3]) MAT3cross_product(normal, v1, v2); MAT3_NORMALIZE_VEC(normal,temp); - /* printf(" Normal = %.2f %.2f %.2f\n", normal[0], normal[1], normal[2]);*/ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n", + normal[0], normal[1], normal[2]);*/ } /* Load a .obj file and generate the GL call list */ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { char line[256], winding_str[256]; - double v1[3], v2[3], approx_normal[3], normal[3], dot_prod, scale, temp; + double approx_normal[3], normal[3], scale; GLint area; FILE *f; int first, ncount, vncount, n1, n2, n3, n4; static int use_vertex_norms = 1; - int i, winding; + int winding; int last1, last2, odd; if ( (f = fopen(path, "r")) == NULL ) { - printf("Cannot open file: %s\n", path); + fgPrintf(FG_TERRAIN, FG_ALERT, "Cannot open file: %s\n", path); /* exit(-1); */ return(0); } @@ -94,7 +95,7 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { } else if ( strncmp(line, "v ", 2) == 0 ) { /* node (vertex) */ if ( ncount < MAXNODES ) { - /* printf("vertex = %s", line); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex = %s", line); */ sscanf(line, "v %f %f %f\n", &nodes[ncount][0], &nodes[ncount][1], &nodes[ncount][2]); if ( ncount == 1 ) { @@ -106,24 +107,24 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { } ncount++; } else { - printf("Read too many nodes ... dying :-(\n"); - exit(-1); + fgPrintf( FG_TERRAIN, FG_EXIT, + "Read too many nodes ... dying :-(\n"); } } else if ( strncmp(line, "vn ", 3) == 0 ) { /* vertex normal */ if ( vncount < MAXNODES ) { - /* printf("vertex normal = %s", line); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex normal = %s", line); */ sscanf(line, "vn %f %f %f\n", &normals[vncount][0], &normals[vncount][1], &normals[vncount][2]); vncount++; } else { - printf("Read too many vertex normals ... dying :-(\n"); - exit(-1); + fgPrintf( FG_TERRAIN, FG_EXIT, + "Read too many vertex normals ... dying :-(\n"); } } else if ( strncmp(line, "winding ", 8) == 0 ) { sscanf(line+8, "%s", winding_str); - printf(" WINDING = %s\n", winding_str); + fgPrintf( FG_TERRAIN, FG_DEBUG, " WINDING = %s\n", winding_str); /* can't call xglFrontFace() between xglBegin() & xglEnd() */ xglEnd(); @@ -148,10 +149,11 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { first = 0; } - /* printf(" new tri strip = %s", line); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, " new tri strip = %s", + line); */ sscanf(line, "t %d %d %d %d\n", &n1, &n2, &n3, &n4); - /* printf("(t) = "); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = "); */ xglBegin(GL_TRIANGLE_STRIP); @@ -226,7 +228,7 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { xglBegin(GL_TRIANGLES); - /* printf("new triangle = %s", line);*/ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "new triangle = %s", line);*/ sscanf(line, "f %d %d %d\n", &n1, &n2, &n3); xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]); @@ -244,9 +246,10 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { /* continue a triangle strip */ n1 = n2 = 0; - /* printf("continued tri strip = %s ", line); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "continued tri strip = %s ", + line); */ sscanf(line, "q %d %d\n", &n1, &n2); - /* printf("read %d %d\n", n1, n2); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2); */ if ( use_vertex_norms ) { MAT3_SCALE_VEC(normal, normals[n1], scale); @@ -271,7 +274,7 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { last2 = n1; if ( n2 > 0 ) { - /* printf(" (cont)\n"); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n"); */ if ( use_vertex_norms ) { MAT3_SCALE_VEC(normal, normals[n2], scale); @@ -296,7 +299,8 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { last2 = n2; } } else { - printf("Unknown line in %s = %s\n", path, line); + fgPrintf( FG_TERRAIN, FG_WARN, "Unknown line in %s = %s\n", + path, line); } } @@ -328,10 +332,13 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) { /* $Log$ -/* Revision 1.18 1998/01/19 19:27:16 curt -/* Merged in make system changes from Bob Kuehne -/* This should simplify things tremendously. +/* Revision 1.19 1998/01/27 03:26:42 curt +/* Playing with new fgPrintf command. /* + * Revision 1.18 1998/01/19 19:27:16 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * * Revision 1.17 1998/01/13 00:23:10 curt * Initial changes to support loading and management of scenery tiles. Note, * there's still a fair amount of work left to be done. diff --git a/Scenery/scenery.c b/Scenery/scenery.c index 3e3ebda09..23dc0f861 100644 --- a/Scenery/scenery.c +++ b/Scenery/scenery.c @@ -35,7 +35,7 @@ #include #include - +#include
#include #include @@ -50,7 +50,7 @@ struct fgSCENERY scenery; /* Initialize the Scenery Management system */ void fgSceneryInit( void ) { - printf("Initializing scenery subsystem\n"); + fgPrintf(FG_TERRAIN, FG_INFO, "Initializing scenery subsystem\n"); /* set the default terrain detail level */ scenery.terrain_skip = 6; @@ -74,7 +74,7 @@ void fgSceneryUpdate(double lon, double lat, double elev) { strcat(path, "/Scenery/"); strcat(path, "mesa-e.obj"); - printf(" Loading Scenery: %s\n", path); + fgPrintf(FG_TERRAIN, FG_DEBUG, " Loading Scenery: %s\n", path); area_terrain = fgObjLoad(path, &scenery.center); } @@ -100,10 +100,13 @@ void fgSceneryRender( void ) { /* $Log$ -/* Revision 1.33 1998/01/19 19:27:17 curt -/* Merged in make system changes from Bob Kuehne -/* This should simplify things tremendously. +/* Revision 1.34 1998/01/27 03:26:43 curt +/* Playing with new fgPrintf command. /* + * Revision 1.33 1998/01/19 19:27:17 curt + * Merged in make system changes from Bob Kuehne + * This should simplify things tremendously. + * * Revision 1.32 1998/01/19 18:40:37 curt * Tons of little changes to clean up the code and to remove fatal errors * when building with the c++ compiler. diff --git a/Scenery/tilecache.c b/Scenery/tilecache.c index e85e71149..0adb150f9 100644 --- a/Scenery/tilecache.c +++ b/Scenery/tilecache.c @@ -31,11 +31,12 @@ #include #include +#include #include #include #include +#include
-#include /* tile cache */ struct fgTILE tile_cache[FG_TILE_CACHE_SIZE]; @@ -45,7 +46,7 @@ struct fgTILE tile_cache[FG_TILE_CACHE_SIZE]; void fgTileCacheInit( void ) { int i; - printf("Initializing the tile cache.\n"); + fgPrintf(FG_TERRAIN, FG_INFO, "Initializing the tile cache.\n"); for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) { tile_cache[i].used = 0; @@ -97,7 +98,7 @@ void fgTileCacheEntryFillIn( int index, struct fgBUCKET *p ) { void fgTileCacheEntryInfo( int index, GLint *display_list, struct fgCartesianPoint *local_ref ) { *display_list = tile_cache[index].display_list; - /* printf("Display list = %d\n", *display_list); */ + /* fgPrintf(FG_TERRAIN, FG_DEBUG, "Display list = %d\n", *display_list); */ local_ref->x = tile_cache[index].local_ref.x; local_ref->y = tile_cache[index].local_ref.y; @@ -112,10 +113,13 @@ void fgTileCacheEntryFree( in index ) { /* $Log$ -/* Revision 1.3 1998/01/27 00:48:03 curt -/* Incorporated Paul Bleisch's new debug message -/* system and commandline/config file processing code. +/* Revision 1.4 1998/01/27 03:26:43 curt +/* Playing with new fgPrintf command. /* + * Revision 1.3 1998/01/27 00:48:03 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * * Revision 1.2 1998/01/26 15:55:24 curt * Progressing on building dynamic scenery system. * diff --git a/Scenery/tilemgr.c b/Scenery/tilemgr.c index 6cef1bbb8..4ab709543 100644 --- a/Scenery/tilemgr.c +++ b/Scenery/tilemgr.c @@ -39,6 +39,7 @@ #include #include #include +#include
#define FG_LOCAL_X 3 /* should be odd */ @@ -58,7 +59,7 @@ struct fgTILE tile_cache[FG_TILE_CACHE_SIZE]; /* Initialize the Tile Manager subsystem */ void fgTileMgrInit( void ) { - printf("Initializing Tile Manager subsystem.\n"); + fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n"); fgTileCacheInit(); } @@ -66,11 +67,11 @@ void fgTileMgrInit( void ) { /* load a tile */ void fgTileMgrLoadTile( struct fgBUCKET *p, int *index) { - printf("Updating for bucket %d %d %d %d\n", + fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n", p->lon, p->lat, p->x, p->y); *index = fgTileCacheNextAvail(); - printf("Selected cache index of %d\n", *index); + fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index); fgTileCacheEntryFillIn(*index, p); } @@ -93,13 +94,13 @@ void fgTileMgrUpdate( void ) { if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) && (p1.x == p_last.x) && (p1.y == p_last.y) ) { /* same bucket as last time */ - printf("Same bucket as last time\n"); + fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n"); } else if ( p_last.lon == -1000 ) { /* First time through, initialize the system and load all * relavant tiles */ - printf("First time through ... \n"); - printf("Updating Tile list for %d,%d %d,%d\n", + fgPrintf( FG_TERRAIN, FG_DEBUG, "First time through ... \n"); + fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n", p1.lon, p1.lat, p1.x, p1.y); /* wipe tile cache */ @@ -198,7 +199,7 @@ void fgTileMgrRender( void ) { for ( i = 0; i < FG_LOCAL_X_Y; i++ ) { index = tiles[i]; - /* printf("Index = %d\n", index); */ + /* fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index); */ fgTileCacheEntryInfo(index, &display_list, &local_ref ); xglPushMatrix(); @@ -212,10 +213,13 @@ void fgTileMgrRender( void ) { /* $Log$ -/* Revision 1.8 1998/01/27 00:48:04 curt -/* Incorporated Paul Bleisch's new debug message -/* system and commandline/config file processing code. +/* Revision 1.9 1998/01/27 03:26:44 curt +/* Playing with new fgPrintf command. /* + * Revision 1.8 1998/01/27 00:48:04 curt + * Incorporated Paul Bleisch's new debug message + * system and commandline/config file processing code. + * * Revision 1.7 1998/01/26 15:55:25 curt * Progressing on building dynamic scenery system. * -- 2.39.2