X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2FLorenz%2Florenz.c;h=6a816b2f16bab15fa387bceab3ad29cd7f3c7882;hb=1a159971346b45c5d25c75176095f38606c6892d;hp=93ed843bae626d8e1e9e6de876f69798914a3433;hpb=a2e6f82b127ee038ef1994e65c25f24148c56a60;p=freeglut diff --git a/progs/demos/Lorenz/lorenz.c b/progs/demos/Lorenz/lorenz.c index 93ed843..6a816b2 100644 --- a/progs/demos/Lorenz/lorenz.c +++ b/progs/demos/Lorenz/lorenz.c @@ -29,10 +29,11 @@ /* Include Files */ #include #include +#include #include #include #include -#ifdef WIN32 +#ifdef _MSC_VER /* DUMP MEMORY LEAKS */ #include #endif @@ -242,10 +243,23 @@ void draw_curve ( int index, double position [ NUM_POINTS ][3] ) glEnd () ; } -void display_cb ( void ) +void bitmapPrintf (const char *fmt, ...) { - char string [ 80 ] ; + static char buf[256]; + va_list args; + + va_start(args, fmt); +#if defined(WIN32) && !defined(__CYGWIN__) + (void) _vsnprintf (buf, sizeof(buf), fmt, args); +#else + (void) vsnprintf (buf, sizeof(buf), fmt, args); +#endif + va_end(args); + glutBitmapString ( GLUT_BITMAP_HELVETICA_12, (unsigned char*)buf ) ; +} +void display_cb ( void ) +{ glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; glColor3d ( 1.0, 1.0, 1.0 ) ; /* White */ @@ -267,9 +281,8 @@ void display_cb ( void ) /* Print the distance between the two points */ glColor3d ( 1.0, 1.0, 1.0 ) ; /* White */ - sprintf ( string, "Distance: %10.6f", distance ) ; - glRasterPos2i ( 10, 10 ) ; - glutBitmapString ( GLUT_BITMAP_HELVETICA_12, (unsigned char*)string ) ; + glRasterPos2i ( 1, 1 ) ; + bitmapPrintf ( "Distance: %10.6f", distance ) ; glutSwapBuffers(); } @@ -356,7 +369,7 @@ int main ( int argc, char *argv[] ) /* Enter the GLUT main loop */ glutMainLoop () ; -#ifdef WIN32 +#ifdef _MSC_VER /* DUMP MEMORY LEAK INFORMATION */ _CrtDumpMemoryLeaks () ; #endif