Adding initialization checking to all GLUT interface functions and removing asserts from the rest of the code - John Fay
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@541 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
9c68fad27d
commit
ee6d3a9a1c
@ -48,6 +48,7 @@
|
||||
*/
|
||||
void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDisplayFunc" );
|
||||
if( !callback )
|
||||
fgError( "Fatal error in program. NULL display callback not "
|
||||
"permitted in GLUT 3.0+ or freeglut 2.0.1+" );
|
||||
@ -59,6 +60,7 @@ void FGAPIENTRY glutDisplayFunc( void (* callback)( void ) )
|
||||
*/
|
||||
void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeFunc" );
|
||||
SET_CALLBACK( Reshape );
|
||||
}
|
||||
|
||||
@ -68,6 +70,7 @@ void FGAPIENTRY glutReshapeFunc( void (* callback)( int, int ) )
|
||||
void FGAPIENTRY glutKeyboardFunc( void (* callback)
|
||||
( unsigned char, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardFunc" );
|
||||
SET_CALLBACK( Keyboard );
|
||||
}
|
||||
|
||||
@ -76,6 +79,7 @@ void FGAPIENTRY glutKeyboardFunc( void (* callback)
|
||||
*/
|
||||
void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialFunc" );
|
||||
SET_CALLBACK( Special );
|
||||
}
|
||||
|
||||
@ -84,7 +88,7 @@ void FGAPIENTRY glutSpecialFunc( void (* callback)( int, int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutIdleFunc( void (* callback)( void ) )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIdleFunc" );
|
||||
fgState.IdleCallback = callback;
|
||||
}
|
||||
|
||||
@ -96,7 +100,7 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ),
|
||||
{
|
||||
SFG_Timer *timer, *node;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTimerFunc" );
|
||||
|
||||
if( (timer = fgState.FreeTimers.Last) )
|
||||
{
|
||||
@ -129,7 +133,6 @@ static void fghVisibility( int status )
|
||||
{
|
||||
int glut_status = GLUT_VISIBLE;
|
||||
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( fgStructure.Window );
|
||||
|
||||
if( ( GLUT_HIDDEN == status ) || ( GLUT_FULLY_COVERED == status ) )
|
||||
@ -139,6 +142,7 @@ static void fghVisibility( int status )
|
||||
|
||||
void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
|
||||
SET_CALLBACK( Visibility );
|
||||
|
||||
if( callback )
|
||||
@ -153,6 +157,7 @@ void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) )
|
||||
void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
|
||||
( unsigned char, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutKeyboardUpFunc" );
|
||||
SET_CALLBACK( KeyboardUp );
|
||||
}
|
||||
|
||||
@ -161,6 +166,7 @@ void FGAPIENTRY glutKeyboardUpFunc( void (* callback)
|
||||
*/
|
||||
void FGAPIENTRY glutSpecialUpFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpecialUpFunc" );
|
||||
SET_CALLBACK( SpecialUp );
|
||||
}
|
||||
|
||||
@ -171,6 +177,7 @@ void FGAPIENTRY glutJoystickFunc( void (* callback)
|
||||
( unsigned int, int, int, int ),
|
||||
int pollInterval )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickFunc" );
|
||||
fgInitialiseJoysticks ();
|
||||
|
||||
SET_CALLBACK( Joystick );
|
||||
@ -188,6 +195,7 @@ void FGAPIENTRY glutJoystickFunc( void (* callback)
|
||||
*/
|
||||
void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseFunc" );
|
||||
SET_CALLBACK( Mouse );
|
||||
}
|
||||
|
||||
@ -196,6 +204,7 @@ void FGAPIENTRY glutMouseFunc( void (* callback)( int, int, int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMouseWheelFunc" );
|
||||
SET_CALLBACK( MouseWheel );
|
||||
}
|
||||
|
||||
@ -205,6 +214,7 @@ void FGAPIENTRY glutMouseWheelFunc( void (* callback)( int, int, int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMotionFunc" );
|
||||
SET_CALLBACK( Motion );
|
||||
}
|
||||
|
||||
@ -214,6 +224,7 @@ void FGAPIENTRY glutMotionFunc( void (* callback)( int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPassiveMotionFunc" );
|
||||
SET_CALLBACK( Passive );
|
||||
}
|
||||
|
||||
@ -222,6 +233,7 @@ void FGAPIENTRY glutPassiveMotionFunc( void (* callback)( int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEntryFunc" );
|
||||
SET_CALLBACK( Entry );
|
||||
}
|
||||
|
||||
@ -230,17 +242,20 @@ void FGAPIENTRY glutEntryFunc( void (* callback)( int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutCloseFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCloseFunc" );
|
||||
SET_CALLBACK( Destroy );
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWMCloseFunc" );
|
||||
glutCloseFunc( callback );
|
||||
}
|
||||
|
||||
/* A. Donev: Destruction callback for menus */
|
||||
void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuDestroyFunc" );
|
||||
if( fgStructure.Menu )
|
||||
fgStructure.Menu->Destroy = callback;
|
||||
}
|
||||
@ -250,7 +265,7 @@ void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) )
|
||||
*/
|
||||
void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStateFunc" );
|
||||
fgState.MenuStateCallback = callback;
|
||||
}
|
||||
|
||||
@ -259,7 +274,7 @@ void FGAPIENTRY glutMenuStateFunc( void (* callback)( int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMenuStatusFunc" );
|
||||
fgState.MenuStatusCallback = callback;
|
||||
}
|
||||
|
||||
@ -268,6 +283,7 @@ void FGAPIENTRY glutMenuStatusFunc( void (* callback)( int, int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutOverlayDisplayFunc" );
|
||||
SET_CALLBACK( OverlayDisplay );
|
||||
}
|
||||
|
||||
@ -276,6 +292,7 @@ void FGAPIENTRY glutOverlayDisplayFunc( void (* callback)( void ) )
|
||||
*/
|
||||
void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWindowStatusFunc" );
|
||||
SET_CALLBACK( WindowStatus );
|
||||
}
|
||||
|
||||
@ -284,6 +301,7 @@ void FGAPIENTRY glutWindowStatusFunc( void (* callback)( int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballMotionFunc" );
|
||||
SET_CALLBACK( SpaceMotion );
|
||||
}
|
||||
|
||||
@ -292,6 +310,7 @@ void FGAPIENTRY glutSpaceballMotionFunc( void (* callback)( int, int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballRotateFunc" );
|
||||
SET_CALLBACK( SpaceRotation );
|
||||
}
|
||||
|
||||
@ -300,6 +319,7 @@ void FGAPIENTRY glutSpaceballRotateFunc( void (* callback)( int, int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSpaceballButtonFunc" );
|
||||
SET_CALLBACK( SpaceButton );
|
||||
}
|
||||
|
||||
@ -308,6 +328,7 @@ void FGAPIENTRY glutSpaceballButtonFunc( void (* callback)( int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutButtonBoxFunc" );
|
||||
SET_CALLBACK( ButtonBox );
|
||||
}
|
||||
|
||||
@ -316,6 +337,7 @@ void FGAPIENTRY glutButtonBoxFunc( void (* callback)( int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDialsFunc" );
|
||||
SET_CALLBACK( Dials );
|
||||
}
|
||||
|
||||
@ -324,6 +346,7 @@ void FGAPIENTRY glutDialsFunc( void (* callback)( int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletMotionFunc" );
|
||||
SET_CALLBACK( TabletMotion );
|
||||
}
|
||||
|
||||
@ -332,6 +355,7 @@ void FGAPIENTRY glutTabletMotionFunc( void (* callback)( int, int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutTabletButtonFunc( void (* callback)( int, int, int, int ) )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutTabletButtonFunc" );
|
||||
SET_CALLBACK( TabletButton );
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static int fghGetCursorError( Cursor cursor )
|
||||
*/
|
||||
void FGAPIENTRY glutSetCursor( int cursorID )
|
||||
{
|
||||
freeglut_assert_ready; /* XXX WHY do we need the timer active for this? */
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetCursor" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetCursor" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -144,7 +144,7 @@ void FGAPIENTRY glutSetCursor( int cursorID )
|
||||
* need to pick a color for foreground/background---but what
|
||||
* one we pick doesn't matter for GLUT_CURSOR_NONE.
|
||||
*/
|
||||
static char no_cursor_bits[ 32 ];
|
||||
static unsigned char no_cursor_bits[ 32 ];
|
||||
XColor black;
|
||||
no_cursor = XCreatePixmapFromBitmapData( fgDisplay.Display,
|
||||
fgDisplay.RootWindow,
|
||||
@ -236,7 +236,7 @@ void FGAPIENTRY glutSetCursor( int cursorID )
|
||||
*/
|
||||
void FGAPIENTRY glutWarpPointer( int x, int y )
|
||||
{
|
||||
freeglut_assert_ready; /* XXX WHY do we need the timer active for this? */
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWarpPointer" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutWarpPointer" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
|
@ -40,7 +40,7 @@
|
||||
*/
|
||||
void FGAPIENTRY glutPostRedisplay( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPostRedisplay" );
|
||||
fgStructure.Window->State.Redisplay = GL_TRUE;
|
||||
}
|
||||
@ -50,7 +50,7 @@ void FGAPIENTRY glutPostRedisplay( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSwapBuffers( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSwapBuffers" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSwapBuffers" );
|
||||
|
||||
glFlush( );
|
||||
@ -90,7 +90,7 @@ void FGAPIENTRY glutPostWindowRedisplay( int windowID )
|
||||
{
|
||||
SFG_Window* window;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostWindowRedisplay" );
|
||||
window = fgWindowByID( windowID );
|
||||
freeglut_return_if_fail( window );
|
||||
window->State.Redisplay = GL_TRUE;
|
||||
|
@ -178,10 +178,8 @@ static struct name_address_pair glut_functions[] =
|
||||
{ "glutStrokeString", (void *) glutStrokeString },
|
||||
{ "glutWireRhombicDodecahedron", (void *) glutWireRhombicDodecahedron },
|
||||
{ "glutSolidRhombicDodecahedron", (void *) glutSolidRhombicDodecahedron },
|
||||
{ "glutWireSierpinskiSponge", (void *) glutWireSierpinskiSponge },
|
||||
{ "glutSolidSierpinskiSponge", (void *) glutSolidSierpinskiSponge },
|
||||
{ "glutWireCylinder", (void *) glutWireCylinder },
|
||||
{ "glutSolidCylinder", (void *) glutSolidCylinder },
|
||||
{ "glutWireSierpinskiSponge ", (void *) glutWireSierpinskiSponge },
|
||||
{ "glutSolidSierpinskiSponge ", (void *) glutSolidSierpinskiSponge },
|
||||
{ "glutGetProcAddress", (void *) glutGetProcAddress },
|
||||
{ "glutMouseWheelFunc", (void *) glutMouseWheelFunc },
|
||||
{ NULL, NULL }
|
||||
@ -192,6 +190,7 @@ void *FGAPIENTRY glutGetProcAddress( const char *procName )
|
||||
{
|
||||
/* Try GLUT functions first */
|
||||
int i;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" );
|
||||
for( i = 0; glut_functions[ i ].name; i++ )
|
||||
if( strcmp( glut_functions[ i ].name, procName ) == 0)
|
||||
return glut_functions[ i ].address;
|
||||
|
@ -105,8 +105,9 @@ static SFG_StrokeFont* fghStrokeByID( void* font )
|
||||
void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
|
||||
{
|
||||
const GLubyte* face;
|
||||
SFG_Font* font = fghFontByID( fontID );
|
||||
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapCharacter" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_if_fail( ( character >= 1 )&&( character < 256 ) );
|
||||
freeglut_return_if_fail( font );
|
||||
|
||||
@ -134,9 +135,10 @@ void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
|
||||
void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
|
||||
{
|
||||
unsigned char c;
|
||||
SFG_Font* font = fghFontByID( fontID );
|
||||
float x = 0.0f ;
|
||||
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapString" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_if_fail( font );
|
||||
if ( !string || ! *string )
|
||||
return;
|
||||
@ -154,8 +156,8 @@ void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
|
||||
* A newline will simply translate the next character's insertion
|
||||
* point back to the start of the line and down one line.
|
||||
*/
|
||||
while( ( c = *string++ ) )
|
||||
if( c == '\n' )
|
||||
while( c = *string++ )
|
||||
if( string[c] == '\n' )
|
||||
{
|
||||
glBitmap ( 0, 0, 0, 0, -x, (float) -font->Height, NULL );
|
||||
x = 0.0f;
|
||||
@ -182,8 +184,9 @@ void FGAPIENTRY glutBitmapString( void* fontID, const unsigned char *string )
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapWidth( void* fontID, int character )
|
||||
{
|
||||
SFG_Font* font = fghFontByID( fontID );
|
||||
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapWidth" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( character > 0 && character < 256, 0 );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
return *( font->Characters[ character ] );
|
||||
@ -196,13 +199,14 @@ int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string )
|
||||
{
|
||||
unsigned char c;
|
||||
int length = 0, this_line_length = 0;
|
||||
SFG_Font* font = fghFontByID( fontID );
|
||||
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapLength" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
if ( !string || ! *string )
|
||||
return 0;
|
||||
|
||||
while( ( c = *string++) )
|
||||
while( c = *string++ )
|
||||
{
|
||||
if( c != '\n' )/* Not an EOL, increment length of line */
|
||||
this_line_length += *( font->Characters[ c ]);
|
||||
@ -224,7 +228,9 @@ int FGAPIENTRY glutBitmapLength( void* fontID, const unsigned char* string )
|
||||
*/
|
||||
int FGAPIENTRY glutBitmapHeight( void* fontID )
|
||||
{
|
||||
SFG_Font* font = fghFontByID( fontID );
|
||||
SFG_Font* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutBitmapHeight" );
|
||||
font = fghFontByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
return font->Height;
|
||||
}
|
||||
@ -237,8 +243,9 @@ void FGAPIENTRY glutStrokeCharacter( void* fontID, int character )
|
||||
const SFG_StrokeChar *schar;
|
||||
const SFG_StrokeStrip *strip;
|
||||
int i, j;
|
||||
SFG_StrokeFont* font = fghStrokeByID( fontID );
|
||||
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeCharacter" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_if_fail( character >= 0 );
|
||||
freeglut_return_if_fail( character < font->Quantity );
|
||||
freeglut_return_if_fail( font );
|
||||
@ -262,8 +269,9 @@ void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string )
|
||||
unsigned char c;
|
||||
int i, j;
|
||||
float length = 0.0;
|
||||
SFG_StrokeFont* font = fghStrokeByID( fontID );
|
||||
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeString" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_if_fail( font );
|
||||
if ( !string || ! *string )
|
||||
return;
|
||||
@ -273,7 +281,7 @@ void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string )
|
||||
* A newline will simply translate the next character's insertion
|
||||
* point back to the start of the line and down one line.
|
||||
*/
|
||||
while( ( c = *string++) )
|
||||
while( c = *string++ )
|
||||
if( c < font->Quantity )
|
||||
{
|
||||
if( c == '\n' )
|
||||
@ -311,8 +319,9 @@ void FGAPIENTRY glutStrokeString( void* fontID, const unsigned char *string )
|
||||
int FGAPIENTRY glutStrokeWidth( void* fontID, int character )
|
||||
{
|
||||
const SFG_StrokeChar *schar;
|
||||
SFG_StrokeFont* font = fghStrokeByID( fontID );
|
||||
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeWidth" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( ( character >= 0 ) &&
|
||||
( character < font->Quantity ),
|
||||
0
|
||||
@ -332,13 +341,14 @@ int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
|
||||
unsigned char c;
|
||||
float length = 0.0;
|
||||
float this_line_length = 0.0;
|
||||
SFG_StrokeFont* font = fghStrokeByID( fontID );
|
||||
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeLength" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0 );
|
||||
if ( !string || ! *string )
|
||||
return 0;
|
||||
|
||||
while( ( c = *string++ ) )
|
||||
while( c = *string++ )
|
||||
if( c < font->Quantity )
|
||||
{
|
||||
if( c == '\n' ) /* EOL; reset the length of this line */
|
||||
@ -364,7 +374,9 @@ int FGAPIENTRY glutStrokeLength( void* fontID, const unsigned char* string )
|
||||
*/
|
||||
GLfloat FGAPIENTRY glutStrokeHeight( void* fontID )
|
||||
{
|
||||
SFG_StrokeFont* font = fghStrokeByID( fontID );
|
||||
SFG_StrokeFont* font;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutStrokeHeight" );
|
||||
font = fghStrokeByID( fontID );
|
||||
freeglut_return_val_if_fail( font, 0.0 );
|
||||
return font->Height;
|
||||
}
|
||||
|
@ -360,6 +360,8 @@ void FGAPIENTRY glutGameModeString( const char* string )
|
||||
{
|
||||
int width = 640, height = 480, depth = 16, refresh = 72;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeString" );
|
||||
|
||||
/*
|
||||
* This one seems a bit easier than glutInitDisplayString. The bad thing
|
||||
* about it that I was unable to find the game mode string definition, so
|
||||
@ -391,6 +393,8 @@ void FGAPIENTRY glutGameModeString( const char* string )
|
||||
*/
|
||||
int FGAPIENTRY glutEnterGameMode( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutEnterGameMode" );
|
||||
|
||||
if( fgStructure.GameMode )
|
||||
fgAddToWindowDestroyList( fgStructure.GameMode );
|
||||
else
|
||||
@ -509,12 +513,13 @@ int FGAPIENTRY glutEnterGameMode( void )
|
||||
*/
|
||||
void FGAPIENTRY glutLeaveGameMode( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveGameMode" );
|
||||
|
||||
freeglut_return_if_fail( fgStructure.GameMode );
|
||||
|
||||
fgStructure.GameMode->State.IsGameMode = GL_FALSE;
|
||||
|
||||
fgAddToWindowDestroyList( fgStructure.GameMode );
|
||||
|
||||
fgStructure.GameMode = NULL;
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -532,6 +537,8 @@ void FGAPIENTRY glutLeaveGameMode( void )
|
||||
*/
|
||||
int FGAPIENTRY glutGameModeGet( GLenum eWhat )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGameModeGet" );
|
||||
|
||||
switch( eWhat )
|
||||
{
|
||||
case GLUT_GAME_MODE_ACTIVE:
|
||||
|
@ -72,6 +72,8 @@ void FGAPIENTRY glutWireCube( GLdouble dSize )
|
||||
{
|
||||
double size = dSize * 0.5;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCube" );
|
||||
|
||||
# define V(a,b,c) glVertex3d( a size, b size, c size );
|
||||
# define N(a,b,c) glNormal3d( a, b, c );
|
||||
|
||||
@ -94,6 +96,8 @@ void FGAPIENTRY glutSolidCube( GLdouble dSize )
|
||||
{
|
||||
double size = dSize * 0.5;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCube" );
|
||||
|
||||
# define V(a,b,c) glVertex3d( a size, b size, c size );
|
||||
# define N(a,b,c) glNormal3d( a, b, c );
|
||||
|
||||
@ -180,6 +184,9 @@ void FGAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
|
||||
|
||||
double *sint1,*cost1;
|
||||
double *sint2,*cost2;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSphere" );
|
||||
|
||||
fghCircleTable(&sint1,&cost1,-slices);
|
||||
fghCircleTable(&sint2,&cost2,stacks*2);
|
||||
|
||||
@ -265,6 +272,9 @@ void FGAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks)
|
||||
|
||||
double *sint1,*cost1;
|
||||
double *sint2,*cost2;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSphere" );
|
||||
|
||||
fghCircleTable(&sint1,&cost1,-slices );
|
||||
fghCircleTable(&sint2,&cost2, stacks*2);
|
||||
|
||||
@ -339,6 +349,9 @@ void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLi
|
||||
/* Pre-computed circle */
|
||||
|
||||
double *sint,*cost;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCone" );
|
||||
|
||||
fghCircleTable(&sint,&cost,-slices);
|
||||
|
||||
/* Cover the circular base with a triangle fan... */
|
||||
@ -423,6 +436,9 @@ void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLin
|
||||
/* Pre-computed circle */
|
||||
|
||||
double *sint,*cost;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCone" );
|
||||
|
||||
fghCircleTable(&sint,&cost,-slices);
|
||||
|
||||
/* Draw the stacks... */
|
||||
@ -480,6 +496,9 @@ void FGAPIENTRY glutSolidCylinder(GLdouble radius, GLdouble height, GLint slices
|
||||
/* Pre-computed circle */
|
||||
|
||||
double *sint,*cost;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidCylinder" );
|
||||
|
||||
fghCircleTable(&sint,&cost,-slices);
|
||||
|
||||
/* Cover the base and top */
|
||||
@ -541,6 +560,9 @@ void FGAPIENTRY glutWireCylinder(GLdouble radius, GLdouble height, GLint slices,
|
||||
/* Pre-computed circle */
|
||||
|
||||
double *sint,*cost;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireCylinder" );
|
||||
|
||||
fghCircleTable(&sint,&cost,-slices);
|
||||
|
||||
/* Draw the stacks... */
|
||||
@ -591,6 +613,9 @@ void FGAPIENTRY glutWireTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GLi
|
||||
double *vertex, *normal;
|
||||
int i, j;
|
||||
double spsi, cpsi, sphi, cphi ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTorus" );
|
||||
|
||||
if ( nSides < 1 ) nSides = 1;
|
||||
if ( nRings < 1 ) nRings = 1;
|
||||
|
||||
@ -669,6 +694,9 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL
|
||||
double *vertex, *normal;
|
||||
int i, j;
|
||||
double spsi, cpsi, sphi, cphi ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTorus" );
|
||||
|
||||
if ( nSides < 1 ) nSides = 1;
|
||||
if ( nRings < 1 ) nRings = 1;
|
||||
|
||||
@ -738,6 +766,8 @@ void FGAPIENTRY glutSolidTorus( GLdouble dInnerRadius, GLdouble dOuterRadius, GL
|
||||
*/
|
||||
void FGAPIENTRY glutWireDodecahedron( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireDodecahedron" );
|
||||
|
||||
/* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
|
||||
* of a cube. The coordinates of the points are:
|
||||
* (+-x,0, z); (+-1, 1, 1); (0, z, x )
|
||||
@ -789,6 +819,8 @@ void FGAPIENTRY glutWireDodecahedron( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSolidDodecahedron( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidDodecahedron" );
|
||||
|
||||
/* Magic Numbers: It is possible to create a dodecahedron by attaching two pentagons to each face of
|
||||
* of a cube. The coordinates of the points are:
|
||||
* (+-x,0, z); (+-1, 1, 1); (0, z, x )
|
||||
@ -840,6 +872,8 @@ void FGAPIENTRY glutSolidDodecahedron( void )
|
||||
*/
|
||||
void FGAPIENTRY glutWireOctahedron( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireOctahedron" );
|
||||
|
||||
#define RADIUS 1.0f
|
||||
glBegin( GL_LINE_LOOP );
|
||||
glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS );
|
||||
@ -859,6 +893,8 @@ void FGAPIENTRY glutWireOctahedron( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSolidOctahedron( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidOctahedron" );
|
||||
|
||||
#define RADIUS 1.0f
|
||||
glBegin( GL_TRIANGLES );
|
||||
glNormal3d( 0.577350269189, 0.577350269189, 0.577350269189); glVertex3d( RADIUS, 0.0, 0.0 ); glVertex3d( 0.0, RADIUS, 0.0 ); glVertex3d( 0.0, 0.0, RADIUS );
|
||||
@ -900,6 +936,8 @@ static GLint tet_i[4][3] = /* Vertex indices */
|
||||
*/
|
||||
void FGAPIENTRY glutWireTetrahedron( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTetrahedron" );
|
||||
|
||||
glBegin( GL_LINE_LOOP ) ;
|
||||
glNormal3d ( -tet_r[0][0], -tet_r[0][1], -tet_r[0][2] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[2] ) ;
|
||||
glNormal3d ( -tet_r[1][0], -tet_r[1][1], -tet_r[1][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[2] ) ; glVertex3dv ( tet_r[3] ) ;
|
||||
@ -913,6 +951,8 @@ void FGAPIENTRY glutWireTetrahedron( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSolidTetrahedron( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTetrahedron" );
|
||||
|
||||
glBegin( GL_TRIANGLES ) ;
|
||||
glNormal3d ( -tet_r[0][0], -tet_r[0][1], -tet_r[0][2] ) ; glVertex3dv ( tet_r[1] ) ; glVertex3dv ( tet_r[3] ) ; glVertex3dv ( tet_r[2] ) ;
|
||||
glNormal3d ( -tet_r[1][0], -tet_r[1][1], -tet_r[1][2] ) ; glVertex3dv ( tet_r[0] ) ; glVertex3dv ( tet_r[2] ) ; glVertex3dv ( tet_r[3] ) ;
|
||||
@ -936,6 +976,9 @@ int icos_v [20][3] = { { 0, 1, 2 }, { 0, 2, 3 }, { 0, 3, 4 }, { 0, 4, 5 }, { 0,
|
||||
void FGAPIENTRY glutWireIcosahedron( void )
|
||||
{
|
||||
int i ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireIcosahedron" );
|
||||
|
||||
for ( i = 0; i < 20; i++ )
|
||||
{
|
||||
double normal[3] ;
|
||||
@ -958,6 +1001,8 @@ void FGAPIENTRY glutSolidIcosahedron( void )
|
||||
{
|
||||
int i ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidIcosahedron" );
|
||||
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
for ( i = 0; i < 20; i++ )
|
||||
{
|
||||
@ -994,6 +1039,9 @@ double rdod_n[12][3] = {
|
||||
void FGAPIENTRY glutWireRhombicDodecahedron( void )
|
||||
{
|
||||
int i ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireRhombicDodecahedron" );
|
||||
|
||||
for ( i = 0; i < 12; i++ )
|
||||
{
|
||||
glBegin ( GL_LINE_LOOP ) ;
|
||||
@ -1013,6 +1061,8 @@ void FGAPIENTRY glutSolidRhombicDodecahedron( void )
|
||||
{
|
||||
int i ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidRhombicDodecahedron" );
|
||||
|
||||
glBegin ( GL_QUADS ) ;
|
||||
for ( i = 0; i < 12; i++ )
|
||||
{
|
||||
@ -1030,6 +1080,8 @@ void FGAPIENTRY glutWireSierpinskiSponge ( int num_levels, GLdouble offset[3], G
|
||||
{
|
||||
int i, j ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireSierpinskiSponge" );
|
||||
|
||||
if ( num_levels == 0 )
|
||||
{
|
||||
|
||||
@ -1067,6 +1119,8 @@ void FGAPIENTRY glutSolidSierpinskiSponge ( int num_levels, GLdouble offset[3],
|
||||
{
|
||||
int i, j ;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidSierpinskiSponge" );
|
||||
|
||||
if ( num_levels == 0 )
|
||||
{
|
||||
glBegin ( GL_TRIANGLES ) ;
|
||||
|
@ -183,7 +183,7 @@ static void fghInitialize( const char* displayName )
|
||||
|
||||
/* Register the window class */
|
||||
atom = RegisterClass( &wc );
|
||||
assert( atom );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fghInitialize" );
|
||||
}
|
||||
|
||||
/* The screen dimensions can be obtained via GetSystemMetrics() calls */
|
||||
@ -219,8 +219,6 @@ void fgDeinitialize( void )
|
||||
return;
|
||||
}
|
||||
|
||||
/* fgState.Initialised = GL_FALSE; */
|
||||
|
||||
/* If there was a menu created, destroy the rendering context */
|
||||
if( fgStructure.MenuContext )
|
||||
{
|
||||
@ -230,13 +228,13 @@ void fgDeinitialize( void )
|
||||
|
||||
fgDestroyStructure( );
|
||||
|
||||
while( ( timer = fgState.Timers.First ) )
|
||||
while( timer = fgState.Timers.First )
|
||||
{
|
||||
fgListRemove( &fgState.Timers, &timer->Node );
|
||||
free( timer );
|
||||
}
|
||||
|
||||
while( ( timer = fgState.FreeTimers.First) )
|
||||
while( timer = fgState.FreeTimers.First )
|
||||
{
|
||||
fgListRemove( &fgState.FreeTimers, &timer->Node );
|
||||
free( timer );
|
||||
@ -311,6 +309,8 @@ void fgDeinitialize( void )
|
||||
XCloseDisplay( fgDisplay.Display );
|
||||
|
||||
#endif
|
||||
|
||||
fgState.Initialised = GL_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -618,15 +618,11 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
||||
* size.
|
||||
*/
|
||||
|
||||
if( geometry )
|
||||
if (geometry )
|
||||
{
|
||||
unsigned int parsedWidth, parsedHeight;
|
||||
int mask = XParseGeometry( geometry,
|
||||
&fgState.Position.X, &fgState.Position.Y,
|
||||
&parsedWidth, &parsedHeight );
|
||||
/* TODO: Check for overflow? */
|
||||
fgState.Size.X = parsedWidth;
|
||||
fgState.Size.Y = parsedHeight;
|
||||
&fgState.Size.X, &fgState.Size.Y );
|
||||
|
||||
if( (mask & (WidthValue|HeightValue)) == (WidthValue|HeightValue) )
|
||||
fgState.Size.Use = GL_TRUE;
|
||||
|
@ -69,7 +69,6 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
#include <unistd.h>
|
||||
@ -634,7 +633,26 @@ extern SFG_State fgState;
|
||||
* A call to this function makes us sure that the Display and Structure
|
||||
* subsystems have been properly initialized and are ready to be used
|
||||
*/
|
||||
#define freeglut_assert_ready assert( fgState.Initialised );
|
||||
#define FREEGLUT_EXIT_IF_NOT_INITIALISED( string ) \
|
||||
if ( ! fgState.Initialised ) \
|
||||
{ \
|
||||
fgError ( " ERROR: Function <%s> called" \
|
||||
" without first calling 'glutInit'.", (string) ) ; \
|
||||
}
|
||||
|
||||
#define FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED( string ) \
|
||||
if ( ! fgState.Initialised ) \
|
||||
{ \
|
||||
fgError ( " ERROR: Internal <%s> function called" \
|
||||
" without first calling 'glutInit'.", (string) ) ; \
|
||||
}
|
||||
|
||||
#define FREEGLUT_INTERNAL_ERROR_EXIT( cond, string, function ) \
|
||||
if ( ! ( cond ) ) \
|
||||
{ \
|
||||
fgError ( " ERROR: Internal error <%s> in function %s", \
|
||||
(string), (function) ) ; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Following definitions are somewhat similiar to GLib's,
|
||||
@ -649,9 +667,8 @@ extern SFG_State fgState;
|
||||
|
||||
/*
|
||||
* A call to those macros assures us that there is a current
|
||||
* window and menu set, respectively:
|
||||
* window set, respectively:
|
||||
*/
|
||||
#define freeglut_assert_menu assert( fgStructure.Menu != NULL );
|
||||
#define FREEGLUT_EXIT_IF_NO_WINDOW( string ) \
|
||||
if ( ! fgStructure.Window ) \
|
||||
{ \
|
||||
|
@ -925,7 +925,9 @@ static void fghJoystickElementEnumerator ( SFG_Joystick *joy, void *element, voi
|
||||
/** element enumerator function : pass NULL for top-level*/
|
||||
static void fghJoystickEnumerateElements ( SFG_Joystick *joy, CFTypeRef element )
|
||||
{
|
||||
assert(CFGetTypeID(element) == CFArrayGetTypeID());
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT( (CFGetTypeID(element) == CFArrayGetTypeID(),
|
||||
"Joystick element type mismatch",
|
||||
"fghJoystickEnumerateElements" );
|
||||
|
||||
CFRange range = {0, CFArrayGetCount ((CFArrayRef)element)};
|
||||
CFArrayApplyFunction((CFArrayRef) element, range,
|
||||
@ -943,7 +945,7 @@ static void fghJoystickParseElement ( SFG_Joystick *joy, CFDictionaryRef element
|
||||
CFDictionaryGetValue ((CFDictionaryRef) element, CFSTR(kIOHIDElementTypeKey)),
|
||||
kCFNumberLongType, &type);
|
||||
|
||||
switch ( typ e) {
|
||||
switch ( type ) {
|
||||
case kIOHIDElementTypeInput_Misc:
|
||||
case kIOHIDElementTypeInput_Axis:
|
||||
case kIOHIDElementTypeInput_Button:
|
||||
@ -1763,63 +1765,76 @@ int fgJoystickDetect( void )
|
||||
*/
|
||||
int glutJoystickGetNumAxes( int ident )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetNumAxes" );
|
||||
return fgJoystick[ ident ]->num_axes;
|
||||
}
|
||||
int glutJoystickGetNumButtons( int ident )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetNumButtons" );
|
||||
return fgJoystick[ ident ]->num_buttons;
|
||||
}
|
||||
int glutJoystickNotWorking( int ident )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickNotWorking" );
|
||||
return fgJoystick[ ident ]->error;
|
||||
}
|
||||
|
||||
float glutJoystickGetDeadBand( int ident, int axis )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetDeadBand" );
|
||||
return fgJoystick[ ident ]->dead_band [ axis ];
|
||||
}
|
||||
void glutJoystickSetDeadBand( int ident, int axis, float db )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickSetDeadBand" );
|
||||
fgJoystick[ ident ]->dead_band[ axis ] = db;
|
||||
}
|
||||
|
||||
float glutJoystickGetSaturation( int ident, int axis )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetSaturation" );
|
||||
return fgJoystick[ ident ]->saturate[ axis ];
|
||||
}
|
||||
void glutJoystickSetSaturation( int ident, int axis, float st )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickSetSaturation" );
|
||||
fgJoystick[ ident ]->saturate [ axis ] = st;
|
||||
}
|
||||
|
||||
void glutJoystickSetMinRange( int ident, float *axes )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickSetMinRange" );
|
||||
memcpy( fgJoystick[ ident ]->min, axes,
|
||||
fgJoystick[ ident ]->num_axes * sizeof( float ) );
|
||||
}
|
||||
void glutJoystickSetMaxRange( int ident, float *axes )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickSetMaxRange" );
|
||||
memcpy( fgJoystick[ ident ]->max, axes,
|
||||
fgJoystick[ ident ]->num_axes * sizeof( float ) );
|
||||
}
|
||||
void glutJoystickSetCenter( int ident, float *axes )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickSetCenter" );
|
||||
memcpy( fgJoystick[ ident ]->center, axes,
|
||||
fgJoystick[ ident ]->num_axes * sizeof( float ) );
|
||||
}
|
||||
|
||||
void glutJoystickGetMinRange( int ident, float *axes )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetMinRange" );
|
||||
memcpy( axes, fgJoystick[ ident ]->min,
|
||||
fgJoystick[ ident ]->num_axes * sizeof( float ) );
|
||||
}
|
||||
void glutJoystickGetMaxRange( int ident, float *axes )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetMaxRange" );
|
||||
memcpy( axes, fgJoystick[ ident ]->max,
|
||||
fgJoystick[ ident ]->num_axes * sizeof( float ) );
|
||||
}
|
||||
void glutJoystickGetCenter( int ident, float *axes )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutJoystickGetCenter" );
|
||||
memcpy( axes, fgJoystick[ ident ]->center,
|
||||
fgJoystick[ ident ]->num_axes * sizeof( float ) );
|
||||
}
|
||||
|
@ -402,6 +402,7 @@ static void fghCheckJoystickCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
static int fghHaveJoystick( void )
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
fgEnumWindows( fghCheckJoystickCallback, &enumerator );
|
||||
@ -419,6 +420,7 @@ static void fghHavePendingRedisplaysCallback( SFG_Window* w, SFG_Enumerator* e)
|
||||
static int fghHavePendingRedisplays (void)
|
||||
{
|
||||
SFG_Enumerator enumerator;
|
||||
|
||||
enumerator.found = GL_FALSE;
|
||||
enumerator.data = NULL;
|
||||
fgEnumWindows( fghHavePendingRedisplaysCallback, &enumerator );
|
||||
@ -478,7 +480,7 @@ static void fghSleepForEvents( void )
|
||||
wait.tv_usec = (msec % 1000) * 1000;
|
||||
err = select( socket+1, &fdset, NULL, NULL, &wait );
|
||||
|
||||
if( ( -1 == err ) && ( errno != EINTR ) )
|
||||
if( -1 == err )
|
||||
fgWarning ( "freeglut select() error: %d", errno );
|
||||
}
|
||||
#elif TARGET_HOST_WIN32 || TARGET_HOST_WINCE
|
||||
@ -527,7 +529,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
window->State.MouseX = event.a.x; \
|
||||
window->State.MouseY = event.a.y;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
|
||||
|
||||
while( XPending( fgDisplay.Display ) )
|
||||
{
|
||||
@ -944,9 +946,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
special_cb = FETCH_WCB( *window, SpecialUp );
|
||||
}
|
||||
|
||||
/*
|
||||
* Is there a keyboard/special callback hooked for this window?
|
||||
*/
|
||||
/* Is there a keyboard/special callback hooked for this window? */
|
||||
if( keyboard_cb || special_cb )
|
||||
{
|
||||
XComposeStatus composeStatus;
|
||||
@ -954,21 +954,15 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
KeySym keySym;
|
||||
int len;
|
||||
|
||||
/*
|
||||
* Check for the ASCII/KeySym codes associated with the event:
|
||||
*/
|
||||
/* Check for the ASCII/KeySym codes associated with the event: */
|
||||
len = XLookupString( &event.xkey, asciiCode, sizeof(asciiCode),
|
||||
&keySym, &composeStatus
|
||||
);
|
||||
|
||||
/*
|
||||
* GLUT API tells us to have two separate callbacks...
|
||||
*/
|
||||
/* GLUT API tells us to have two separate callbacks... */
|
||||
if( len > 0 )
|
||||
{
|
||||
/*
|
||||
* ...one for the ASCII translateable keypresses...
|
||||
*/
|
||||
/* ...one for the ASCII translateable keypresses... */
|
||||
if( keyboard_cb )
|
||||
{
|
||||
fgSetWindow( window );
|
||||
@ -1048,6 +1042,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
|
||||
|
||||
MSG stMsg;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoopEvent" );
|
||||
|
||||
while( PeekMessage( &stMsg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
if( GetMessage( &stMsg, NULL, 0, 0 ) == 0 )
|
||||
@ -1088,7 +1084,7 @@ void FGAPIENTRY glutMainLoop( void )
|
||||
SFG_Window *window = (SFG_Window *)fgStructure.Windows.First ;
|
||||
#endif
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutMainLoop" );
|
||||
|
||||
#if TARGET_HOST_WIN32 || TARGET_HOST_WINCE
|
||||
/*
|
||||
@ -1158,6 +1154,7 @@ void FGAPIENTRY glutMainLoop( void )
|
||||
*/
|
||||
void FGAPIENTRY glutLeaveMainLoop( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLeaveMainLoop" );
|
||||
fgState.ExecState = GLUT_EXEC_STATE_STOP ;
|
||||
}
|
||||
|
||||
@ -1183,10 +1180,14 @@ static int fghGetWin32Modifiers (void)
|
||||
LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
SFG_Window* window = fgWindowByHandle( hWnd );
|
||||
SFG_Window* window;
|
||||
PAINTSTRUCT ps;
|
||||
LONG lRet = 1;
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Event Handler" ) ;
|
||||
|
||||
window = fgWindowByHandle( hWnd );
|
||||
|
||||
if ( ( window == NULL ) && ( uMsg != WM_CREATE ) )
|
||||
return DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
|
||||
@ -1197,7 +1198,8 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
case WM_CREATE:
|
||||
/* The window structure is passed as the creation structure paramter... */
|
||||
window = (SFG_Window *) (((LPCREATESTRUCT) lParam)->lpCreateParams);
|
||||
assert( window != NULL );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( ( window != NULL ), "Cannot create window",
|
||||
"fgWindowProc" );
|
||||
|
||||
window->Window.Handle = hWnd;
|
||||
window->Window.Device = GetDC( hWnd );
|
||||
@ -1311,7 +1313,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
* XXX function (or perhaps invoke glutSetCursor())?
|
||||
* XXX That is, why are we duplicating code, here, from
|
||||
* XXX glutSetCursor()? The WIN32 code should be able to just
|
||||
* XXX call glutSetCurdsor() instead of defining two macros
|
||||
* XXX call glutSetCursor() instead of defining two macros
|
||||
* XXX and implementing a nested case in-line.
|
||||
*/
|
||||
case WM_SETCURSOR:
|
||||
@ -1666,9 +1668,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
window->State.MouseX = mouse_pos.x;
|
||||
window->State.MouseY = mouse_pos.y;
|
||||
|
||||
/*
|
||||
* Convert the Win32 keystroke codes to GLUTtish way
|
||||
*/
|
||||
/* Convert the Win32 keystroke codes to GLUTtish way */
|
||||
# define KEY(a,b) case a: keypress = b; break;
|
||||
|
||||
switch( wParam )
|
||||
@ -1696,9 +1696,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
KEY( VK_INSERT, GLUT_KEY_INSERT );
|
||||
|
||||
case VK_DELETE:
|
||||
/*
|
||||
* The delete key should be treated as an ASCII keypress:
|
||||
*/
|
||||
/* The delete key should be treated as an ASCII keypress: */
|
||||
INVOKE_WCB( *window, Keyboard,
|
||||
( 127, window->State.MouseX, window->State.MouseY )
|
||||
);
|
||||
@ -1784,9 +1782,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
KEY( VK_INSERT, GLUT_KEY_INSERT );
|
||||
|
||||
case VK_DELETE:
|
||||
/*
|
||||
* The delete key should be treated as an ASCII keypress:
|
||||
*/
|
||||
/* The delete key should be treated as an ASCII keypress: */
|
||||
INVOKE_WCB( *window, KeyboardUp,
|
||||
( 127, window->State.MouseX, window->State.MouseY )
|
||||
);
|
||||
@ -1843,9 +1839,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
/*lRet = DefWindowProc( hWnd, uMsg, wParam, lParam ); */
|
||||
break;
|
||||
|
||||
/*
|
||||
* Other messages that I have seen and which are not handled already
|
||||
*/
|
||||
/* Other messages that I have seen and which are not handled already */
|
||||
case WM_SETTEXT: /* 0x000c */
|
||||
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
/* Pass it on to "DefWindowProc" to set the window text */
|
||||
@ -1964,9 +1958,7 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
break;
|
||||
|
||||
default:
|
||||
/*
|
||||
* Handle unhandled messages
|
||||
*/
|
||||
/* Handle unhandled messages */
|
||||
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
break;
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu )
|
||||
|
||||
/* The mouse cursor is somewhere over our box, check it out. */
|
||||
menuEntry = fghFindMenuEntry( menu, menuID + 1 );
|
||||
assert( menuEntry );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT( menuEntry, "Cannot find menu entry",
|
||||
"fghCheckMenuStatus" );
|
||||
|
||||
menuEntry->IsActive = GL_TRUE;
|
||||
menuEntry->Ordinal = menuID;
|
||||
@ -394,7 +395,8 @@ void fgDisplayMenu( void )
|
||||
SFG_Window* window = fgStructure.Window;
|
||||
SFG_Menu* menu = NULL;
|
||||
|
||||
freeglut_return_if_fail ( fgStructure.Window != NULL );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( fgStructure.Window, "Displaying menu in nonexistent window",
|
||||
"fgDisplayMenu" );
|
||||
|
||||
/* Check if there is an active menu attached to this window... */
|
||||
menu = window->ActiveMenu;
|
||||
@ -588,7 +590,6 @@ void fghCalculateMenuBoxSize( void )
|
||||
int width = 0, height = 0;
|
||||
|
||||
/* Make sure there is a current menu set */
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
|
||||
/* The menu's box size depends on the menu entries: */
|
||||
@ -633,6 +634,7 @@ void fghCalculateMenuBoxSize( void )
|
||||
int FGAPIENTRY glutCreateMenu( void(* callback)( int ) )
|
||||
{
|
||||
/* The menu object creation code resides in freeglut_structure.c */
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenu" );
|
||||
return fgCreateMenu( callback )->ID;
|
||||
}
|
||||
|
||||
@ -641,9 +643,11 @@ int FGAPIENTRY glutCreateMenu( void(* callback)( int ) )
|
||||
*/
|
||||
void FGAPIENTRY glutDestroyMenu( int menuID )
|
||||
{
|
||||
SFG_Menu* menu = fgMenuByID( menuID );
|
||||
SFG_Menu* menu;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDestroyMenu" );
|
||||
menu = fgMenuByID( menuID );
|
||||
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( menu );
|
||||
|
||||
/* The menu object destruction code resides in freeglut_structure.c */
|
||||
@ -655,7 +659,7 @@ void FGAPIENTRY glutDestroyMenu( int menuID )
|
||||
*/
|
||||
int FGAPIENTRY glutGetMenu( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetMenu" );
|
||||
|
||||
if( fgStructure.Menu )
|
||||
return fgStructure.Menu->ID;
|
||||
@ -668,9 +672,11 @@ int FGAPIENTRY glutGetMenu( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSetMenu( int menuID )
|
||||
{
|
||||
SFG_Menu* menu = fgMenuByID( menuID );
|
||||
SFG_Menu* menu;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetMenu" );
|
||||
menu = fgMenuByID( menuID );
|
||||
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( menu );
|
||||
|
||||
fgStructure.Menu = menu;
|
||||
@ -681,10 +687,9 @@ void FGAPIENTRY glutSetMenu( int menuID )
|
||||
*/
|
||||
void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
|
||||
{
|
||||
SFG_MenuEntry* menuEntry =
|
||||
(SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 );
|
||||
|
||||
freeglut_assert_ready;
|
||||
SFG_MenuEntry* menuEntry;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutAddMenuEntry" );
|
||||
menuEntry = (SFG_MenuEntry *)calloc( sizeof(SFG_MenuEntry), 1 );
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
|
||||
menuEntry->Text = strdup( label );
|
||||
@ -701,11 +706,13 @@ void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
|
||||
*/
|
||||
void FGAPIENTRY glutAddSubMenu( const char *label, int subMenuID )
|
||||
{
|
||||
SFG_MenuEntry *menuEntry =
|
||||
( SFG_MenuEntry * )calloc( sizeof( SFG_MenuEntry ), 1 );
|
||||
SFG_Menu *subMenu = fgMenuByID( subMenuID );
|
||||
SFG_MenuEntry *menuEntry;
|
||||
SFG_Menu *subMenu;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutAddSubMenu" );
|
||||
menuEntry = ( SFG_MenuEntry * )calloc( sizeof( SFG_MenuEntry ), 1 );
|
||||
subMenu = fgMenuByID( subMenuID );
|
||||
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
freeglut_return_if_fail( subMenu );
|
||||
|
||||
@ -727,7 +734,7 @@ void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value )
|
||||
{
|
||||
SFG_MenuEntry* menuEntry = NULL;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutChangeToMenuEntry" );
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
|
||||
/* Get n-th menu entry in the current menu, starting from one: */
|
||||
@ -751,10 +758,13 @@ void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value )
|
||||
void FGAPIENTRY glutChangeToSubMenu( int item, const char* label,
|
||||
int subMenuID )
|
||||
{
|
||||
SFG_Menu* subMenu = fgMenuByID( subMenuID );
|
||||
SFG_MenuEntry* menuEntry = NULL;
|
||||
SFG_Menu* subMenu;
|
||||
SFG_MenuEntry* menuEntry;
|
||||
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutChangeToSubMenu" );
|
||||
subMenu = fgMenuByID( subMenuID );
|
||||
menuEntry = NULL;
|
||||
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
freeglut_return_if_fail( subMenu );
|
||||
|
||||
@ -780,7 +790,7 @@ void FGAPIENTRY glutRemoveMenuItem( int item )
|
||||
{
|
||||
SFG_MenuEntry* menuEntry;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutRemoveMenuItem" );
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
|
||||
/* Get n-th menu entry in the current menu, starting from one: */
|
||||
@ -801,7 +811,7 @@ void FGAPIENTRY glutRemoveMenuItem( int item )
|
||||
*/
|
||||
void FGAPIENTRY glutAttachMenu( int button )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutAttachMenu" );
|
||||
|
||||
freeglut_return_if_fail( fgStructure.Window );
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
@ -820,7 +830,7 @@ void FGAPIENTRY glutAttachMenu( int button )
|
||||
*/
|
||||
void FGAPIENTRY glutDetachMenu( int button )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDetachMenu" );
|
||||
|
||||
freeglut_return_if_fail( fgStructure.Window );
|
||||
freeglut_return_if_fail( fgStructure.Menu );
|
||||
@ -836,11 +846,13 @@ void FGAPIENTRY glutDetachMenu( int button )
|
||||
*/
|
||||
void* FGAPIENTRY glutGetMenuData( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetMenuData" );
|
||||
return fgStructure.Menu->UserData;
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutSetMenuData(void* data)
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetMenuData" );
|
||||
fgStructure.Menu->UserData=data;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ int FGAPIENTRY glutExtensionSupported( const char* extension )
|
||||
const int len = strlen( extension );
|
||||
|
||||
/* Make sure there is a current window, and thus a current context available */
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutExtensionSupported" );
|
||||
freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
|
||||
|
||||
if (strchr(extension, ' '))
|
||||
@ -86,6 +86,7 @@ int FGAPIENTRY glutExtensionSupported( const char* extension )
|
||||
void FGAPIENTRY glutReportErrors( void )
|
||||
{
|
||||
GLenum error;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReportErrors" );
|
||||
while( ( error = glGetError() ) != GL_NO_ERROR )
|
||||
fgWarning( "GL error: %s", gluErrorString( error ) );
|
||||
}
|
||||
@ -95,7 +96,7 @@ void FGAPIENTRY glutReportErrors( void )
|
||||
*/
|
||||
void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIgnoreKeyRepeat" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIgnoreKeyRepeat" );
|
||||
|
||||
fgStructure.Window->State.IgnoreKeyRepeat = ignore ? GL_TRUE : GL_FALSE;
|
||||
@ -111,7 +112,7 @@ void FGAPIENTRY glutIgnoreKeyRepeat( int ignore )
|
||||
*/
|
||||
void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetKeyRepeat" );
|
||||
|
||||
switch( repeatMode )
|
||||
{
|
||||
@ -135,8 +136,8 @@ void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
|
||||
*/
|
||||
void FGAPIENTRY glutForceJoystickFunc( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutForceJoystickFunc" );
|
||||
#if !TARGET_HOST_WINCE
|
||||
freeglut_assert_ready;
|
||||
freeglut_return_if_fail( fgStructure.Window != NULL );
|
||||
freeglut_return_if_fail( FETCH_WCB( *( fgStructure.Window ), Joystick ) );
|
||||
fgJoystickPollWindow( fgStructure.Window );
|
||||
@ -148,6 +149,7 @@ void FGAPIENTRY glutForceJoystickFunc( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat blue )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetColor" );
|
||||
/* We really need to do something here. */
|
||||
}
|
||||
|
||||
@ -156,6 +158,7 @@ void FGAPIENTRY glutSetColor( int nColor, GLfloat red, GLfloat green, GLfloat bl
|
||||
*/
|
||||
GLfloat FGAPIENTRY glutGetColor( int color, int component )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetColor" );
|
||||
/* We really need to do something here. */
|
||||
return( 0.0f );
|
||||
}
|
||||
@ -165,6 +168,7 @@ GLfloat FGAPIENTRY glutGetColor( int color, int component )
|
||||
*/
|
||||
void FGAPIENTRY glutCopyColormap( int window )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCopyColormap" );
|
||||
/* We really need to do something here. */
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ static int fghGetConfig( int attribute )
|
||||
*/
|
||||
void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetOption" );
|
||||
|
||||
/*
|
||||
* XXX In chronological code add order. (WHY in that order?)
|
||||
@ -142,7 +142,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
||||
return fgElapsedTime();
|
||||
}
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGet" );
|
||||
|
||||
/* XXX In chronological code add order. (WHY in that order?) */
|
||||
switch( eWhat )
|
||||
@ -465,7 +465,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
||||
*/
|
||||
int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDeviceGet" );
|
||||
|
||||
/* XXX WARNING: we are mostly lying in this function. */
|
||||
switch( eWhat )
|
||||
@ -537,7 +537,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
case GLUT_JOYSTICK_POLL_RATE:
|
||||
return fgStructure.Window ? fgStructure.Window->State.JoystickPollRate : 0;
|
||||
|
||||
/* The following two are only for Joystick 0 but this is an improvement */
|
||||
/* XXX The following two are only for Joystick 0 but this is an improvement */
|
||||
case GLUT_JOYSTICK_BUTTONS:
|
||||
return glutJoystickGetNumButtons ( 0 );
|
||||
|
||||
@ -559,7 +559,8 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
return fgStructure.Window ? fgStructure.Window->State.IgnoreKeyRepeat : 0;
|
||||
|
||||
case GLUT_DEVICE_KEY_REPEAT:
|
||||
return fgState.KeyRepeat;
|
||||
/* XXX WARNING: THIS IS A BIG LIE! */
|
||||
return GLUT_KEY_REPEAT_DEFAULT;
|
||||
|
||||
default:
|
||||
fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat );
|
||||
@ -575,6 +576,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
|
||||
*/
|
||||
int FGAPIENTRY glutGetModifiers( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetModifiers" );
|
||||
if( fgState.Modifiers == 0xffffffff )
|
||||
{
|
||||
fgWarning( "glutGetModifiers() called outside an input callback" );
|
||||
@ -589,7 +591,7 @@ int FGAPIENTRY glutGetModifiers( void )
|
||||
*/
|
||||
int FGAPIENTRY glutLayerGet( GLenum eWhat )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutLayerGet" );
|
||||
|
||||
/*
|
||||
* This is easy as layers are not implemented ;-)
|
||||
|
@ -79,13 +79,6 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
|
||||
|
||||
fghClearCallBacks( window );
|
||||
|
||||
/*
|
||||
* If the freeglut internals haven't been initialized yet,
|
||||
* do it now. Hack's idea courtesy of Chris Purnell...
|
||||
*/
|
||||
if( !fgState.Initialised )
|
||||
glutInit( &fakeArgc, NULL );
|
||||
|
||||
/* Initialize the object properties */
|
||||
window->ID = ++fgStructure.WindowID;
|
||||
window->State.OldHeight = window->State.OldWidth = -1;
|
||||
@ -129,13 +122,6 @@ SFG_Menu* fgCreateMenu( FGCBMenu menuCallback )
|
||||
SFG_Menu* menu = (SFG_Menu *)calloc( sizeof(SFG_Menu), 1 );
|
||||
int fakeArgc = 0;
|
||||
|
||||
/*
|
||||
* If the freeglut internals haven't been initialized yet,
|
||||
* do it now. Hack's idea courtesy of Chris Purnell...
|
||||
*/
|
||||
if( !fgState.Initialised )
|
||||
glutInit( &fakeArgc, NULL );
|
||||
|
||||
menu->ParentWindow = fgStructure.Window;
|
||||
|
||||
/* Create a window for the menu to reside in. */
|
||||
@ -215,8 +201,8 @@ void fgDestroyWindow( SFG_Window* window )
|
||||
{
|
||||
int menu_index;
|
||||
|
||||
assert( window );
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( window, "Window destroy function called with null window",
|
||||
"fgDestroyWindow" );
|
||||
|
||||
while( window->Children.First )
|
||||
fgDestroyWindow( ( SFG_Window * )window->Children.First );
|
||||
@ -294,8 +280,8 @@ void fgDestroyMenu( SFG_Menu* menu )
|
||||
SFG_Window *window;
|
||||
SFG_Menu *from;
|
||||
|
||||
assert( menu );
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( menu, "Menu destroy function called with null menu",
|
||||
"fgDestroyMenu" );
|
||||
|
||||
/* First of all, have all references to this menu removed from all windows: */
|
||||
for( window = (SFG_Window *)fgStructure.Windows.First;
|
||||
@ -374,8 +360,6 @@ void fgCreateStructure( void )
|
||||
*/
|
||||
void fgDestroyStructure( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
|
||||
/* Clean up the WindowsToDestroy list. */
|
||||
fgCloseWindows( );
|
||||
|
||||
@ -394,8 +378,9 @@ void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator )
|
||||
{
|
||||
SFG_Window *window;
|
||||
|
||||
assert( enumCallback && enumerator );
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( enumCallback && enumerator,
|
||||
"Enumerator or callback missing from window enumerator call",
|
||||
"fgEnumWindows" );
|
||||
|
||||
/* Check every of the top-level windows */
|
||||
for( window = ( SFG_Window * )fgStructure.Windows.First;
|
||||
@ -417,8 +402,10 @@ void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback,
|
||||
{
|
||||
SFG_Window *child;
|
||||
|
||||
assert( enumCallback && enumerator );
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( enumCallback && enumerator,
|
||||
"Enumerator or callback missing from subwindow enumerator call",
|
||||
"fgEnumSubWindows" );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT_IF_NOT_INITIALISED ( "Window Enumeration" );
|
||||
|
||||
for( child = ( SFG_Window * )window->Children.First;
|
||||
child;
|
||||
@ -519,8 +506,6 @@ SFG_Menu* fgMenuByID( int menuID )
|
||||
{
|
||||
SFG_Menu *menu = NULL;
|
||||
|
||||
freeglut_assert_ready;
|
||||
|
||||
/* It's enough to check all entries in fgStructure.Menus... */
|
||||
for( menu = (SFG_Menu *)fgStructure.Menus.First;
|
||||
menu;
|
||||
|
@ -182,6 +182,7 @@ static void fghTeapot( GLint grid, GLdouble scale, GLenum type )
|
||||
*/
|
||||
void FGAPIENTRY glutWireTeapot( GLdouble size )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutWireTeapot" );
|
||||
/* We will use the general teapot rendering code */
|
||||
fghTeapot( 10, size, GL_LINE );
|
||||
}
|
||||
@ -191,6 +192,7 @@ void FGAPIENTRY glutWireTeapot( GLdouble size )
|
||||
*/
|
||||
void FGAPIENTRY glutSolidTeapot( GLdouble size )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSolidTeapot" );
|
||||
/* We will use the general teapot rendering code */
|
||||
fghTeapot( 7, size, GL_FILL );
|
||||
}
|
||||
|
@ -2426,3 +2426,4 @@ static double tex[2][2][2] =
|
||||
|
||||
|
||||
#endif /* FREEGLUT_TEAPOT_DATA_H */
|
||||
|
||||
|
@ -275,8 +275,6 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
XWMHints wmHints;
|
||||
unsigned long mask;
|
||||
|
||||
freeglut_assert_ready;
|
||||
|
||||
/*
|
||||
* XXX fgChooseVisual() is a common part of all three.
|
||||
* XXX With a little thought, we should be able to greatly
|
||||
@ -315,14 +313,8 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX This seems to be abusing an assert() for error-checking.
|
||||
* XXX It is possible that the visual simply can't be found,
|
||||
* XXX in which case we should print an error and return a 0
|
||||
* XXX for the window id, I think.
|
||||
*/
|
||||
assert( window->Window.VisualInfo != NULL );
|
||||
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT( window->Window.VisualInfo != NULL,
|
||||
"Unable to get window visual info", "fgOpenWindow" );
|
||||
|
||||
/*
|
||||
* XXX HINT: the masks should be updated when adding/removing callbacks.
|
||||
@ -336,7 +328,7 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
*/
|
||||
winAttr.event_mask =
|
||||
StructureNotifyMask | SubstructureNotifyMask | ExposureMask |
|
||||
ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask |
|
||||
ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyRelease |
|
||||
VisibilityChangeMask | EnterWindowMask | LeaveWindowMask |
|
||||
PointerMotionMask | ButtonMotionMask;
|
||||
winAttr.background_pixmap = None;
|
||||
@ -488,15 +480,16 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
DWORD exFlags = 0;
|
||||
ATOM atom;
|
||||
|
||||
freeglut_assert_ready;
|
||||
|
||||
/* Grab the window class we have registered on glutInit(): */
|
||||
atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc );
|
||||
assert( atom != 0 );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Info Not Found",
|
||||
"fgOpenWindow" );
|
||||
|
||||
if( gameMode )
|
||||
{
|
||||
assert( window->Parent == NULL );
|
||||
FREEGLUT_INTERNAL_ERROR_EXIT ( window->Parent == NULL,
|
||||
"Game mode being invoked on a subwindow",
|
||||
"fgOpenWindow" );
|
||||
|
||||
/*
|
||||
* Set the window creation flags appropriately to make the window
|
||||
@ -620,8 +613,6 @@ void fgOpenWindow( SFG_Window* window, const char* title,
|
||||
*/
|
||||
void fgCloseWindow( SFG_Window* window )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
|
||||
glXDestroyContext( fgDisplay.Display, window->Window.Context );
|
||||
@ -667,6 +658,8 @@ void fgCloseWindow( SFG_Window* window )
|
||||
*/
|
||||
int FGAPIENTRY glutCreateWindow( const char* title )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateWindow" );
|
||||
|
||||
return fgCreateWindow( NULL, title, fgState.Position.X, fgState.Position.Y,
|
||||
fgState.Size.X, fgState.Size.Y, GL_FALSE,
|
||||
GL_FALSE )->ID;
|
||||
@ -681,7 +674,7 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
|
||||
SFG_Window* window = NULL;
|
||||
SFG_Window* parent = NULL;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateSubWindow" );
|
||||
parent = fgWindowByID( parentID );
|
||||
freeglut_return_val_if_fail( parent != NULL, 0 );
|
||||
window = fgCreateWindow( parent, "", x, y, w, h, GL_FALSE, GL_FALSE );
|
||||
@ -695,7 +688,9 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
|
||||
*/
|
||||
void FGAPIENTRY glutDestroyWindow( int windowID )
|
||||
{
|
||||
SFG_Window* window = fgWindowByID( windowID );
|
||||
SFG_Window* window;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutDestroyWindow" );
|
||||
window = fgWindowByID( windowID );
|
||||
freeglut_return_if_fail( window != NULL );
|
||||
{
|
||||
fgExecutionState ExecState = fgState.ExecState;
|
||||
@ -711,7 +706,7 @@ void FGAPIENTRY glutSetWindow( int ID )
|
||||
{
|
||||
SFG_Window* window = NULL;
|
||||
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetWindow" );
|
||||
if( fgStructure.Window != NULL )
|
||||
if( fgStructure.Window->ID == ID )
|
||||
return;
|
||||
@ -731,7 +726,7 @@ void FGAPIENTRY glutSetWindow( int ID )
|
||||
*/
|
||||
int FGAPIENTRY glutGetWindow( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetWindow" );
|
||||
if( fgStructure.Window == NULL )
|
||||
return 0;
|
||||
return fgStructure.Window->ID;
|
||||
@ -742,7 +737,7 @@ int FGAPIENTRY glutGetWindow( void )
|
||||
*/
|
||||
void FGAPIENTRY glutShowWindow( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutShowWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutShowWindow" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -764,7 +759,7 @@ void FGAPIENTRY glutShowWindow( void )
|
||||
*/
|
||||
void FGAPIENTRY glutHideWindow( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutHideWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutHideWindow" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -792,7 +787,7 @@ void FGAPIENTRY glutHideWindow( void )
|
||||
*/
|
||||
void FGAPIENTRY glutIconifyWindow( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutIconifyWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutIconifyWindow" );
|
||||
|
||||
fgStructure.Window->State.Visible = GL_FALSE;
|
||||
@ -816,7 +811,7 @@ void FGAPIENTRY glutIconifyWindow( void )
|
||||
*/
|
||||
void FGAPIENTRY glutSetWindowTitle( const char* title )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetWindowTitle" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetWindowTitle" );
|
||||
if( ! fgStructure.Window->Parent )
|
||||
{
|
||||
@ -858,7 +853,7 @@ void FGAPIENTRY glutSetWindowTitle( const char* title )
|
||||
*/
|
||||
void FGAPIENTRY glutSetIconTitle( const char* title )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetIconTitle" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetIconTitle" );
|
||||
|
||||
if( ! fgStructure.Window->Parent )
|
||||
@ -901,7 +896,7 @@ void FGAPIENTRY glutSetIconTitle( const char* title )
|
||||
*/
|
||||
void FGAPIENTRY glutReshapeWindow( int width, int height )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutReshapeWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutReshapeWindow" );
|
||||
|
||||
fgStructure.Window->State.NeedToResize = GL_TRUE;
|
||||
@ -914,7 +909,7 @@ void FGAPIENTRY glutReshapeWindow( int width, int height )
|
||||
*/
|
||||
void FGAPIENTRY glutPositionWindow( int x, int y )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPositionWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPositionWindow" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -948,7 +943,7 @@ void FGAPIENTRY glutPositionWindow( int x, int y )
|
||||
*/
|
||||
void FGAPIENTRY glutPushWindow( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPushWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPushWindow" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -972,7 +967,7 @@ void FGAPIENTRY glutPushWindow( void )
|
||||
*/
|
||||
void FGAPIENTRY glutPopWindow( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPopWindow" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutPopWindow" );
|
||||
|
||||
#if TARGET_HOST_UNIX_X11
|
||||
@ -996,7 +991,7 @@ void FGAPIENTRY glutPopWindow( void )
|
||||
*/
|
||||
void FGAPIENTRY glutFullScreen( void )
|
||||
{
|
||||
freeglut_assert_ready;
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutFullScreen" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutFullScreen" );
|
||||
|
||||
{
|
||||
@ -1071,11 +1066,15 @@ void FGAPIENTRY glutFullScreen( void )
|
||||
*/
|
||||
void* FGAPIENTRY glutGetWindowData( void )
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetWindowData" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutGetWindowData" );
|
||||
return fgStructure.Window->UserData;
|
||||
}
|
||||
|
||||
void FGAPIENTRY glutSetWindowData(void* data)
|
||||
{
|
||||
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutSetWindowData" );
|
||||
FREEGLUT_EXIT_IF_NO_WINDOW ( "glutSetWindowData" );
|
||||
fgStructure.Window->UserData = data;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user