Removed glib dependancy

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@12 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
cjp 2001-07-29 11:17:00 +00:00
parent b4a9d78580
commit 704d1bfe6b
19 changed files with 1392 additions and 1298 deletions

View File

@ -31,7 +31,7 @@ libfreeglut_1_3_la_SOURCES = freeglut_callbacks.c \
#
# Additional linker flags
#
libfreeglut_1_3_la_LIBADD = $(LIBM) $(X_LIBS) -lGL -lGLU -lXext -lX11 -lXxf86vm -lglib
libfreeglut_1_3_la_LIBADD = $(LIBM) $(X_LIBS) -lGL -lGLU -lXext -lX11 -lXxf86vm
libfreeglut_1_3_la_LDFLAGS = -version-info 0:0:0
#

View File

@ -100,7 +100,7 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ), i
/*
* Create a new freeglut timer hook structure
*/
timer = g_new0( SFG_Timer, 1 );
timer = calloc( sizeof(SFG_Timer), 1 );
/*
* Remember the callback address and timer hook's ID
@ -111,13 +111,12 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ), i
/*
* When will the time out happen (in terms of window's timer)
*/
timer->TriggerTime =
g_timer_elapsed( fgState.Timer, NULL ) + (((double) timeOut) / 1000.0);
timer->TriggerTime = fgElapsedTime() + timeOut;
/*
* Have the new hook attached to the current window
*/
fgState.Timers = g_list_append( fgState.Timers, timer );
fgListAppend( &fgState.Timers, &timer->Node );
}
/*
@ -126,7 +125,7 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ), i
* I had to peer to GLUT sources to clean up the mess.
* Can anyone please explain me what is going on here?!?
*/
static void fghVisibility( gint status )
static void fghVisibility( int status )
{
freeglut_assert_ready; freeglut_return_if_fail( fgStructure.Window != NULL );
freeglut_return_if_fail( fgStructure.Window->Callbacks.Visibility != NULL );
@ -175,13 +174,13 @@ void FGAPIENTRY glutJoystickFunc( void (* callback)( unsigned int, int, int, int
/*
* Do not forget setting the joystick poll rate
*/
fgStructure.Window->State.JoystickPollRate = ((double) pollInterval) / 1000.0;
fgStructure.Window->State.JoystickPollRate = pollInterval;
/*
* Make sure the joystick polling routine gets called as early as possible:
*/
fgStructure.Window->State.JoystickLastPoll =
g_timer_elapsed( fgState.Timer, NULL ) - fgStructure.Window->State.JoystickPollRate;
fgElapsedTime() - fgStructure.Window->State.JoystickPollRate;
if( fgStructure.Window->State.JoystickLastPoll < 0.0 )
fgStructure.Window->State.JoystickLastPoll = 0.0;

View File

@ -92,7 +92,9 @@ static SFG_Font* fghFontByID( void* font )
/*
* This probably is the library user's fault
*/
g_error( "font 0x%08x not found", font );
fgError( "font 0x%08x not found", font );
return 0;
}
@ -103,7 +105,7 @@ static SFG_Font* fghFontByID( void* font )
*/
void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
{
const guchar* face;
const GLubyte* face;
/*
* First of all we'll need a font to use
@ -151,6 +153,14 @@ void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
glPopClientAttrib();
}
void FGAPIENTRY glutBitmapString( void* fontID, const char *string )
{
int i;
for( i=0; i<strlen( string ); i++ )
glutBitmapCharacter( fontID, string[ i ] );
}
/*
* Returns the width in pixels of a font's character
*/
@ -199,12 +209,12 @@ int FGAPIENTRY glutStrokeWidth( void* fontID, int character )
*/
int FGAPIENTRY glutBitmapLength( void* fontID, const char* string )
{
gint i, length = 0;
int i, length = 0;
/*
* Using glutBitmapWidth() function to calculate the result
*/
for( i=0; i<(gint) strlen( string ); i++ )
for( i=0; i<strlen( string ); i++ )
length += glutBitmapWidth( fontID, string[ i ] );
/*
@ -218,12 +228,12 @@ int FGAPIENTRY glutBitmapLength( void* fontID, const char* string )
*/
int FGAPIENTRY glutStrokeLength( void* fontID, const char* string )
{
gint i, length = 0;
int i, length = 0;
/*
* Using glutStrokeWidth() function to calculate the result
*/
for( i=0; i<(gint) strlen( string ); i++ )
for( i=0; i<strlen( string ); i++ )
length += glutStrokeWidth( fontID, string[ i ] );
/*

File diff suppressed because one or more lines are too long

View File

@ -103,7 +103,7 @@ void fghRestoreState( void )
# ifdef X_XF86VidModeGetAllModeLines
XF86VidModeModeInfo** displayModes;
gint i, displayModesCount;
int i, displayModesCount;
/*
* Query for all the display available...
@ -154,7 +154,7 @@ void fghRestoreState( void )
/*
* Checks the display mode settings against user's preferences
*/
gboolean fghCheckDisplayMode( gint width, gint height, gint depth, gint refresh )
GLboolean fghCheckDisplayMode( int width, int height, int depth, int refresh )
{
/*
* The desired values should be stored in fgState structure...
@ -166,7 +166,7 @@ gboolean fghCheckDisplayMode( gint width, gint height, gint depth, gint refresh
/*
* Changes the current display mode to match user's settings
*/
gboolean fghChangeDisplayMode( gboolean haveToTest )
GLboolean fghChangeDisplayMode( GLboolean haveToTest )
{
#if TARGET_HOST_UNIX_X11
@ -176,7 +176,7 @@ gboolean fghChangeDisplayMode( gboolean haveToTest )
# ifdef X_XF86VidModeGetAllModeLines
XF86VidModeModeInfo** displayModes;
gint i, displayModesCount;
int i, displayModesCount;
/*
* Query for all the display available...
@ -267,7 +267,7 @@ gboolean fghChangeDisplayMode( gboolean haveToTest )
*/
if( mode != 0xffffffff )
{
gint retVal = DISP_CHANGE_SUCCESSFUL;
int retVal = DISP_CHANGE_SUCCESSFUL;
/*
* Mark the values we want to modify in the display change call
@ -310,9 +310,9 @@ gboolean fghChangeDisplayMode( gboolean haveToTest )
/*
* Sets the game mode display string
*/
void FGAPIENTRY glutGameModeString( const gchar* string )
void FGAPIENTRY glutGameModeString( const char* string )
{
gint width = 640, height = 480, depth = 16, refresh = 72;
int width = 640, height = 480, depth = 16, refresh = 72;
/*
* This one seems a bit easier than glutInitDisplayString. The bad thing
@ -327,7 +327,7 @@ void FGAPIENTRY glutGameModeString( const gchar* string )
if( sscanf( string, ":%i@%i", &depth, &refresh ) != 2 )
if( sscanf( string, ":%i", &depth ) != 1 )
if( sscanf( string, "@%i", &refresh ) != 1 )
g_warning( "unable to parse game mode string `%s'", string );
fgWarning( "unable to parse game mode string `%s'", string );
/*
* Hopefully it worked, and if not, we still have the default values
@ -366,7 +366,7 @@ int FGAPIENTRY glutEnterGameMode( void )
*/
if( fghChangeDisplayMode( FALSE ) == FALSE )
{
g_warning( "failed to change screen settings" );
fgWarning( "failed to change screen settings" );
return( FALSE );
}
@ -502,6 +502,8 @@ int FGAPIENTRY glutGameModeGet( GLenum eWhat )
*/
return( fgStructure.GameMode != NULL );
}
return( -1 );
}
/*** END OF FILE ***/

View File

@ -123,12 +123,12 @@ void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks )
{
float radius = (float) dRadius, phi, psi, dpsi, dphi;
float* vertex;
gint i, j;
int i, j;
/*
* Allocate the vertices array
*/
vertex = g_new0( float, 3 * slices * (stacks - 1) );
vertex = calloc( sizeof(float), 3 * slices * (stacks - 1) );
glPushMatrix();
glScalef( radius, radius, radius );
@ -183,7 +183,7 @@ void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks )
glEnd();
}
g_free( vertex );
free( vertex );
glPopMatrix();
}
@ -194,13 +194,13 @@ void FGAPIENTRY glutSolidSphere( GLdouble dRadius, GLint slices, GLint stacks )
{
float radius = (float) dRadius, phi, psi, dpsi, dphi;
float *next, *tmp, *row;
gint i, j;
int i, j;
glPushMatrix();
//glScalef( radius, radius, radius );
row = g_new0( float, slices * 3 );
next = g_new0( float, slices * 3 );
row = calloc( sizeof(float), slices * 3 );
next = calloc( sizeof(float), slices * 3 );
dpsi = M_PI / (stacks + 1);
dphi = 2 * M_PI / slices;
@ -294,8 +294,8 @@ void FGAPIENTRY glutSolidSphere( GLdouble dRadius, GLint slices, GLint stacks )
glEnd();
g_free(row);
g_free(next);
free(row);
free(next);
glPopMatrix();
}
@ -308,12 +308,12 @@ void FGAPIENTRY glutWireCone( GLdouble base, GLdouble height, GLint slices, GLin
float angle = (float) M_PI / (float) slices * 2.0f;
float slope = (float) tan( height / base );
float* vertices = NULL;
gint i, j;
int i, j;
/*
* We need 'slices' points on a circle
*/
vertices = g_new0( float, 2 * (slices + 1) );
vertices = calloc( sizeof(float), 2 * (slices + 1) );
for( i=0; i<slices+1; i++ )
{
@ -387,12 +387,12 @@ void FGAPIENTRY glutSolidCone( GLdouble base, GLdouble height, GLint slices, GLi
float angle = (float) M_PI / (float) slices * 2.0f;
float slope = (float) tan( height / base );
float* vertices = NULL;
gint i, j;
int i, j;
/*
* We need 'slices' points on a circle
*/
vertices = g_new0( float, 2 * (slices + 1) );
vertices = calloc( sizeof(float), 2 * (slices + 1) );
for( i=0; i<slices+1; i++ )
{

View File

@ -63,7 +63,7 @@ SFG_State fgState;
/*
* A call to this function should initialize all the display stuff...
*/
void fgInitialize( const gchar* displayName )
void fgInitialize( const char* displayName )
{
#if TARGET_HOST_UNIX_X11
/*
@ -76,7 +76,7 @@ void fgInitialize( const gchar* displayName )
/*
* Failed to open a display. That's no good.
*/
g_error( "failed to open display '%s'", XDisplayName( displayName ) );
fgError( "failed to open display '%s'", XDisplayName( displayName ) );
}
/*
@ -87,7 +87,7 @@ void fgInitialize( const gchar* displayName )
/*
* GLX extensions have not been found...
*/
g_error( "OpenGL GLX extension not supported by display '%s'", XDisplayName( displayName ) );
fgError( "OpenGL GLX extension not supported by display '%s'", XDisplayName( displayName ) );
}
/*
@ -229,14 +229,14 @@ void fgInitialize( const gchar* displayName )
*/
void fgDeinitialize( void )
{
gint i;
SFG_Timer *timer;
/*
* Check if initialization has been performed before
*/
if( fgState.Timer == NULL )
if( !fgState.Time.Set )
{
g_warning( "fgDeinitialize(): fgState.Timer is null => no valid initialization has been performed" );
fgWarning( "fgDeinitialize(): fgState.Timer is null => no valid initialization has been performed" );
return;
}
@ -248,18 +248,11 @@ void fgDeinitialize( void )
/*
* Delete all the timers and their storage list
*/
for( i=0; i<(gint) g_list_length( fgState.Timers ); i++ )
g_free( g_list_nth( fgState.Timers, i )->data );
g_list_free( fgState.Timers );
fgState.Timers = NULL;
/*
* Destroy the timer itself
*/
g_timer_stop( fgState.Timer );
g_timer_destroy( fgState.Timer );
fgState.Timer = NULL;
while ( (timer = fgState.Timers.First) != NULL )
{
fgListRemove(&fgState.Timers, &timer->Node);
free(timer);
}
/*
* Deinitialize the joystick device
@ -290,19 +283,19 @@ void fgDeinitialize( void )
*/
void FGAPIENTRY glutInit( int* pargc, char** argv )
{
gchar* geometrySettings = NULL;
gchar* displayName = NULL;
gint i, j, argc = *pargc;
char* geometrySettings = NULL;
char* displayName = NULL;
int i, j, argc = *pargc;
/*
* Do not allow multiple initialization of the library
*/
if( fgState.Timer != NULL )
if( fgState.Time.Set )
{
/*
* We can't have multiple initialization performed
*/
g_error( "illegal glutInit() reinitialization attemp" );
fgError( "illegal glutInit() reinitialization attemp" );
}
/*
@ -356,14 +349,14 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
/*
* Remember the function's call time
*/
fgState.Timer = g_timer_new();
g_timer_start( fgState.Timer );
gettimeofday(&fgState.Time.Value, NULL);
fgState.Time.Set = TRUE;
/*
* Grab the environment variable indicating the X display to use.
* This is harmless under Win32, so let's let it stay here...
*/
displayName = (gchar *) strdup( (gchar *) g_getenv( "DISPLAY" ) );
displayName = strdup( getenv( "DISPLAY" ) );
/*
* Have the program arguments parsed.
@ -379,12 +372,12 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
* Check for possible lack of the next argument
*/
if( ++i >= argc )
g_error( "-display parameter must be followed by display name" );
fgError( "-display parameter must be followed by display name" );
/*
* Release the previous display name (the one from app's environment)
*/
g_free( displayName );
free( displayName );
/*
* Make a working copy of the name for us to use
@ -408,7 +401,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
* Again, check if there is at least one more argument
*/
if( ++i >= argc )
g_error( "-geometry parameter must be followed by window geometry settings" );
fgError( "-geometry parameter must be followed by window geometry settings" );
/*
* Otherwise make a duplicate of the geometry settings...
@ -432,7 +425,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
* We try to force direct rendering...
*/
if( fgState.TryDirectContext == FALSE )
g_error( "parameters ambiguity, -direct and -indirect cannot be both specified" );
fgError( "parameters ambiguity, -direct and -indirect cannot be both specified" );
fgState.ForceDirectContext = TRUE;
argv[ i ] = NULL;
@ -444,7 +437,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
* We try to force indirect rendering...
*/
if( fgState.ForceDirectContext == TRUE )
g_error( "parameters ambiguity, -direct and -indirect cannot be both specified" );
fgError( "parameters ambiguity, -direct and -indirect cannot be both specified" );
fgState.TryDirectContext = FALSE;
argv[ i ] = NULL;
@ -516,13 +509,14 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
*/
if( geometrySettings != NULL )
{
gint result, x, y, w, h;
int result, x, y;
unsigned int w, h;
/*
* Have the settings parsed now. This is easy.
* We will use the XParseGeometry function.
*/
result = XParseGeometry( geometrySettings, &x, &y, (guint *) &w, (guint *) &h );
result = XParseGeometry( geometrySettings, &x, &y, &w, &h );
/*
* Check what we have been supplied with...
@ -534,21 +528,25 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
fgState.Size.Y = h;
if( result & XValue )
{
if( result & XNegative )
fgState.Position.X = fgDisplay.ScreenWidth + x - fgState.Size.X;
else
fgState.Position.X = x;
}
if( result & YValue )
{
if( result & YNegative )
fgState.Position.Y = fgDisplay.ScreenHeight + y - fgState.Size.Y;
else
fgState.Position.Y = y;
}
/*
* Free the geometry settings string
*/
g_free( geometrySettings );
free( geometrySettings );
}
#endif
@ -564,7 +562,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
/*
* Do not forget about releasing the display name string
*/
g_free( displayName );
free( displayName );
}
/*
@ -637,6 +635,7 @@ void FGAPIENTRY glutInitDisplayMode( int displayMode )
/* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
#if 0 /* FIXME: CJP */
/*
* There is a discrete number of comparison operators we can encounter:
*
@ -916,10 +915,10 @@ void FGAPIENTRY glutInitDisplayString( char* displayMode )
*/
g_scanner_destroy( scanner );
}
#endif
void FGAPIENTRY glutInitDisplayString( char* displayMode )
{
}
/*** END OF FILE ***/

View File

@ -114,7 +114,7 @@ typedef struct tagSFG_Joystick SFG_Joystick;
struct tagSFG_Joystick
{
#ifdef __FreeBSD__
gint id;
int id;
#endif
#ifdef WIN32
@ -123,19 +123,19 @@ struct tagSFG_Joystick
#else
# ifdef JS_NEW
struct js_event js;
gint tmp_buttons;
int tmp_buttons;
float tmp_axes[ _JS_MAX_AXES ];
# else
JS_DATA_TYPE js;
# endif
gchar fname[ 128 ];
gint fd;
char fname[ 128 ];
int fd;
#endif
gboolean error;
gint num_axes;
gint num_buttons;
GLboolean error;
int num_axes;
int num_buttons;
float dead_band[ _JS_MAX_AXES ];
float saturate [ _JS_MAX_AXES ];
@ -152,15 +152,15 @@ static SFG_Joystick* fgJoystick = NULL;
/*
* Read the raw joystick data
*/
static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
static void fghJoystickRawRead ( SFG_Joystick* joy, int* buttons, float* axes )
{
#ifdef WIN32
MMRESULT status;
#else
gint status;
int status;
#endif
gint i;
int i;
if( joy->error )
{
@ -184,7 +184,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
}
if( buttons )
*buttons = (int) joy->js.dwButtons;
*buttons = joy->js.dwButtons;
if( axes )
{
@ -206,7 +206,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
while( 1 )
{
gint status = read( joy->fd, &joy->js, sizeof(struct js_event) );
status = read( joy->fd, &joy->js, sizeof(struct js_event) );
if( status != sizeof(struct js_event) )
{
@ -220,7 +220,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
return;
}
g_warning( joy->fname );
fgWarning( "%s", joy->fname );
joy->error = TRUE;
return;
}
@ -275,7 +275,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
/*
* Correct the joystick axis data
*/
static float fghJoystickFudgeAxis( SFG_Joystick* joy, float value, gint axis )
static float fghJoystickFudgeAxis( SFG_Joystick* joy, float value, int axis )
{
if( value < joy->center[ axis ] )
{
@ -310,10 +310,10 @@ static float fghJoystickFudgeAxis( SFG_Joystick* joy, float value, gint axis )
/*
* Read the corrected joystick data
*/
static void fghJoystickRead( SFG_Joystick* joy, gint* buttons, float* axes )
static void fghJoystickRead( SFG_Joystick* joy, int* buttons, float* axes )
{
float raw_axes[ _JS_MAX_AXES ];
gint i;
int i;
if( joy->error )
{
@ -339,7 +339,7 @@ static void fghJoystickOpen( SFG_Joystick* joy )
{
#ifdef WIN32
JOYCAPS jsCaps;
gint i;
int i;
joy->js.dwFlags = JOY_RETURNALL;
joy->js.dwSize = sizeof( joy->js );
@ -379,14 +379,17 @@ static void fghJoystickOpen( SFG_Joystick* joy )
#else
# ifdef __FreeBSD__
gint buttons[ _JS_MAX_AXES ];
int buttons[ _JS_MAX_AXES ];
float axes[ _JS_MAX_AXES ];
gint noargs, in_no_axes;
gchar joyfname[ 1024 ];
int noargs, in_no_axes;
char joyfname[ 1024 ];
FILE* joyfile;
# else
# ifndef JS_NEW
int counter;
# endif
gint i, counter;
# endif
int i;
/*
* Default for older Linux systems.
@ -491,18 +494,18 @@ static void fghJoystickOpen( SFG_Joystick* joy )
/*
*
*/
void fgJoystickInit( gint ident )
void fgJoystickInit( int ident )
{
/*
* Make sure we don't get reinitialized
*/
if( fgJoystick != NULL )
g_error( "illegal attemp to initialize joystick device" );
fgError( "illegal attemp to initialize joystick device" );
/*
* Have the global joystick structure created
*/
fgJoystick = g_new0( SFG_Joystick, 1 );
fgJoystick = calloc( sizeof(SFG_Joystick), 1 );
#ifdef WIN32
switch( ident )
@ -533,7 +536,7 @@ void fgJoystickInit( gint ident )
void fgJoystickClose( void )
{
if( fgJoystick == NULL )
g_error( "illegal attempt to deinitialize joystick device" );
fgError( "illegal attempt to deinitialize joystick device" );
#ifndef WIN32
if( fgJoystick->error != TRUE )
@ -548,7 +551,7 @@ void fgJoystickClose( void )
void fgJoystickPollWindow( SFG_Window* window )
{
float axes[ _JS_MAX_AXES ];
gint buttons;
int buttons;
/*
* Make sure the joystick device is initialized, the window seems valid
@ -567,9 +570,9 @@ void fgJoystickPollWindow( SFG_Window* window )
*/
window->Callbacks.Joystick(
buttons,
(gint) (axes[ 0 ] * 1000.0f),
(gint) (axes[ 1 ] * 1000.0f),
(gint) (axes[ 2 ] * 1000.0f)
(int) (axes[ 0 ] * 1000.0f),
(int) (axes[ 1 ] * 1000.0f),
(int) (axes[ 2 ] * 1000.0f)
);
}

View File

@ -95,9 +95,9 @@ static void fghRedrawWindowByHandle
*/
static void fghReshapeWindowByHandle
#if TARGET_HOST_UNIX_X11
( Window handle, gint width, gint height )
( Window handle, int width, int height )
#elif TARGET_HOST_WIN32
( HWND handle, gint width, gint height )
( HWND handle, int width, int height )
#endif
{
/*
@ -133,31 +133,31 @@ static void fghReshapeWindowByHandle
/*
* A static helper function to execute display callback for a window
*/
static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
static void fghcbDisplayWindow( SFG_Window *window, SFG_Enumerator *enumerator )
{
#if TARGET_HOST_UNIX_X11
/*
* Check if there is an idle callback hooked
*/
# warning there is a redisplay hack here (see the code commented out)
if( (((SFG_Window *) window)->Callbacks.Display != NULL) /*&&
/*(((SFG_Window *) window)->State.Redisplay == TRUE)*/ &&
(((SFG_Window *) window)->State.Visible == TRUE) )
// # warning there is a redisplay hack here (see the code commented out)
if( (window->Callbacks.Display != NULL) &&
/*(window->State.Redisplay == TRUE) &&*/
(window->State.Visible == TRUE) )
{
/*
* OKi, this is the case: have the window set as the current one
*/
glutSetWindow( ((SFG_Window *) window)->ID );
glutSetWindow( window->ID );
/*
* Do not exagerate with the redisplaying
*/
((SFG_Window *) window)->State.Redisplay = FALSE;
window->State.Redisplay = FALSE;
/*
* And execute the display callback immediately after
*/
((SFG_Window *) window)->Callbacks.Display();
window->Callbacks.Display();
}
#elif TARGET_HOST_WIN32
@ -165,12 +165,12 @@ static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
/*
* Do we need to explicitly resize the window?
*/
if( ((SFG_Window *) window)->State.NeedToResize )
if( window->State.NeedToResize )
{
glutSetWindow( ((SFG_Window *) window)->ID );
glutSetWindow( window->ID );
fghReshapeWindowByHandle(
((SFG_Window *) window)->Window.Handle,
window->Window.Handle,
glutGet( GLUT_WINDOW_WIDTH ),
glutGet( GLUT_WINDOW_HEIGHT )
);
@ -178,14 +178,14 @@ static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
/*
* Never ever do that again:
*/
((SFG_Window *) window)->State.NeedToResize = FALSE;
window->State.NeedToResize = FALSE;
}
/*
* This is done in a bit different way under Windows
*/
RedrawWindow(
((SFG_Window *) window)->Window.Handle, NULL, NULL,
window->Window.Handle, NULL, NULL,
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE
);
@ -194,7 +194,7 @@ static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
/*
* Process this window's children (if any)
*/
fgEnumSubWindows( (SFG_Window *) window, fghcbDisplayWindow, enumerator );
fgEnumSubWindows( window, fghcbDisplayWindow, enumerator );
}
/*
@ -219,31 +219,30 @@ static void fghDisplayAll( void )
/*
* Window enumerator callback to check for the joystick polling code
*/
static void fghcbCheckJoystickPolls( gpointer window, gpointer enumerator )
static void fghcbCheckJoystickPolls( SFG_Window *window, SFG_Enumerator *enumerator )
{
double checkTime = g_timer_elapsed( fgState.Timer, NULL );
SFG_Window* win = (SFG_Window *) window;
double checkTime = fgElapsedTime();
/*
* Check if actually need to do the poll for the currently enumerated window:
*/
if( win->State.JoystickLastPoll + win->State.JoystickPollRate >= checkTime )
if( window->State.JoystickLastPoll + window->State.JoystickPollRate >= checkTime )
{
/*
* Yeah, that's it. Poll the joystick...
*/
fgJoystickPollWindow( (SFG_Window *) window );
fgJoystickPollWindow( window );
/*
* ...and reset the polling counters:
*/
win->State.JoystickLastPoll = checkTime;
window->State.JoystickLastPoll = checkTime;
}
/*
* Process this window's children (if any)
*/
fgEnumSubWindows( (SFG_Window *) window, fghcbCheckJoystickPolls, enumerator );
fgEnumSubWindows( window, fghcbCheckJoystickPolls, enumerator );
}
/*
@ -270,21 +269,18 @@ static void fghCheckJoystickPolls( void )
*/
static void fghCheckTimers( void )
{
double checkTime = g_timer_elapsed( fgState.Timer, NULL );
SFG_Timer* timer = NULL;
GList* timedOut = NULL;
gint i, length;
long checkTime = fgElapsedTime();
SFG_Timer *timer, *next;
SFG_List timedOut;
fgListInit(&timedOut);
/*
* For every timer that is waiting for triggering
*/
for( i=0; i<(gint) g_list_length( fgState.Timers ); i++ )
for( timer = fgState.Timers.First; timer; timer = next )
{
/*
* ...grab the appropriate timer hook structure pointer
*/
timer = (SFG_Timer *) g_list_nth( fgState.Timers, i )->data;
g_assert( timer != NULL );
next = timer->Node.Next;
/*
* Check for the timeout:
@ -294,45 +290,70 @@ static void fghCheckTimers( void )
/*
* Add the timer to the timed out timers list
*/
timedOut = g_list_append( timedOut, timer );
fgListRemove( &fgState.Timers, &timer->Node );
fgListAppend( &timedOut, &timer->Node );
}
}
/*
* Now, have all the timed out timers removed from the window hooks
*/
length = g_list_length( timedOut );
for( i=0; i<length; i++ )
{
fgState.Timers = g_list_remove(
fgState.Timers,
g_list_nth( timedOut, i )->data
);
}
/*
* Now feel free to execute all the hooked and timed out timer callbacks
* And delete the timed out timers...
*/
for( i=0; i<length; i++ )
while ( (timer = timedOut.First) )
{
if( timer->Callback != NULL )
timer->Callback( timer->ID );
fgListRemove( &timedOut, &timer->Node );
free( timer );
}
}
/*
* Finally, delete the timed out timers...
* Elapsed Time
*/
for( i=0; i<length; i++ )
g_free( g_list_nth( timedOut, i )->data );
long fgElapsedTime( void )
{
struct timeval now;
long elapsed;
/*
* Finally, have the timed out timers list released
*/
if( timedOut != NULL )
g_list_free( timedOut );
gettimeofday( &now, NULL );
elapsed = (now.tv_usec - fgState.Time.Value.tv_usec) / 1000;
elapsed += (now.tv_sec - fgState.Time.Value.tv_sec) * 1000;
return( elapsed );
}
/*
* Error Messages.
*/
void fgError( const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
fprintf( stderr, "freeglut: ");
vfprintf( stderr, fmt, ap );
fprintf( stderr, "\n" );
va_end( ap );
exit( 1 );
}
void fgWarning( const char *fmt, ... )
{
va_list ap;
va_start( ap, fmt );
fprintf( stderr, "freeglut: ");
vfprintf( stderr, fmt, ap );
fprintf( stderr, "\n" );
va_end( ap );
}
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
@ -360,7 +381,7 @@ void FGAPIENTRY glutMainLoop( void )
* Enter the loop. Iterate as long as there are
* any windows in the freeglut structure.
*/
while( fgStructure.Windows != NULL )
while( fgStructure.Windows.First != NULL )
{
/*
* Do we have any event messages pending?
@ -572,7 +593,7 @@ void FGAPIENTRY glutMainLoop( void )
case ButtonRelease:
case ButtonPress:
{
gint button;
int button;
/*
* A mouse button has been pressed or released. Traditionally,
@ -679,9 +700,9 @@ void FGAPIENTRY glutMainLoop( void )
if( (window->Callbacks.Keyboard != NULL) || (window->Callbacks.Special != NULL) )
{
XComposeStatus composeStatus;
gchar asciiCode[ 32 ];
char asciiCode[ 32 ];
KeySym keySym;
gint len;
int len;
/*
* Check for the ASCII/KeySym codes associated with the event:
@ -721,7 +742,7 @@ void FGAPIENTRY glutMainLoop( void )
}
else
{
gint special = -1;
int special = -1;
/*
* ...and one for all the others, which need to be translated to GLUT_KEY_Xs...
@ -1286,9 +1307,3 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
#endif
/*** END OF FILE ***/

View File

@ -53,21 +53,39 @@
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
/*
* Private static function to find a menu entry by index
*/
static SFG_MenuEntry *fghFindMenuEntry( SFG_Menu* menu, int index )
{
SFG_MenuEntry *entry;
int i = 1;
for( entry = menu->Entries.First; entry; entry = entry->Node.Next)
{
if (i == index)
break;
++i;
}
return entry;
}
/*
* Private static function to check for the current menu/sub menu activity state
*/
static gboolean fghCheckMenuStatus( SFG_Menu* menu )
static GLboolean fghCheckMenuStatus( SFG_Menu* menu )
{
SFG_Window* window = fgStructure.Window;
gint i, x, y;
SFG_MenuEntry* menuEntry;
int x, y;
/*
* First of all check any of the active sub menus...
*/
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
for( menuEntry = menu->Entries.First; menuEntry;
menuEntry = menuEntry->Node.Next )
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
/*
* Is that an active sub menu by any case?
*/
@ -92,10 +110,9 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
/*
* Mark all menu entries inactive...
*/
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
for( menuEntry = menu->Entries.First; menuEntry;
menuEntry = menuEntry->Node.Next )
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
menuEntry->IsActive = FALSE;
}
@ -109,13 +126,13 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
/*
* Calculation of the highlighted menu item is easy enough now:
*/
gint menuID = y / FREEGLUT_MENU_HEIGHT;
int menuID = y / FREEGLUT_MENU_HEIGHT;
/*
* The mouse cursor is somewhere over our box, check it out.
*/
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, menuID )->data;
g_assert( menuEntry != NULL );
menuEntry = fghFindMenuEntry( menu, menuID + 1 );
assert( menuEntry != NULL );
/*
* Mark the menu as active...
@ -135,8 +152,8 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
*/
if( menuEntry->SubMenu != NULL )
{
gint x = window->State.MouseX;
gint y = window->State.MouseY;
int x = window->State.MouseX;
int y = window->State.MouseY;
/*
* Set up the initial menu position now...
@ -173,8 +190,8 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
*/
static void fghDisplayMenuBox( SFG_Menu* menu )
{
SFG_Window* window = fgStructure.Window;
gint i, j, x, y;
SFG_MenuEntry *menuEntry;
int i;
/*
* Have the menu box drawn first. The +- values are
@ -199,10 +216,9 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
/*
* Check if any of the submenus is currently active...
*/
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
for( menuEntry = menu->Entries.First; menuEntry;
menuEntry = menuEntry->Node.Next )
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
/*
* Has the menu been marked as active, maybe?
*/
@ -213,7 +229,7 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
* There is an assumption that mouse cursor didn't move
* since the last check of menu activity state:
*/
gint menuID = menuEntry->Ordinal;
int menuID = menuEntry->Ordinal;
/*
* So have the highlight drawn...
@ -233,10 +249,9 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
*/
glColor4f( 1, 1, 1, 1 );
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
for( menuEntry = menu->Entries.First, i=0; menuEntry;
menuEntry = menuEntry->Node.Next, ++i )
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
/*
* Move the raster into position...
*/
@ -248,17 +263,15 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
/*
* Have the label drawn, character after character:
*/
for( j=0; j<menuEntry->Text->len; j++ )
glutBitmapCharacter( FREEGLUT_MENU_FONT, (gint) menuEntry->Text->str[ j ] );
glutBitmapString( FREEGLUT_MENU_FONT, menuEntry->Text);
}
/*
* Now we are ready to check if any of our children needs to be redrawn:
*/
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
for( menuEntry = menu->Entries.First; menuEntry;
menuEntry = menuEntry->Node.Next )
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
/*
* Is that an active sub menu by any case?
*/
@ -279,7 +292,7 @@ void fgDisplayMenu( void )
{
SFG_Window* window = fgStructure.Window;
SFG_Menu* menu = NULL;
gint i;
int i;
/*
* Make sure there is a current window available
@ -353,11 +366,11 @@ void fgDisplayMenu( void )
/*
* Activates a menu pointed by the function argument
*/
void fgActivateMenu( gint button )
void fgActivateMenu( int button )
{
SFG_Window* window = fgStructure.Window;
SFG_Menu* menu = NULL;
gint x, y;
int x, y;
freeglut_assert_window;
@ -394,15 +407,14 @@ void fgActivateMenu( gint button )
*/
static void fghCheckMenuSelect( SFG_Menu* menu )
{
gint i;
SFG_MenuEntry *menuEntry;
/*
* First of all check any of the active sub menus...
*/
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
for( menuEntry = menu->Entries.First; menuEntry;
menuEntry = menuEntry->Node.Next)
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
/*
* Is this menu entry active?
*/
@ -438,11 +450,11 @@ static void fghCheckMenuSelect( SFG_Menu* menu )
/*
* Deactivates a menu pointed by the function argument.
*/
void fgDeactivateMenu( gint button )
void fgDeactivateMenu( int button )
{
SFG_Window* window = fgStructure.Window;
SFG_Menu* menu = NULL;
gint i, x, y;
int i;
/*
* Make sure there is a current window available...
@ -480,7 +492,8 @@ void fgDeactivateMenu( gint button )
*/
void fghCalculateMenuBoxSize( void )
{
gint i, width;
SFG_MenuEntry* menuEntry;
int width = 0, height = 0;
/*
* Make sure there is a current menu set
@ -490,26 +503,27 @@ void fghCalculateMenuBoxSize( void )
/*
* The menu's box size depends on the menu entries:
*/
for( i=0, width=0; i<(gint) g_list_length( fgStructure.Menu->Entries ); i++ )
for( menuEntry = fgStructure.Menu->Entries.First; menuEntry;
menuEntry = menuEntry->Node.Next)
{
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( fgStructure.Menu->Entries, i )->data;
/*
* Update the menu entry's width value
*/
menuEntry->Width = glutBitmapLength( FREEGLUT_MENU_FONT, menuEntry->Text->str );
menuEntry->Width = glutBitmapLength( FREEGLUT_MENU_FONT, menuEntry->Text );
/*
* Check if it's the biggest we've found
*/
if( menuEntry->Width > width )
width = menuEntry->Width;
height += FREEGLUT_MENU_HEIGHT;
}
/*
* Store the menu's box size now:
*/
fgStructure.Menu->Height = i * FREEGLUT_MENU_HEIGHT;
fgStructure.Menu->Height = height;
fgStructure.Menu->Width = width;
}
@ -586,7 +600,7 @@ void FGAPIENTRY glutSetMenu( int menuID )
*/
void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
{
SFG_MenuEntry* menuEntry = g_new0( SFG_MenuEntry, 1 );
SFG_MenuEntry* menuEntry = calloc( sizeof(SFG_MenuEntry), 1 );
/*
* Make sure there is a current menu set
@ -596,13 +610,13 @@ void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
/*
* Fill in the appropriate values...
*/
menuEntry->Text = g_string_new( label );
menuEntry->Text = strdup( label );
menuEntry->ID = value;
/*
* Have the new menu entry attached to the current menu
*/
fgStructure.Menu->Entries = g_list_append( fgStructure.Menu->Entries, menuEntry );
fgListAppend( &fgStructure.Menu->Entries, &menuEntry->Node );
/*
* Update the menu's dimensions now
@ -615,7 +629,7 @@ void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
*/
void FGAPIENTRY glutAddSubMenu( const char* label, int subMenuID )
{
SFG_MenuEntry* menuEntry = g_new0( SFG_MenuEntry, 1 );
SFG_MenuEntry* menuEntry = calloc( sizeof(SFG_MenuEntry), 1 );
SFG_Menu* subMenu = fgMenuByID( subMenuID );
/*
@ -628,14 +642,14 @@ void FGAPIENTRY glutAddSubMenu( const char* label, int subMenuID )
/*
* Fill in the appropriate values
*/
menuEntry->Text = g_string_new( label );
menuEntry->Text = strdup( label );
menuEntry->SubMenu = subMenu;
menuEntry->ID = -1;
/*
* Have the new menu entry attached to the current menu
*/
fgStructure.Menu->Entries = g_list_append( fgStructure.Menu->Entries, menuEntry );
fgListAppend( &fgStructure.Menu->Entries, &menuEntry->Node );
/*
* Update the menu's dimensions now
@ -655,23 +669,23 @@ void FGAPIENTRY glutChangeToMenuEntry( int item, const char* label, int value )
*/
freeglut_assert_ready; freeglut_return_if_fail( fgStructure.Menu != NULL );
/*
* Make sure the item counter seems valid
*/
freeglut_return_if_fail( (item > 0) && (item <= (gint) g_list_length( fgStructure.Menu->Entries ) ) );
/*
* Get n-th menu entry in the current menu, starting from one:
*/
menuEntry = (SFG_MenuEntry *) g_list_nth( fgStructure.Menu->Entries, item - 1 )->data;
menuEntry = fghFindMenuEntry( fgStructure.Menu, item );
/*
* Make sure the menu entry exists
*/
freeglut_return_if_fail( menuEntry != NULL );
/*
* We want it to become a normal menu entry, so:
*/
if( menuEntry->Text != NULL )
g_string_free( menuEntry->Text, TRUE );
free( menuEntry->Text );
menuEntry->Text = g_string_new( label );
menuEntry->Text = strdup( label );
menuEntry->ID = value;
menuEntry->SubMenu = NULL;
@ -695,23 +709,23 @@ void FGAPIENTRY glutChangeToSubMenu( int item, const char* label, int subMenuID
freeglut_assert_ready; freeglut_return_if_fail( fgStructure.Menu != NULL );
freeglut_return_if_fail( subMenu != NULL );
/*
* Make sure the item counter seems valid
*/
freeglut_return_if_fail( (item > 0) && (item <= (gint) g_list_length( fgStructure.Menu->Entries ) ) );
/*
* Get n-th menu entry in the current menu, starting from one:
*/
menuEntry = (SFG_MenuEntry *) g_list_nth( fgStructure.Menu->Entries, item - 1 )->data;
menuEntry = fghFindMenuEntry( fgStructure.Menu, item );
/*
* Make sure the menu entry exists
*/
freeglut_return_if_fail( menuEntry != NULL );
/*
* We want it to become a sub menu entry, so:
*/
if( menuEntry->Text != NULL )
g_string_free( menuEntry->Text, TRUE );
free( menuEntry->Text );
menuEntry->Text = g_string_new( label );
menuEntry->Text = strdup( label );
menuEntry->SubMenu = subMenu;
menuEntry->ID = -1;
@ -734,24 +748,26 @@ void FGAPIENTRY glutRemoveMenuItem( int item )
freeglut_assert_ready; freeglut_return_if_fail( fgStructure.Menu != NULL );
/*
* Make sure the item counter seems valid
* Get n-th menu entry in the current menu, starting from one:
*/
freeglut_return_if_fail( (item > 0) && (item <= (gint) g_list_length( fgStructure.Menu->Entries ) ) );
menuEntry = fghFindMenuEntry( fgStructure.Menu, item );
/*
* Make sure the menu entry exists
*/
freeglut_return_if_fail( menuEntry != NULL );
/*
* Removing a menu entry is quite simple...
*/
menuEntry = (SFG_MenuEntry *) g_list_nth( fgStructure.Menu->Entries, item - 1 )->data;
fgStructure.Menu->Entries = g_list_remove(
fgStructure.Menu->Entries,
menuEntry
);
fgListRemove( &fgStructure.Menu->Entries, &menuEntry->Node );
/*
* Free the entry label string, too
*/
g_string_free( menuEntry->Text, TRUE );
free( menuEntry->Text );
free( menuEntry );
/*
* Update the menu's dimensions now

View File

@ -50,76 +50,54 @@
*/
int FGAPIENTRY glutExtensionSupported( const char* extension )
{
/*
* Grab the current context's OpenGL extensions
* and create a new GLib lexical analyzer...
*/
gchar *glExtensions = (gchar *) glGetString( GL_EXTENSIONS );
GScanner* scanner = g_scanner_new( NULL );
gint i;
const char *extensions;
const char *ptr;
int i;
/*
* Make sure there is a current window, and thus -- a current context available
*/
freeglut_assert_ready; freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
freeglut_assert_ready;
freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
/*
* Fail if there is no extension, extensions or scanner available
* Not it is safe to query the extenstions
*/
freeglut_return_val_if_fail( (scanner != NULL) && (strlen( extension ) > 0)
&& (strlen( glExtensions ) > 0), 0 );
extensions = glGetString(GL_EXTENSIONS);
freeglut_return_val_if_fail( extensions != NULL, 0 );
/*
* Check if the extension itself looks valid
*/
for( i=0; i<(gint) strlen( extension ); i++ )
for( i=0; i<strlen( extension ); i++ )
if( extension[ i ] == ' ' )
return( 0 );
/*
* Set the scanner's input name (for debugging)
* Look for our extension
*/
scanner->input_name = "glutExtensionSupported()";
/*
* Start the lexical analysis of the extensions string
*/
g_scanner_input_text( scanner, glExtensions, strlen( glExtensions ) );
/*
* While there are any more tokens to be checked...
*/
while( !g_scanner_eof( scanner ) )
for (ptr = extensions; *ptr;)
{
/*
* Actually we're expecting only string tokens
*/
GTokenType tokenType = g_scanner_get_next_token( scanner );
const char *str = extension;
char c;
/*
* We are looking for identifiers
*/
if( tokenType == G_TOKEN_IDENTIFIER )
while ( (c = *(str++)) )
{
/*
* Compare the token and the extension string
*/
if( strcmp( scanner->value.v_identifier, extension ) == 0 )
{
/*
* OKi, we have found the extension string we've been looking for
*/
g_scanner_destroy( scanner );
return( 1 );
}
if (*ptr != c)
goto next;
ptr++;
}
if ( !(c = *ptr) || c == ' ' )
return 1;
next:
while ( (c = *ptr) && c != ' ' )
ptr++;
while (*ptr == ' ')
ptr++;
}
/*
* Well, looks like we have failed to find the extension string
*/
g_scanner_destroy( scanner );
return( 0 );
return 0;
}
/*
@ -140,7 +118,7 @@ void FGAPIENTRY glutReportErrors( void )
# undef G_LOG_DOMAIN
# define G_LOG_DOMAIN ((gchar *) 0)
g_warning( "GL error: %s", gluErrorString( error ) );
fgWarning( "GL error: %s", gluErrorString( error ) );
# undef G_LOG_DOMAIN
# define G_LOG_DOMAIN "freeglut_misc.c"
@ -202,7 +180,7 @@ void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
/*
* Whoops, this was not expected at all
*/
g_assert_not_reached();
break;
}
#endif

View File

@ -76,9 +76,9 @@
/*
* Queries the GL context about some attributes
*/
static gint fghGetConfig( gint attribute )
static int fghGetConfig( int attribute )
{
gint returnValue;
int returnValue;
/*
* Return nothing if there is no current window set
@ -137,8 +137,6 @@ static gint fghGetConfig( gint attribute )
*/
int FGAPIENTRY glutGet( GLenum eWhat )
{
gint returnValue;
freeglut_assert_ready;
/*
@ -150,7 +148,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
/*
* This is easy and nicely portable, as we are using GLib...
*/
return( (int) (g_timer_elapsed( fgState.Timer, NULL ) * 1000.0) );
return( fgElapsedTime() );
/*
* Following values are stored in fgState and fgDisplay global structures
@ -226,7 +224,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
{
XWindowAttributes winAttributes;
Window another, window;
gint x, y;
int x, y;
/*
* Return zero if there is no current window set
@ -393,7 +391,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
if( fgStructure.Window == NULL )
return( 0 );
return( g_list_length( fgStructure.Window->Children ) );
return( fgListLength( &fgStructure.Window->Children ) );
case GLUT_WINDOW_CURSOR:
/*
@ -411,20 +409,20 @@ int FGAPIENTRY glutGet( GLenum eWhat )
if( fgStructure.Menu == NULL )
return( 0 );
return( g_list_length( fgStructure.Menu->Entries ) );
return( fgListLength( &fgStructure.Menu->Entries ) );
default:
/*
* Just have it reported, so that we can see what needs to be implemented
*/
g_warning( "glutGet(): missing enum handle %i\n", eWhat );
fgWarning( "glutGet(): missing enum handle %i\n", eWhat );
break;
}
/*
* If nothing happens, then we are in deep trouble...
*/
g_assert_not_reached();
return( -1 );
}
/*
@ -520,14 +518,14 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
/*
* Complain.
*/
g_warning( "glutDeviceGet(): missing enum handle %i\n", eWhat );
fgWarning( "glutDeviceGet(): missing enum handle %i\n", eWhat );
break;
}
/*
* And now -- the failure.
*/
g_assert_not_reached();
return( -1 );
}
/*
@ -543,7 +541,7 @@ int FGAPIENTRY glutGetModifiers( void )
if( fgStructure.Window->State.Modifiers == 0xffffffff )
{
g_warning( "glutGetModifiers() called outside an input callback" );
fgWarning( "glutGetModifiers() called outside an input callback" );
return( 0 );
}
@ -605,14 +603,14 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
/*
* Complain to the user about the obvious bug
*/
g_warning( "glutLayerGet(): missing enum handle %i\n", eWhat );
fgWarning( "glutLayerGet(): missing enum handle %i\n", eWhat );
break;
}
/*
* And fail. That's good. Programs do love failing.
*/
g_assert_not_reached();
return( -1 );
}
/*** END OF FILE ***/

View File

@ -52,19 +52,19 @@ SFG_Structure fgStructure;
*
* If parent is set to NULL, the window created will be a topmost one.
*/
SFG_Window* fgCreateWindow( SFG_Window* parent, const gchar* title, gint x, gint y, gint w, gint h, gboolean gameMode )
SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title, int x, int y, int w, int h, GLboolean gameMode )
{
/*
* Have the window object created
*/
SFG_Window* window = g_new0( SFG_Window, 1 );
gint fakeArgc = 0;
SFG_Window* window = calloc( sizeof(SFG_Window), 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.Timer == NULL )
if( !fgState.Time.Set )
glutInit( &fakeArgc, NULL );
/*
@ -72,6 +72,11 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const gchar* title, gint x, gint
*/
window->ID = ++fgStructure.WindowID;
/*
* Initialize the children list
*/
fgListInit( &window->Children );
/*
* Does this window have a parent?
*/
@ -80,7 +85,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const gchar* title, gint x, gint
/*
* That's quite right, attach this windows as a child window
*/
parent->Children = g_list_append( parent->Children, window );
fgListAppend( &parent->Children, &window->Node );
window->Parent = parent;
}
else
@ -88,7 +93,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const gchar* title, gint x, gint
/*
* Otherwise add the newly created window to the topmost windows list
*/
fgStructure.Windows = g_list_append( fgStructure.Windows, window );
fgListAppend( &fgStructure.Windows, &window->Node );
}
/*
@ -117,14 +122,14 @@ SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
/*
* Have the menu object created
*/
SFG_Menu* menu = g_new0( SFG_Menu, 1 );
gint fakeArgc = 0;
SFG_Menu* 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.Timer == NULL )
if( !fgState.Time.Set )
glutInit( &fakeArgc, NULL );
/*
@ -133,10 +138,15 @@ SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
menu->ID = ++fgStructure.MenuID;
menu->Callback = menuCallback;
/*
* Initialize the entries list
*/
fgListInit( &menu->Entries );
/*
* Add it to the menu structure hierarchy
*/
fgStructure.Menus = g_list_append( fgStructure.Menus, menu );
fgListAppend( &fgStructure.Menus, &menu->Node );
/*
* Newly created menus implicitly become current ones
@ -154,50 +164,32 @@ SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
* another function, defined in freeglut_window.c is called, but this is
* a whole different story...
*/
void fgDestroyWindow( SFG_Window* window, gboolean needToClose )
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose )
{
int i;
SFG_Window* subWindow;
g_assert( window != NULL );
assert( window != NULL );
freeglut_assert_ready;
/*
* Does this window have any subwindows?
*/
if( window->Children != NULL )
if( (subWindow = window->Children.First) != NULL )
{
/*
* OKi, while there are any subwindows left...
*/
while( g_list_first( window->Children ) != NULL )
{
SFG_Window* subWindow = g_list_first( window->Children )->data;
/*
* Destroy the first window in the list (possibly destroying
* it's subwindows too. This is not very effective, but works
* it's subwindows too). This is not very effective, but works
*/
fgDestroyWindow( subWindow, TRUE );
/*
* Remove the just destroyed node from the subwindows list
*/
window->Children = g_list_remove( window->Children, subWindow );
}
/*
* Have the list freed now (probably it already is, but you can
* never be sure with no GLib documentation on your hdd...)
*/
g_list_free( window->Children );
window->Children = NULL;
}
/*
* Now we should remove the reference to this window from it's parent
*/
if( window->Parent != NULL )
window->Parent->Children = g_list_remove( window->Parent->Children, window );
fgListRemove( &window->Parent->Children, &window->Node );
else
fgListRemove( &fgStructure.Windows, &window->Node );
/*
* OK, this window seems disconnected from the structure enough
@ -206,12 +198,6 @@ void fgDestroyWindow( SFG_Window* window, gboolean needToClose )
if( needToClose == TRUE )
fgCloseWindow( window );
/*
* Try removing the window from the parents list in fgStructure.
* This might fail as the window is not guaranteed to be there:
*/
fgStructure.Windows = g_list_remove( fgStructure.Windows, window );
/*
* Check if the window is the current one...
*/
@ -222,7 +208,7 @@ void fgDestroyWindow( SFG_Window* window, gboolean needToClose )
* Finally, we can delete the window's object. It hopefully does
* have everything inside it freed and we do not have to care...
*/
g_free( window );
free( window );
}
/*
@ -231,24 +217,27 @@ void fgDestroyWindow( SFG_Window* window, gboolean needToClose )
*/
static void fghRemoveMenuFromWindow( SFG_Window* window, SFG_Menu* menu )
{
gint i;
SFG_Window *subWindow;
int i;
/*
* Check if the menu is attached to the current window,
* if so, have it detached (by overwriting with a NULL):
*/
for( i=0; i<3; i++ )
{
if( window->Menu[ i ] == menu )
window->Menu[ i ] = NULL;
}
/*
* Call this function for all of the window's children recursively:
*/
for( i=0; i<(gint) g_list_length( window->Children ); i++ )
fghRemoveMenuFromWindow(
(SFG_Window *) g_list_nth( window->Children, i )->data,
menu
);
for( subWindow = window->Children.First; subWindow;
subWindow = subWindow->Node.Next);
{
fghRemoveMenuFromWindow(subWindow, menu );
}
}
/*
@ -257,49 +246,15 @@ static void fghRemoveMenuFromWindow( SFG_Window* window, SFG_Menu* menu )
*/
static void fghRemoveMenuFromMenu( SFG_Menu* from, SFG_Menu* menu )
{
gboolean found = FALSE;
SFG_MenuEntry *entry;
/*
* Do not allow removing a menu from itself...
*/
if( from == menu )
return;
/*
* Look up for the first entry that matches the given
* menu and have it removed, then search again and again:
*/
do
for( entry = from->Entries.First; entry; entry = entry->Node.Next )
{
/*
* Try searching for the incriminated menu entry
*/
GList* where = g_list_find( from->Entries, menu );
/*
* Make sure we still have a list to be searched
*/
if( where != NULL )
if (entry->SubMenu == menu)
{
/*
* Did we actually find the menu entry we want to remove?
*/
found = ((SFG_Menu *) where->data == menu);
/*
* Need to check that, as the search might have failed
*/
if( found )
from->Entries = g_list_remove( from->Entries, menu );
entry->SubMenu = NULL;
}
else
{
/*
* It would be nice if we had a stop rule ;-)
*/
found = FALSE;
}
} while( found == TRUE );
}
/*
@ -308,58 +263,53 @@ static void fghRemoveMenuFromMenu( SFG_Menu* from, SFG_Menu* menu )
*/
void fgDestroyMenu( SFG_Menu* menu )
{
gint i;
SFG_Window *window;
SFG_Menu *from;
SFG_MenuEntry *entry;
g_assert( menu != NULL );
assert( menu != NULL );
freeglut_assert_ready;
/*
* First of all, have all references to this menu removed from all windows:
*/
for( i=0; i<(gint) g_list_length( fgStructure.Windows ); i++ )
fghRemoveMenuFromWindow(
(SFG_Window *) g_list_nth( fgStructure.Windows, i )->data,
menu
);
for( window = fgStructure.Windows.First; window;
window = window->Node.Next )
{
fghRemoveMenuFromWindow( window, menu );
}
/*
* Now proceed with removing menu entries that lead to this menu
*/
for( i=0; i<(gint) g_list_length( fgStructure.Menus ); i++ )
fghRemoveMenuFromMenu(
(SFG_Menu *) g_list_nth( fgStructure.Menus, i )->data,
menu
);
for( from = fgStructure.Menus.First; from; from = from->Node.Next )
{
fghRemoveMenuFromMenu( from, menu );
}
/*
* Now we are pretty sure the menu is not used anywhere
* and that we can remove all of it's entries
*/
for( i=0; i<(gint) g_list_length( menu->Entries ); i++ )
while( (entry = menu->Entries.First) != NULL )
{
SFG_MenuEntry* entry = (SFG_MenuEntry *) g_list_nth( menu->Entries, i )->data;
fgListRemove(&menu->Entries, &entry->Node);
/*
* There might be a string allocated, have it freed:
*/
g_string_free( entry->Text, TRUE );
free( entry->Text );
/*
* Deallocate the entry itself:
*/
g_free( entry );
free( entry );
}
/*
* Deallocate the entries list
*/
g_list_free( menu->Entries );
menu->Entries = NULL;
/*
* Remove the menu from the menus list
*/
fgStructure.Menus = g_list_remove( fgStructure.Menus, menu );
fgListRemove( &fgStructure.Menus, &menu->Node );
/*
* If that menu was the current one...
@ -370,7 +320,7 @@ void fgDestroyMenu( SFG_Menu* menu )
/*
* Have the menu structure freed
*/
g_free( menu );
free( menu );
}
/*
@ -382,11 +332,13 @@ void fgDestroyMenu( SFG_Menu* menu )
void fgCreateStructure( void )
{
/*
* We will be needing two lists: the first containing windows, and the second
* containing the user-defined menus. However we do not need allocating anything,
* as it is done automagically by GLib when appending new entries to both of them.
* We will be needing two lists: the first containing windows,
* and the second containing the user-defined menus.
* Also, no current window/menu is set, as none has been created yet.
*/
fgListInit(&fgStructure.Windows);
fgListInit(&fgStructure.Menus);
}
/*
@ -395,6 +347,9 @@ void fgCreateStructure( void )
*/
void fgDestroyStructure( void )
{
SFG_Window *window;
SFG_Menu *menu;
/*
* Just make sure we are not called in vain...
*/
@ -403,32 +358,33 @@ void fgDestroyStructure( void )
/*
* Make sure all windows and menus have been deallocated
*/
while( fgStructure.Windows != NULL )
fgDestroyWindow( (SFG_Window *) g_list_first( fgStructure.Windows )->data, TRUE );
while( (window = fgStructure.Windows.First) != NULL )
fgDestroyWindow( window, TRUE );
while( fgStructure.Menus != NULL )
fgDestroyMenu( (SFG_Menu *) g_list_first( fgStructure.Menus )->data );
while( (menu = fgStructure.Menus.First) != NULL )
fgDestroyMenu( menu );
}
/*
* Helper function to enumerate through all registered top-level windows
*/
void fgEnumWindows( GFunc enumCallback, SFG_Enumerator* enumerator )
void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator )
{
gint i;
SFG_Window *window;
g_assert( (enumCallback != NULL) && (enumerator != NULL) );
assert( (enumCallback != NULL) && (enumerator != NULL) );
freeglut_assert_ready;
/*
* Check every of the top-level windows
*/
for( i=0; i<(gint) g_list_length( fgStructure.Windows ); i++ )
for( window = fgStructure.Windows.First; window;
window = window->Node.Next )
{
/*
* Execute the callback...
*/
enumCallback( (gpointer) g_list_nth( fgStructure.Windows, i )->data, (gpointer) enumerator );
enumCallback( window, enumerator );
/*
* If it has been marked as 'found', stop searching
@ -441,22 +397,22 @@ void fgEnumWindows( GFunc enumCallback, SFG_Enumerator* enumerator )
/*
* Helper function to enumerate through all a window's subwindows (single level descent)
*/
void fgEnumSubWindows( SFG_Window* window, GFunc enumCallback, SFG_Enumerator* enumerator )
void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback, SFG_Enumerator* enumerator )
{
gint i;
SFG_Window *child;
g_assert( (enumCallback != NULL) && (enumerator != NULL) );
assert( (enumCallback != NULL) && (enumerator != NULL) );
freeglut_assert_ready;
/*
* Check every of the window's children:
*/
for( i=0; i<(gint) g_list_length( window->Children ); i++ )
for( child = window->Children.First; child; child = child->Node.Next )
{
/*
* Execute the callback...
*/
enumCallback( (gpointer) g_list_nth( window->Children, i )->data, (gpointer) enumerator );
enumCallback( child, enumerator );
/*
* If it has been marked as 'found', stop searching
@ -469,12 +425,12 @@ void fgEnumSubWindows( SFG_Window* window, GFunc enumCallback, SFG_Enumerator* e
/*
* A static helper function to look for a window given it's handle
*/
static void fghcbWindowByHandle( gpointer window, gpointer enumerator )
static void fghcbWindowByHandle( SFG_Window *window, SFG_Enumerator *enumerator )
{
/*
* Make sure we do not overwrite our precious results...
*/
freeglut_return_if_fail( ((SFG_Enumerator *) enumerator)->found == FALSE );
freeglut_return_if_fail( enumerator->found == FALSE );
#if TARGET_HOST_UNIX_X11
#define WBHANDLE (Window)
@ -485,10 +441,10 @@ static void fghcbWindowByHandle( gpointer window, gpointer enumerator )
/*
* Check the window's handle. Hope this works. Looks ugly. That's for sure.
*/
if( ((SFG_Window *) window)->Window.Handle == (WBHANDLE ((SFG_Enumerator *) enumerator)->data) )
if( window->Window.Handle == WBHANDLE (enumerator->data) )
{
((SFG_Enumerator *) enumerator)->found = TRUE;
((SFG_Enumerator *) enumerator)->data = (gpointer) window;
enumerator->found = TRUE;
enumerator->data = window;
return;
}
@ -496,7 +452,7 @@ static void fghcbWindowByHandle( gpointer window, gpointer enumerator )
/*
* Otherwise, check this window's children
*/
fgEnumSubWindows( (SFG_Window *) window, fghcbWindowByHandle, enumerator );
fgEnumSubWindows( window, fghcbWindowByHandle, enumerator );
#undef WBHANDLE
}
@ -519,7 +475,7 @@ SFG_Window* fgWindowByHandle
* This is easy and makes use of the windows enumeration defined above
*/
enumerator.found = FALSE;
enumerator.data = (gpointer) hWindow;
enumerator.data = (void *)hWindow;
/*
* Start the enumeration now:
@ -541,20 +497,20 @@ SFG_Window* fgWindowByHandle
/*
* A static helper function to look for a window given it's ID
*/
static void fghcbWindowByID( gpointer window, gpointer enumerator )
static void fghcbWindowByID( SFG_Window *window, SFG_Enumerator *enumerator )
{
/*
* Make sure we do not overwrite our precious results...
*/
g_return_if_fail( ((SFG_Enumerator *) enumerator)->found == FALSE );
freeglut_return_if_fail( enumerator->found == FALSE );
/*
* Check the window's handle. Hope this works. Looks ugly. That's for sure.
*/
if( ((SFG_Window *) window)->ID == (gint) (((SFG_Enumerator *) enumerator)->data) )
if( window->ID == (int) (enumerator->data) )
{
((SFG_Enumerator *) enumerator)->found = TRUE;
((SFG_Enumerator *) enumerator)->data = (gpointer) window;
enumerator->found = TRUE;
enumerator->data = window;
return;
}
@ -562,7 +518,7 @@ static void fghcbWindowByID( gpointer window, gpointer enumerator )
/*
* Otherwise, check this window's children
*/
fgEnumSubWindows( (SFG_Window *) window, fghcbWindowByID, enumerator );
fgEnumSubWindows( window, fghcbWindowByID, enumerator );
}
/*
@ -570,7 +526,7 @@ static void fghcbWindowByID( gpointer window, gpointer enumerator )
* looking for a specified (sub)window identifier. The function
* is defined in freeglut_structure.c file.
*/
SFG_Window* fgWindowByID( gint windowID )
SFG_Window* fgWindowByID( int windowID )
{
SFG_Enumerator enumerator;
@ -578,7 +534,7 @@ SFG_Window* fgWindowByID( gint windowID )
* Uses a method very similiar for fgWindowByHandle...
*/
enumerator.found = FALSE;
enumerator.data = (gpointer) windowID;
enumerator.data = (void *) windowID;
/*
* Start the enumeration now:
@ -601,23 +557,17 @@ SFG_Window* fgWindowByID( gint windowID )
* Looks up a menu given it's ID. This is easier that fgWindowByXXX
* as all menus are placed in a single doubly linked list...
*/
SFG_Menu* fgMenuByID( gint menuID )
SFG_Menu* fgMenuByID( int menuID )
{
SFG_Menu *menu = NULL;
gint i;
freeglut_assert_ready;
/*
* It's enough to check all entries in fgStructure.Menus...
*/
for( i=0; i<(gint) g_list_length( fgStructure.Menus ); i++ )
for( menu = fgStructure.Menus.First; menu; menu = menu->Node.Next )
{
/*
* Grab the n-th element of the menu objects list...
*/
menu = (SFG_Menu *) g_list_nth( fgStructure.Menus, i )->data;
/*
* Does the ID number match?
*/
@ -631,13 +581,56 @@ SFG_Menu* fgMenuByID( gint menuID )
return( NULL );
}
/*
* List functions...
*/
void fgListInit(SFG_List *list)
{
list->First = NULL;
list->Last = NULL;
}
void fgListAppend(SFG_List *list, SFG_Node *node)
{
SFG_Node *ln;
if ( (ln = list->Last) != NULL )
{
node->Prev = ln;
}
else
{
node->Prev = NULL;
list->First = node;
}
node->Next = NULL;
list->Last = node;
}
void fgListRemove(SFG_List *list, SFG_Node *node)
{
SFG_Node *ln;
if ( (ln = node->Next) != NULL )
ln->Prev = node->Prev;
if ( (ln = node->Prev) != NULL )
ln->Next = node->Next;
if ( (ln = list->First) == node )
list->First = node->Next;
if ( (ln = list->Last) == node )
list->Last = node->Prev;
}
int fgListLength(SFG_List *list)
{
SFG_Node *node;
int length = 0;
for( node = list->First; node; node = node->Next )
++length;
return( length );
}
/*** END OF FILE ***/

View File

@ -65,10 +65,10 @@
#if TARGET_HOST_UNIX_X11
XVisualInfo* fgChooseVisual( void )
{
gint bufferSize[] = { 16, 12, 8, 4, 2, 1 };
gboolean wantIndexedMode = FALSE;
gint attributes[ 32 ];
gint where = 0;
int bufferSize[] = { 16, 12, 8, 4, 2, 1 };
GLboolean wantIndexedMode = FALSE;
int attributes[ 32 ];
int where = 0;
/*
* First we have to process the display mode settings...
@ -300,14 +300,14 @@ gboolean fgSetupPixelFormat( SFG_Window* window, gboolean checkOnly )
* Opens a window. Requires a SFG_Window object created and attached
* to the freeglut structure. OpenGL context is created here.
*/
void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint w, gint h, gboolean gameMode )
void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, int h, GLboolean gameMode )
{
#if TARGET_HOST_UNIX_X11
XSetWindowAttributes winAttr;
XTextProperty textProperty;
XSizeHints sizeHints;
XWMHints wmHints;
guint32 mask;
unsigned long mask;
freeglut_assert_ready;
@ -315,7 +315,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
* Here we are upon the stage. Have the visual selected.
*/
window->Window.VisualInfo = fgChooseVisual();
g_assert( window->Window.VisualInfo != NULL );
assert( window->Window.VisualInfo != NULL );
/*
* Have the windows attributes set
@ -368,7 +368,7 @@ void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint
* Make sure the context is direct when the user wants it forced
*/
if( fgState.ForceDirectContext && !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
g_error( "unable to force direct context rendering for window '%s'", title );
fgError( "unable to force direct context rendering for window '%s'", title );
/*
* Set the new context as the current one. That's all about the window creation.
@ -624,7 +624,7 @@ int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
/*
* Fail if the parent has not been found
*/
g_return_val_if_fail( parent != NULL, 0 );
freeglut_return_val_if_fail( parent != NULL, 0 );
/*
* Create the new window
@ -687,7 +687,7 @@ void FGAPIENTRY glutSetWindow( int ID )
/*
* ...issue a warning message and keep rolling on
*/
g_warning( "glutSetWindow(): window ID %i not found!", ID );
fgWarning( "glutSetWindow(): window ID %i not found!", ID );
return;
}

View File

@ -4,5 +4,5 @@ bin_PROGRAMS = genfonts genstroke
genfonts_SOURCES = genfonts.c
genstroke_SOURCES = genstroke.c
genfonts_LDADD = $(X_LIBS) -lglib -lX11 -lXext
genstroke_LDADD = -lglib
genstroke_LDADD =
EXTRA_DIST = genfonts.c genstroke.c

View File

@ -31,11 +31,11 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <glib.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
/*
* Define the log domain
@ -46,13 +46,13 @@
/*
* The alphabet we want to export.
*/
gchar* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
gint g_AlphabetLength = 0;
char* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
int g_AlphabetLength = 0;
/*
* All undefined characters will get replaced by this one:
*/
gchar g_NoChar = '*';
char g_NoChar = '*';
/*
* The stream we want to redirect our output to
@ -64,10 +64,15 @@ FILE* g_Output = NULL;
*/
Display* g_Display;
/*
* Our argv[0]
*/
char *g_ProgName = "";
/*
* This function outputs the font file prologue
*/
void OutputPrologue( gchar* fileName )
void OutputPrologue( char* fileName )
{
/*
* Output the copyright and permission notices:
@ -98,13 +103,13 @@ void OutputPrologue( gchar* fileName )
/*
* This function outputs a font set
*/
void OutputFont( gchar* freeglutFontName, gchar* fontName )
void OutputFont( char* freeglutFontName, char* fontName )
{
gint character, lineWidth, maxWidth = 0, maxHeight = 0;
int character, lineWidth, maxWidth = 0, maxHeight = 0;
XFontStruct* fontStruct = NULL;
XGCValues contextValues;
XImage* image = NULL;
guchar* lineBuffer;
unsigned char* lineBuffer;
Pixmap buffer;
GC context;
@ -118,7 +123,9 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
/*
* Whoops, the font was not found
*/
g_error( "couldn't get font `%s' using local display", fontName );
fprintf( stderr, "%s: couldn't get font `%s' using local display\n",
g_ProgName, fontName );
exit( 1 );
}
/*
@ -130,7 +137,7 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
/*
* Allocate the line buffer for storing the font bitmap lines
*/
lineBuffer = g_new0( guchar, maxWidth );
lineBuffer = malloc( maxWidth );
/*
* Create a pixmap buffer where we'll be rendering our fonts to.
@ -163,7 +170,7 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
*/
for( character=0; character<g_AlphabetLength; character++ )
{
gint x, y, start_x, stop_x;
int x, y, start_x, stop_x;
/*
* Clear the context black (0 is black in our case)...
@ -229,8 +236,8 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
/*
* Output the character we have just grabbed
*/
fprintf( g_Output, "static const guchar %s_Character_%03i[] = {%3i",
freeglutFontName, (gint) g_Alphabet[ character ], stop_x-start_x
fprintf( g_Output, "static const GLubyte %s_Character_%03i[] = {%3i",
freeglutFontName, (int) g_Alphabet[ character ], stop_x-start_x
);
for( y=maxHeight-1; y>=0; y-- )
@ -266,33 +273,33 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
* Now we are ready to output the final data concerning the font charset
*/
fprintf( g_Output, "\n/* The font characters mapping: */\n" );
fprintf( g_Output, "static const guchar* %s_Character_Map[] = {", freeglutFontName );
fprintf( g_Output, "static const GLubyte* %s_Character_Map[] = {", freeglutFontName );
/*
* I have decided to change the characters mapping a bit...
*/
for( character=1; character<256; character++ )
{
gchar ourCharacter[ 2 ] = { 0, 0 };
char ourCharacter[ 2 ] = { 0, 0 };
/*
* Do we have the character defined or not?
*/
ourCharacter[ 0 ] = (gchar) character;
ourCharacter[ 0 ] = (char) character;
if( strstr( g_Alphabet, ourCharacter ) == NULL )
{
/*
* Nope, output the g_NoChar character instead:
*/
fprintf( g_Output, "%s_Character_%03i,", freeglutFontName, (gint) g_NoChar );
fprintf( g_Output, "%s_Character_%03i,", freeglutFontName, (int) g_NoChar );
}
else
{
/*
* Otherwise we're welcome to output the character:
*/
fprintf( g_Output, "%s_Character_%03i,", freeglutFontName, (gint) ourCharacter[ 0 ] );
fprintf( g_Output, "%s_Character_%03i,", freeglutFontName, (int) ourCharacter[ 0 ] );
}
}
@ -311,7 +318,7 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
*/
XFreeGC( g_Display, context );
XFreePixmap( g_Display, buffer );
g_free( lineBuffer );
free( lineBuffer );
}
/*
@ -328,16 +335,16 @@ void OutputEpilogue( void )
*/
int main( int argc, char** argv )
{
gchar ourCharacter[ 2 ] = { 0, 0 };
gchar* outputFileName = NULL;
gchar* displayName = NULL;
gint i = 1;
char ourCharacter[ 2 ] = { 0, 0 };
char* outputFileName = NULL;
char* displayName = NULL;
int i = 1;
/*
* The fonts that are going to be rasterized and added to the output file:
*/
gint fontsQuantity = 7;
gchar* fontsList[] = {
int fontsQuantity = 7;
char* fontsList[] = {
"Fixed8x13", "-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1",
"Fixed9x15", "-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1",
"Helvetica10", "-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1",
@ -347,6 +354,8 @@ int main( int argc, char** argv )
"TimesRoman24", "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1"
};
g_ProgName = argv[0];
/*
* Initialize the alphabet's length
*/
@ -358,17 +367,21 @@ int main( int argc, char** argv )
ourCharacter[ 0 ] = g_NoChar;
if( strstr( g_Alphabet, ourCharacter ) == NULL )
g_error( "the g_NoChar `%c' character not found in the alphabet `%s'", g_NoChar, g_Alphabet );
{
fprintf( stderr, "%s the g_NoChar `%c' character not found in the alphabet `%s'\n",
g_ProgName, g_NoChar, g_Alphabet );
exit( 1 );
}
/*
* Grab the display name to be used
*/
displayName = g_strdup( (gchar *) g_getenv( "DISPLAY" ) );
displayName = strdup( getenv( "DISPLAY" ) );
/*
* Define the default output file name
*/
outputFileName = g_strdup( "freeglut_font_data.c" );
outputFileName = strdup( "freeglut_font_data.c" );
/*
* Process the command line arguments now. Command line arguments expected:
@ -381,25 +394,25 @@ int main( int argc, char** argv )
/*
* See what the current token is
*/
if( g_strcasecmp( argv[ i ], "-display" ) == 0 )
if( strcasecmp( argv[ i ], "-display" ) == 0 )
{
g_assert( (i + 1) < argc );
g_free( displayName );
assert( (i + 1) < argc );
free( displayName );
/*
* The next token is expected to contain the X display name to use
*/
displayName = g_strdup( (gchar *) argv[ ++i ] );
displayName = strdup( argv[ ++i ] );
}
else if( g_strcasecmp( argv[ i ], "-file" ) == 0 )
else if( strcasecmp( argv[ i ], "-file" ) == 0 )
{
g_assert( (i + 1) < argc );
g_free( outputFileName );
assert( (i + 1) < argc );
free( outputFileName );
/*
* The next token is expected to contain the destination file name
*/
outputFileName = g_strdup( (gchar *) argv[ ++i ] );
outputFileName = strdup( argv[ ++i ] );
}
/*
@ -412,13 +425,13 @@ int main( int argc, char** argv )
* Connect to the X display
*/
g_Display = XOpenDisplay( displayName );
g_assert( g_Display != NULL );
assert( g_Display != NULL );
/*
* Have the destination file opened
*/
g_Output = fopen( outputFileName, "wt" );
g_assert( g_Output != NULL );
assert( g_Output != NULL );
/*
* Output the file header first
@ -461,8 +474,8 @@ int main( int argc, char** argv )
/*
* Clean up all the rest of the mess
*/
g_free( outputFileName );
g_free( displayName );
free( outputFileName );
free( displayName );
/*
* Return successful!

View File

@ -30,11 +30,10 @@
#include <config.h>
#endif
#include <glib.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
/*
* Define the log domain
@ -45,23 +44,28 @@
/*
* The alphabet we want to export.
*/
gchar* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
gint g_AlphabetLength = 0;
char* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
int g_AlphabetLength = 0;
/*
* All undefined characters will get replaced by this one:
*/
gchar g_NoChar = '*';
char g_NoChar = '*';
/*
* The stream we want to redirect our output to
*/
FILE* g_Output = NULL;
/*
* Our argv[0]
*/
char *g_ProgName = "";
/*
* This function outputs the font file prologue
*/
void OutputPrologue( gchar* fileName )
void OutputPrologue( char* fileName )
{
/*
* Output the copyright and permission notices:
@ -92,7 +96,7 @@ void OutputPrologue( gchar* fileName )
/*
* This function outputs a font set
*/
void OutputFont( gchar* freeglutFontName, gchar* fontName )
void OutputFont( char* freeglutFontName, char* fontName )
{
/*
* This is an easy one. I just have to write a parser for the SRC files
@ -116,9 +120,11 @@ void OutputEpilogue( void )
*/
int main( int argc, char** argv )
{
gchar ourCharacter[ 2 ] = { 0, 0 };
gchar* outputFileName = NULL;
gint i = 1;
char ourCharacter[ 2 ] = { 0, 0 };
char* outputFileName = NULL;
int i = 1;
g_ProgName = argv[0];
/*
* Initialize the alphabet's length
@ -131,12 +137,17 @@ int main( int argc, char** argv )
ourCharacter[ 0 ] = g_NoChar;
if( strstr( g_Alphabet, ourCharacter ) == NULL )
g_error( "the g_NoChar `%c' character not found in the alphabet `%s'", g_NoChar, g_Alphabet );
{
fprintf( stderr,
"%s: the g_NoChar `%c' character not found in the alphabet `%s'\n",
g_ProgName, g_NoChar, g_Alphabet );
exit( 1 );
}
/*
* Define the default output file name
*/
outputFileName = g_strdup( "freeglut_font_stroke.c" );
outputFileName = strdup( "freeglut_font_stroke.c" );
/*
* Process the command line arguments now. Command line arguments expected:
@ -148,15 +159,15 @@ int main( int argc, char** argv )
/*
* See what the current token is
*/
if( g_strcasecmp( argv[ i ], "-file" ) == 0 )
if( strcasecmp( argv[ i ], "-file" ) == 0 )
{
g_assert( (i + 1) < argc );
g_free( outputFileName );
assert( (i + 1) < argc );
free( outputFileName );
/*
* The next token is expected to contain the destination file name
*/
outputFileName = g_strdup( (gchar *) argv[ ++i ] );
outputFileName = strdup( argv[ ++i ] );
}
/*
@ -169,7 +180,7 @@ int main( int argc, char** argv )
* Have the destination file opened
*/
g_Output = fopen( outputFileName, "wt" );
g_assert( g_Output != NULL );
assert( g_Output != NULL );
/*
* Output the file header first
@ -195,7 +206,7 @@ int main( int argc, char** argv )
/*
* Clean up all the rest of the mess
*/
g_free( outputFileName );
free( outputFileName );
/*
* Return successful!

View File

@ -448,6 +448,8 @@ FGAPI int FGAPIENTRY glutBitmapLength( void* font, const char* string );
FGAPI int FGAPIENTRY glutStrokeLength( void* font, const char* string );
FGAPI int FGAPIENTRY glutBitmapHeight( void* font );
FGAPI int FGAPIENTRY glutStrokeHeight( void* font );
FGAPI void FGAPIENTRY glutBitmapString( void* font, const char *string );
FGAPI void FGAPIENTRY glutStrokeString( void* font, const char *string );
/*
* Geometry functions, see freeglut_geometry.c
@ -520,7 +522,3 @@ FGAPI void FGAPIENTRY glutReportErrors( void );
#endif /* FREEGLUT_H */
/*** END OF FILE ***/

View File

@ -59,16 +59,17 @@
#endif
/*
* Those files should be available on every platform. GLib can be
* downloaded from ftp.gtk.org. Ports are available for most Unix
* systems and Win32 (for both native and posix-emulation modes).
* Those files should be available on every platform.
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <glib.h>
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
#include <sys/time.h>
/*
* The system-dependant include files should go here:
@ -92,6 +93,13 @@
# define M_PI 3.14159265358979323846
#endif
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
@ -134,14 +142,45 @@ typedef void (* FGCBtimer )( int );
*/
typedef void (* FGCBmenu )( int );
/*
* A list structure
*/
typedef struct tagSFG_List SFG_List;
struct tagSFG_List
{
void *First;
void *Last;
};
/*
* A list node structure
*/
typedef struct tagSFG_Node SFG_Node;
struct tagSFG_Node
{
void *Next;
void *Prev;
};
/*
* A helper structure holding two ints and a boolean
*/
typedef struct tagSFG_XYUse SFG_XYUse;
struct tagSFG_XYUse
{
gint X, Y; /* The two integers... */
gboolean Use; /* ...and a single boolean. */
GLint X, Y; /* The two integers... */
GLboolean Use; /* ...and a single boolean. */
};
/*
* A helper structure holding a timeval and a boolean
*/
typedef struct tagSFG_Time SFG_Time;
struct tagSFG_Time
{
struct timeval Value;
GLboolean Set;
};
/*
@ -152,26 +191,26 @@ struct tagSFG_State
{
SFG_XYUse Position; /* The default windows' position */
SFG_XYUse Size; /* The default windows' size */
guint DisplayMode; /* The display mode for new windows */
unsigned int DisplayMode; /* The display mode for new windows */
gboolean ForceDirectContext; /* Should we force direct contexts? */
gboolean TryDirectContext; /* What about giving a try to? */
GLboolean ForceDirectContext; /* Should we force direct contexts? */
GLboolean TryDirectContext; /* What about giving a try to? */
gboolean ForceIconic; /* All new top windows are iconified */
GLboolean ForceIconic; /* All new top windows are iconified */
gboolean GLDebugSwitch; /* OpenGL state debugging switch */
gboolean XSyncSwitch; /* X11 sync protocol switch */
GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
GLboolean XSyncSwitch; /* X11 sync protocol switch */
gboolean IgnoreKeyRepeat; /* Whether to ignore key repeat... */
GLboolean IgnoreKeyRepeat; /* Whether to ignore key repeat... */
GTimer* Timer; /* This timer is started on glutInit */
GList* Timers; /* The freeglut timer hooks */
SFG_Time Time; /* The time that glutInit was called */
SFG_List Timers; /* The freeglut timer hooks */
FGCBidle IdleCallback; /* The global idle callback */
SFG_XYUse GameModeSize; /* The game mode screen's dimensions */
gint GameModeDepth; /* The pixel depth for game mode */
gint GameModeRefresh; /* The refresh rate for game mode */
int GameModeDepth; /* The pixel depth for game mode */
int GameModeRefresh; /* The refresh rate for game mode */
};
/*
@ -182,14 +221,14 @@ struct tagSFG_Display
{
#if TARGET_HOST_UNIX_X11
Display* Display; /* The display we are being run in. */
gint Screen; /* The screen we are about to use. */
int Screen; /* The screen we are about to use. */
Window RootWindow; /* The screen's root window. */
gint Connection; /* The display's connection number */
int Connection; /* The display's connection number */
Atom DeleteWindow; /* The window deletion atom */
#ifdef X_XF86VidModeGetModeLine
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
gint DisplayModeClock; /* The display mode's refresh rate */
int DisplayModeClock; /* The display mode's refresh rate */
#endif
#elif TARGET_HOST_WIN32
@ -198,10 +237,10 @@ struct tagSFG_Display
#endif
gint ScreenWidth; /* The screen's width in pixels */
gint ScreenHeight; /* The screen's height in pixels */
gint ScreenWidthMM; /* The screen's width in milimeters */
gint ScreenHeightMM; /* The screen's height in milimeters */
int ScreenWidth; /* The screen's width in pixels */
int ScreenHeight; /* The screen's height in pixels */
int ScreenWidthMM; /* The screen's width in milimeters */
int ScreenHeightMM; /* The screen's height in milimeters */
};
@ -211,9 +250,10 @@ struct tagSFG_Display
typedef struct tagSFG_Timer SFG_Timer;
struct tagSFG_Timer
{
gint32 ID; /* The timer ID integer */
SFG_Node Node;
int ID; /* The timer ID integer */
FGCBtimer Callback; /* The timer callback */
double TriggerTime; /* The timer trigger time */
long TriggerTime; /* The timer trigger time */
};
/*
@ -242,24 +282,24 @@ struct tagSFG_Context
typedef struct tagSFG_WindowState SFG_WindowState;
struct tagSFG_WindowState
{
gint Width; /* Window's width in pixels */
gint Height; /* The same about the height */
int Width; /* Window's width in pixels */
int Height; /* The same about the height */
gboolean Redisplay; /* Do we have to redisplay? */
gboolean Visible; /* Is the window visible now */
GLboolean Redisplay; /* Do we have to redisplay? */
GLboolean Visible; /* Is the window visible now */
gint Cursor; /* The currently selected cursor */
guint32 Modifiers; /* The current ALT/SHIFT/CTRL state */
int Cursor; /* The currently selected cursor */
int Modifiers; /* The current ALT/SHIFT/CTRL state */
double JoystickPollRate; /* The joystick polling rate */
double JoystickLastPoll; /* When the last poll has happened */
long JoystickPollRate; /* The joystick polling rate */
long JoystickLastPoll; /* When the last poll has happened */
gint MouseX, MouseY; /* The most recent mouse position */
int MouseX, MouseY; /* The most recent mouse position */
gboolean IsGameMode; /* Is this the game mode window? */
GLboolean IsGameMode; /* Is this the game mode window? */
#if TARGET_HOST_WIN32
gboolean NeedToResize; /* Do we need to explicitly resize? */
GLboolean NeedToResize; /* Do we need to explicitly resize? */
#endif
};
@ -313,13 +353,14 @@ struct tagSFG_WindowCallbacks
typedef struct tagSFG_Menu SFG_Menu;
struct tagSFG_Menu
{
gint ID; /* The global menu ID */
GList* Entries; /* The menu entries list */
SFG_Node Node;
int ID; /* The global menu ID */
SFG_List Entries; /* The menu entries list */
FGCBmenu Callback; /* The menu callback */
gboolean IsActive; /* Is the menu selected? */
gint Width; /* Menu box width in pixels */
gint Height; /* Menu box height in pixels */
gint X, Y; /* Menu box raster position */
GLboolean IsActive; /* Is the menu selected? */
int Width; /* Menu box width in pixels */
int Height; /* Menu box height in pixels */
int X, Y; /* Menu box raster position */
};
/*
@ -328,12 +369,13 @@ struct tagSFG_Menu
typedef struct tagSFG_MenuEntry SFG_MenuEntry;
struct tagSFG_MenuEntry
{
gint ID; /* The menu entry ID (local) */
gint Ordinal; /* The menu's ordinal number */
GString* Text; /* The text to be displayed */
SFG_Node Node;
int ID; /* The menu entry ID (local) */
int Ordinal; /* The menu's ordinal number */
char* Text; /* The text to be displayed */
SFG_Menu* SubMenu; /* Optional sub-menu tree */
gboolean IsActive; /* Is the entry highlighted? */
gint Width; /* Label's width in pixels */
GLboolean IsActive; /* Is the entry highlighted? */
int Width; /* Label's width in pixels */
};
/*
@ -342,17 +384,18 @@ struct tagSFG_MenuEntry
typedef struct tagSFG_Window SFG_Window;
struct tagSFG_Window
{
gint ID; /* Window's ID number */
SFG_Node Node;
int ID; /* Window's ID number */
SFG_Context Window; /* Window and OpenGL context */
SFG_WindowState State; /* The window state */
SFG_WindowCallbacks Callbacks; /* The window callbacks */
SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
gboolean MenuActive[ FREEGLUT_MAX_MENUS ]; /* The menus activity flags */
GLboolean MenuActive[ FREEGLUT_MAX_MENUS ]; /* The menus activity flags */
SFG_Window* Parent; /* The parent to this window */
GList* Children; /* The subwindows d.l. list */
SFG_List Children; /* The subwindows d.l. list */
};
/*
@ -361,16 +404,16 @@ struct tagSFG_Window
typedef struct tagSFG_Structure SFG_Structure;
struct tagSFG_Structure
{
GList* Windows; /* The global windows list */
GList* Menus; /* The global menus list */
SFG_List Windows; /* The global windows list */
SFG_List Menus; /* The global menus list */
SFG_Window* Window; /* The currently active win. */
SFG_Menu* Menu; /* Same, but menu... */
SFG_Window* GameMode; /* The game mode window */
gint WindowID; /* The new current window ID */
gint MenuID; /* The new current menu ID */
int WindowID; /* The new current window ID */
int MenuID; /* The new current menu ID */
};
/*
@ -382,9 +425,10 @@ struct tagSFG_Structure
typedef struct tagSFG_Enumerator SFG_Enumerator;
struct tagSFG_Enumerator
{
gboolean found; /* Used to terminate search */
gpointer data; /* Custom data pointer */
GLboolean found; /* Used to terminate search */
void* data; /* Custom data pointer */
};
typedef void (* FGCBenumerator )( SFG_Window *, SFG_Enumerator * );
/*
* The bitmap font structure
@ -392,10 +436,10 @@ struct tagSFG_Enumerator
typedef struct tagSFG_Font SFG_Font;
struct tagSFG_Font
{
gchar* Name; /* The source font name */
gint Quantity; /* Number of chars in font */
gint Height; /* Height of the characters */
const guchar** Characters; /* The characters mapping */
char* Name; /* The source font name */
int Quantity; /* Number of chars in font */
int Height; /* Height of the characters */
const GLubyte** Characters; /* The characters mapping */
};
@ -423,7 +467,7 @@ 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 g_assert( fgState.Timer != NULL );
#define freeglut_assert_ready assert( fgState.Time.Set );
/*
* Following definitions are somewhat similiar to GLib's,
@ -436,15 +480,15 @@ extern SFG_State fgState;
* A call to those macros assures us that there is a current
* window and menu set, respectively:
*/
#define freeglut_assert_window g_assert( fgStructure.Window != NULL );
#define freeglut_assert_menu g_assert( fgStructure.Menu != NULL );
#define freeglut_assert_window assert( fgStructure.Window != NULL );
#define freeglut_assert_menu assert( fgStructure.Menu != NULL );
/*
* The initialize and deinitialize functions get called on glutInit()
* and glutMainLoop() end respectively. They should create/clean up
* everything inside of the freeglut
*/
void fgInitialize( const gchar* displayName );
void fgInitialize( const char* displayName );
void fgDeinitialize( void );
/*
@ -475,10 +519,10 @@ gboolean fgSetupPixelFormat( SFG_Window* window, gboolean checkOnly );
* Window creation, opening, closing and destruction.
* Defined in freeglut_structure.c, freeglut_window.c.
*/
SFG_Window* fgCreateWindow( SFG_Window* parent, const gchar* title, gint x, gint y, gint w, gint h, gboolean gameMode );
void fgOpenWindow( SFG_Window* window, const gchar* title, gint x, gint y, gint w, gint h, gboolean gameMode );
SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title, int x, int y, int w, int h, GLboolean gameMode );
void fgOpenWindow( SFG_Window* window, const char* title, int x, int y, int w, int h, GLboolean gameMode );
void fgCloseWindow( SFG_Window* window );
void fgDestroyWindow( SFG_Window* window, gboolean needToClose );
void fgDestroyWindow( SFG_Window* window, GLboolean needToClose );
/*
* Menu creation and destruction. Defined in freeglut_structure.c
@ -489,7 +533,7 @@ void fgDestroyMenu( SFG_Menu* menu );
/*
* Joystick device management functions, defined in freeglut_joystick.c
*/
void fgJoystickInit( gint ident );
void fgJoystickInit( int ident );
void fgJoystickClose( void );
void fgJoystickPollWindow( SFG_Window* window );
@ -505,8 +549,8 @@ void fgJoystickPollWindow( SFG_Window* window );
* and userData is the a custom user-supplied pointer. Functions
* are defined and exported from freeglut_structure.c file.
*/
void fgEnumWindows( GFunc enumCallback, SFG_Enumerator* enumerator );
void fgEnumSubWindows( SFG_Window* window, GFunc enumCallback, SFG_Enumerator* enumerator );
void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
/*
* fgWindowByHandle returns a (SFG_Window *) value pointing to the
@ -525,20 +569,20 @@ void fgEnumSubWindows( SFG_Window* window, GFunc enumCallback, SFG_Enumerator* e
* looking for a specified (sub)window identifier. The function
* is defined in freeglut_structure.c file.
*/
SFG_Window* fgWindowByID( gint windowID );
SFG_Window* fgWindowByID( int windowID );
/*
* Looks up a menu given it's ID. This is easier that fgWindowByXXX
* as all menus are placed in a single doubly linked list...
*/
SFG_Menu* fgMenuByID( gint menuID );
SFG_Menu* fgMenuByID( int menuID );
/*
* The menu activation and deactivation the code. This is the meat
* of the menu user interface handling code...
*/
void fgActivateMenu( gint button );
void fgDeactivateMenu( gint button );
void fgActivateMenu( int button );
void fgDeactivateMenu( int button );
/*
* This function gets called just before the buffers swap, so that
@ -553,10 +597,25 @@ void fgDisplayMenu( void );
*/
void fgDisplayCursor( void );
/*
* Elapsed time as per glutGet(GLUT_ELAPSED_TIME).
*/
long fgElapsedTime( void );
/*
* List functions
*/
void fgListInit(SFG_List *list);
void fgListAppend(SFG_List *list, SFG_Node *node);
void fgListRemove(SFG_List *list, SFG_Node *node);
int fgListLength(SFG_List *list);
/*
* Error Messages functions
*/
void fgError( const char *fmt, ... );
void fgWarning( const char *fmt, ... );
#endif /* FREEGLUT_INTERNAL_H */
/*** END OF FILE ***/