X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffreeglut_init_mswin.c;h=d5c94e58a6e80d7c2265522e6245f770ec1fd5f8;hb=2dfbfbf7b7adf327e62b5f1e5c572c495cbb9063;hp=ff476fd849c849d9e70cf559d187bd1bad9ad7ac;hpb=d7c65149e8416abadd0437fabfdf527091bf1bfe;p=freeglut diff --git a/src/mswin/freeglut_init_mswin.c b/src/mswin/freeglut_init_mswin.c index ff476fd..d5c94e5 100644 --- a/src/mswin/freeglut_init_mswin.c +++ b/src/mswin/freeglut_init_mswin.c @@ -25,22 +25,28 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#define FREEGLUT_BUILDING_LIB #include -#include "freeglut_internal_mswin.h" +#include "../Common/freeglut_internal.h" + + + +extern LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, + WPARAM wParam, LPARAM lParam ); /* * A call to this function should initialize all the display stuff... */ -void fghInitialize( const char* displayName ) +void fgPlatformInitialize( const char* displayName ) { WNDCLASS wc; ATOM atom; /* What we need to do is to initialize the fgDisplay global structure here. */ - fgDisplay.Instance = GetModuleHandle( NULL ); - fgDisplay.DisplayName= displayName ? strdup(displayName) : 0 ; - atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc ); + fgDisplay.pDisplay.Instance = GetModuleHandle( NULL ); + fgDisplay.pDisplay.DisplayName= displayName ? strdup(displayName) : 0 ; + atom = GetClassInfo( fgDisplay.pDisplay.Instance, _T("FREEGLUT"), &wc ); if( atom == 0 ) { @@ -54,11 +60,11 @@ void fghInitialize( const char* displayName ) * XXX Old code had "| CS_DBCLCKS" commented out. Plans for the * XXX future? Dead-end idea? */ - wc.lpfnWndProc = fgWindowProc; + wc.lpfnWndProc = fgPlatformWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = fgDisplay.Instance; - wc.hIcon = LoadIcon( fgDisplay.Instance, _T("GLUT_ICON") ); + wc.hInstance = fgDisplay.pDisplay.Instance; + wc.hIcon = LoadIcon( fgDisplay.pDisplay.Instance, _T("GLUT_ICON") ); #if defined(_WIN32_WCE) wc.style = CS_HREDRAW | CS_VREDRAW; @@ -75,7 +81,7 @@ void fghInitialize( const char* displayName ) /* Register the window class */ atom = RegisterClass( &wc ); - FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fghInitialize" ); + FREEGLUT_INTERNAL_ERROR_EXIT ( atom, "Window Class Not Registered", "fgPlatformInitialize" ); } /* The screen dimensions can be obtained via GetSystemMetrics() calls */ @@ -92,9 +98,9 @@ void fghInitialize( const char* displayName ) ReleaseDC( desktop, context ); } /* If we have a DisplayName try to use it for metrics */ - if( fgDisplay.DisplayName ) + if( fgDisplay.pDisplay.DisplayName ) { - HDC context = CreateDC(fgDisplay.DisplayName,0,0,0); + HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0); if( context ) { fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES ); @@ -104,7 +110,7 @@ void fghInitialize( const char* displayName ) DeleteDC(context); } else - fgWarning("fghInitialize: " + fgWarning("fgPlatformInitialize: " "CreateDC failed, Screen size info may be incorrect\n" "This is quite likely caused by a bad '-display' parameter"); @@ -131,7 +137,7 @@ void fghInitialize( const char* displayName ) /* Platform-Specific Deinitialization Functions: */ extern void fghCloseInputDevices ( void ); -void fghDeinitialiseInputDevices ( void ) +void fgPlatformDeinitialiseInputDevices ( void ) { #if !defined(_WIN32_WCE) fghCloseInputDevices (); @@ -140,12 +146,12 @@ void fghDeinitialiseInputDevices ( void ) fgState.InputDevsInitialised = GL_FALSE; } -void fghCloseDisplay ( void ) +void fgPlatformCloseDisplay ( void ) { - if( fgDisplay.DisplayName ) + if( fgDisplay.pDisplay.DisplayName ) { - free( fgDisplay.DisplayName ); - fgDisplay.DisplayName = NULL; + free( fgDisplay.pDisplay.DisplayName ); + fgDisplay.pDisplay.DisplayName = NULL; } /* Reset the timer granularity */ @@ -324,3 +330,13 @@ int XParseGeometry ( +/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */ + +void (__cdecl *__glutExitFunc)( int return_value ) = NULL; + +void FGAPIENTRY __glutInitWithExit( int *pargc, char **argv, void (__cdecl *exit_function)(int) ) +{ + __glutExitFunc = exit_function; + glutInit(pargc, argv); +} +