Necessary compilation fixes for newer GCCs (e.g. 3.3.5, 4.0).

Side effect: The shapes demo has a new 'i' key now.


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@600 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
spanne 2005-05-06 15:39:24 +00:00
parent 53c452c7a2
commit 4257efb83f
4 changed files with 29 additions and 22 deletions

View File

@ -992,6 +992,5 @@ mouse pointers don't work) on the way:
(259) Changed the "shapes" demo to the OpenGLUT "shapes" demo, which is much (259) Changed the "shapes" demo to the OpenGLUT "shapes" demo, which is much
niftier. niftier.
(260) Necessary compilation fixes for newer GCCs (e.g. 3.3.5, 4.0).
Side effect: The shapes demo has a new 'i' key now.

View File

@ -12,6 +12,7 @@
Keys: Keys:
- <tt>Esc &nbsp;</tt> Quit - <tt>Esc &nbsp;</tt> Quit
- <tt>q Q &nbsp;</tt> Quit - <tt>q Q &nbsp;</tt> Quit
- <tt>i I &nbsp;</tt> Show info
- <tt>= + &nbsp;</tt> Increase \a slices - <tt>= + &nbsp;</tt> Increase \a slices
- <tt>- _ &nbsp;</tt> Decreate \a slices - <tt>- _ &nbsp;</tt> Decreate \a slices
- <tt>, < &nbsp;</tt> Decreate \a stacks - <tt>, < &nbsp;</tt> Decreate \a stacks
@ -41,7 +42,8 @@
#include <stdlib.h> #include <stdlib.h>
#ifdef WIN32 #ifdef WIN32
#include <crtdbg.h> // DUMP MEMORY LEAKS /* DUMP MEMORY LEAKS */
#include <crtdbg.h>
#endif #endif
/* /*
@ -61,7 +63,7 @@ static double irad = .25;
static double orad = 1.0; static double orad = 1.0;
static int depth = 4; static int depth = 4;
static double offset[ 3 ] = { 0, 0, 0 }; static double offset[ 3 ] = { 0, 0, 0 };
static GLboolean show_info = GL_TRUE;
/* /*
* These one-liners draw particular objects, fetching appropriate * These one-liners draw particular objects, fetching appropriate
@ -193,7 +195,7 @@ static void shapesPrintf (int row, int col, const char *fmt, ...)
glutBitmapWidth(font, ' ') * col, glutBitmapWidth(font, ' ') * col,
- glutBitmapHeight(font) * (row+2) + viewport[3] - glutBitmapHeight(font) * (row+2) + viewport[3]
); );
glutBitmapString (font, buf); glutBitmapString (font, (unsigned char*)buf);
glPopMatrix(); glPopMatrix();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
@ -226,8 +228,6 @@ static void display(void)
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
printf ( "Shape %d slides %d stacks %d\n", function_index, slices, stacks ) ;
glColor3d(1,0,0); glColor3d(1,0,0);
glPushMatrix(); glPushMatrix();
@ -247,13 +247,17 @@ static void display(void)
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glColor3d(0.1,0.1,0.4); glColor3d(0.1,0.1,0.4);
/* shapesPrintf (1, 3, "Shape PgUp PgDn: %s", table [function_index].name); if( show_info ) {
shapesPrintf (1, 3, "Shape PgUp PgDn: %s", table [function_index].name);
shapesPrintf (2, 3, "Slices +-: %d Stacks <>: %d", slices, stacks); shapesPrintf (2, 3, "Slices +-: %d Stacks <>: %d", slices, stacks);
shapesPrintf (3, 3, "nSides +-: %d nRings <>: %d", slices, stacks); shapesPrintf (3, 3, "nSides +-: %d nRings <>: %d", slices, stacks);
shapesPrintf (4, 3, "Depth (): %d", depth); shapesPrintf (4, 3, "Depth (): %d", depth);
shapesPrintf (5, 3, "Outer radius Up Down : %f", orad); shapesPrintf (5, 3, "Outer radius Up Down : %f", orad);
shapesPrintf (6, 3, "Inner radius Left Right: %f", irad); shapesPrintf (6, 3, "Inner radius Left Right: %f", irad);
*/ } else {
printf ( "Shape %d slides %d stacks %d\n", function_index, slices, stacks ) ;
}
glutSwapBuffers(); glutSwapBuffers();
} }
@ -267,6 +271,9 @@ key(unsigned char key, int x, int y)
case 'Q': case 'Q':
case 'q': glutLeaveMainLoop () ; break; case 'q': glutLeaveMainLoop () ; break;
case 'I':
case 'i': show_info = ( show_info == GL_TRUE ) ? GL_FALSE : GL_TRUE; break;
case '=': case '=':
case '+': slices++; break; case '+': slices++; break;
@ -376,7 +383,8 @@ main(int argc, char *argv[])
glutMainLoop(); glutMainLoop();
#ifdef WIN32 #ifdef WIN32
_CrtDumpMemoryLeaks () ; // DUMP MEMORY LEAK INFORMATION /* DUMP MEMORY LEAK INFORMATION */
_CrtDumpMemoryLeaks () ;
#endif #endif
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -385,8 +385,8 @@ typedef void (*SFG_Proc)();
#define SET_WCB(window,cbname,func) \ #define SET_WCB(window,cbname,func) \
do \ do \
{ \ { \
if( FETCH_WCB( window, cbname ) != func ) \ if( FETCH_WCB( window, cbname ) != (SFG_Proc)(func) ) \
(((window).CallBacks[CB_ ## cbname]) = (SFG_Proc) func); \ (((window).CallBacks[CB_ ## cbname]) = (SFG_Proc)(func)); \
} while( 0 ) } while( 0 )
/* /*

View File

@ -858,13 +858,13 @@ void FGAPIENTRY glutMainLoopEvent( void )
if( event.type == KeyPress ) if( event.type == KeyPress )
{ {
keyboard_cb = FETCH_WCB( *window, Keyboard ); keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, Keyboard ));
special_cb = FETCH_WCB( *window, Special ); special_cb = (FGCBSpecial) ( FETCH_WCB( *window, Special ));
} }
else else
{ {
keyboard_cb = FETCH_WCB( *window, KeyboardUp ); keyboard_cb = (FGCBKeyboard)( FETCH_WCB( *window, KeyboardUp ));
special_cb = FETCH_WCB( *window, SpecialUp ); special_cb = (FGCBSpecial) ( FETCH_WCB( *window, SpecialUp ));
} }
/* Is there a keyboard/special callback hooked for this window? */ /* Is there a keyboard/special callback hooked for this window? */