X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Ffreeglut_main.c;h=d1ba612b5cbef37eef6fb4aa989a6d24638cf6de;hb=ba21dbc1eca4d994466497da8a309ce1300e775f;hp=7c214ddcc730481e67b043a588715dca24e29107;hpb=2c9161e532490d2623896ad4720fb5e7bb6480bb;p=freeglut diff --git a/src/freeglut_main.c b/src/freeglut_main.c index 7c214dd..d1ba612 100644 --- a/src/freeglut_main.c +++ b/src/freeglut_main.c @@ -27,13 +27,19 @@ #include #include "freeglut_internal.h" +#if HAVE_ERRNO_H +# include +#endif +#include +#if HAVE_VPRINTF +# define VFPRINTF(s,f,a) vfprintf((s),(f),(a)) +#elif HAVE_DOPRNT +# define VFPRINTF(s,f,a) _doprnt((f),(a),(s)) +#else +# define VFPRINTF(s,f,a) +#endif -#include -#if TARGET_HOST_UNIX_X11 -#include -#include -#elif TARGET_HOST_WIN32 -#elif TARGET_HOST_WINCE +#if TARGET_HOST_WINCE typedef struct GXDisplayProperties GXDisplayProperties; typedef struct GXKeyList GXKeyList; @@ -49,8 +55,15 @@ struct GXKeyList gxKeyList; #endif -#ifndef MAX -#define MAX(a,b) (((a)>(b)) ? (a) : (b)) +/* + * Try to get the maximum value allowed for ints, falling back to the minimum + * guaranteed by ISO C99 if there is no suitable header. + */ +#if HAVE_LIMITS_H +# include +#endif +#ifndef INT_MAX +# define INT_MAX 32767 #endif #ifndef MIN @@ -343,8 +356,8 @@ void fgError( const char *fmt, ... ) fprintf( stderr, "freeglut "); if( fgState.ProgramName ) - fprintf (stderr, "(%s): ", fgState.ProgramName); - vfprintf( stderr, fmt, ap ); + fprintf( stderr, "(%s): ", fgState.ProgramName ); + VFPRINTF( stderr, fmt, ap ); fprintf( stderr, "\n" ); va_end( ap ); @@ -364,7 +377,7 @@ void fgWarning( const char *fmt, ... ) fprintf( stderr, "freeglut "); if( fgState.ProgramName ) fprintf( stderr, "(%s): ", fgState.ProgramName ); - vfprintf( stderr, fmt, ap ); + VFPRINTF( stderr, fmt, ap ); fprintf( stderr, "\n" ); va_end( ap ); @@ -445,8 +458,10 @@ static void fghSleepForEvents( void ) return; msec = fghNextTimer( ); - if( fghHaveJoystick( ) ) /* XXX Use GLUT timers for joysticks... */ - msec = MIN( msec, 10 ); /* XXX Dumb; forces granularity to .01sec */ + /* XXX Use GLUT timers for joysticks... */ + /* XXX Dumb; forces granularity to .01sec */ + if( fghHaveJoystick( ) && ( msec < 10 ) ) + msec = 10; #if TARGET_HOST_UNIX_X11 /*