mirror of
				https://github.com/glfw/glfw.git
				synced 2025-10-30 20:22:30 +00:00 
			
		
		
		
	Formatting pass.
This commit is contained in:
		
							parent
							
								
									484a2714fc
								
							
						
					
					
						commit
						479c9255fc
					
				| @ -31,16 +31,12 @@ | |||||||
| #include "internal.h" | #include "internal.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 |  | ||||||
| //****                  GLFW internal functions                       ****
 |  | ||||||
| //************************************************************************
 |  | ||||||
| 
 |  | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Low level keyboard hook (system callback) function
 | // Low level keyboard hook (system callback) function
 | ||||||
| // Used to disable system keys under Windows NT
 | // Used to disable system keys under Windows NT
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam ) | static LRESULT CALLBACK keyboardHook(int nCode, WPARAM wParam, LPARAM lParam) | ||||||
| { | { | ||||||
|     BOOL syskeys = FALSE; |     BOOL syskeys = FALSE; | ||||||
|     PKBDLLHOOKSTRUCT p; |     PKBDLLHOOKSTRUCT p; | ||||||
| @ -49,11 +45,11 @@ static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam ) | |||||||
|     // pointer to a KBDLLHOOKSTRUCT
 |     // pointer to a KBDLLHOOKSTRUCT
 | ||||||
|     p = (PKBDLLHOOKSTRUCT) lParam; |     p = (PKBDLLHOOKSTRUCT) lParam; | ||||||
| 
 | 
 | ||||||
|     if( nCode == HC_ACTION ) |     if (nCode == HC_ACTION) | ||||||
|     { |     { | ||||||
|         // We have a keyboard event
 |         // We have a keyboard event
 | ||||||
| 
 | 
 | ||||||
|         switch( wParam ) |         switch (wParam) | ||||||
|         { |         { | ||||||
|             case WM_KEYDOWN: |             case WM_KEYDOWN: | ||||||
|             case WM_SYSKEYDOWN: |             case WM_SYSKEYDOWN: | ||||||
| @ -61,14 +57,14 @@ static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam ) | |||||||
|             case WM_SYSKEYUP: |             case WM_SYSKEYUP: | ||||||
|                 // Detect: ALT+TAB, ALT+ESC, ALT+F4, CTRL+ESC,
 |                 // Detect: ALT+TAB, ALT+ESC, ALT+F4, CTRL+ESC,
 | ||||||
|                 // LWIN, RWIN, APPS (mysterious menu key)
 |                 // LWIN, RWIN, APPS (mysterious menu key)
 | ||||||
|                 syskeys = ( p->vkCode == VK_TAB && |                 syskeys = (p->vkCode == VK_TAB && | ||||||
|                             p->flags & LLKHF_ALTDOWN ) || |                            p->flags & LLKHF_ALTDOWN) || | ||||||
|                           ( p->vkCode == VK_ESCAPE && |                           (p->vkCode == VK_ESCAPE && | ||||||
|                             p->flags & LLKHF_ALTDOWN ) || |                            p->flags & LLKHF_ALTDOWN) || | ||||||
|                           ( p->vkCode == VK_F4 && |                           (p->vkCode == VK_F4 && | ||||||
|                             p->flags & LLKHF_ALTDOWN ) || |                            p->flags & LLKHF_ALTDOWN) || | ||||||
|                           ( p->vkCode == VK_ESCAPE && |                           (p->vkCode == VK_ESCAPE && | ||||||
|                             (GetKeyState(VK_CONTROL) & 0x8000)) || |                            (GetKeyState(VK_CONTROL) & 0x8000)) || | ||||||
|                           p->vkCode == VK_LWIN || |                           p->vkCode == VK_LWIN || | ||||||
|                           p->vkCode == VK_RWIN || |                           p->vkCode == VK_RWIN || | ||||||
|                           p->vkCode == VK_APPS; |                           p->vkCode == VK_APPS; | ||||||
| @ -80,13 +76,11 @@ static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam ) | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Was it a system key combination (e.g. ALT+TAB)?
 |     // Was it a system key combination (e.g. ALT+TAB)?
 | ||||||
|     if( syskeys ) |     if (syskeys) | ||||||
|     { |     { | ||||||
|         // Pass the key event to our window message loop
 |         // Pass the key event to our window message loop
 | ||||||
|         if( _glfwWin.opened ) |         if (_glfwWin.opened) | ||||||
|         { |             PostMessage(_glfwWin.window, (UINT) wParam, p->vkCode, 0); | ||||||
|             PostMessage( _glfwWin.window, (UINT) wParam, p->vkCode, 0 ); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         // We've taken care of it - don't let the system know about this
 |         // We've taken care of it - don't let the system know about this
 | ||||||
|         // key event
 |         // key event
 | ||||||
| @ -95,61 +89,59 @@ static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam ) | |||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         // It's a harmless key press, let the system deal with it
 |         // It's a harmless key press, let the system deal with it
 | ||||||
|         return CallNextHookEx( _glfwWin.keyboardHook, nCode, wParam, lParam ); |         return CallNextHookEx(_glfwWin.keyboardHook, nCode, wParam, lParam); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //************************************************************************
 | //////                       GLFW platform API                      //////
 | ||||||
| //****               Platform implementation functions                ****
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //************************************************************************
 |  | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Enable system keys
 | // Enable system keys
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwPlatformEnableSystemKeys( void ) | void _glfwPlatformEnableSystemKeys(void) | ||||||
| { | { | ||||||
|     BOOL dummy; |     BOOL dummy; | ||||||
| 
 | 
 | ||||||
|     // Use different methods depending on operating system version
 |     // Use different methods depending on operating system version
 | ||||||
|     if( _glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4 ) |     if (_glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4) | ||||||
|     { |     { | ||||||
|         if( _glfwWin.keyboardHook != NULL ) |         if (_glfwWin.keyboardHook != NULL) | ||||||
|         { |         { | ||||||
|             UnhookWindowsHookEx( _glfwWin.keyboardHook ); |             UnhookWindowsHookEx(_glfwWin.keyboardHook); | ||||||
|             _glfwWin.keyboardHook = NULL; |             _glfwWin.keyboardHook = NULL; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |         SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0); | ||||||
|         (void) SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0 ); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Disable system keys
 | // Disable system keys
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwPlatformDisableSystemKeys( void ) | void _glfwPlatformDisableSystemKeys(void) | ||||||
| { | { | ||||||
|     BOOL dummy; |     BOOL dummy; | ||||||
| 
 | 
 | ||||||
|     // Use different methods depending on operating system version
 |     // Use different methods depending on operating system version
 | ||||||
|     if( _glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4 ) |     if (_glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4) | ||||||
|     { |     { | ||||||
|         // Under Windows NT, install a low level keyboard hook
 |         // Under Windows NT, install a low level keyboard hook
 | ||||||
|         _glfwWin.keyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, |         _glfwWin.keyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, | ||||||
|                                                   keyboardHook, |                                                  keyboardHook, | ||||||
|                                                   _glfwLibrary.instance, |                                                  _glfwLibrary.instance, | ||||||
|                                                   0 ); |                                                  0); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         // Under Windows 95/98/ME, fool Windows that a screensaver
 |         // Under Windows 95/98/ME, fool Windows that a screensaver
 | ||||||
|         // is running => prevents ALT+TAB, CTRL+ESC and CTRL+ALT+DEL
 |         // is running => prevents ALT+TAB, CTRL+ESC and CTRL+ALT+DEL
 | ||||||
|         (void) SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0 ); |         SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -31,77 +31,102 @@ | |||||||
| #include "internal.h" | #include "internal.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 |  | ||||||
| //****                  GLFW internal functions                       ****
 |  | ||||||
| //************************************************************************
 |  | ||||||
| 
 |  | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Convert BPP to RGB bits based on "best guess"
 | // Convert BPP to RGB bits based on "best guess"
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| static void bpp2rgb( int bpp, int *r, int *g, int *b ) | static void bpp2rgb(int bpp, int* r, int* g, int* b) | ||||||
| { | { | ||||||
|     int delta; |     int delta; | ||||||
| 
 | 
 | ||||||
|     // We assume that by 32 they really meant 24
 |     // We assume that by 32 they really meant 24
 | ||||||
|     if( bpp == 32 ) |     if (bpp == 32) | ||||||
|     { |  | ||||||
|         bpp = 24; |         bpp = 24; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Convert "bits per pixel" to red, green & blue sizes
 |     // Convert "bits per pixel" to red, green & blue sizes
 | ||||||
| 
 | 
 | ||||||
|     *r = *g = *b = bpp / 3; |     *r = *g = *b = bpp / 3; | ||||||
|     delta = bpp - (*r * 3); |     delta = bpp - (*r * 3); | ||||||
|     if( delta >= 1 ) |     if (delta >= 1) | ||||||
|     { |  | ||||||
|         *g = *g + 1; |         *g = *g + 1; | ||||||
|     } | 
 | ||||||
|     if( delta == 2 ) |     if (delta == 2) | ||||||
|     { |  | ||||||
|         *r = *r + 1; |         *r = *r + 1; | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | //========================================================================
 | ||||||
|  | // Return closest video mode by dimensions, refresh rate and channel sizes
 | ||||||
|  | //========================================================================
 | ||||||
|  | 
 | ||||||
|  | static int getClosestVideoMode(int* w, int* h, | ||||||
|  |                                int* r, int* g, int* b, | ||||||
|  |                                int* refresh) | ||||||
|  | { | ||||||
|  |     int bpp, bestmode; | ||||||
|  | 
 | ||||||
|  |     // Colorbits = sum of red/green/blue bits
 | ||||||
|  |     bpp = *r + *g + *b; | ||||||
|  | 
 | ||||||
|  |     // If colorbits < 15 (e.g. 0) or >= 24, default to 32 bpp
 | ||||||
|  |     if (bpp < 15 || bpp >= 24) | ||||||
|  |         bpp = 32; | ||||||
|  | 
 | ||||||
|  |     // Find best match
 | ||||||
|  |     bestmode = _glfwGetClosestVideoModeBPP(w, h, &bpp, refresh); | ||||||
|  | 
 | ||||||
|  |     // Convert "bits per pixel" to red, green & blue sizes
 | ||||||
|  |     bpp2rgb(bpp, r, g, b); | ||||||
|  | 
 | ||||||
|  |     return bestmode; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //////////////////////////////////////////////////////////////////////////
 | ||||||
|  | //////                       GLFW internal API                      //////
 | ||||||
|  | //////////////////////////////////////////////////////////////////////////
 | ||||||
|  | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Return closest video mode by dimensions, refresh rate and bits per pixel
 | // Return closest video mode by dimensions, refresh rate and bits per pixel
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh ) | int _glfwGetClosestVideoModeBPP(int* w, int* h, int* bpp, int* refresh) | ||||||
| { | { | ||||||
|     int     mode, bestmode, match, bestmatch, rr, bestrr, success; |     int mode, bestmode, match, bestmatch, rr, bestrr, success; | ||||||
|     DEVMODE dm; |     DEVMODE dm; | ||||||
| 
 | 
 | ||||||
|     // Find best match
 |     // Find best match
 | ||||||
|     bestmatch = 0x7fffffff; |     bestmatch = 0x7fffffff; | ||||||
|     bestrr    = 0x7fffffff; |     bestrr    = 0x7fffffff; | ||||||
|     mode = bestmode = 0; |     mode = bestmode = 0; | ||||||
|  | 
 | ||||||
|     do |     do | ||||||
|     { |     { | ||||||
|         dm.dmSize = sizeof( DEVMODE ); |         dm.dmSize = sizeof(DEVMODE); | ||||||
|         success = EnumDisplaySettings( NULL, mode, &dm ); |         success = EnumDisplaySettings(NULL, mode, &dm); | ||||||
|         if( success ) |         if (success) | ||||||
|         { |         { | ||||||
|             match = dm.dmBitsPerPel - *bpp; |             match = dm.dmBitsPerPel - *bpp; | ||||||
|             if( match < 0 ) match = -match; |             if (match < 0) | ||||||
|             match = ( match << 25 ) | |                 match = -match; | ||||||
|                     ( (dm.dmPelsWidth - *w) * | 
 | ||||||
|                       (dm.dmPelsWidth - *w) + |             match = (match << 25) | | ||||||
|                       (dm.dmPelsHeight - *h) * |                     ((dm.dmPelsWidth - *w) * | ||||||
|                       (dm.dmPelsHeight - *h) ); |                      (dm.dmPelsWidth - *w) + | ||||||
|             if( match < bestmatch ) |                      (dm.dmPelsHeight - *h) * | ||||||
|  |                      (dm.dmPelsHeight - *h)); | ||||||
|  |             if (match < bestmatch) | ||||||
|             { |             { | ||||||
|                 bestmatch = match; |                 bestmatch = match; | ||||||
|                 bestmode  = mode; |                 bestmode  = mode; | ||||||
|                 bestrr = (dm.dmDisplayFrequency - *refresh) * |                 bestrr = (dm.dmDisplayFrequency - *refresh) * | ||||||
|                          (dm.dmDisplayFrequency - *refresh); |                          (dm.dmDisplayFrequency - *refresh); | ||||||
|             } |             } | ||||||
|             else if( match == bestmatch && *refresh > 0 ) |             else if (match == bestmatch && *refresh > 0) | ||||||
|             { |             { | ||||||
|                 rr = (dm.dmDisplayFrequency - *refresh) * |                 rr = (dm.dmDisplayFrequency - *refresh) * | ||||||
|                      (dm.dmDisplayFrequency - *refresh); |                      (dm.dmDisplayFrequency - *refresh); | ||||||
|                 if( rr < bestrr ) |                 if (rr < bestrr) | ||||||
|                 { |                 { | ||||||
|                     bestmatch = match; |                     bestmatch = match; | ||||||
|                     bestmode  = mode; |                     bestmode  = mode; | ||||||
| @ -109,13 +134,13 @@ int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh ) | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         mode ++; |         mode++; | ||||||
|     } |     } | ||||||
|     while( success ); |     while (success); | ||||||
| 
 | 
 | ||||||
|     // Get the parameters for the best matching display mode
 |     // Get the parameters for the best matching display mode
 | ||||||
|     dm.dmSize = sizeof( DEVMODE ); |     dm.dmSize = sizeof(DEVMODE); | ||||||
|     (void) EnumDisplaySettings( NULL, bestmode, &dm ); |     EnumDisplaySettings(NULL, bestmode, &dm); | ||||||
| 
 | 
 | ||||||
|     // Fill out actual width and height
 |     // Fill out actual width and height
 | ||||||
|     *w = dm.dmPelsWidth; |     *w = dm.dmPelsWidth; | ||||||
| @ -131,72 +156,41 @@ int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh ) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //========================================================================
 |  | ||||||
| // Return closest video mode by dimensions, refresh rate and channel sizes
 |  | ||||||
| //========================================================================
 |  | ||||||
| 
 |  | ||||||
| static int getClosestVideoMode( int *w, int *h, |  | ||||||
|                                 int *r, int *g, int *b, |  | ||||||
|                                 int *refresh ) |  | ||||||
| { |  | ||||||
|     int bpp, bestmode; |  | ||||||
| 
 |  | ||||||
|     // Colorbits = sum of red/green/blue bits
 |  | ||||||
|     bpp = *r + *g + *b; |  | ||||||
| 
 |  | ||||||
|     // If colorbits < 15 (e.g. 0) or >= 24, default to 32 bpp
 |  | ||||||
|     if( bpp < 15 || bpp >= 24 ) |  | ||||||
|     { |  | ||||||
|         bpp = 32; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     // Find best match
 |  | ||||||
|     bestmode = _glfwGetClosestVideoModeBPP( w, h, &bpp, refresh ); |  | ||||||
| 
 |  | ||||||
|     // Convert "bits per pixel" to red, green & blue sizes
 |  | ||||||
|     bpp2rgb( bpp, r, g, b ); |  | ||||||
| 
 |  | ||||||
|     return bestmode; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Change the current video mode
 | // Change the current video mode
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwSetVideoModeMODE( int mode ) | void _glfwSetVideoModeMODE(int mode) | ||||||
| { | { | ||||||
|     DEVMODE dm; |     DEVMODE dm; | ||||||
|     int success; |     int success; | ||||||
| 
 | 
 | ||||||
|     // Get the parameters for the best matching display mode
 |     // Get the parameters for the best matching display mode
 | ||||||
|     dm.dmSize = sizeof( DEVMODE ); |     dm.dmSize = sizeof(DEVMODE); | ||||||
|     (void) EnumDisplaySettings( NULL, mode, &dm ); |     EnumDisplaySettings(NULL, mode, &dm); | ||||||
| 
 | 
 | ||||||
|     // Set which fields we want to specify
 |     // Set which fields we want to specify
 | ||||||
|     dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; |     dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; | ||||||
| 
 | 
 | ||||||
|     // Do we have a prefered refresh rate?
 |     // Do we have a prefered refresh rate?
 | ||||||
|     if( _glfwWin.desiredRefreshRate > 0 ) |     if (_glfwWin.desiredRefreshRate > 0) | ||||||
|     { |     { | ||||||
|         dm.dmFields = dm.dmFields | DM_DISPLAYFREQUENCY; |         dm.dmFields = dm.dmFields | DM_DISPLAYFREQUENCY; | ||||||
|         dm.dmDisplayFrequency = _glfwWin.desiredRefreshRate; |         dm.dmDisplayFrequency = _glfwWin.desiredRefreshRate; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Change display setting
 |     // Change display setting
 | ||||||
|     dm.dmSize = sizeof( DEVMODE ); |     dm.dmSize = sizeof(DEVMODE); | ||||||
|     success = ChangeDisplaySettings( &dm, CDS_FULLSCREEN ); |     success = ChangeDisplaySettings(&dm, CDS_FULLSCREEN); | ||||||
| 
 | 
 | ||||||
|     // If the mode change was not possible, query the current display
 |     // If the mode change was not possible, query the current display
 | ||||||
|     // settings (we'll use the desktop resolution for fullscreen mode)
 |     // settings (we'll use the desktop resolution for fullscreen mode)
 | ||||||
|     if( success == DISP_CHANGE_SUCCESSFUL ) |     if (success == DISP_CHANGE_SUCCESSFUL) | ||||||
|     { |  | ||||||
|         _glfwWin.modeID = mode; |         _glfwWin.modeID = mode; | ||||||
|     } |  | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         _glfwWin.modeID = ENUM_REGISTRY_SETTINGS; |         _glfwWin.modeID = ENUM_REGISTRY_SETTINGS; | ||||||
|         EnumDisplaySettings( NULL, ENUM_REGISTRY_SETTINGS, &dm ); |         EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &dm); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Set the window size to that of the display mode
 |     // Set the window size to that of the display mode
 | ||||||
| @ -209,27 +203,27 @@ void _glfwSetVideoModeMODE( int mode ) | |||||||
| // Change the current video mode
 | // Change the current video mode
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwSetVideoMode( int *w, int *h, int r, int g, int b, int refresh ) | void _glfwSetVideoMode(int* w, int* h, int r, int g, int b, int refresh) | ||||||
| { | { | ||||||
|     int     bestmode; |     int bestmode; | ||||||
| 
 | 
 | ||||||
|     // Find a best match mode
 |     // Find a best match mode
 | ||||||
|     bestmode = getClosestVideoMode( w, h, &r, &g, &b, &refresh ); |     bestmode = getClosestVideoMode(w, h, &r, &g, &b, &refresh); | ||||||
| 
 | 
 | ||||||
|     // Change mode
 |     // Change mode
 | ||||||
|     _glfwSetVideoModeMODE( bestmode ); |     _glfwSetVideoModeMODE(bestmode); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //****                    GLFW user functions                         ****
 | //////                       GLFW platform API                      //////
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Get a list of available video modes
 | // Get a list of available video modes
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) | int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount) | ||||||
| { | { | ||||||
|     int count, success, mode, i, j; |     int count, success, mode, i, j; | ||||||
|     int m1, m2, bpp, r, g, b; |     int m1, m2, bpp, r, g, b; | ||||||
| @ -238,37 +232,35 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) | |||||||
|     // Loop through all video modes and extract all the UNIQUE modes
 |     // Loop through all video modes and extract all the UNIQUE modes
 | ||||||
|     count = 0; |     count = 0; | ||||||
|     mode  = 0; |     mode  = 0; | ||||||
|  | 
 | ||||||
|     do |     do | ||||||
|     { |     { | ||||||
|         // Get video mode properties
 |         // Get video mode properties
 | ||||||
|         dm.dmSize = sizeof( DEVMODE ); |         dm.dmSize = sizeof(DEVMODE); | ||||||
|         success = EnumDisplaySettings( NULL, mode, &dm ); |         success = EnumDisplaySettings(NULL, mode, &dm); | ||||||
| 
 | 
 | ||||||
|         // Is it a valid mode? (only list depths >= 15 bpp)
 |         // Is it a valid mode? (only list depths >= 15 bpp)
 | ||||||
|         if( success && dm.dmBitsPerPel >= 15 ) |         if (success && dm.dmBitsPerPel >= 15) | ||||||
|         { |         { | ||||||
|             // Convert to RGB, and back to bpp ("mask out" alpha bits etc)
 |             // Convert to RGB, and back to bpp ("mask out" alpha bits etc)
 | ||||||
|             bpp2rgb( dm.dmBitsPerPel, &r, &g, &b ); |             bpp2rgb(dm.dmBitsPerPel, &r, &g, &b); | ||||||
|             bpp = r + g + b; |             bpp = r + g + b; | ||||||
| 
 | 
 | ||||||
|             // Mode "code" for this mode
 |             // Mode "code" for this mode
 | ||||||
|             m1 = (bpp << 25) | (dm.dmPelsWidth * dm.dmPelsHeight); |             m1 = (bpp << 25) | (dm.dmPelsWidth * dm.dmPelsHeight); | ||||||
| 
 | 
 | ||||||
|             // Insert mode in list (sorted), and avoid duplicates
 |             // Insert mode in list (sorted), and avoid duplicates
 | ||||||
|             for( i = 0; i < count; i ++ ) |             for (i = 0;  i < count;  i++) | ||||||
|             { |             { | ||||||
|                 // Mode "code" for already listed mode
 |                 // Mode "code" for already listed mode
 | ||||||
|                 bpp = list[i].redBits + list[i].greenBits + |                 bpp = list[i].redBits + list[i].greenBits + list[i].blueBits; | ||||||
|                       list[i].blueBits; |  | ||||||
|                 m2 = (bpp << 25) | (list[i].width * list[i].height); |                 m2 = (bpp << 25) | (list[i].width * list[i].height); | ||||||
|                 if( m1 <= m2 ) |                 if (m1 <= m2) | ||||||
|                 { |  | ||||||
|                     break; |                     break; | ||||||
|                 } |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             // New entry at the end of the list?
 |             // New entry at the end of the list?
 | ||||||
|             if( i >= count ) |             if (i >= count) | ||||||
|             { |             { | ||||||
|                 list[count].width     = dm.dmPelsWidth; |                 list[count].width     = dm.dmPelsWidth; | ||||||
|                 list[count].height    = dm.dmPelsHeight; |                 list[count].height    = dm.dmPelsHeight; | ||||||
| @ -278,23 +270,22 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) | |||||||
|                 count ++; |                 count ++; | ||||||
|             } |             } | ||||||
|             // Insert new entry in the list?
 |             // Insert new entry in the list?
 | ||||||
|             else if( m1 < m2 ) |             else if (m1 < m2) | ||||||
|             { |             { | ||||||
|                 for( j = count; j > i; j -- ) |                 for (j = count;  j > i;  j--) | ||||||
|                 { |                     list[j] = list[j - 1]; | ||||||
|                     list[j] = list[j-1]; | 
 | ||||||
|                 } |  | ||||||
|                 list[i].width     = dm.dmPelsWidth; |                 list[i].width     = dm.dmPelsWidth; | ||||||
|                 list[i].height    = dm.dmPelsHeight; |                 list[i].height    = dm.dmPelsHeight; | ||||||
|                 list[i].redBits   = r; |                 list[i].redBits   = r; | ||||||
|                 list[i].greenBits = g; |                 list[i].greenBits = g; | ||||||
|                 list[i].blueBits  = b; |                 list[i].blueBits  = b; | ||||||
|                 count ++; |                 count++; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         mode ++; |         mode++; | ||||||
|     } |     } | ||||||
|     while( success && (count < maxcount) ); |     while (success && (count < maxcount)); | ||||||
| 
 | 
 | ||||||
|     return count; |     return count; | ||||||
| } | } | ||||||
| @ -304,17 +295,17 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) | |||||||
| // Get the desktop video mode
 | // Get the desktop video mode
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwPlatformGetDesktopMode( GLFWvidmode *mode ) | void _glfwPlatformGetDesktopMode(GLFWvidmode* mode) | ||||||
| { | { | ||||||
|     DEVMODE dm; |     DEVMODE dm; | ||||||
| 
 | 
 | ||||||
|     // Get desktop display mode
 |     // Get desktop display mode
 | ||||||
|     dm.dmSize = sizeof( DEVMODE ); |     dm.dmSize = sizeof(DEVMODE); | ||||||
|     (void) EnumDisplaySettings( NULL, ENUM_REGISTRY_SETTINGS, &dm ); |     EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &dm); | ||||||
| 
 | 
 | ||||||
|     // Return desktop mode parameters
 |     // Return desktop mode parameters
 | ||||||
|     mode->width  = dm.dmPelsWidth; |     mode->width  = dm.dmPelsWidth; | ||||||
|     mode->height = dm.dmPelsHeight; |     mode->height = dm.dmPelsHeight; | ||||||
|     bpp2rgb( dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits ); |     bpp2rgb(dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -31,39 +31,35 @@ | |||||||
| #include "internal.h" | #include "internal.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //****               Platform implementation functions                ****
 | //////                       GLFW platform API                      //////
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Check if the current context supports the specified WGL extension
 | // Check if the current context supports the specified WGL extension
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformExtensionSupported( const char *extension ) | int _glfwPlatformExtensionSupported(const char* extension) | ||||||
| { | { | ||||||
|     const GLubyte *extensions; |     const GLubyte* extensions; | ||||||
| 
 | 
 | ||||||
|     if( _glfwWin.GetExtensionsStringEXT != NULL ) |     if (_glfwWin.GetExtensionsStringEXT != NULL) | ||||||
|     { |     { | ||||||
|         extensions = (GLubyte *) _glfwWin.GetExtensionsStringEXT(); |         extensions = (GLubyte*) _glfwWin.GetExtensionsStringEXT(); | ||||||
|         if( extensions != NULL ) |         if (extensions != NULL) | ||||||
|         { |         { | ||||||
|             if( _glfwStringInExtensionString( extension, extensions ) ) |             if (_glfwStringInExtensionString(extension, extensions)) | ||||||
|             { |  | ||||||
|                 return GL_TRUE; |                 return GL_TRUE; | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if( _glfwWin.GetExtensionsStringARB != NULL ) |     if (_glfwWin.GetExtensionsStringARB != NULL) | ||||||
|     { |     { | ||||||
|         extensions = (GLubyte *) _glfwWin.GetExtensionsStringARB( _glfwWin.DC ); |         extensions = (GLubyte*) _glfwWin.GetExtensionsStringARB(_glfwWin.DC); | ||||||
|         if( extensions != NULL ) |         if (extensions != NULL) | ||||||
|         { |         { | ||||||
|             if( _glfwStringInExtensionString( extension, extensions ) ) |             if (_glfwStringInExtensionString(extension, extensions)) | ||||||
|             { |  | ||||||
|                 return GL_TRUE; |                 return GL_TRUE; | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -75,8 +71,8 @@ int _glfwPlatformExtensionSupported( const char *extension ) | |||||||
| // Get the function pointer to an OpenGL function
 | // Get the function pointer to an OpenGL function
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void *_glfwPlatformGetProcAddress( const char *procname ) | void* _glfwPlatformGetProcAddress(const char* procname) | ||||||
| { | { | ||||||
|     return (void *) wglGetProcAddress( procname ); |     return (void*) wglGetProcAddress(procname); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -36,76 +36,69 @@ | |||||||
| #endif // __BORLANDC__
 | #endif // __BORLANDC__
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| //************************************************************************
 |  | ||||||
| //****                  GLFW internal functions                       ****
 |  | ||||||
| //************************************************************************
 |  | ||||||
| 
 |  | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Load necessary libraries (DLLs)
 | // Load necessary libraries (DLLs)
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| static int _glfwInitLibraries( void ) | static GLboolean initLibraries(void) | ||||||
| { | { | ||||||
|     // gdi32.dll (OpenGL pixel format functions & SwapBuffers)
 |     // gdi32.dll (OpenGL pixel format functions & SwapBuffers)
 | ||||||
| #ifndef _GLFW_NO_DLOAD_GDI32 | #ifndef _GLFW_NO_DLOAD_GDI32 | ||||||
|     _glfwLibrary.Libs.gdi32 = LoadLibrary( "gdi32.dll" ); |     _glfwLibrary.Libs.gdi32 = LoadLibrary("gdi32.dll"); | ||||||
|     if( _glfwLibrary.Libs.gdi32 != NULL ) |     if (_glfwLibrary.Libs.gdi32 != NULL) | ||||||
|     { |     { | ||||||
|         _glfwLibrary.Libs.ChoosePixelFormat   = (CHOOSEPIXELFORMAT_T) |         _glfwLibrary.Libs.ChoosePixelFormat = (CHOOSEPIXELFORMAT_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.gdi32, "ChoosePixelFormat" ); |             GetProcAddress(_glfwLibrary.Libs.gdi32, "ChoosePixelFormat"); | ||||||
|         _glfwLibrary.Libs.DescribePixelFormat = (DESCRIBEPIXELFORMAT_T) |         _glfwLibrary.Libs.DescribePixelFormat = (DESCRIBEPIXELFORMAT_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.gdi32, "DescribePixelFormat" ); |             GetProcAddress(_glfwLibrary.Libs.gdi32, "DescribePixelFormat"); | ||||||
|         _glfwLibrary.Libs.GetPixelFormat      = (GETPIXELFORMAT_T) |         _glfwLibrary.Libs.GetPixelFormat = (GETPIXELFORMAT_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.gdi32, "GetPixelFormat" ); |             GetProcAddress(_glfwLibrary.Libs.gdi32, "GetPixelFormat"); | ||||||
|         _glfwLibrary.Libs.SetPixelFormat      = (SETPIXELFORMAT_T) |         _glfwLibrary.Libs.SetPixelFormat = (SETPIXELFORMAT_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.gdi32, "SetPixelFormat" ); |             GetProcAddress(_glfwLibrary.Libs.gdi32, "SetPixelFormat"); | ||||||
|         _glfwLibrary.Libs.SwapBuffers         = (SWAPBUFFERS_T) |         _glfwLibrary.Libs.SwapBuffers = (SWAPBUFFERS_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.gdi32, "SwapBuffers" ); |             GetProcAddress(_glfwLibrary.Libs.gdi32, "SwapBuffers"); | ||||||
|         if( _glfwLibrary.Libs.ChoosePixelFormat   == NULL || | 
 | ||||||
|             _glfwLibrary.Libs.DescribePixelFormat == NULL || |         if (_glfwLibrary.Libs.ChoosePixelFormat && | ||||||
|             _glfwLibrary.Libs.GetPixelFormat      == NULL || |             _glfwLibrary.Libs.DescribePixelFormat && | ||||||
|             _glfwLibrary.Libs.SetPixelFormat      == NULL || |             _glfwLibrary.Libs.GetPixelFormat && | ||||||
|             _glfwLibrary.Libs.SwapBuffers         == NULL ) |             _glfwLibrary.Libs.SetPixelFormat && | ||||||
|  |             _glfwLibrary.Libs.SwapBuffers) | ||||||
|         { |         { | ||||||
|             FreeLibrary( _glfwLibrary.Libs.gdi32 ); |             FreeLibrary(_glfwLibrary.Libs.gdi32); | ||||||
|             _glfwLibrary.Libs.gdi32 = NULL; |             _glfwLibrary.Libs.gdi32 = NULL; | ||||||
|             return GL_FALSE; |             return GL_FALSE; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |  | ||||||
|         return GL_FALSE; |         return GL_FALSE; | ||||||
|     } |  | ||||||
| #endif // _GLFW_NO_DLOAD_GDI32
 | #endif // _GLFW_NO_DLOAD_GDI32
 | ||||||
| 
 | 
 | ||||||
|     // winmm.dll (for joystick and timer support)
 |     // winmm.dll (for joystick and timer support)
 | ||||||
| #ifndef _GLFW_NO_DLOAD_WINMM | #ifndef _GLFW_NO_DLOAD_WINMM | ||||||
|     _glfwLibrary.Libs.winmm = LoadLibrary( "winmm.dll" ); |     _glfwLibrary.Libs.winmm = LoadLibrary("winmm.dll"); | ||||||
|     if( _glfwLibrary.Libs.winmm != NULL ) |     if (_glfwLibrary.Libs.winmm != NULL) | ||||||
|     { |     { | ||||||
|         _glfwLibrary.Libs.joyGetDevCapsA = (JOYGETDEVCAPSA_T) |         _glfwLibrary.Libs.joyGetDevCapsA = (JOYGETDEVCAPSA_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.winmm, "joyGetDevCapsA" ); |             GetProcAddress(_glfwLibrary.Libs.winmm, "joyGetDevCapsA"); | ||||||
|         _glfwLibrary.Libs.joyGetPos      = (JOYGETPOS_T) |         _glfwLibrary.Libs.joyGetPos = (JOYGETPOS_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.winmm, "joyGetPos" ); |             GetProcAddress(_glfwLibrary.Libs.winmm, "joyGetPos"); | ||||||
|         _glfwLibrary.Libs.joyGetPosEx    = (JOYGETPOSEX_T) |         _glfwLibrary.Libs.joyGetPosEx = (JOYGETPOSEX_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.winmm, "joyGetPosEx" ); |             GetProcAddress(_glfwLibrary.Libs.winmm, "joyGetPosEx"); | ||||||
|         _glfwLibrary.Libs.timeGetTime    = (TIMEGETTIME_T) |         _glfwLibrary.Libs.timeGetTime = (TIMEGETTIME_T) | ||||||
|             GetProcAddress( _glfwLibrary.Libs.winmm, "timeGetTime" ); |             GetProcAddress(_glfwLibrary.Libs.winmm, "timeGetTime"); | ||||||
|         if( _glfwLibrary.Libs.joyGetDevCapsA == NULL || | 
 | ||||||
|             _glfwLibrary.Libs.joyGetPos      == NULL || |         if (_glfwLibrary.Libs.joyGetDevCapsA && | ||||||
|             _glfwLibrary.Libs.joyGetPosEx    == NULL || |             _glfwLibrary.Libs.joyGetPos && | ||||||
|             _glfwLibrary.Libs.timeGetTime    == NULL ) |             _glfwLibrary.Libs.joyGetPosEx && | ||||||
|  |             _glfwLibrary.Libs.timeGetTime) | ||||||
|         { |         { | ||||||
|             FreeLibrary( _glfwLibrary.Libs.winmm ); |             FreeLibrary(_glfwLibrary.Libs.winmm); | ||||||
|             _glfwLibrary.Libs.winmm = NULL; |             _glfwLibrary.Libs.winmm = NULL; | ||||||
|             return GL_FALSE; |             return GL_FALSE; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |  | ||||||
|         return GL_FALSE; |         return GL_FALSE; | ||||||
|     } |  | ||||||
| #endif // _GLFW_NO_DLOAD_WINMM
 | #endif // _GLFW_NO_DLOAD_WINMM
 | ||||||
| 
 | 
 | ||||||
|     return GL_TRUE; |     return GL_TRUE; | ||||||
| @ -116,22 +109,22 @@ static int _glfwInitLibraries( void ) | |||||||
| // Unload used libraries (DLLs)
 | // Unload used libraries (DLLs)
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| static void _glfwFreeLibraries( void ) | static void freeLibraries(void) | ||||||
| { | { | ||||||
|     // gdi32.dll
 |     // gdi32.dll
 | ||||||
| #ifndef _GLFW_NO_DLOAD_GDI32 | #ifndef _GLFW_NO_DLOAD_GDI32 | ||||||
|     if( _glfwLibrary.Libs.gdi32 != NULL ) |     if (_glfwLibrary.Libs.gdi32 != NULL) | ||||||
|     { |     { | ||||||
|         FreeLibrary( _glfwLibrary.Libs.gdi32 ); |         FreeLibrary(_glfwLibrary.Libs.gdi32); | ||||||
|         _glfwLibrary.Libs.gdi32 = NULL; |         _glfwLibrary.Libs.gdi32 = NULL; | ||||||
|     } |     } | ||||||
| #endif // _GLFW_NO_DLOAD_GDI32
 | #endif // _GLFW_NO_DLOAD_GDI32
 | ||||||
| 
 | 
 | ||||||
|     // winmm.dll
 |     // winmm.dll
 | ||||||
| #ifndef _GLFW_NO_DLOAD_WINMM | #ifndef _GLFW_NO_DLOAD_WINMM | ||||||
|     if( _glfwLibrary.Libs.winmm != NULL ) |     if (_glfwLibrary.Libs.winmm != NULL) | ||||||
|     { |     { | ||||||
|         FreeLibrary( _glfwLibrary.Libs.winmm ); |         FreeLibrary(_glfwLibrary.Libs.winmm); | ||||||
|         _glfwLibrary.Libs.winmm = NULL; |         _glfwLibrary.Libs.winmm = NULL; | ||||||
|     } |     } | ||||||
| #endif // _GLFW_NO_DLOAD_WINMM
 | #endif // _GLFW_NO_DLOAD_WINMM
 | ||||||
| @ -142,82 +135,65 @@ static void _glfwFreeLibraries( void ) | |||||||
| // Terminate GLFW when exiting application
 | // Terminate GLFW when exiting application
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwTerminate_atexit( void ) | static void glfw_atexit(void) | ||||||
| { | { | ||||||
|     glfwTerminate(); |     glfwTerminate(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //************************************************************************
 | //////                       GLFW platform API                      //////
 | ||||||
| //****               Platform implementation functions                ****
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //************************************************************************
 |  | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Initialize various GLFW state
 | // Initialize various GLFW state
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformInit( void ) | int _glfwPlatformInit(void) | ||||||
| { | { | ||||||
|     OSVERSIONINFO osi; |     OSVERSIONINFO osi; | ||||||
| 
 | 
 | ||||||
|     // To make SetForegroundWindow() work as we want, we need to fiddle
 |     // To make SetForegroundWindow() work as we want, we need to fiddle
 | ||||||
|     // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
 |     // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
 | ||||||
|     // as possible in the hope of still being the foreground process)
 |     // as possible in the hope of still being the foreground process)
 | ||||||
|     SystemParametersInfo( SPI_GETFOREGROUNDLOCKTIMEOUT, 0, |     SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, | ||||||
|                           &_glfwLibrary.Sys.foregroundLockTimeout, 0 ); |                          &_glfwLibrary.Sys.foregroundLockTimeout, 0); | ||||||
|     SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID)0, |     SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID) 0, | ||||||
|                           SPIF_SENDCHANGE ); |                          SPIF_SENDCHANGE); | ||||||
| 
 | 
 | ||||||
|     // Check which OS version we are running
 |     // Check which OS version we are running
 | ||||||
|     osi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); |     osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | ||||||
|     GetVersionEx( &osi ); |     GetVersionEx(&osi); | ||||||
|  | 
 | ||||||
|     _glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN; |     _glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN; | ||||||
|     if( osi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) | 
 | ||||||
|  |     if (osi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) | ||||||
|     { |     { | ||||||
|         if( osi.dwMajorVersion == 4 && osi.dwMinorVersion < 10 ) |         if (osi.dwMajorVersion == 4 && osi.dwMinorVersion < 10) | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_95; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_95; | ||||||
|         } |         else if (osi.dwMajorVersion == 4 && osi.dwMinorVersion < 90) | ||||||
|         else if( osi.dwMajorVersion == 4 && osi.dwMinorVersion < 90 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_98; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_98; | ||||||
|         } |         else if (osi.dwMajorVersion == 4 && osi.dwMinorVersion == 90) | ||||||
|         else if( osi.dwMajorVersion == 4 && osi.dwMinorVersion == 90 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_ME; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_ME; | ||||||
|         } |         else if (osi.dwMajorVersion >= 4) | ||||||
|         else if( osi.dwMajorVersion >= 4 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN_9x; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN_9x; | ||||||
|         } |  | ||||||
|     } |     } | ||||||
|     else if( osi.dwPlatformId == VER_PLATFORM_WIN32_NT ) |     else if (osi.dwPlatformId == VER_PLATFORM_WIN32_NT) | ||||||
|     { |     { | ||||||
|         if( osi.dwMajorVersion == 4 && osi.dwMinorVersion == 0 ) |         if (osi.dwMajorVersion == 4 && osi.dwMinorVersion == 0) | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_NT4; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_NT4; | ||||||
|         } |         else if (osi.dwMajorVersion == 5 && osi.dwMinorVersion == 0) | ||||||
|         else if( osi.dwMajorVersion == 5 && osi.dwMinorVersion == 0 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_2K; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_2K; | ||||||
|         } |         else if (osi.dwMajorVersion == 5 && osi.dwMinorVersion == 1) | ||||||
|         else if( osi.dwMajorVersion == 5 && osi.dwMinorVersion == 1 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_XP; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_XP; | ||||||
|         } |         else if (osi.dwMajorVersion == 5 && osi.dwMinorVersion == 2) | ||||||
|         else if( osi.dwMajorVersion == 5 && osi.dwMinorVersion == 2 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_NET_SERVER; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_NET_SERVER; | ||||||
|         } |         else if (osi.dwMajorVersion >= 5) | ||||||
|         else if( osi.dwMajorVersion >= 5 ) |  | ||||||
|         { |  | ||||||
|             _glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN_NT; |             _glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN_NT; | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Do we have Unicode support?
 |     // Do we have Unicode support?
 | ||||||
|     if( _glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4 ) |     if (_glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4) | ||||||
|     { |     { | ||||||
|         // Windows NT/2000/XP/.NET has Unicode support
 |         // Windows NT/2000/XP/.NET has Unicode support
 | ||||||
|         _glfwLibrary.Sys.hasUnicode = GL_TRUE; |         _glfwLibrary.Sys.hasUnicode = GL_TRUE; | ||||||
| @ -229,25 +205,23 @@ int _glfwPlatformInit( void ) | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Load libraries (DLLs)
 |     // Load libraries (DLLs)
 | ||||||
|     if( !_glfwInitLibraries() ) |     if (!_glfwInitLibraries()) | ||||||
|     { |  | ||||||
|         return GL_FALSE; |         return GL_FALSE; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // With the Borland C++ compiler, we want to disable FPU exceptions
 |     // With the Borland C++ compiler, we want to disable FPU exceptions
 | ||||||
|     // (this is recommended for OpenGL applications under Windows)
 |     // (this is recommended for OpenGL applications under Windows)
 | ||||||
| #ifdef __BORLANDC__ | #ifdef __BORLANDC__ | ||||||
|     _control87( MCW_EM, MCW_EM ); |     _control87(MCW_EM, MCW_EM); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     // Retrieve GLFW instance handle
 |     // Retrieve GLFW instance handle
 | ||||||
|     _glfwLibrary.instance = GetModuleHandle( NULL ); |     _glfwLibrary.instance = GetModuleHandle(NULL); | ||||||
| 
 | 
 | ||||||
|     // System keys are not disabled
 |     // System keys are not disabled
 | ||||||
|     _glfwWin.keyboardHook = NULL; |     _glfwWin.keyboardHook = NULL; | ||||||
| 
 | 
 | ||||||
|     // Install atexit() routine
 |     // Install atexit() routine
 | ||||||
|     atexit( _glfwTerminate_atexit ); |     atexit(glfw_atexit); | ||||||
| 
 | 
 | ||||||
|     // Start the timer
 |     // Start the timer
 | ||||||
|     _glfwInitTimer(); |     _glfwInitTimer(); | ||||||
| @ -260,21 +234,21 @@ int _glfwPlatformInit( void ) | |||||||
| // Close window and shut down library
 | // Close window and shut down library
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformTerminate( void ) | int _glfwPlatformTerminate(void) | ||||||
| { | { | ||||||
|     // Close OpenGL window
 |     // Close OpenGL window
 | ||||||
|     glfwCloseWindow(); |     glfwCloseWindow(); | ||||||
| 
 | 
 | ||||||
|     // Enable system keys again (if they were disabled)
 |     // Enable system keys again (if they were disabled)
 | ||||||
|     glfwEnable( GLFW_SYSTEM_KEYS ); |     glfwEnable(GLFW_SYSTEM_KEYS); | ||||||
| 
 | 
 | ||||||
|     // Unload libraries (DLLs)
 |     // Unload libraries (DLLs)
 | ||||||
|     _glfwFreeLibraries(); |     _glfwFreeLibraries(); | ||||||
| 
 | 
 | ||||||
|     // Restore FOREGROUNDLOCKTIMEOUT system setting
 |     // Restore FOREGROUNDLOCKTIMEOUT system setting
 | ||||||
|     SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT, 0, |     SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, | ||||||
|                           (LPVOID)_glfwLibrary.Sys.foregroundLockTimeout, |                          (LPVOID) _glfwLibrary.Sys.foregroundLockTimeout, | ||||||
|                           SPIF_SENDCHANGE ); |                          SPIF_SENDCHANGE); | ||||||
| 
 | 
 | ||||||
|     return GL_TRUE; |     return GL_TRUE; | ||||||
| } | } | ||||||
|  | |||||||
| @ -31,36 +31,30 @@ | |||||||
| #include "internal.h" | #include "internal.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //****                  GLFW internal functions                       ****
 | //////                       GLFW internal API                      //////
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Return GL_TRUE if joystick is present, else return GL_FALSE.
 | // Return GL_TRUE if joystick is present, else return GL_FALSE.
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| static int _glfwJoystickPresent( int joy ) | static GLboolean isJoystickPresent(int joy) | ||||||
| { | { | ||||||
|     JOYINFO ji; |     JOYINFO ji; | ||||||
| 
 | 
 | ||||||
|     // Windows NT 4.0 MMSYSTEM only supports 2 sticks (other Windows
 |     // Windows NT 4.0 MMSYSTEM only supports 2 sticks (other Windows
 | ||||||
|     // versions support 16 sticks)
 |     // versions support 16 sticks)
 | ||||||
|     if( _glfwLibrary.Sys.winVer == _GLFW_WIN_NT4 && joy > GLFW_JOYSTICK_2 ) |     if (_glfwLibrary.Sys.winVer == _GLFW_WIN_NT4 && joy > GLFW_JOYSTICK_2) | ||||||
|     { |  | ||||||
|         return GL_FALSE; |         return GL_FALSE; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Is it a valid stick ID (Windows don't support more than 16 sticks)?
 |     // Is it a valid stick ID (Windows don't support more than 16 sticks)?
 | ||||||
|     if( joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_16 ) |     if (joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_16) | ||||||
|     { |  | ||||||
|         return GL_FALSE; |         return GL_FALSE; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Is the joystick present?
 |     // Is the joystick present?
 | ||||||
|     if( _glfw_joyGetPos( joy - GLFW_JOYSTICK_1, &ji ) != JOYERR_NOERROR ) |     if (_glfw_joyGetPos(joy - GLFW_JOYSTICK_1, &ji) != JOYERR_NOERROR) | ||||||
|     { |  | ||||||
|         return GL_FALSE; |         return GL_FALSE; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     return GL_TRUE; |     return GL_TRUE; | ||||||
| } | } | ||||||
| @ -70,57 +64,50 @@ static int _glfwJoystickPresent( int joy ) | |||||||
| // Calculate joystick position
 | // Calculate joystick position
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| static float _glfwCalcJoystickPos( DWORD pos, DWORD min, DWORD max ) | static float calcJoystickPos(DWORD pos, DWORD min, DWORD max) | ||||||
| { | { | ||||||
|     float fpos = (float) pos; |     float fpos = (float) pos; | ||||||
|     float fmin = (float) min; |     float fmin = (float) min; | ||||||
|     float fmax = (float) max; |     float fmax = (float) max; | ||||||
|     return (2.0f*(fpos - fmin) / (fmax - fmin)) - 1.0f; | 
 | ||||||
|  |     return (2.f * (fpos - fmin) / (fmax - fmin)) - 1.f; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //************************************************************************
 | //////                       GLFW platform API                      //////
 | ||||||
| //****               Platform implementation functions                ****
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //************************************************************************
 |  | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Determine joystick capabilities
 | // Determine joystick capabilities
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformGetJoystickParam( int joy, int param ) | int _glfwPlatformGetJoystickParam(int joy, int param) | ||||||
| { | { | ||||||
|     JOYCAPS jc; |     JOYCAPS jc; | ||||||
| 
 | 
 | ||||||
| //  return 0;
 |     if (!isJoystickPresent(joy)) | ||||||
| 
 |  | ||||||
|     // Is joystick present?
 |  | ||||||
|     if( !_glfwJoystickPresent( joy ) ) |  | ||||||
|     { |  | ||||||
|         return 0; |         return 0; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // We got this far, the joystick is present
 |     // We got this far, the joystick is present
 | ||||||
|     if( param == GLFW_PRESENT ) |     if (param == GLFW_PRESENT) | ||||||
|     { |  | ||||||
|         return GL_TRUE; |         return GL_TRUE; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Get joystick capabilities
 |     // Get joystick capabilities
 | ||||||
|     _glfw_joyGetDevCaps( joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS) ); |     _glfw_joyGetDevCaps(joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS)); | ||||||
| 
 | 
 | ||||||
|     switch( param ) |     switch (param) | ||||||
|     { |     { | ||||||
|     case GLFW_AXES: |         case GLFW_AXES: | ||||||
|         // Return number of joystick axes
 |             // Return number of joystick axes
 | ||||||
|         return jc.wNumAxes; |             return jc.wNumAxes; | ||||||
| 
 | 
 | ||||||
|     case GLFW_BUTTONS: |         case GLFW_BUTTONS: | ||||||
|         // Return number of joystick axes
 |             // Return number of joystick axes
 | ||||||
|         return jc.wNumButtons; |             return jc.wNumButtons; | ||||||
| 
 | 
 | ||||||
|     default: |         default: | ||||||
|         break; |             break; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
| @ -131,63 +118,44 @@ int _glfwPlatformGetJoystickParam( int joy, int param ) | |||||||
| // Get joystick axis positions
 | // Get joystick axis positions
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes ) | int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes) | ||||||
| { | { | ||||||
|     JOYCAPS   jc; |     JOYCAPS jc; | ||||||
|     JOYINFOEX ji; |     JOYINFOEX ji; | ||||||
|     int       axis; |     int axis; | ||||||
| 
 | 
 | ||||||
| //  return 0;
 |     if (!isJoystickPresent(joy)) | ||||||
| 
 |  | ||||||
|     // Is joystick present?
 |  | ||||||
|     if( !_glfwJoystickPresent( joy ) ) |  | ||||||
|     { |  | ||||||
|         return 0; |         return 0; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Get joystick capabilities
 |     // Get joystick capabilities
 | ||||||
|     _glfw_joyGetDevCaps( joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS) ); |     _glfw_joyGetDevCaps(joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS)); | ||||||
| 
 | 
 | ||||||
|     // Get joystick state
 |     // Get joystick state
 | ||||||
|     ji.dwSize = sizeof( JOYINFOEX ); |     ji.dwSize = sizeof(JOYINFOEX); | ||||||
|     ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | |     ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ | | ||||||
|                  JOY_RETURNR | JOY_RETURNU | JOY_RETURNV; |                  JOY_RETURNR | JOY_RETURNU | JOY_RETURNV; | ||||||
|     _glfw_joyGetPosEx( joy - GLFW_JOYSTICK_1, &ji ); |     _glfw_joyGetPosEx(joy - GLFW_JOYSTICK_1, &ji); | ||||||
| 
 | 
 | ||||||
|     // Get position values for all axes
 |     // Get position values for all axes
 | ||||||
|     axis = 0; |     axis = 0; | ||||||
|     if( axis < numaxes ) |     if (axis < numaxes) | ||||||
|     { |         pos[axis++] = _glfwCalcJoystickPos(ji.dwXpos, jc.wXmin, jc.wXmax); | ||||||
|         pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwXpos, jc.wXmin, | 
 | ||||||
|                                               jc.wXmax ); |     if (axis < numaxes) | ||||||
|     } |         pos[axis++] = -_glfwCalcJoystickPos(ji.dwYpos, jc.wYmin, jc.wYmax); | ||||||
|     if( axis < numaxes ) | 
 | ||||||
|     { |     if (axis < numaxes && jc.wCaps & JOYCAPS_HASZ) | ||||||
|         pos[ axis++ ] = -_glfwCalcJoystickPos( ji.dwYpos, jc.wYmin, |         pos[axis++] = _glfwCalcJoystickPos(ji.dwZpos, jc.wZmin, jc.wZmax); | ||||||
|                                                jc.wYmax ); | 
 | ||||||
|     } |     if (axis < numaxes && jc.wCaps & JOYCAPS_HASR) | ||||||
|     if( axis < numaxes && jc.wCaps & JOYCAPS_HASZ ) |         pos[axis++] = _glfwCalcJoystickPos(ji.dwRpos, jc.wRmin, jc.wRmax); | ||||||
|     { | 
 | ||||||
|         pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwZpos, jc.wZmin, |     if (axis < numaxes && jc.wCaps & JOYCAPS_HASU) | ||||||
|                                               jc.wZmax ); |         pos[axis++] = _glfwCalcJoystickPos(ji.dwUpos, jc.wUmin, jc.wUmax); | ||||||
|     } | 
 | ||||||
|     if( axis < numaxes && jc.wCaps & JOYCAPS_HASR ) |     if (axis < numaxes && jc.wCaps & JOYCAPS_HASV) | ||||||
|     { |         pos[axis++] = -_glfwCalcJoystickPos(ji.dwVpos, jc.wVmin, jc.wVmax); | ||||||
|         pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwRpos, jc.wRmin, |  | ||||||
|                                               jc.wRmax ); |  | ||||||
|     } |  | ||||||
|     if( axis < numaxes && jc.wCaps & JOYCAPS_HASU ) |  | ||||||
|     { |  | ||||||
|         pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwUpos, jc.wUmin, |  | ||||||
|                                               jc.wUmax ); |  | ||||||
|     } |  | ||||||
|     if( axis < numaxes && jc.wCaps & JOYCAPS_HASV ) |  | ||||||
|     { |  | ||||||
|         pos[ axis++ ] = -_glfwCalcJoystickPos( ji.dwVpos, jc.wVmin, |  | ||||||
|                                                jc.wVmax ); |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Return number of returned axes
 |  | ||||||
|     return axis; |     return axis; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -196,36 +164,31 @@ int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes ) | |||||||
| // Get joystick button states
 | // Get joystick button states
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, | int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons, | ||||||
|     int numbuttons ) |     int numbuttons) | ||||||
| { | { | ||||||
|     JOYCAPS   jc; |     JOYCAPS jc; | ||||||
|     JOYINFOEX ji; |     JOYINFOEX ji; | ||||||
|     int       button; |     int button; | ||||||
| 
 | 
 | ||||||
| //  return 0;
 |     if (!isJoystickPresent(joy)) | ||||||
| 
 |  | ||||||
|     // Is joystick present?
 |  | ||||||
|     if( !_glfwJoystickPresent( joy ) ) |  | ||||||
|     { |  | ||||||
|         return 0; |         return 0; | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Get joystick capabilities
 |     // Get joystick capabilities
 | ||||||
|     _glfw_joyGetDevCaps( joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS) ); |     _glfw_joyGetDevCaps(joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS)); | ||||||
| 
 | 
 | ||||||
|     // Get joystick state
 |     // Get joystick state
 | ||||||
|     ji.dwSize = sizeof( JOYINFOEX ); |     ji.dwSize = sizeof(JOYINFOEX); | ||||||
|     ji.dwFlags = JOY_RETURNBUTTONS; |     ji.dwFlags = JOY_RETURNBUTTONS; | ||||||
|     _glfw_joyGetPosEx( joy - GLFW_JOYSTICK_1, &ji ); |     _glfw_joyGetPosEx(joy - GLFW_JOYSTICK_1, &ji); | ||||||
| 
 | 
 | ||||||
|     // Get states of all requested buttons
 |     // Get states of all requested buttons
 | ||||||
|     button = 0; |     button = 0; | ||||||
|     while( button < numbuttons && button < (int) jc.wNumButtons ) |     while (button < numbuttons && button < (int) jc.wNumButtons) | ||||||
|     { |     { | ||||||
|         buttons[ button ] = (unsigned char) |         buttons[button] = (unsigned char) | ||||||
|             (ji.dwButtons & (1UL << button) ? GLFW_PRESS : GLFW_RELEASE); |             (ji.dwButtons & (1UL << button) ? GLFW_PRESS : GLFW_RELEASE); | ||||||
|         button ++; |         button++; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return button; |     return button; | ||||||
|  | |||||||
| @ -31,29 +31,29 @@ | |||||||
| #include "internal.h" | #include "internal.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //****                  GLFW internal functions                       ****
 | //////                       GLFW internal API                      //////
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Initialise timer
 | // Initialise timer
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwInitTimer( void ) | void _glfwInitTimer(void) | ||||||
| { | { | ||||||
|     __int64 freq; |     __int64 freq; | ||||||
| 
 | 
 | ||||||
|     // Check if we have a performance counter
 |     // Check if we have a performance counter
 | ||||||
|     if( QueryPerformanceFrequency( (LARGE_INTEGER *)&freq ) ) |     if (QueryPerformanceFrequency((LARGE_INTEGER*) &freq)) | ||||||
|     { |     { | ||||||
|         // Performance counter is available => use it!
 |         // Performance counter is available => use it!
 | ||||||
|         _glfwLibrary.Timer.HasPerformanceCounter = GL_TRUE; |         _glfwLibrary.Timer.HasPerformanceCounter = GL_TRUE; | ||||||
| 
 | 
 | ||||||
|         // Counter resolution is 1 / counter frequency
 |         // Counter resolution is 1 / counter frequency
 | ||||||
|         _glfwLibrary.Timer.Resolution = 1.0 / (double)freq; |         _glfwLibrary.Timer.Resolution = 1.0 / (double) freq; | ||||||
| 
 | 
 | ||||||
|         // Set start time for timer
 |         // Set start time for timer
 | ||||||
|         QueryPerformanceCounter( (LARGE_INTEGER *)&_glfwLibrary.Timer.t0_64 ); |         QueryPerformanceCounter((LARGE_INTEGER*) &_glfwLibrary.Timer.t0_64); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
| @ -69,28 +69,26 @@ void _glfwInitTimer( void ) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| //****               Platform implementation functions                ****
 | //////                       GLFW platform API                      //////
 | ||||||
| //************************************************************************
 | //////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| // Return timer value in seconds
 | // Return timer value in seconds
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| double _glfwPlatformGetTime( void ) | double _glfwPlatformGetTime(void) | ||||||
| { | { | ||||||
|     double  t; |     double t; | ||||||
|     __int64 t_64; |     __int64 t_64; | ||||||
| 
 | 
 | ||||||
|     if( _glfwLibrary.Timer.HasPerformanceCounter ) |     if (_glfwLibrary.Timer.HasPerformanceCounter) | ||||||
|     { |     { | ||||||
|         QueryPerformanceCounter( (LARGE_INTEGER *)&t_64 ); |         QueryPerformanceCounter((LARGE_INTEGER*) &t_64); | ||||||
|         t =  (double)(t_64 - _glfwLibrary.Timer.t0_64); |         t =  (double)(t_64 - _glfwLibrary.Timer.t0_64); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |  | ||||||
|         t = (double)(_glfw_timeGetTime() - _glfwLibrary.Timer.t0_32); |         t = (double)(_glfw_timeGetTime() - _glfwLibrary.Timer.t0_32); | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     // Calculate the current time in seconds
 |     // Calculate the current time in seconds
 | ||||||
|     return t * _glfwLibrary.Timer.Resolution; |     return t * _glfwLibrary.Timer.Resolution; | ||||||
| @ -101,18 +99,16 @@ double _glfwPlatformGetTime( void ) | |||||||
| // Set timer value in seconds
 | // Set timer value in seconds
 | ||||||
| //========================================================================
 | //========================================================================
 | ||||||
| 
 | 
 | ||||||
| void _glfwPlatformSetTime( double t ) | void _glfwPlatformSetTime(double t) | ||||||
| { | { | ||||||
|     __int64 t_64; |     __int64 t_64; | ||||||
| 
 | 
 | ||||||
|     if( _glfwLibrary.Timer.HasPerformanceCounter ) |     if (_glfwLibrary.Timer.HasPerformanceCounter) | ||||||
|     { |     { | ||||||
|         QueryPerformanceCounter( (LARGE_INTEGER *)&t_64 ); |         QueryPerformanceCounter((LARGE_INTEGER*) &t_64); | ||||||
|         _glfwLibrary.Timer.t0_64 = t_64 - (__int64)(t/_glfwLibrary.Timer.Resolution); |         _glfwLibrary.Timer.t0_64 = t_64 - (__int64) (t / _glfwLibrary.Timer.Resolution); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |         _glfwLibrary.Timer.t0_32 = _glfw_timeGetTime() - (int)(t * 1000.0); | ||||||
|         _glfwLibrary.Timer.t0_32 = _glfw_timeGetTime() - (int)(t*1000.0); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue
	
	Block a user