From 3bfd20a2b9cd02cd1a8bdb5e2cf415d12dce5f5e Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 2 Jun 1999 22:22:47 +0000 Subject: [PATCH] Mac portability changes contributed by "Darrell Walisser" --- Lib/Misc/fgstream.cxx | 27 +++++++++++++++++---------- Simulator/Cockpit/panel.cxx | 1 - Simulator/Main/GLUTmain.cxx | 15 ++++++--------- Simulator/Objects/material.cxx | 7 ++++++- Simulator/Objects/obj.cxx | 14 +++++++++++++- Simulator/Time/timestamp.hxx | 21 ++++++++++++++------- Tests/gl-info.c | 7 +++++++ 7 files changed, 63 insertions(+), 29 deletions(-) diff --git a/Lib/Misc/fgstream.cxx b/Lib/Misc/fgstream.cxx index 830154c2a..01b2c230b 100644 --- a/Lib/Misc/fgstream.cxx +++ b/Lib/Misc/fgstream.cxx @@ -95,12 +95,11 @@ skipeol( istream& in ) { char c = 0; // skip to end of line. - while ( in.get(c) && (c != '\n' && c != '\r') ) - ; - - #ifdef __MWERKS // -dw- need to strip line ending! - in >> skipws; - #endif + while ( in.get(c) ) { + if ( (c == '\n') || (c == '\r') ) { + break; + } + } return in; } @@ -109,11 +108,15 @@ istream& skipws( istream& in ) { char c; while ( in.get(c) ) { - #ifdef __MWERKS__ // -dw- for unix file compatibility - if ( ! (isspace( c ) ) || c != '\0' || c!='\n' || c != '\r' ) { - #else - if ( ! isspace( c ) ) { + // -dw- for unix file compatibility + // -clo- this causes problems for unix + #ifdef __MWERKS__ + if ( (c == '\n') || (c == '\r') ) { + break; + } #endif + + if ( ! isspace( c ) ) { // put pack the non-space character in.putback(c); break; @@ -128,7 +131,11 @@ skipcomment( istream& in ) while ( in ) { // skip whitespace +#ifdef __MWERKS__ + in >> ::skipws; +#else in >> skipws; +#endif char c; if ( in.get( c ) && c != '#' ) diff --git a/Simulator/Cockpit/panel.cxx b/Simulator/Cockpit/panel.cxx index 47eb3a397..d1a4382c0 100644 --- a/Simulator/Cockpit/panel.cxx +++ b/Simulator/Cockpit/panel.cxx @@ -184,7 +184,6 @@ FGPanel::FGPanel(void){ xglPixelZoom(Xzoom, Yzoom); xglPixelStorei(GL_UNPACK_ALIGNMENT, 1); xglPixelStorei(GL_UNPACK_ROW_LENGTH, 1024); - xglPixelStorei(GL_UNPACK_ROW_LENGTH, 1024); xglRasterPos2i(0,0); xglPixelZoom(Xzoom, Yzoom); xglPixelStorei(GL_UNPACK_ROW_LENGTH, 256); diff --git a/Simulator/Main/GLUTmain.cxx b/Simulator/Main/GLUTmain.cxx index 5224c0c3e..fbfbfb5bd 100644 --- a/Simulator/Main/GLUTmain.cxx +++ b/Simulator/Main/GLUTmain.cxx @@ -98,6 +98,7 @@ # ifndef FG_NDEBUG # include // settings for output window # endif +# include #endif @@ -845,9 +846,12 @@ void fgReshape( int width, int height ) { // Initialize GLUT and define a main window int fgGlutInit( int *argc, char **argv ) { + +#if !defined( MACOS ) // GLUT will extract all glut specific options so later on we only // need wory about our own. xglutInit(argc, argv); +#endif // Define Display Parameters xglutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); @@ -954,16 +958,9 @@ int fgGlutInitEvents( void ) { // Main ... int main( int argc, char **argv ) { -#ifdef MACOS -# ifndef FG_NDEBUG - - // -dw- this will not work unless called before any standard - // output, so why not put it here? - SIOUXSettings.toppixel = 540; - SIOUXSettings.leftpixel = 50; - SIOUXSettings.rows = 15; -# endif +#if defined( MACOS ) + argc = ccommand( &argv ); #endif FGInterface *f; diff --git a/Simulator/Objects/material.cxx b/Simulator/Objects/material.cxx index 819405db6..0a300253a 100644 --- a/Simulator/Objects/material.cxx +++ b/Simulator/Objects/material.cxx @@ -126,8 +126,13 @@ FGMaterial::load_texture( const string& root ) # error port me #endif - // set the texture parameters for this texture + // set the texture parameters back to the defaults for loading + // this texture xglPixelStorei(GL_UNPACK_ALIGNMENT, 4); + xglPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + xglPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + xglPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ) ; xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ) ; xglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); diff --git a/Simulator/Objects/obj.cxx b/Simulator/Objects/obj.cxx index c868f7d82..979befd62 100644 --- a/Simulator/Objects/obj.cxx +++ b/Simulator/Objects/obj.cxx @@ -148,7 +148,7 @@ int fgObjLoad( const string& path, fgTILE *t) { // Attempt to open "path.gz" or "path" fg_gzifstream in( path ); - if ( ! in ) { + if ( ! in.is_open() ) { FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << path ); return 0; } @@ -174,7 +174,11 @@ int fgObjLoad( const string& path, fgTILE *t) { string token; char c; +#if defined( MACOS ) + in >> ::skipws; +#else in >> skipws; +#endif if ( in.get( c ) && c == '#' ) { // process a comment line @@ -450,7 +454,11 @@ int fgObjLoad( const string& path, fgTILE *t) { // read all subsequent numbers until next thing isn't a number while ( true ) { +#if defined( MACOS ) + in >> ::skipws; +#else in >> skipws; +#endif char c; in.get(c); @@ -604,7 +612,11 @@ int fgObjLoad( const string& path, fgTILE *t) { // eat white space before start of while loop so if we are // done with useful input it is noticed before hand. +#if defined( MACOS ) + in >> ::skipws; +#else in >> skipws; +#endif } } diff --git a/Simulator/Time/timestamp.hxx b/Simulator/Time/timestamp.hxx index bbd073861..50af0ead1 100644 --- a/Simulator/Time/timestamp.hxx +++ b/Simulator/Time/timestamp.hxx @@ -1,4 +1,3 @@ -// // timestamp.hxx -- class for managing a timestamp (seconds & milliseconds.) // // Written by Curtis Olson, started December 1998. @@ -56,7 +55,13 @@ # include // for get/setitimer, gettimeofday, struct timeval #endif -#ifdef WIN32 +// -dw- want to use metrowerks time.h +#ifdef MACOS +# include +# include +#endif + +#ifdef WIN32 # include # if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) # define NEAR /* */ @@ -136,11 +141,13 @@ inline void FGTimeStamp::stamp() { ftime(¤t); seconds = current.time; usec = current.millitm * 1000; -#elif defined( __MWERKS__ ) - // -dw- uses system clock to get time stamp... don't know if this works - long ticks = clock(); - seconds = ticks / CLOCKS_PER_SEC; - usec = seconds * 100000; +// -dw- uses time manager +#elif defined( MACOS ) + UnsignedWide ms; + Microseconds(&ms); + + seconds = ms.lo / 1000000; + usec = ms.lo - ( seconds * 1000000 ); #else # error Port me #endif diff --git a/Tests/gl-info.c b/Tests/gl-info.c index 1e3d9146d..8df65f160 100644 --- a/Tests/gl-info.c +++ b/Tests/gl-info.c @@ -94,5 +94,12 @@ int main ( int argc, char **argv ) getPrintf ( GL_POINT_SIZE_GRANULARITY, "GL_POINT_SIZE_GRANULARITY" ) ; getPrint2f( GL_POINT_SIZE_RANGE , "GL_POINT_SIZE_RANGE" ) ; + printf("Default values:\n\n"); + + getPrinti( GL_UNPACK_ALIGNMENT , "GL_UNPACK_ALIGNMENT" ) ; + getPrinti( GL_UNPACK_ROW_LENGTH , "GL_UNPACK_ROW_LENGTH" ) ; + getPrinti( GL_UNPACK_SKIP_PIXELS , "GL_UNPACK_SKIP_PIXELS" ) ; + getPrinti( GL_UNPACK_SKIP_ROWS , "GL_UNPACK_SKIP_ROWS" ) ; + return 0 ; } -- 2.39.5