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:
parent
b4a9d78580
commit
704d1bfe6b
@ -31,7 +31,7 @@ libfreeglut_1_3_la_SOURCES = freeglut_callbacks.c \
|
|||||||
#
|
#
|
||||||
# Additional linker flags
|
# 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
|
libfreeglut_1_3_la_LDFLAGS = -version-info 0:0:0
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -100,7 +100,7 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ), i
|
|||||||
/*
|
/*
|
||||||
* Create a new freeglut timer hook structure
|
* 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
|
* 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)
|
* When will the time out happen (in terms of window's timer)
|
||||||
*/
|
*/
|
||||||
timer->TriggerTime =
|
timer->TriggerTime = fgElapsedTime() + timeOut;
|
||||||
g_timer_elapsed( fgState.Timer, NULL ) + (((double) timeOut) / 1000.0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the new hook attached to the current window
|
* 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.
|
* I had to peer to GLUT sources to clean up the mess.
|
||||||
* Can anyone please explain me what is going on here?!?
|
* 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_assert_ready; freeglut_return_if_fail( fgStructure.Window != NULL );
|
||||||
freeglut_return_if_fail( fgStructure.Window->Callbacks.Visibility != 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
|
* 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:
|
* Make sure the joystick polling routine gets called as early as possible:
|
||||||
*/
|
*/
|
||||||
fgStructure.Window->State.JoystickLastPoll =
|
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 )
|
if( fgStructure.Window->State.JoystickLastPoll < 0.0 )
|
||||||
fgStructure.Window->State.JoystickLastPoll = 0.0;
|
fgStructure.Window->State.JoystickLastPoll = 0.0;
|
||||||
|
@ -92,7 +92,9 @@ static SFG_Font* fghFontByID( void* font )
|
|||||||
/*
|
/*
|
||||||
* This probably is the library user's fault
|
* 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 )
|
void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
|
||||||
{
|
{
|
||||||
const guchar* face;
|
const GLubyte* face;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First of all we'll need a font to use
|
* First of all we'll need a font to use
|
||||||
@ -151,6 +153,14 @@ void FGAPIENTRY glutBitmapCharacter( void* fontID, int character )
|
|||||||
glPopClientAttrib();
|
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
|
* 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 )
|
int FGAPIENTRY glutBitmapLength( void* fontID, const char* string )
|
||||||
{
|
{
|
||||||
gint i, length = 0;
|
int i, length = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Using glutBitmapWidth() function to calculate the result
|
* 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 ] );
|
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 )
|
int FGAPIENTRY glutStrokeLength( void* fontID, const char* string )
|
||||||
{
|
{
|
||||||
gint i, length = 0;
|
int i, length = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Using glutStrokeWidth() function to calculate the result
|
* 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 ] );
|
length += glutStrokeWidth( fontID, string[ i ] );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
File diff suppressed because one or more lines are too long
@ -103,7 +103,7 @@ void fghRestoreState( void )
|
|||||||
# ifdef X_XF86VidModeGetAllModeLines
|
# ifdef X_XF86VidModeGetAllModeLines
|
||||||
|
|
||||||
XF86VidModeModeInfo** displayModes;
|
XF86VidModeModeInfo** displayModes;
|
||||||
gint i, displayModesCount;
|
int i, displayModesCount;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Query for all the display available...
|
* Query for all the display available...
|
||||||
@ -154,7 +154,7 @@ void fghRestoreState( void )
|
|||||||
/*
|
/*
|
||||||
* Checks the display mode settings against user's preferences
|
* 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...
|
* 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
|
* Changes the current display mode to match user's settings
|
||||||
*/
|
*/
|
||||||
gboolean fghChangeDisplayMode( gboolean haveToTest )
|
GLboolean fghChangeDisplayMode( GLboolean haveToTest )
|
||||||
{
|
{
|
||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ gboolean fghChangeDisplayMode( gboolean haveToTest )
|
|||||||
# ifdef X_XF86VidModeGetAllModeLines
|
# ifdef X_XF86VidModeGetAllModeLines
|
||||||
|
|
||||||
XF86VidModeModeInfo** displayModes;
|
XF86VidModeModeInfo** displayModes;
|
||||||
gint i, displayModesCount;
|
int i, displayModesCount;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Query for all the display available...
|
* Query for all the display available...
|
||||||
@ -267,7 +267,7 @@ gboolean fghChangeDisplayMode( gboolean haveToTest )
|
|||||||
*/
|
*/
|
||||||
if( mode != 0xffffffff )
|
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
|
* 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
|
* 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
|
* 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@%i", &depth, &refresh ) != 2 )
|
||||||
if( sscanf( string, ":%i", &depth ) != 1 )
|
if( sscanf( string, ":%i", &depth ) != 1 )
|
||||||
if( sscanf( string, "@%i", &refresh ) != 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
|
* Hopefully it worked, and if not, we still have the default values
|
||||||
@ -366,7 +366,7 @@ int FGAPIENTRY glutEnterGameMode( void )
|
|||||||
*/
|
*/
|
||||||
if( fghChangeDisplayMode( FALSE ) == FALSE )
|
if( fghChangeDisplayMode( FALSE ) == FALSE )
|
||||||
{
|
{
|
||||||
g_warning( "failed to change screen settings" );
|
fgWarning( "failed to change screen settings" );
|
||||||
return( FALSE );
|
return( FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,6 +502,8 @@ int FGAPIENTRY glutGameModeGet( GLenum eWhat )
|
|||||||
*/
|
*/
|
||||||
return( fgStructure.GameMode != NULL );
|
return( fgStructure.GameMode != NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** END OF FILE ***/
|
/*** END OF FILE ***/
|
||||||
|
@ -123,12 +123,12 @@ void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks )
|
|||||||
{
|
{
|
||||||
float radius = (float) dRadius, phi, psi, dpsi, dphi;
|
float radius = (float) dRadius, phi, psi, dpsi, dphi;
|
||||||
float* vertex;
|
float* vertex;
|
||||||
gint i, j;
|
int i, j;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate the vertices array
|
* Allocate the vertices array
|
||||||
*/
|
*/
|
||||||
vertex = g_new0( float, 3 * slices * (stacks - 1) );
|
vertex = calloc( sizeof(float), 3 * slices * (stacks - 1) );
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glScalef( radius, radius, radius );
|
glScalef( radius, radius, radius );
|
||||||
@ -183,7 +183,7 @@ void FGAPIENTRY glutWireSphere( GLdouble dRadius, GLint slices, GLint stacks )
|
|||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free( vertex );
|
free( vertex );
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,13 +194,13 @@ void FGAPIENTRY glutSolidSphere( GLdouble dRadius, GLint slices, GLint stacks )
|
|||||||
{
|
{
|
||||||
float radius = (float) dRadius, phi, psi, dpsi, dphi;
|
float radius = (float) dRadius, phi, psi, dpsi, dphi;
|
||||||
float *next, *tmp, *row;
|
float *next, *tmp, *row;
|
||||||
gint i, j;
|
int i, j;
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
//glScalef( radius, radius, radius );
|
//glScalef( radius, radius, radius );
|
||||||
|
|
||||||
row = g_new0( float, slices * 3 );
|
row = calloc( sizeof(float), slices * 3 );
|
||||||
next = g_new0( float, slices * 3 );
|
next = calloc( sizeof(float), slices * 3 );
|
||||||
|
|
||||||
dpsi = M_PI / (stacks + 1);
|
dpsi = M_PI / (stacks + 1);
|
||||||
dphi = 2 * M_PI / slices;
|
dphi = 2 * M_PI / slices;
|
||||||
@ -294,8 +294,8 @@ void FGAPIENTRY glutSolidSphere( GLdouble dRadius, GLint slices, GLint stacks )
|
|||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
g_free(row);
|
free(row);
|
||||||
g_free(next);
|
free(next);
|
||||||
glPopMatrix();
|
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 angle = (float) M_PI / (float) slices * 2.0f;
|
||||||
float slope = (float) tan( height / base );
|
float slope = (float) tan( height / base );
|
||||||
float* vertices = NULL;
|
float* vertices = NULL;
|
||||||
gint i, j;
|
int i, j;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need 'slices' points on a circle
|
* 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++ )
|
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 angle = (float) M_PI / (float) slices * 2.0f;
|
||||||
float slope = (float) tan( height / base );
|
float slope = (float) tan( height / base );
|
||||||
float* vertices = NULL;
|
float* vertices = NULL;
|
||||||
gint i, j;
|
int i, j;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need 'slices' points on a circle
|
* 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++ )
|
for( i=0; i<slices+1; i++ )
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ SFG_State fgState;
|
|||||||
/*
|
/*
|
||||||
* A call to this function should initialize all the display stuff...
|
* 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
|
#if TARGET_HOST_UNIX_X11
|
||||||
/*
|
/*
|
||||||
@ -76,7 +76,7 @@ void fgInitialize( const gchar* displayName )
|
|||||||
/*
|
/*
|
||||||
* Failed to open a display. That's no good.
|
* 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...
|
* 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 )
|
void fgDeinitialize( void )
|
||||||
{
|
{
|
||||||
gint i;
|
SFG_Timer *timer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if initialization has been performed before
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,18 +248,11 @@ void fgDeinitialize( void )
|
|||||||
/*
|
/*
|
||||||
* Delete all the timers and their storage list
|
* Delete all the timers and their storage list
|
||||||
*/
|
*/
|
||||||
for( i=0; i<(gint) g_list_length( fgState.Timers ); i++ )
|
while ( (timer = fgState.Timers.First) != NULL )
|
||||||
g_free( g_list_nth( fgState.Timers, i )->data );
|
{
|
||||||
|
fgListRemove(&fgState.Timers, &timer->Node);
|
||||||
g_list_free( fgState.Timers );
|
free(timer);
|
||||||
fgState.Timers = NULL;
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Destroy the timer itself
|
|
||||||
*/
|
|
||||||
g_timer_stop( fgState.Timer );
|
|
||||||
g_timer_destroy( fgState.Timer );
|
|
||||||
fgState.Timer = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deinitialize the joystick device
|
* Deinitialize the joystick device
|
||||||
@ -290,19 +283,19 @@ void fgDeinitialize( void )
|
|||||||
*/
|
*/
|
||||||
void FGAPIENTRY glutInit( int* pargc, char** argv )
|
void FGAPIENTRY glutInit( int* pargc, char** argv )
|
||||||
{
|
{
|
||||||
gchar* geometrySettings = NULL;
|
char* geometrySettings = NULL;
|
||||||
gchar* displayName = NULL;
|
char* displayName = NULL;
|
||||||
gint i, j, argc = *pargc;
|
int i, j, argc = *pargc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not allow multiple initialization of the library
|
* Do not allow multiple initialization of the library
|
||||||
*/
|
*/
|
||||||
if( fgState.Timer != NULL )
|
if( fgState.Time.Set )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We can't have multiple initialization performed
|
* 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
|
* Remember the function's call time
|
||||||
*/
|
*/
|
||||||
fgState.Timer = g_timer_new();
|
gettimeofday(&fgState.Time.Value, NULL);
|
||||||
g_timer_start( fgState.Timer );
|
fgState.Time.Set = TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the environment variable indicating the X display to use.
|
* Grab the environment variable indicating the X display to use.
|
||||||
* This is harmless under Win32, so let's let it stay here...
|
* 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.
|
* Have the program arguments parsed.
|
||||||
@ -379,12 +372,12 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
* Check for possible lack of the next argument
|
* Check for possible lack of the next argument
|
||||||
*/
|
*/
|
||||||
if( ++i >= argc )
|
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)
|
* 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
|
* 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
|
* Again, check if there is at least one more argument
|
||||||
*/
|
*/
|
||||||
if( ++i >= argc )
|
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...
|
* 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...
|
* We try to force direct rendering...
|
||||||
*/
|
*/
|
||||||
if( fgState.TryDirectContext == FALSE )
|
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;
|
fgState.ForceDirectContext = TRUE;
|
||||||
argv[ i ] = NULL;
|
argv[ i ] = NULL;
|
||||||
@ -444,7 +437,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
* We try to force indirect rendering...
|
* We try to force indirect rendering...
|
||||||
*/
|
*/
|
||||||
if( fgState.ForceDirectContext == TRUE )
|
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;
|
fgState.TryDirectContext = FALSE;
|
||||||
argv[ i ] = NULL;
|
argv[ i ] = NULL;
|
||||||
@ -516,13 +509,14 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
*/
|
*/
|
||||||
if( geometrySettings != NULL )
|
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.
|
* Have the settings parsed now. This is easy.
|
||||||
* We will use the XParseGeometry function.
|
* 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...
|
* Check what we have been supplied with...
|
||||||
@ -534,21 +528,25 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
fgState.Size.Y = h;
|
fgState.Size.Y = h;
|
||||||
|
|
||||||
if( result & XValue )
|
if( result & XValue )
|
||||||
|
{
|
||||||
if( result & XNegative )
|
if( result & XNegative )
|
||||||
fgState.Position.X = fgDisplay.ScreenWidth + x - fgState.Size.X;
|
fgState.Position.X = fgDisplay.ScreenWidth + x - fgState.Size.X;
|
||||||
else
|
else
|
||||||
fgState.Position.X = x;
|
fgState.Position.X = x;
|
||||||
|
}
|
||||||
|
|
||||||
if( result & YValue )
|
if( result & YValue )
|
||||||
|
{
|
||||||
if( result & YNegative )
|
if( result & YNegative )
|
||||||
fgState.Position.Y = fgDisplay.ScreenHeight + y - fgState.Size.Y;
|
fgState.Position.Y = fgDisplay.ScreenHeight + y - fgState.Size.Y;
|
||||||
else
|
else
|
||||||
fgState.Position.Y = y;
|
fgState.Position.Y = y;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the geometry settings string
|
* Free the geometry settings string
|
||||||
*/
|
*/
|
||||||
g_free( geometrySettings );
|
free( geometrySettings );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -564,7 +562,7 @@ void FGAPIENTRY glutInit( int* pargc, char** argv )
|
|||||||
/*
|
/*
|
||||||
* Do not forget about releasing the display name string
|
* 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 ------------------------------------------ */
|
/* -- INIT DISPLAY STRING PARSING ------------------------------------------ */
|
||||||
|
|
||||||
|
#if 0 /* FIXME: CJP */
|
||||||
/*
|
/*
|
||||||
* There is a discrete number of comparison operators we can encounter:
|
* There is a discrete number of comparison operators we can encounter:
|
||||||
*
|
*
|
||||||
@ -916,10 +915,10 @@ void FGAPIENTRY glutInitDisplayString( char* displayMode )
|
|||||||
*/
|
*/
|
||||||
g_scanner_destroy( scanner );
|
g_scanner_destroy( scanner );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void FGAPIENTRY glutInitDisplayString( char* displayMode )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*** END OF FILE ***/
|
/*** END OF FILE ***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ typedef struct tagSFG_Joystick SFG_Joystick;
|
|||||||
struct tagSFG_Joystick
|
struct tagSFG_Joystick
|
||||||
{
|
{
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
gint id;
|
int id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -123,19 +123,19 @@ struct tagSFG_Joystick
|
|||||||
#else
|
#else
|
||||||
# ifdef JS_NEW
|
# ifdef JS_NEW
|
||||||
struct js_event js;
|
struct js_event js;
|
||||||
gint tmp_buttons;
|
int tmp_buttons;
|
||||||
float tmp_axes[ _JS_MAX_AXES ];
|
float tmp_axes[ _JS_MAX_AXES ];
|
||||||
# else
|
# else
|
||||||
JS_DATA_TYPE js;
|
JS_DATA_TYPE js;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
gchar fname[ 128 ];
|
char fname[ 128 ];
|
||||||
gint fd;
|
int fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gboolean error;
|
GLboolean error;
|
||||||
gint num_axes;
|
int num_axes;
|
||||||
gint num_buttons;
|
int num_buttons;
|
||||||
|
|
||||||
float dead_band[ _JS_MAX_AXES ];
|
float dead_band[ _JS_MAX_AXES ];
|
||||||
float saturate [ _JS_MAX_AXES ];
|
float saturate [ _JS_MAX_AXES ];
|
||||||
@ -152,15 +152,15 @@ static SFG_Joystick* fgJoystick = NULL;
|
|||||||
/*
|
/*
|
||||||
* Read the raw joystick data
|
* 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
|
#ifdef WIN32
|
||||||
MMRESULT status;
|
MMRESULT status;
|
||||||
#else
|
#else
|
||||||
gint status;
|
int status;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gint i;
|
int i;
|
||||||
|
|
||||||
if( joy->error )
|
if( joy->error )
|
||||||
{
|
{
|
||||||
@ -184,7 +184,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( buttons )
|
if( buttons )
|
||||||
*buttons = (int) joy->js.dwButtons;
|
*buttons = joy->js.dwButtons;
|
||||||
|
|
||||||
if( axes )
|
if( axes )
|
||||||
{
|
{
|
||||||
@ -206,7 +206,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
|
|||||||
|
|
||||||
while( 1 )
|
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) )
|
if( status != sizeof(struct js_event) )
|
||||||
{
|
{
|
||||||
@ -220,7 +220,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_warning( joy->fname );
|
fgWarning( "%s", joy->fname );
|
||||||
joy->error = TRUE;
|
joy->error = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ static void fghJoystickRawRead ( SFG_Joystick* joy, gint* buttons, float* axes )
|
|||||||
/*
|
/*
|
||||||
* Correct the joystick axis data
|
* 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 ] )
|
if( value < joy->center[ axis ] )
|
||||||
{
|
{
|
||||||
@ -310,10 +310,10 @@ static float fghJoystickFudgeAxis( SFG_Joystick* joy, float value, gint axis )
|
|||||||
/*
|
/*
|
||||||
* Read the corrected joystick data
|
* 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 ];
|
float raw_axes[ _JS_MAX_AXES ];
|
||||||
gint i;
|
int i;
|
||||||
|
|
||||||
if( joy->error )
|
if( joy->error )
|
||||||
{
|
{
|
||||||
@ -339,7 +339,7 @@ static void fghJoystickOpen( SFG_Joystick* joy )
|
|||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
JOYCAPS jsCaps;
|
JOYCAPS jsCaps;
|
||||||
gint i;
|
int i;
|
||||||
|
|
||||||
joy->js.dwFlags = JOY_RETURNALL;
|
joy->js.dwFlags = JOY_RETURNALL;
|
||||||
joy->js.dwSize = sizeof( joy->js );
|
joy->js.dwSize = sizeof( joy->js );
|
||||||
@ -379,14 +379,17 @@ static void fghJoystickOpen( SFG_Joystick* joy )
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
# ifdef __FreeBSD__
|
# ifdef __FreeBSD__
|
||||||
gint buttons[ _JS_MAX_AXES ];
|
int buttons[ _JS_MAX_AXES ];
|
||||||
float axes[ _JS_MAX_AXES ];
|
float axes[ _JS_MAX_AXES ];
|
||||||
gint noargs, in_no_axes;
|
int noargs, in_no_axes;
|
||||||
gchar joyfname[ 1024 ];
|
char joyfname[ 1024 ];
|
||||||
FILE* joyfile;
|
FILE* joyfile;
|
||||||
|
# else
|
||||||
|
# ifndef JS_NEW
|
||||||
|
int counter;
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
int i;
|
||||||
gint i, counter;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default for older Linux systems.
|
* 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
|
* Make sure we don't get reinitialized
|
||||||
*/
|
*/
|
||||||
if( fgJoystick != NULL )
|
if( fgJoystick != NULL )
|
||||||
g_error( "illegal attemp to initialize joystick device" );
|
fgError( "illegal attemp to initialize joystick device" );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the global joystick structure created
|
* Have the global joystick structure created
|
||||||
*/
|
*/
|
||||||
fgJoystick = g_new0( SFG_Joystick, 1 );
|
fgJoystick = calloc( sizeof(SFG_Joystick), 1 );
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
switch( ident )
|
switch( ident )
|
||||||
@ -533,7 +536,7 @@ void fgJoystickInit( gint ident )
|
|||||||
void fgJoystickClose( void )
|
void fgJoystickClose( void )
|
||||||
{
|
{
|
||||||
if( fgJoystick == NULL )
|
if( fgJoystick == NULL )
|
||||||
g_error( "illegal attempt to deinitialize joystick device" );
|
fgError( "illegal attempt to deinitialize joystick device" );
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if( fgJoystick->error != TRUE )
|
if( fgJoystick->error != TRUE )
|
||||||
@ -548,7 +551,7 @@ void fgJoystickClose( void )
|
|||||||
void fgJoystickPollWindow( SFG_Window* window )
|
void fgJoystickPollWindow( SFG_Window* window )
|
||||||
{
|
{
|
||||||
float axes[ _JS_MAX_AXES ];
|
float axes[ _JS_MAX_AXES ];
|
||||||
gint buttons;
|
int buttons;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure the joystick device is initialized, the window seems valid
|
* Make sure the joystick device is initialized, the window seems valid
|
||||||
@ -567,9 +570,9 @@ void fgJoystickPollWindow( SFG_Window* window )
|
|||||||
*/
|
*/
|
||||||
window->Callbacks.Joystick(
|
window->Callbacks.Joystick(
|
||||||
buttons,
|
buttons,
|
||||||
(gint) (axes[ 0 ] * 1000.0f),
|
(int) (axes[ 0 ] * 1000.0f),
|
||||||
(gint) (axes[ 1 ] * 1000.0f),
|
(int) (axes[ 1 ] * 1000.0f),
|
||||||
(gint) (axes[ 2 ] * 1000.0f)
|
(int) (axes[ 2 ] * 1000.0f)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ static void fghRedrawWindowByHandle
|
|||||||
*/
|
*/
|
||||||
static void fghReshapeWindowByHandle
|
static void fghReshapeWindowByHandle
|
||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
( Window handle, gint width, gint height )
|
( Window handle, int width, int height )
|
||||||
#elif TARGET_HOST_WIN32
|
#elif TARGET_HOST_WIN32
|
||||||
( HWND handle, gint width, gint height )
|
( HWND handle, int width, int height )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -133,31 +133,31 @@ static void fghReshapeWindowByHandle
|
|||||||
/*
|
/*
|
||||||
* A static helper function to execute display callback for a window
|
* 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
|
#if TARGET_HOST_UNIX_X11
|
||||||
/*
|
/*
|
||||||
* Check if there is an idle callback hooked
|
* Check if there is an idle callback hooked
|
||||||
*/
|
*/
|
||||||
# warning there is a redisplay hack here (see the code commented out)
|
// # warning there is a redisplay hack here (see the code commented out)
|
||||||
if( (((SFG_Window *) window)->Callbacks.Display != NULL) /*&&
|
if( (window->Callbacks.Display != NULL) &&
|
||||||
/*(((SFG_Window *) window)->State.Redisplay == TRUE)*/ &&
|
/*(window->State.Redisplay == TRUE) &&*/
|
||||||
(((SFG_Window *) window)->State.Visible == TRUE) )
|
(window->State.Visible == TRUE) )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* OKi, this is the case: have the window set as the current one
|
* 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
|
* Do not exagerate with the redisplaying
|
||||||
*/
|
*/
|
||||||
((SFG_Window *) window)->State.Redisplay = FALSE;
|
window->State.Redisplay = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And execute the display callback immediately after
|
* And execute the display callback immediately after
|
||||||
*/
|
*/
|
||||||
((SFG_Window *) window)->Callbacks.Display();
|
window->Callbacks.Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif TARGET_HOST_WIN32
|
#elif TARGET_HOST_WIN32
|
||||||
@ -165,12 +165,12 @@ static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
|
|||||||
/*
|
/*
|
||||||
* Do we need to explicitly resize the window?
|
* 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(
|
fghReshapeWindowByHandle(
|
||||||
((SFG_Window *) window)->Window.Handle,
|
window->Window.Handle,
|
||||||
glutGet( GLUT_WINDOW_WIDTH ),
|
glutGet( GLUT_WINDOW_WIDTH ),
|
||||||
glutGet( GLUT_WINDOW_HEIGHT )
|
glutGet( GLUT_WINDOW_HEIGHT )
|
||||||
);
|
);
|
||||||
@ -178,14 +178,14 @@ static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
|
|||||||
/*
|
/*
|
||||||
* Never ever do that again:
|
* 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
|
* This is done in a bit different way under Windows
|
||||||
*/
|
*/
|
||||||
RedrawWindow(
|
RedrawWindow(
|
||||||
((SFG_Window *) window)->Window.Handle, NULL, NULL,
|
window->Window.Handle, NULL, NULL,
|
||||||
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE
|
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ static void fghcbDisplayWindow( gpointer window, gpointer enumerator )
|
|||||||
/*
|
/*
|
||||||
* Process this window's children (if any)
|
* 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
|
* 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 );
|
double checkTime = fgElapsedTime();
|
||||||
SFG_Window* win = (SFG_Window *) window;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if actually need to do the poll for the currently enumerated window:
|
* 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...
|
* Yeah, that's it. Poll the joystick...
|
||||||
*/
|
*/
|
||||||
fgJoystickPollWindow( (SFG_Window *) window );
|
fgJoystickPollWindow( window );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ...and reset the polling counters:
|
* ...and reset the polling counters:
|
||||||
*/
|
*/
|
||||||
win->State.JoystickLastPoll = checkTime;
|
window->State.JoystickLastPoll = checkTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process this window's children (if any)
|
* 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 )
|
static void fghCheckTimers( void )
|
||||||
{
|
{
|
||||||
double checkTime = g_timer_elapsed( fgState.Timer, NULL );
|
long checkTime = fgElapsedTime();
|
||||||
SFG_Timer* timer = NULL;
|
SFG_Timer *timer, *next;
|
||||||
GList* timedOut = NULL;
|
SFG_List timedOut;
|
||||||
gint i, length;
|
|
||||||
|
fgListInit(&timedOut);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For every timer that is waiting for triggering
|
* 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 )
|
||||||
{
|
{
|
||||||
/*
|
next = timer->Node.Next;
|
||||||
* ...grab the appropriate timer hook structure pointer
|
|
||||||
*/
|
|
||||||
timer = (SFG_Timer *) g_list_nth( fgState.Timers, i )->data;
|
|
||||||
g_assert( timer != NULL );
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for the timeout:
|
* Check for the timeout:
|
||||||
@ -294,45 +290,70 @@ static void fghCheckTimers( void )
|
|||||||
/*
|
/*
|
||||||
* Add the timer to the timed out timers list
|
* 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
|
* 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 )
|
if( timer->Callback != NULL )
|
||||||
timer->Callback( timer->ID );
|
timer->Callback( timer->ID );
|
||||||
|
fgListRemove( &timedOut, &timer->Node );
|
||||||
|
free( timer );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Finally, delete the timed out timers...
|
|
||||||
*/
|
|
||||||
for( i=0; i<length; i++ )
|
|
||||||
g_free( g_list_nth( timedOut, i )->data );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Finally, have the timed out timers list released
|
|
||||||
*/
|
|
||||||
if( timedOut != NULL )
|
|
||||||
g_list_free( timedOut );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Elapsed Time
|
||||||
|
*/
|
||||||
|
long fgElapsedTime( void )
|
||||||
|
{
|
||||||
|
struct timeval now;
|
||||||
|
long elapsed;
|
||||||
|
|
||||||
|
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 -------------------------------------------------- */
|
/* -- INTERFACE FUNCTIONS -------------------------------------------------- */
|
||||||
|
|
||||||
@ -360,7 +381,7 @@ void FGAPIENTRY glutMainLoop( void )
|
|||||||
* Enter the loop. Iterate as long as there are
|
* Enter the loop. Iterate as long as there are
|
||||||
* any windows in the freeglut structure.
|
* any windows in the freeglut structure.
|
||||||
*/
|
*/
|
||||||
while( fgStructure.Windows != NULL )
|
while( fgStructure.Windows.First != NULL )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Do we have any event messages pending?
|
* Do we have any event messages pending?
|
||||||
@ -572,7 +593,7 @@ void FGAPIENTRY glutMainLoop( void )
|
|||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
{
|
{
|
||||||
gint button;
|
int button;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A mouse button has been pressed or released. Traditionally,
|
* 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) )
|
if( (window->Callbacks.Keyboard != NULL) || (window->Callbacks.Special != NULL) )
|
||||||
{
|
{
|
||||||
XComposeStatus composeStatus;
|
XComposeStatus composeStatus;
|
||||||
gchar asciiCode[ 32 ];
|
char asciiCode[ 32 ];
|
||||||
KeySym keySym;
|
KeySym keySym;
|
||||||
gint len;
|
int len;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for the ASCII/KeySym codes associated with the event:
|
* Check for the ASCII/KeySym codes associated with the event:
|
||||||
@ -721,7 +742,7 @@ void FGAPIENTRY glutMainLoop( void )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gint special = -1;
|
int special = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ...and one for all the others, which need to be translated to GLUT_KEY_Xs...
|
* ...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
|
#endif
|
||||||
|
|
||||||
/*** END OF FILE ***/
|
/*** END OF FILE ***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,21 +53,39 @@
|
|||||||
|
|
||||||
/* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
|
/* -- 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
|
* 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;
|
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...
|
* 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?
|
* Is that an active sub menu by any case?
|
||||||
*/
|
*/
|
||||||
@ -92,10 +110,9 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
|
|||||||
/*
|
/*
|
||||||
* Mark all menu entries inactive...
|
* 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;
|
menuEntry->IsActive = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,13 +126,13 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
|
|||||||
/*
|
/*
|
||||||
* Calculation of the highlighted menu item is easy enough now:
|
* 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.
|
* The mouse cursor is somewhere over our box, check it out.
|
||||||
*/
|
*/
|
||||||
SFG_MenuEntry* menuEntry = (SFG_MenuEntry *) g_list_nth( menu->Entries, menuID )->data;
|
menuEntry = fghFindMenuEntry( menu, menuID + 1 );
|
||||||
g_assert( menuEntry != NULL );
|
assert( menuEntry != NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark the menu as active...
|
* Mark the menu as active...
|
||||||
@ -135,8 +152,8 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
|
|||||||
*/
|
*/
|
||||||
if( menuEntry->SubMenu != NULL )
|
if( menuEntry->SubMenu != NULL )
|
||||||
{
|
{
|
||||||
gint x = window->State.MouseX;
|
int x = window->State.MouseX;
|
||||||
gint y = window->State.MouseY;
|
int y = window->State.MouseY;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set up the initial menu position now...
|
* Set up the initial menu position now...
|
||||||
@ -173,8 +190,8 @@ static gboolean fghCheckMenuStatus( SFG_Menu* menu )
|
|||||||
*/
|
*/
|
||||||
static void fghDisplayMenuBox( SFG_Menu* menu )
|
static void fghDisplayMenuBox( SFG_Menu* menu )
|
||||||
{
|
{
|
||||||
SFG_Window* window = fgStructure.Window;
|
SFG_MenuEntry *menuEntry;
|
||||||
gint i, j, x, y;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the menu box drawn first. The +- values are
|
* 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...
|
* 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?
|
* 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
|
* There is an assumption that mouse cursor didn't move
|
||||||
* since the last check of menu activity state:
|
* since the last check of menu activity state:
|
||||||
*/
|
*/
|
||||||
gint menuID = menuEntry->Ordinal;
|
int menuID = menuEntry->Ordinal;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* So have the highlight drawn...
|
* So have the highlight drawn...
|
||||||
@ -233,10 +249,9 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
|
|||||||
*/
|
*/
|
||||||
glColor4f( 1, 1, 1, 1 );
|
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...
|
* Move the raster into position...
|
||||||
*/
|
*/
|
||||||
@ -248,17 +263,15 @@ static void fghDisplayMenuBox( SFG_Menu* menu )
|
|||||||
/*
|
/*
|
||||||
* Have the label drawn, character after character:
|
* Have the label drawn, character after character:
|
||||||
*/
|
*/
|
||||||
for( j=0; j<menuEntry->Text->len; j++ )
|
glutBitmapString( FREEGLUT_MENU_FONT, menuEntry->Text);
|
||||||
glutBitmapCharacter( FREEGLUT_MENU_FONT, (gint) menuEntry->Text->str[ j ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we are ready to check if any of our children needs to be redrawn:
|
* 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?
|
* Is that an active sub menu by any case?
|
||||||
*/
|
*/
|
||||||
@ -279,7 +292,7 @@ void fgDisplayMenu( void )
|
|||||||
{
|
{
|
||||||
SFG_Window* window = fgStructure.Window;
|
SFG_Window* window = fgStructure.Window;
|
||||||
SFG_Menu* menu = NULL;
|
SFG_Menu* menu = NULL;
|
||||||
gint i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure there is a current window available
|
* Make sure there is a current window available
|
||||||
@ -353,11 +366,11 @@ void fgDisplayMenu( void )
|
|||||||
/*
|
/*
|
||||||
* Activates a menu pointed by the function argument
|
* Activates a menu pointed by the function argument
|
||||||
*/
|
*/
|
||||||
void fgActivateMenu( gint button )
|
void fgActivateMenu( int button )
|
||||||
{
|
{
|
||||||
SFG_Window* window = fgStructure.Window;
|
SFG_Window* window = fgStructure.Window;
|
||||||
SFG_Menu* menu = NULL;
|
SFG_Menu* menu = NULL;
|
||||||
gint x, y;
|
int x, y;
|
||||||
|
|
||||||
freeglut_assert_window;
|
freeglut_assert_window;
|
||||||
|
|
||||||
@ -394,15 +407,14 @@ void fgActivateMenu( gint button )
|
|||||||
*/
|
*/
|
||||||
static void fghCheckMenuSelect( SFG_Menu* menu )
|
static void fghCheckMenuSelect( SFG_Menu* menu )
|
||||||
{
|
{
|
||||||
gint i;
|
SFG_MenuEntry *menuEntry;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First of all check any of the active sub menus...
|
* 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?
|
* Is this menu entry active?
|
||||||
*/
|
*/
|
||||||
@ -438,11 +450,11 @@ static void fghCheckMenuSelect( SFG_Menu* menu )
|
|||||||
/*
|
/*
|
||||||
* Deactivates a menu pointed by the function argument.
|
* Deactivates a menu pointed by the function argument.
|
||||||
*/
|
*/
|
||||||
void fgDeactivateMenu( gint button )
|
void fgDeactivateMenu( int button )
|
||||||
{
|
{
|
||||||
SFG_Window* window = fgStructure.Window;
|
SFG_Window* window = fgStructure.Window;
|
||||||
SFG_Menu* menu = NULL;
|
SFG_Menu* menu = NULL;
|
||||||
gint i, x, y;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure there is a current window available...
|
* Make sure there is a current window available...
|
||||||
@ -480,7 +492,8 @@ void fgDeactivateMenu( gint button )
|
|||||||
*/
|
*/
|
||||||
void fghCalculateMenuBoxSize( void )
|
void fghCalculateMenuBoxSize( void )
|
||||||
{
|
{
|
||||||
gint i, width;
|
SFG_MenuEntry* menuEntry;
|
||||||
|
int width = 0, height = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure there is a current menu set
|
* 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:
|
* 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
|
* 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
|
* Check if it's the biggest we've found
|
||||||
*/
|
*/
|
||||||
if( menuEntry->Width > width )
|
if( menuEntry->Width > width )
|
||||||
width = menuEntry->Width;
|
width = menuEntry->Width;
|
||||||
|
|
||||||
|
height += FREEGLUT_MENU_HEIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store the menu's box size now:
|
* Store the menu's box size now:
|
||||||
*/
|
*/
|
||||||
fgStructure.Menu->Height = i * FREEGLUT_MENU_HEIGHT;
|
fgStructure.Menu->Height = height;
|
||||||
fgStructure.Menu->Width = width;
|
fgStructure.Menu->Width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,7 +600,7 @@ void FGAPIENTRY glutSetMenu( int menuID )
|
|||||||
*/
|
*/
|
||||||
void FGAPIENTRY glutAddMenuEntry( const char* label, int value )
|
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
|
* 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...
|
* Fill in the appropriate values...
|
||||||
*/
|
*/
|
||||||
menuEntry->Text = g_string_new( label );
|
menuEntry->Text = strdup( label );
|
||||||
menuEntry->ID = value;
|
menuEntry->ID = value;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the new menu entry attached to the current menu
|
* 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
|
* 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 )
|
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 );
|
SFG_Menu* subMenu = fgMenuByID( subMenuID );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -628,14 +642,14 @@ void FGAPIENTRY glutAddSubMenu( const char* label, int subMenuID )
|
|||||||
/*
|
/*
|
||||||
* Fill in the appropriate values
|
* Fill in the appropriate values
|
||||||
*/
|
*/
|
||||||
menuEntry->Text = g_string_new( label );
|
menuEntry->Text = strdup( label );
|
||||||
menuEntry->SubMenu = subMenu;
|
menuEntry->SubMenu = subMenu;
|
||||||
menuEntry->ID = -1;
|
menuEntry->ID = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the new menu entry attached to the current menu
|
* 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
|
* 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 );
|
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:
|
* 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:
|
* We want it to become a normal menu entry, so:
|
||||||
*/
|
*/
|
||||||
if( menuEntry->Text != NULL )
|
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->ID = value;
|
||||||
menuEntry->SubMenu = NULL;
|
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_assert_ready; freeglut_return_if_fail( fgStructure.Menu != NULL );
|
||||||
freeglut_return_if_fail( subMenu != 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:
|
* 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:
|
* We want it to become a sub menu entry, so:
|
||||||
*/
|
*/
|
||||||
if( menuEntry->Text != NULL )
|
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->SubMenu = subMenu;
|
||||||
menuEntry->ID = -1;
|
menuEntry->ID = -1;
|
||||||
|
|
||||||
@ -734,24 +748,26 @@ void FGAPIENTRY glutRemoveMenuItem( int item )
|
|||||||
freeglut_assert_ready; freeglut_return_if_fail( fgStructure.Menu != NULL );
|
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...
|
* Removing a menu entry is quite simple...
|
||||||
*/
|
*/
|
||||||
menuEntry = (SFG_MenuEntry *) g_list_nth( fgStructure.Menu->Entries, item - 1 )->data;
|
fgListRemove( &fgStructure.Menu->Entries, &menuEntry->Node );
|
||||||
|
|
||||||
fgStructure.Menu->Entries = g_list_remove(
|
|
||||||
fgStructure.Menu->Entries,
|
|
||||||
menuEntry
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the entry label string, too
|
* Free the entry label string, too
|
||||||
*/
|
*/
|
||||||
g_string_free( menuEntry->Text, TRUE );
|
free( menuEntry->Text );
|
||||||
|
|
||||||
|
free( menuEntry );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the menu's dimensions now
|
* Update the menu's dimensions now
|
||||||
|
@ -50,76 +50,54 @@
|
|||||||
*/
|
*/
|
||||||
int FGAPIENTRY glutExtensionSupported( const char* extension )
|
int FGAPIENTRY glutExtensionSupported( const char* extension )
|
||||||
{
|
{
|
||||||
/*
|
const char *extensions;
|
||||||
* Grab the current context's OpenGL extensions
|
const char *ptr;
|
||||||
* and create a new GLib lexical analyzer...
|
int i;
|
||||||
*/
|
|
||||||
gchar *glExtensions = (gchar *) glGetString( GL_EXTENSIONS );
|
|
||||||
GScanner* scanner = g_scanner_new( NULL );
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure there is a current window, and thus -- a current context available
|
* 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)
|
extensions = glGetString(GL_EXTENSIONS);
|
||||||
&& (strlen( glExtensions ) > 0), 0 );
|
|
||||||
|
freeglut_return_val_if_fail( extensions != NULL, 0 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the extension itself looks valid
|
* 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 ] == ' ' )
|
if( extension[ i ] == ' ' )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the scanner's input name (for debugging)
|
* Look for our extension
|
||||||
*/
|
*/
|
||||||
scanner->input_name = "glutExtensionSupported()";
|
for (ptr = extensions; *ptr;)
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 ) )
|
|
||||||
{
|
{
|
||||||
/*
|
const char *str = extension;
|
||||||
* Actually we're expecting only string tokens
|
char c;
|
||||||
*/
|
|
||||||
GTokenType tokenType = g_scanner_get_next_token( scanner );
|
|
||||||
|
|
||||||
/*
|
while ( (c = *(str++)) )
|
||||||
* We are looking for identifiers
|
|
||||||
*/
|
|
||||||
if( tokenType == G_TOKEN_IDENTIFIER )
|
|
||||||
{
|
{
|
||||||
/*
|
if (*ptr != c)
|
||||||
* Compare the token and the extension string
|
goto next;
|
||||||
*/
|
ptr++;
|
||||||
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 ( !(c = *ptr) || c == ' ' )
|
||||||
|
return 1;
|
||||||
|
next:
|
||||||
|
while ( (c = *ptr) && c != ' ' )
|
||||||
|
ptr++;
|
||||||
|
while (*ptr == ' ')
|
||||||
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
return 0;
|
||||||
* Well, looks like we have failed to find the extension string
|
|
||||||
*/
|
|
||||||
g_scanner_destroy( scanner );
|
|
||||||
return( 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -140,7 +118,7 @@ void FGAPIENTRY glutReportErrors( void )
|
|||||||
# undef G_LOG_DOMAIN
|
# undef G_LOG_DOMAIN
|
||||||
# define G_LOG_DOMAIN ((gchar *) 0)
|
# define G_LOG_DOMAIN ((gchar *) 0)
|
||||||
|
|
||||||
g_warning( "GL error: %s", gluErrorString( error ) );
|
fgWarning( "GL error: %s", gluErrorString( error ) );
|
||||||
|
|
||||||
# undef G_LOG_DOMAIN
|
# undef G_LOG_DOMAIN
|
||||||
# define G_LOG_DOMAIN "freeglut_misc.c"
|
# define G_LOG_DOMAIN "freeglut_misc.c"
|
||||||
@ -202,7 +180,7 @@ void FGAPIENTRY glutSetKeyRepeat( int repeatMode )
|
|||||||
/*
|
/*
|
||||||
* Whoops, this was not expected at all
|
* Whoops, this was not expected at all
|
||||||
*/
|
*/
|
||||||
g_assert_not_reached();
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -76,9 +76,9 @@
|
|||||||
/*
|
/*
|
||||||
* Queries the GL context about some attributes
|
* 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
|
* Return nothing if there is no current window set
|
||||||
@ -137,8 +137,6 @@ static gint fghGetConfig( gint attribute )
|
|||||||
*/
|
*/
|
||||||
int FGAPIENTRY glutGet( GLenum eWhat )
|
int FGAPIENTRY glutGet( GLenum eWhat )
|
||||||
{
|
{
|
||||||
gint returnValue;
|
|
||||||
|
|
||||||
freeglut_assert_ready;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -150,7 +148,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
|||||||
/*
|
/*
|
||||||
* This is easy and nicely portable, as we are using GLib...
|
* 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
|
* Following values are stored in fgState and fgDisplay global structures
|
||||||
@ -226,7 +224,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
|||||||
{
|
{
|
||||||
XWindowAttributes winAttributes;
|
XWindowAttributes winAttributes;
|
||||||
Window another, window;
|
Window another, window;
|
||||||
gint x, y;
|
int x, y;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return zero if there is no current window set
|
* Return zero if there is no current window set
|
||||||
@ -393,7 +391,7 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
|||||||
if( fgStructure.Window == NULL )
|
if( fgStructure.Window == NULL )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
return( g_list_length( fgStructure.Window->Children ) );
|
return( fgListLength( &fgStructure.Window->Children ) );
|
||||||
|
|
||||||
case GLUT_WINDOW_CURSOR:
|
case GLUT_WINDOW_CURSOR:
|
||||||
/*
|
/*
|
||||||
@ -411,20 +409,20 @@ int FGAPIENTRY glutGet( GLenum eWhat )
|
|||||||
if( fgStructure.Menu == NULL )
|
if( fgStructure.Menu == NULL )
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
|
||||||
return( g_list_length( fgStructure.Menu->Entries ) );
|
return( fgListLength( &fgStructure.Menu->Entries ) );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
* Just have it reported, so that we can see what needs to be implemented
|
* 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If nothing happens, then we are in deep trouble...
|
* 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.
|
* Complain.
|
||||||
*/
|
*/
|
||||||
g_warning( "glutDeviceGet(): missing enum handle %i\n", eWhat );
|
fgWarning( "glutDeviceGet(): missing enum handle %i\n", eWhat );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And now -- the failure.
|
* And now -- the failure.
|
||||||
*/
|
*/
|
||||||
g_assert_not_reached();
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -543,7 +541,7 @@ int FGAPIENTRY glutGetModifiers( void )
|
|||||||
|
|
||||||
if( fgStructure.Window->State.Modifiers == 0xffffffff )
|
if( fgStructure.Window->State.Modifiers == 0xffffffff )
|
||||||
{
|
{
|
||||||
g_warning( "glutGetModifiers() called outside an input callback" );
|
fgWarning( "glutGetModifiers() called outside an input callback" );
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,14 +603,14 @@ int FGAPIENTRY glutLayerGet( GLenum eWhat )
|
|||||||
/*
|
/*
|
||||||
* Complain to the user about the obvious bug
|
* 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* And fail. That's good. Programs do love failing.
|
* And fail. That's good. Programs do love failing.
|
||||||
*/
|
*/
|
||||||
g_assert_not_reached();
|
return( -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** END OF FILE ***/
|
/*** END OF FILE ***/
|
||||||
|
@ -52,19 +52,19 @@ SFG_Structure fgStructure;
|
|||||||
*
|
*
|
||||||
* If parent is set to NULL, the window created will be a topmost one.
|
* 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
|
* Have the window object created
|
||||||
*/
|
*/
|
||||||
SFG_Window* window = g_new0( SFG_Window, 1 );
|
SFG_Window* window = calloc( sizeof(SFG_Window), 1 );
|
||||||
gint fakeArgc = 0;
|
int fakeArgc = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the freeglut internals haven't been initialized yet,
|
* If the freeglut internals haven't been initialized yet,
|
||||||
* do it now. Hack's idea courtesy of Chris Purnell...
|
* do it now. Hack's idea courtesy of Chris Purnell...
|
||||||
*/
|
*/
|
||||||
if( fgState.Timer == NULL )
|
if( !fgState.Time.Set )
|
||||||
glutInit( &fakeArgc, NULL );
|
glutInit( &fakeArgc, NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -72,6 +72,11 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const gchar* title, gint x, gint
|
|||||||
*/
|
*/
|
||||||
window->ID = ++fgStructure.WindowID;
|
window->ID = ++fgStructure.WindowID;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the children list
|
||||||
|
*/
|
||||||
|
fgListInit( &window->Children );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does this window have a parent?
|
* 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
|
* 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;
|
window->Parent = parent;
|
||||||
}
|
}
|
||||||
else
|
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
|
* 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
|
* Have the menu object created
|
||||||
*/
|
*/
|
||||||
SFG_Menu* menu = g_new0( SFG_Menu, 1 );
|
SFG_Menu* menu = calloc( sizeof(SFG_Menu), 1 );
|
||||||
gint fakeArgc = 0;
|
int fakeArgc = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the freeglut internals haven't been initialized yet,
|
* If the freeglut internals haven't been initialized yet,
|
||||||
* do it now. Hack's idea courtesy of Chris Purnell...
|
* do it now. Hack's idea courtesy of Chris Purnell...
|
||||||
*/
|
*/
|
||||||
if( fgState.Timer == NULL )
|
if( !fgState.Time.Set )
|
||||||
glutInit( &fakeArgc, NULL );
|
glutInit( &fakeArgc, NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -133,10 +138,15 @@ SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
|
|||||||
menu->ID = ++fgStructure.MenuID;
|
menu->ID = ++fgStructure.MenuID;
|
||||||
menu->Callback = menuCallback;
|
menu->Callback = menuCallback;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize the entries list
|
||||||
|
*/
|
||||||
|
fgListInit( &menu->Entries );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add it to the menu structure hierarchy
|
* 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
|
* Newly created menus implicitly become current ones
|
||||||
@ -154,63 +164,39 @@ SFG_Menu* fgCreateMenu( FGCBmenu menuCallback )
|
|||||||
* another function, defined in freeglut_window.c is called, but this is
|
* another function, defined in freeglut_window.c is called, but this is
|
||||||
* a whole different story...
|
* 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;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does this window have any subwindows?
|
* Does this window have any subwindows?
|
||||||
*/
|
*/
|
||||||
if( window->Children != NULL )
|
if( (subWindow = window->Children.First) != NULL )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* OKi, while there are any subwindows left...
|
* Destroy the first window in the list (possibly destroying
|
||||||
|
* it's subwindows too). This is not very effective, but works
|
||||||
*/
|
*/
|
||||||
while( g_list_first( window->Children ) != NULL )
|
fgDestroyWindow( subWindow, TRUE );
|
||||||
{
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
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
|
* Now we should remove the reference to this window from it's parent
|
||||||
*/
|
*/
|
||||||
if( window->Parent != NULL )
|
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
|
* OK, this window seems disconnected from the structure enough
|
||||||
* in order to be closed without any bigger risks...
|
* in order to be closed without any bigger risks...
|
||||||
*/
|
*/
|
||||||
if( needToClose == TRUE )
|
if( needToClose == TRUE )
|
||||||
fgCloseWindow( window );
|
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...
|
* 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
|
* Finally, we can delete the window's object. It hopefully does
|
||||||
* have everything inside it freed and we do not have to care...
|
* 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 )
|
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,
|
* Check if the menu is attached to the current window,
|
||||||
* if so, have it detached (by overwriting with a NULL):
|
* if so, have it detached (by overwriting with a NULL):
|
||||||
*/
|
*/
|
||||||
for( i=0; i<3; i++ )
|
for( i=0; i<3; i++ )
|
||||||
|
{
|
||||||
if( window->Menu[ i ] == menu )
|
if( window->Menu[ i ] == menu )
|
||||||
window->Menu[ i ] = NULL;
|
window->Menu[ i ] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call this function for all of the window's children recursively:
|
* Call this function for all of the window's children recursively:
|
||||||
*/
|
*/
|
||||||
for( i=0; i<(gint) g_list_length( window->Children ); i++ )
|
for( subWindow = window->Children.First; subWindow;
|
||||||
fghRemoveMenuFromWindow(
|
subWindow = subWindow->Node.Next);
|
||||||
(SFG_Window *) g_list_nth( window->Children, i )->data,
|
{
|
||||||
menu
|
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 )
|
static void fghRemoveMenuFromMenu( SFG_Menu* from, SFG_Menu* menu )
|
||||||
{
|
{
|
||||||
gboolean found = FALSE;
|
SFG_MenuEntry *entry;
|
||||||
|
|
||||||
/*
|
for( entry = from->Entries.First; entry; entry = entry->Node.Next )
|
||||||
* 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
|
|
||||||
{
|
{
|
||||||
/*
|
if (entry->SubMenu == menu)
|
||||||
* 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 )
|
|
||||||
{
|
{
|
||||||
/*
|
entry->SubMenu = NULL;
|
||||||
* 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 );
|
|
||||||
}
|
}
|
||||||
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 )
|
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;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First of all, have all references to this menu removed from all windows:
|
* First of all, have all references to this menu removed from all windows:
|
||||||
*/
|
*/
|
||||||
for( i=0; i<(gint) g_list_length( fgStructure.Windows ); i++ )
|
for( window = fgStructure.Windows.First; window;
|
||||||
fghRemoveMenuFromWindow(
|
window = window->Node.Next )
|
||||||
(SFG_Window *) g_list_nth( fgStructure.Windows, i )->data,
|
{
|
||||||
menu
|
fghRemoveMenuFromWindow( window, menu );
|
||||||
);
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now proceed with removing menu entries that lead to this menu
|
* Now proceed with removing menu entries that lead to this menu
|
||||||
*/
|
*/
|
||||||
for( i=0; i<(gint) g_list_length( fgStructure.Menus ); i++ )
|
for( from = fgStructure.Menus.First; from; from = from->Node.Next )
|
||||||
fghRemoveMenuFromMenu(
|
{
|
||||||
(SFG_Menu *) g_list_nth( fgStructure.Menus, i )->data,
|
fghRemoveMenuFromMenu( from, menu );
|
||||||
menu
|
}
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now we are pretty sure the menu is not used anywhere
|
* Now we are pretty sure the menu is not used anywhere
|
||||||
* and that we can remove all of it's entries
|
* 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:
|
* There might be a string allocated, have it freed:
|
||||||
*/
|
*/
|
||||||
g_string_free( entry->Text, TRUE );
|
free( entry->Text );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deallocate the entry itself:
|
* 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
|
* 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...
|
* If that menu was the current one...
|
||||||
@ -370,7 +320,7 @@ void fgDestroyMenu( SFG_Menu* menu )
|
|||||||
/*
|
/*
|
||||||
* Have the menu structure freed
|
* Have the menu structure freed
|
||||||
*/
|
*/
|
||||||
g_free( menu );
|
free( menu );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -382,11 +332,13 @@ void fgDestroyMenu( SFG_Menu* menu )
|
|||||||
void fgCreateStructure( void )
|
void fgCreateStructure( void )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* We will be needing two lists: the first containing windows, and the second
|
* We will be needing two lists: the first containing windows,
|
||||||
* containing the user-defined menus. However we do not need allocating anything,
|
* and the second containing the user-defined menus.
|
||||||
* as it is done automagically by GLib when appending new entries to both of them.
|
* Also, no current window/menu is set, as none has been created yet.
|
||||||
* Also, no current window/menu is set, as none has been created yet.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
fgListInit(&fgStructure.Windows);
|
||||||
|
fgListInit(&fgStructure.Menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -395,40 +347,44 @@ void fgCreateStructure( void )
|
|||||||
*/
|
*/
|
||||||
void fgDestroyStructure( void )
|
void fgDestroyStructure( void )
|
||||||
{
|
{
|
||||||
/*
|
SFG_Window *window;
|
||||||
* Just make sure we are not called in vain...
|
SFG_Menu *menu;
|
||||||
*/
|
|
||||||
|
/*
|
||||||
|
* Just make sure we are not called in vain...
|
||||||
|
*/
|
||||||
freeglut_assert_ready;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure all windows and menus have been deallocated
|
* Make sure all windows and menus have been deallocated
|
||||||
*/
|
*/
|
||||||
while( fgStructure.Windows != NULL )
|
while( (window = fgStructure.Windows.First) != NULL )
|
||||||
fgDestroyWindow( (SFG_Window *) g_list_first( fgStructure.Windows )->data, TRUE );
|
fgDestroyWindow( window, TRUE );
|
||||||
|
|
||||||
while( fgStructure.Menus != NULL )
|
while( (menu = fgStructure.Menus.First) != NULL )
|
||||||
fgDestroyMenu( (SFG_Menu *) g_list_first( fgStructure.Menus )->data );
|
fgDestroyMenu( menu );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to enumerate through all registered top-level windows
|
* 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;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check every of the top-level windows
|
* 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...
|
* 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
|
* 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)
|
* 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;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check every of the window's children:
|
* 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...
|
* 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
|
* 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
|
* 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...
|
* 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
|
#if TARGET_HOST_UNIX_X11
|
||||||
#define WBHANDLE (Window)
|
#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.
|
* 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;
|
enumerator->found = TRUE;
|
||||||
((SFG_Enumerator *) enumerator)->data = (gpointer) window;
|
enumerator->data = window;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -496,7 +452,7 @@ static void fghcbWindowByHandle( gpointer window, gpointer enumerator )
|
|||||||
/*
|
/*
|
||||||
* Otherwise, check this window's children
|
* Otherwise, check this window's children
|
||||||
*/
|
*/
|
||||||
fgEnumSubWindows( (SFG_Window *) window, fghcbWindowByHandle, enumerator );
|
fgEnumSubWindows( window, fghcbWindowByHandle, enumerator );
|
||||||
|
|
||||||
#undef WBHANDLE
|
#undef WBHANDLE
|
||||||
}
|
}
|
||||||
@ -519,7 +475,7 @@ SFG_Window* fgWindowByHandle
|
|||||||
* This is easy and makes use of the windows enumeration defined above
|
* This is easy and makes use of the windows enumeration defined above
|
||||||
*/
|
*/
|
||||||
enumerator.found = FALSE;
|
enumerator.found = FALSE;
|
||||||
enumerator.data = (gpointer) hWindow;
|
enumerator.data = (void *)hWindow;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the enumeration now:
|
* Start the enumeration now:
|
||||||
@ -541,20 +497,20 @@ SFG_Window* fgWindowByHandle
|
|||||||
/*
|
/*
|
||||||
* A static helper function to look for a window given it's ID
|
* 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...
|
* 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.
|
* 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;
|
enumerator->found = TRUE;
|
||||||
((SFG_Enumerator *) enumerator)->data = (gpointer) window;
|
enumerator->data = window;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -562,7 +518,7 @@ static void fghcbWindowByID( gpointer window, gpointer enumerator )
|
|||||||
/*
|
/*
|
||||||
* Otherwise, check this window's children
|
* 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
|
* looking for a specified (sub)window identifier. The function
|
||||||
* is defined in freeglut_structure.c file.
|
* is defined in freeglut_structure.c file.
|
||||||
*/
|
*/
|
||||||
SFG_Window* fgWindowByID( gint windowID )
|
SFG_Window* fgWindowByID( int windowID )
|
||||||
{
|
{
|
||||||
SFG_Enumerator enumerator;
|
SFG_Enumerator enumerator;
|
||||||
|
|
||||||
@ -578,7 +534,7 @@ SFG_Window* fgWindowByID( gint windowID )
|
|||||||
* Uses a method very similiar for fgWindowByHandle...
|
* Uses a method very similiar for fgWindowByHandle...
|
||||||
*/
|
*/
|
||||||
enumerator.found = FALSE;
|
enumerator.found = FALSE;
|
||||||
enumerator.data = (gpointer) windowID;
|
enumerator.data = (void *) windowID;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the enumeration now:
|
* 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
|
* Looks up a menu given it's ID. This is easier that fgWindowByXXX
|
||||||
* as all menus are placed in a single doubly linked list...
|
* 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;
|
SFG_Menu *menu = NULL;
|
||||||
gint i;
|
|
||||||
|
|
||||||
freeglut_assert_ready;
|
freeglut_assert_ready;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It's enough to check all entries in fgStructure.Menus...
|
* 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?
|
* Does the ID number match?
|
||||||
*/
|
*/
|
||||||
@ -631,13 +581,56 @@ SFG_Menu* fgMenuByID( gint menuID )
|
|||||||
return( NULL );
|
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 ***/
|
/*** END OF FILE ***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,10 +65,10 @@
|
|||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
XVisualInfo* fgChooseVisual( void )
|
XVisualInfo* fgChooseVisual( void )
|
||||||
{
|
{
|
||||||
gint bufferSize[] = { 16, 12, 8, 4, 2, 1 };
|
int bufferSize[] = { 16, 12, 8, 4, 2, 1 };
|
||||||
gboolean wantIndexedMode = FALSE;
|
GLboolean wantIndexedMode = FALSE;
|
||||||
gint attributes[ 32 ];
|
int attributes[ 32 ];
|
||||||
gint where = 0;
|
int where = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First we have to process the display mode settings...
|
* 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
|
* Opens a window. Requires a SFG_Window object created and attached
|
||||||
* to the freeglut structure. OpenGL context is created here.
|
* 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
|
#if TARGET_HOST_UNIX_X11
|
||||||
XSetWindowAttributes winAttr;
|
XSetWindowAttributes winAttr;
|
||||||
XTextProperty textProperty;
|
XTextProperty textProperty;
|
||||||
XSizeHints sizeHints;
|
XSizeHints sizeHints;
|
||||||
XWMHints wmHints;
|
XWMHints wmHints;
|
||||||
guint32 mask;
|
unsigned long mask;
|
||||||
|
|
||||||
freeglut_assert_ready;
|
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.
|
* Here we are upon the stage. Have the visual selected.
|
||||||
*/
|
*/
|
||||||
window->Window.VisualInfo = fgChooseVisual();
|
window->Window.VisualInfo = fgChooseVisual();
|
||||||
g_assert( window->Window.VisualInfo != NULL );
|
assert( window->Window.VisualInfo != NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the windows attributes set
|
* 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
|
* Make sure the context is direct when the user wants it forced
|
||||||
*/
|
*/
|
||||||
if( fgState.ForceDirectContext && !glXIsDirect( fgDisplay.Display, window->Window.Context ) )
|
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.
|
* 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
|
* 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
|
* Create the new window
|
||||||
@ -687,7 +687,7 @@ void FGAPIENTRY glutSetWindow( int ID )
|
|||||||
/*
|
/*
|
||||||
* ...issue a warning message and keep rolling on
|
* ...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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,5 +4,5 @@ bin_PROGRAMS = genfonts genstroke
|
|||||||
genfonts_SOURCES = genfonts.c
|
genfonts_SOURCES = genfonts.c
|
||||||
genstroke_SOURCES = genstroke.c
|
genstroke_SOURCES = genstroke.c
|
||||||
genfonts_LDADD = $(X_LIBS) -lglib -lX11 -lXext
|
genfonts_LDADD = $(X_LIBS) -lglib -lX11 -lXext
|
||||||
genstroke_LDADD = -lglib
|
genstroke_LDADD =
|
||||||
EXTRA_DIST = genfonts.c genstroke.c
|
EXTRA_DIST = genfonts.c genstroke.c
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the log domain
|
* Define the log domain
|
||||||
@ -46,13 +46,13 @@
|
|||||||
/*
|
/*
|
||||||
* The alphabet we want to export.
|
* The alphabet we want to export.
|
||||||
*/
|
*/
|
||||||
gchar* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
|
char* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
|
||||||
gint g_AlphabetLength = 0;
|
int g_AlphabetLength = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All undefined characters will get replaced by this one:
|
* All undefined characters will get replaced by this one:
|
||||||
*/
|
*/
|
||||||
gchar g_NoChar = '*';
|
char g_NoChar = '*';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The stream we want to redirect our output to
|
* The stream we want to redirect our output to
|
||||||
@ -64,10 +64,15 @@ FILE* g_Output = NULL;
|
|||||||
*/
|
*/
|
||||||
Display* g_Display;
|
Display* g_Display;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our argv[0]
|
||||||
|
*/
|
||||||
|
char *g_ProgName = "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function outputs the font file prologue
|
* This function outputs the font file prologue
|
||||||
*/
|
*/
|
||||||
void OutputPrologue( gchar* fileName )
|
void OutputPrologue( char* fileName )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Output the copyright and permission notices:
|
* Output the copyright and permission notices:
|
||||||
@ -98,13 +103,13 @@ void OutputPrologue( gchar* fileName )
|
|||||||
/*
|
/*
|
||||||
* This function outputs a font set
|
* 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;
|
XFontStruct* fontStruct = NULL;
|
||||||
XGCValues contextValues;
|
XGCValues contextValues;
|
||||||
XImage* image = NULL;
|
XImage* image = NULL;
|
||||||
guchar* lineBuffer;
|
unsigned char* lineBuffer;
|
||||||
Pixmap buffer;
|
Pixmap buffer;
|
||||||
GC context;
|
GC context;
|
||||||
|
|
||||||
@ -118,7 +123,9 @@ void OutputFont( gchar* freeglutFontName, gchar* fontName )
|
|||||||
/*
|
/*
|
||||||
* Whoops, the font was not found
|
* 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
|
* 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.
|
* 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++ )
|
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)...
|
* 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
|
* Output the character we have just grabbed
|
||||||
*/
|
*/
|
||||||
fprintf( g_Output, "static const guchar %s_Character_%03i[] = {%3i",
|
fprintf( g_Output, "static const GLubyte %s_Character_%03i[] = {%3i",
|
||||||
freeglutFontName, (gint) g_Alphabet[ character ], stop_x-start_x
|
freeglutFontName, (int) g_Alphabet[ character ], stop_x-start_x
|
||||||
);
|
);
|
||||||
|
|
||||||
for( y=maxHeight-1; y>=0; y-- )
|
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
|
* 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, "\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...
|
* I have decided to change the characters mapping a bit...
|
||||||
*/
|
*/
|
||||||
for( character=1; character<256; character++ )
|
for( character=1; character<256; character++ )
|
||||||
{
|
{
|
||||||
gchar ourCharacter[ 2 ] = { 0, 0 };
|
char ourCharacter[ 2 ] = { 0, 0 };
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do we have the character defined or not?
|
* Do we have the character defined or not?
|
||||||
*/
|
*/
|
||||||
ourCharacter[ 0 ] = (gchar) character;
|
ourCharacter[ 0 ] = (char) character;
|
||||||
|
|
||||||
if( strstr( g_Alphabet, ourCharacter ) == NULL )
|
if( strstr( g_Alphabet, ourCharacter ) == NULL )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Nope, output the g_NoChar character instead:
|
* 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
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Otherwise we're welcome to output the character:
|
* 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 );
|
XFreeGC( g_Display, context );
|
||||||
XFreePixmap( g_Display, buffer );
|
XFreePixmap( g_Display, buffer );
|
||||||
g_free( lineBuffer );
|
free( lineBuffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -328,16 +335,16 @@ void OutputEpilogue( void )
|
|||||||
*/
|
*/
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
gchar ourCharacter[ 2 ] = { 0, 0 };
|
char ourCharacter[ 2 ] = { 0, 0 };
|
||||||
gchar* outputFileName = NULL;
|
char* outputFileName = NULL;
|
||||||
gchar* displayName = NULL;
|
char* displayName = NULL;
|
||||||
gint i = 1;
|
int i = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The fonts that are going to be rasterized and added to the output file:
|
* The fonts that are going to be rasterized and added to the output file:
|
||||||
*/
|
*/
|
||||||
gint fontsQuantity = 7;
|
int fontsQuantity = 7;
|
||||||
gchar* fontsList[] = {
|
char* fontsList[] = {
|
||||||
"Fixed8x13", "-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1",
|
"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",
|
"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",
|
"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"
|
"TimesRoman24", "-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
g_ProgName = argv[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the alphabet's length
|
* Initialize the alphabet's length
|
||||||
*/
|
*/
|
||||||
@ -358,17 +367,21 @@ int main( int argc, char** argv )
|
|||||||
ourCharacter[ 0 ] = g_NoChar;
|
ourCharacter[ 0 ] = g_NoChar;
|
||||||
|
|
||||||
if( strstr( g_Alphabet, ourCharacter ) == NULL )
|
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
|
* Grab the display name to be used
|
||||||
*/
|
*/
|
||||||
displayName = g_strdup( (gchar *) g_getenv( "DISPLAY" ) );
|
displayName = strdup( getenv( "DISPLAY" ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the default output file name
|
* 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:
|
* 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
|
* See what the current token is
|
||||||
*/
|
*/
|
||||||
if( g_strcasecmp( argv[ i ], "-display" ) == 0 )
|
if( strcasecmp( argv[ i ], "-display" ) == 0 )
|
||||||
{
|
{
|
||||||
g_assert( (i + 1) < argc );
|
assert( (i + 1) < argc );
|
||||||
g_free( displayName );
|
free( displayName );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The next token is expected to contain the X display name to use
|
* 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 );
|
assert( (i + 1) < argc );
|
||||||
g_free( outputFileName );
|
free( outputFileName );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The next token is expected to contain the destination file name
|
* 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
|
* Connect to the X display
|
||||||
*/
|
*/
|
||||||
g_Display = XOpenDisplay( displayName );
|
g_Display = XOpenDisplay( displayName );
|
||||||
g_assert( g_Display != NULL );
|
assert( g_Display != NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Have the destination file opened
|
* Have the destination file opened
|
||||||
*/
|
*/
|
||||||
g_Output = fopen( outputFileName, "wt" );
|
g_Output = fopen( outputFileName, "wt" );
|
||||||
g_assert( g_Output != NULL );
|
assert( g_Output != NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output the file header first
|
* Output the file header first
|
||||||
@ -461,8 +474,8 @@ int main( int argc, char** argv )
|
|||||||
/*
|
/*
|
||||||
* Clean up all the rest of the mess
|
* Clean up all the rest of the mess
|
||||||
*/
|
*/
|
||||||
g_free( outputFileName );
|
free( outputFileName );
|
||||||
g_free( displayName );
|
free( displayName );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return successful!
|
* Return successful!
|
||||||
|
@ -30,11 +30,10 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Define the log domain
|
* Define the log domain
|
||||||
@ -45,23 +44,28 @@
|
|||||||
/*
|
/*
|
||||||
* The alphabet we want to export.
|
* The alphabet we want to export.
|
||||||
*/
|
*/
|
||||||
gchar* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
|
char* g_Alphabet = " abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ0123456789`~!@#$%^&*()-_=+[{}];:,.<>/?\\\"";
|
||||||
gint g_AlphabetLength = 0;
|
int g_AlphabetLength = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All undefined characters will get replaced by this one:
|
* All undefined characters will get replaced by this one:
|
||||||
*/
|
*/
|
||||||
gchar g_NoChar = '*';
|
char g_NoChar = '*';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The stream we want to redirect our output to
|
* The stream we want to redirect our output to
|
||||||
*/
|
*/
|
||||||
FILE* g_Output = NULL;
|
FILE* g_Output = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Our argv[0]
|
||||||
|
*/
|
||||||
|
char *g_ProgName = "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function outputs the font file prologue
|
* This function outputs the font file prologue
|
||||||
*/
|
*/
|
||||||
void OutputPrologue( gchar* fileName )
|
void OutputPrologue( char* fileName )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Output the copyright and permission notices:
|
* Output the copyright and permission notices:
|
||||||
@ -92,7 +96,7 @@ void OutputPrologue( gchar* fileName )
|
|||||||
/*
|
/*
|
||||||
* This function outputs a font set
|
* 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
|
* 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 )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
gchar ourCharacter[ 2 ] = { 0, 0 };
|
char ourCharacter[ 2 ] = { 0, 0 };
|
||||||
gchar* outputFileName = NULL;
|
char* outputFileName = NULL;
|
||||||
gint i = 1;
|
int i = 1;
|
||||||
|
|
||||||
|
g_ProgName = argv[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the alphabet's length
|
* Initialize the alphabet's length
|
||||||
@ -131,12 +137,17 @@ int main( int argc, char** argv )
|
|||||||
ourCharacter[ 0 ] = g_NoChar;
|
ourCharacter[ 0 ] = g_NoChar;
|
||||||
|
|
||||||
if( strstr( g_Alphabet, ourCharacter ) == NULL )
|
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
|
* 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:
|
* 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
|
* See what the current token is
|
||||||
*/
|
*/
|
||||||
if( g_strcasecmp( argv[ i ], "-file" ) == 0 )
|
if( strcasecmp( argv[ i ], "-file" ) == 0 )
|
||||||
{
|
{
|
||||||
g_assert( (i + 1) < argc );
|
assert( (i + 1) < argc );
|
||||||
g_free( outputFileName );
|
free( outputFileName );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The next token is expected to contain the destination file name
|
* 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
|
* Have the destination file opened
|
||||||
*/
|
*/
|
||||||
g_Output = fopen( outputFileName, "wt" );
|
g_Output = fopen( outputFileName, "wt" );
|
||||||
g_assert( g_Output != NULL );
|
assert( g_Output != NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output the file header first
|
* Output the file header first
|
||||||
@ -195,7 +206,7 @@ int main( int argc, char** argv )
|
|||||||
/*
|
/*
|
||||||
* Clean up all the rest of the mess
|
* Clean up all the rest of the mess
|
||||||
*/
|
*/
|
||||||
g_free( outputFileName );
|
free( outputFileName );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return successful!
|
* Return successful!
|
||||||
|
@ -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 glutStrokeLength( void* font, const char* string );
|
||||||
FGAPI int FGAPIENTRY glutBitmapHeight( void* font );
|
FGAPI int FGAPIENTRY glutBitmapHeight( void* font );
|
||||||
FGAPI int FGAPIENTRY glutStrokeHeight( 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
|
* Geometry functions, see freeglut_geometry.c
|
||||||
@ -520,7 +522,3 @@ FGAPI void FGAPIENTRY glutReportErrors( void );
|
|||||||
#endif /* FREEGLUT_H */
|
#endif /* FREEGLUT_H */
|
||||||
|
|
||||||
/*** END OF FILE ***/
|
/*** END OF FILE ***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,20 +55,21 @@
|
|||||||
*/
|
*/
|
||||||
#if TARGET_HOST_WIN32
|
#if TARGET_HOST_WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Those files should be available on every platform. GLib can be
|
* Those files should be available on every platform.
|
||||||
* downloaded from ftp.gtk.org. Ports are available for most Unix
|
|
||||||
* systems and Win32 (for both native and posix-emulation modes).
|
|
||||||
*/
|
*/
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.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:
|
* The system-dependant include files should go here:
|
||||||
@ -89,9 +90,16 @@
|
|||||||
* Microsoft VisualC++ 5.0's <math.h> does not define the PI
|
* Microsoft VisualC++ 5.0's <math.h> does not define the PI
|
||||||
*/
|
*/
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
# define M_PI 3.14159265358979323846
|
# define M_PI 3.14159265358979323846
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
|
# define TRUE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
# define FALSE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
|
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
|
||||||
|
|
||||||
@ -134,14 +142,45 @@ typedef void (* FGCBtimer )( int );
|
|||||||
*/
|
*/
|
||||||
typedef void (* FGCBmenu )( 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
|
* A helper structure holding two ints and a boolean
|
||||||
*/
|
*/
|
||||||
typedef struct tagSFG_XYUse SFG_XYUse;
|
typedef struct tagSFG_XYUse SFG_XYUse;
|
||||||
struct tagSFG_XYUse
|
struct tagSFG_XYUse
|
||||||
{
|
{
|
||||||
gint X, Y; /* The two integers... */
|
GLint X, Y; /* The two integers... */
|
||||||
gboolean Use; /* ...and a single boolean. */
|
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 Position; /* The default windows' position */
|
||||||
SFG_XYUse Size; /* The default windows' size */
|
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? */
|
GLboolean ForceDirectContext; /* Should we force direct contexts? */
|
||||||
gboolean TryDirectContext; /* What about giving a try to? */
|
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 */
|
GLboolean GLDebugSwitch; /* OpenGL state debugging switch */
|
||||||
gboolean XSyncSwitch; /* X11 sync protocol 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 */
|
SFG_Time Time; /* The time that glutInit was called */
|
||||||
GList* Timers; /* The freeglut timer hooks */
|
SFG_List Timers; /* The freeglut timer hooks */
|
||||||
|
|
||||||
FGCBidle IdleCallback; /* The global idle callback */
|
FGCBidle IdleCallback; /* The global idle callback */
|
||||||
|
|
||||||
SFG_XYUse GameModeSize; /* The game mode screen's dimensions */
|
SFG_XYUse GameModeSize; /* The game mode screen's dimensions */
|
||||||
gint GameModeDepth; /* The pixel depth for game mode */
|
int GameModeDepth; /* The pixel depth for game mode */
|
||||||
gint GameModeRefresh; /* The refresh rate for game mode */
|
int GameModeRefresh; /* The refresh rate for game mode */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -182,26 +221,26 @@ struct tagSFG_Display
|
|||||||
{
|
{
|
||||||
#if TARGET_HOST_UNIX_X11
|
#if TARGET_HOST_UNIX_X11
|
||||||
Display* Display; /* The display we are being run in. */
|
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. */
|
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 */
|
Atom DeleteWindow; /* The window deletion atom */
|
||||||
|
|
||||||
#ifdef X_XF86VidModeGetModeLine
|
#ifdef X_XF86VidModeGetModeLine
|
||||||
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
|
XF86VidModeModeLine DisplayMode; /* Current screen's display settings */
|
||||||
gint DisplayModeClock; /* The display mode's refresh rate */
|
int DisplayModeClock; /* The display mode's refresh rate */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif TARGET_HOST_WIN32
|
#elif TARGET_HOST_WIN32
|
||||||
HINSTANCE Instance; /* The application's instance */
|
HINSTANCE Instance; /* The application's instance */
|
||||||
DEVMODE DisplayMode; /* Desktop's display settings */
|
DEVMODE DisplayMode; /* Desktop's display settings */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gint ScreenWidth; /* The screen's width in pixels */
|
int ScreenWidth; /* The screen's width in pixels */
|
||||||
gint ScreenHeight; /* The screen's height in pixels */
|
int ScreenHeight; /* The screen's height in pixels */
|
||||||
gint ScreenWidthMM; /* The screen's width in milimeters */
|
int ScreenWidthMM; /* The screen's width in milimeters */
|
||||||
gint ScreenHeightMM; /* The screen's height in milimeters */
|
int ScreenHeightMM; /* The screen's height in milimeters */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -211,9 +250,10 @@ struct tagSFG_Display
|
|||||||
typedef struct tagSFG_Timer SFG_Timer;
|
typedef struct tagSFG_Timer SFG_Timer;
|
||||||
struct tagSFG_Timer
|
struct tagSFG_Timer
|
||||||
{
|
{
|
||||||
gint32 ID; /* The timer ID integer */
|
SFG_Node Node;
|
||||||
|
int ID; /* The timer ID integer */
|
||||||
FGCBtimer Callback; /* The timer callback */
|
FGCBtimer Callback; /* The timer callback */
|
||||||
double TriggerTime; /* The timer trigger time */
|
long TriggerTime; /* The timer trigger time */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -230,8 +270,8 @@ struct tagSFG_Context
|
|||||||
|
|
||||||
#elif TARGET_HOST_WIN32
|
#elif TARGET_HOST_WIN32
|
||||||
HWND Handle; /* The window's handle */
|
HWND Handle; /* The window's handle */
|
||||||
HDC Device; /* The window's device context */
|
HDC Device; /* The window's device context */
|
||||||
HGLRC Context; /* The window's WGL context */
|
HGLRC Context; /* The window's WGL context */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -242,24 +282,24 @@ struct tagSFG_Context
|
|||||||
typedef struct tagSFG_WindowState SFG_WindowState;
|
typedef struct tagSFG_WindowState SFG_WindowState;
|
||||||
struct tagSFG_WindowState
|
struct tagSFG_WindowState
|
||||||
{
|
{
|
||||||
gint Width; /* Window's width in pixels */
|
int Width; /* Window's width in pixels */
|
||||||
gint Height; /* The same about the height */
|
int Height; /* The same about the height */
|
||||||
|
|
||||||
gboolean Redisplay; /* Do we have to redisplay? */
|
GLboolean Redisplay; /* Do we have to redisplay? */
|
||||||
gboolean Visible; /* Is the window visible now */
|
GLboolean Visible; /* Is the window visible now */
|
||||||
|
|
||||||
gint Cursor; /* The currently selected cursor */
|
int Cursor; /* The currently selected cursor */
|
||||||
guint32 Modifiers; /* The current ALT/SHIFT/CTRL state */
|
int Modifiers; /* The current ALT/SHIFT/CTRL state */
|
||||||
|
|
||||||
double JoystickPollRate; /* The joystick polling rate */
|
long JoystickPollRate; /* The joystick polling rate */
|
||||||
double JoystickLastPoll; /* When the last poll has happened */
|
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
|
#if TARGET_HOST_WIN32
|
||||||
gboolean NeedToResize; /* Do we need to explicitly resize? */
|
GLboolean NeedToResize; /* Do we need to explicitly resize? */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -313,13 +353,14 @@ struct tagSFG_WindowCallbacks
|
|||||||
typedef struct tagSFG_Menu SFG_Menu;
|
typedef struct tagSFG_Menu SFG_Menu;
|
||||||
struct tagSFG_Menu
|
struct tagSFG_Menu
|
||||||
{
|
{
|
||||||
gint ID; /* The global menu ID */
|
SFG_Node Node;
|
||||||
GList* Entries; /* The menu entries list */
|
int ID; /* The global menu ID */
|
||||||
|
SFG_List Entries; /* The menu entries list */
|
||||||
FGCBmenu Callback; /* The menu callback */
|
FGCBmenu Callback; /* The menu callback */
|
||||||
gboolean IsActive; /* Is the menu selected? */
|
GLboolean IsActive; /* Is the menu selected? */
|
||||||
gint Width; /* Menu box width in pixels */
|
int Width; /* Menu box width in pixels */
|
||||||
gint Height; /* Menu box height in pixels */
|
int Height; /* Menu box height in pixels */
|
||||||
gint X, Y; /* Menu box raster position */
|
int X, Y; /* Menu box raster position */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -328,12 +369,13 @@ struct tagSFG_Menu
|
|||||||
typedef struct tagSFG_MenuEntry SFG_MenuEntry;
|
typedef struct tagSFG_MenuEntry SFG_MenuEntry;
|
||||||
struct tagSFG_MenuEntry
|
struct tagSFG_MenuEntry
|
||||||
{
|
{
|
||||||
gint ID; /* The menu entry ID (local) */
|
SFG_Node Node;
|
||||||
gint Ordinal; /* The menu's ordinal number */
|
int ID; /* The menu entry ID (local) */
|
||||||
GString* Text; /* The text to be displayed */
|
int Ordinal; /* The menu's ordinal number */
|
||||||
|
char* Text; /* The text to be displayed */
|
||||||
SFG_Menu* SubMenu; /* Optional sub-menu tree */
|
SFG_Menu* SubMenu; /* Optional sub-menu tree */
|
||||||
gboolean IsActive; /* Is the entry highlighted? */
|
GLboolean IsActive; /* Is the entry highlighted? */
|
||||||
gint Width; /* Label's width in pixels */
|
int Width; /* Label's width in pixels */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -342,17 +384,18 @@ struct tagSFG_MenuEntry
|
|||||||
typedef struct tagSFG_Window SFG_Window;
|
typedef struct tagSFG_Window SFG_Window;
|
||||||
struct tagSFG_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_Context Window; /* Window and OpenGL context */
|
||||||
SFG_WindowState State; /* The window state */
|
SFG_WindowState State; /* The window state */
|
||||||
SFG_WindowCallbacks Callbacks; /* The window callbacks */
|
SFG_WindowCallbacks Callbacks; /* The window callbacks */
|
||||||
|
|
||||||
SFG_Menu* Menu[ FREEGLUT_MAX_MENUS ]; /* Menus appended to window */
|
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 */
|
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;
|
typedef struct tagSFG_Structure SFG_Structure;
|
||||||
struct tagSFG_Structure
|
struct tagSFG_Structure
|
||||||
{
|
{
|
||||||
GList* Windows; /* The global windows list */
|
SFG_List Windows; /* The global windows list */
|
||||||
GList* Menus; /* The global menus list */
|
SFG_List Menus; /* The global menus list */
|
||||||
|
|
||||||
SFG_Window* Window; /* The currently active win. */
|
SFG_Window* Window; /* The currently active win. */
|
||||||
SFG_Menu* Menu; /* Same, but menu... */
|
SFG_Menu* Menu; /* Same, but menu... */
|
||||||
|
|
||||||
SFG_Window* GameMode; /* The game mode window */
|
SFG_Window* GameMode; /* The game mode window */
|
||||||
|
|
||||||
gint WindowID; /* The new current window ID */
|
int WindowID; /* The new current window ID */
|
||||||
gint MenuID; /* The new current menu ID */
|
int MenuID; /* The new current menu ID */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -382,9 +425,10 @@ struct tagSFG_Structure
|
|||||||
typedef struct tagSFG_Enumerator SFG_Enumerator;
|
typedef struct tagSFG_Enumerator SFG_Enumerator;
|
||||||
struct tagSFG_Enumerator
|
struct tagSFG_Enumerator
|
||||||
{
|
{
|
||||||
gboolean found; /* Used to terminate search */
|
GLboolean found; /* Used to terminate search */
|
||||||
gpointer data; /* Custom data pointer */
|
void* data; /* Custom data pointer */
|
||||||
};
|
};
|
||||||
|
typedef void (* FGCBenumerator )( SFG_Window *, SFG_Enumerator * );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The bitmap font structure
|
* The bitmap font structure
|
||||||
@ -392,10 +436,10 @@ struct tagSFG_Enumerator
|
|||||||
typedef struct tagSFG_Font SFG_Font;
|
typedef struct tagSFG_Font SFG_Font;
|
||||||
struct tagSFG_Font
|
struct tagSFG_Font
|
||||||
{
|
{
|
||||||
gchar* Name; /* The source font name */
|
char* Name; /* The source font name */
|
||||||
gint Quantity; /* Number of chars in font */
|
int Quantity; /* Number of chars in font */
|
||||||
gint Height; /* Height of the characters */
|
int Height; /* Height of the characters */
|
||||||
const guchar** Characters; /* The characters mapping */
|
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
|
* A call to this function makes us sure that the Display and Structure
|
||||||
* subsystems have been properly initialized and are ready to be used
|
* 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,
|
* 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
|
* A call to those macros assures us that there is a current
|
||||||
* window and menu set, respectively:
|
* window and menu set, respectively:
|
||||||
*/
|
*/
|
||||||
#define freeglut_assert_window g_assert( fgStructure.Window != NULL );
|
#define freeglut_assert_window assert( fgStructure.Window != NULL );
|
||||||
#define freeglut_assert_menu g_assert( fgStructure.Menu != NULL );
|
#define freeglut_assert_menu assert( fgStructure.Menu != NULL );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The initialize and deinitialize functions get called on glutInit()
|
* The initialize and deinitialize functions get called on glutInit()
|
||||||
* and glutMainLoop() end respectively. They should create/clean up
|
* and glutMainLoop() end respectively. They should create/clean up
|
||||||
* everything inside of the freeglut
|
* everything inside of the freeglut
|
||||||
*/
|
*/
|
||||||
void fgInitialize( const gchar* displayName );
|
void fgInitialize( const char* displayName );
|
||||||
void fgDeinitialize( void );
|
void fgDeinitialize( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -475,10 +519,10 @@ gboolean fgSetupPixelFormat( SFG_Window* window, gboolean checkOnly );
|
|||||||
* Window creation, opening, closing and destruction.
|
* Window creation, opening, closing and destruction.
|
||||||
* Defined in freeglut_structure.c, freeglut_window.c.
|
* 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 );
|
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 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 );
|
||||||
void fgCloseWindow( SFG_Window* window );
|
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
|
* 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
|
* Joystick device management functions, defined in freeglut_joystick.c
|
||||||
*/
|
*/
|
||||||
void fgJoystickInit( gint ident );
|
void fgJoystickInit( int ident );
|
||||||
void fgJoystickClose( void );
|
void fgJoystickClose( void );
|
||||||
void fgJoystickPollWindow( SFG_Window* window );
|
void fgJoystickPollWindow( SFG_Window* window );
|
||||||
|
|
||||||
@ -505,8 +549,8 @@ void fgJoystickPollWindow( SFG_Window* window );
|
|||||||
* and userData is the a custom user-supplied pointer. Functions
|
* and userData is the a custom user-supplied pointer. Functions
|
||||||
* are defined and exported from freeglut_structure.c file.
|
* are defined and exported from freeglut_structure.c file.
|
||||||
*/
|
*/
|
||||||
void fgEnumWindows( GFunc enumCallback, SFG_Enumerator* enumerator );
|
void fgEnumWindows( FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
|
||||||
void fgEnumSubWindows( SFG_Window* window, GFunc enumCallback, SFG_Enumerator* enumerator );
|
void fgEnumSubWindows( SFG_Window* window, FGCBenumerator enumCallback, SFG_Enumerator* enumerator );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fgWindowByHandle returns a (SFG_Window *) value pointing to the
|
* 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
|
* looking for a specified (sub)window identifier. The function
|
||||||
* is defined in freeglut_structure.c file.
|
* 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
|
* Looks up a menu given it's ID. This is easier that fgWindowByXXX
|
||||||
* as all menus are placed in a single doubly linked list...
|
* 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
|
* The menu activation and deactivation the code. This is the meat
|
||||||
* of the menu user interface handling code...
|
* of the menu user interface handling code...
|
||||||
*/
|
*/
|
||||||
void fgActivateMenu( gint button );
|
void fgActivateMenu( int button );
|
||||||
void fgDeactivateMenu( gint button );
|
void fgDeactivateMenu( int button );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function gets called just before the buffers swap, so that
|
* This function gets called just before the buffers swap, so that
|
||||||
@ -553,10 +597,25 @@ void fgDisplayMenu( void );
|
|||||||
*/
|
*/
|
||||||
void fgDisplayCursor( 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 */
|
#endif /* FREEGLUT_INTERNAL_H */
|
||||||
|
|
||||||
/*** END OF FILE ***/
|
/*** END OF FILE ***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user