X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffreeglut_init.c;fp=src%2Ffreeglut_init.c;h=c96ca104c259e87e42587fc56e6abe9bd54fdeaa;hb=4826072e24eb7393cc2564d0da9d95f471cb14c9;hp=8b9d34d12e03127878489a4af71f773a17f2f743;hpb=6c3fc917f914a223cfa23f867ebfcb15ae3e24ae;p=freeglut diff --git a/src/freeglut_init.c b/src/freeglut_init.c index 8b9d34d..c96ca10 100644 --- a/src/freeglut_init.c +++ b/src/freeglut_init.c @@ -311,7 +311,7 @@ static void fghInitialize( const char* displayName ) /* What we need to do is to initialize the fgDisplay global structure here. */ fgDisplay.Instance = GetModuleHandle( NULL ); - + fgDisplay.DisplayName=strdup(displayName); atom = GetClassInfo( fgDisplay.Instance, _T("FREEGLUT"), &wc ); if( atom == 0 ) @@ -363,7 +363,23 @@ static void fghInitialize( const char* displayName ) ReleaseDC( desktop, context ); } - + /* If we have a DisplayName try to use it for metrics */ + if( fgDisplay.DisplayName ) + { + HDC context = CreateDC(fgDisplay.DisplayName,0,0,0); + if( context ) + { + fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES ); + fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES ); + fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE ); + fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE ); + DeleteDC(context); + } + else + fgWarning("fghInitialize: " + "CreateDC failed, Screen size info may be incorrect"); + + } /* Set the timer granularity to 1 ms */ timeBeginPeriod ( 1 ); @@ -489,6 +505,11 @@ void fgDeinitialize( void ) XCloseDisplay( fgDisplay.Display ); #elif TARGET_HOST_MS_WINDOWS + if( fgDisplay.DisplayName ) + { + free( fgDisplay.DisplayName ); + fgDisplay.DisplayName = NULL; + } /* Reset the timer granularity */ timeEndPeriod ( 1 );