X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=freeglut-1.3%2Ffreeglut_init.c;h=a1367b82d905bec95cf0ccf8796191d072a21813;hb=9d66916bab11e22ff2b670638be3a50e604897a1;hp=720fb69888f3d7b01c093764a852d14a2751a35b;hpb=19ac41b4392cee221c884511c0495d9d425a381e;p=freeglut diff --git a/freeglut-1.3/freeglut_init.c b/freeglut-1.3/freeglut_init.c index 720fb69..a1367b8 100644 --- a/freeglut-1.3/freeglut_init.c +++ b/freeglut-1.3/freeglut_init.c @@ -32,7 +32,7 @@ #define G_LOG_DOMAIN "freeglut-init" #include "../include/GL/freeglut.h" -#include "../include/GL/freeglut_internal.h" +#include "freeglut_internal.h" /* * TODO BEFORE THE STABLE RELEASE: @@ -55,14 +55,33 @@ SFG_Display fgDisplay; /* * The settings for the current freeglut session */ -SFG_State fgState = { { -1, -1, FALSE }, { 300, 300, TRUE }, GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, - FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, +SFG_State fgState = { { -1, -1, FALSE }, /* Position */ + { 300, 300, TRUE }, /* Size */ + GLUT_RGBA | GLUT_SINGLE | GLUT_DEPTH, /* DisplayMode */ + FALSE, /* ForceDirectContext */ + TRUE, /* TryDirectContext */ + FALSE, /* ForceIconic */ + FALSE, /* GLDebugSwitch */ + FALSE, /* XSyncSwitch */ + TRUE, /* IgnoreKeyRepeat */ + 0, /* FPSInterval */ + 0, /* SwapCount */ + 0, /* SwapTime */ #ifdef TARGET_HOST_WIN32 - { 0, FALSE }, + { 0, FALSE }, /* Time */ #else { { 0, 0 }, FALSE }, #endif - { NULL, NULL }, NULL, NULL, NULL, { 640, 480, TRUE }, 16, 72, GLUT_ACTION_EXIT, GLUT_EXEC_STATE_INIT } ; + { NULL, NULL }, /* Timers */ + NULL, /* IdleCallback */ + NULL, /* MenuStateCallback */ + NULL, /* MenuStatusCallback */ + { 640, 480, TRUE }, /* GameModeSize */ + 16, /* GameModeDepth */ + 72, /* GameModeRefresh */ + GLUT_ACTION_EXIT, /* ActionOnWindowClose */ + GLUT_EXEC_STATE_INIT /* ExecState */ +}; /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */ @@ -183,7 +202,10 @@ void fgInitialize( const char* displayName ) wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = fgDisplay.Instance; - wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); + wc.hIcon = LoadIcon( fgDisplay.Instance, "GLUT_ICON" ); + if (!wc.hIcon) + wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; @@ -309,6 +331,14 @@ void fgDeinitialize( void ) fgState.MenuStateCallback = (FGCBmenuState)NULL ; fgState.MenuStatusCallback = (FGCBmenuStatus)NULL ; + /* + * FPS display + */ + fgState.SwapCount = 0; + fgState.SwapTime = 0; + fgState.FPSInterval = 0; + + #if TARGET_HOST_UNIX_X11 /* @@ -362,13 +392,23 @@ void FGAPIENTRY glutInit( int* pargc, char** argv ) #endif fgState.Time.Set = TRUE; + /* check if GLUT_FPS env var is set */ + { + const char *fps = getenv("GLUT_FPS"); + if (fps) { + sscanf(fps, "%d", &fgState.FPSInterval); + if (fgState.FPSInterval <= 0) + fgState.FPSInterval = 5000; /* 5000 milliseconds */ + } + } + /* * Grab the environment variable indicating the X display to use. * This is harmless under Win32, so let's let it stay here... */ #if TARGET_HOST_WIN32 - if ( !getenv( "DISPLAY" ) ) - displayName = strdup( "" ); + if ( !getenv ( "DISPLAY" ) ) + displayName = strdup ( "" ) ; else #endif displayName = strdup( getenv( "DISPLAY" ) ); @@ -613,7 +653,7 @@ void FGAPIENTRY glutInitWindowSize( int width, int height ) /* * Sets the default display mode for all new windows */ -void FGAPIENTRY glutInitDisplayMode( int displayMode ) +void FGAPIENTRY glutInitDisplayMode( unsigned int displayMode ) { /* * We will make use of this value when creating a new OpenGL context... @@ -821,7 +861,7 @@ void FGAPIENTRY glutInitDisplayString( char* displayMode ) * Grab the value string that must follow the comparison operator... */ if( comparison != FG_NONE && i < (gint) strlen( scanner->value.v_identifier ) ) - valueString = g_strdup( scanner->value.v_identifier + i ); + valueString = strdup( scanner->value.v_identifier + i ); /* * If there was a value string, convert it to integer... @@ -923,7 +963,7 @@ static int TokenLengths[] = 10, 12 }; -void FGAPIENTRY glutInitDisplayString( char* displayMode ) +void FGAPIENTRY glutInitDisplayString( const char* displayMode ) { int glut_state_flag = 0 ; /*