mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Formatting pass.
This commit is contained in:
parent
484a2714fc
commit
479c9255fc
@ -31,10 +31,6 @@
|
|||||||
#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
|
||||||
@ -84,9 +80,7 @@ static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam )
|
|||||||
{
|
{
|
||||||
// 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
|
||||||
@ -100,10 +94,9 @@ static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//************************************************************************
|
////// GLFW platform API //////
|
||||||
//**** Platform implementation functions ****
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//************************************************************************
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Enable system keys
|
// Enable system keys
|
||||||
@ -123,11 +116,10 @@ void _glfwPlatformEnableSystemKeys( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0);
|
||||||
(void) SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Disable system keys
|
// Disable system keys
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -149,7 +141,7 @@ void _glfwPlatformDisableSystemKeys( void )
|
|||||||
{
|
{
|
||||||
// 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,10 +31,6 @@
|
|||||||
#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"
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -45,25 +41,51 @@ static void bpp2rgb( int bpp, int *r, int *g, int *b )
|
|||||||
|
|
||||||
// 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
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -77,6 +99,7 @@ int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh )
|
|||||||
bestmatch = 0x7fffffff;
|
bestmatch = 0x7fffffff;
|
||||||
bestrr = 0x7fffffff;
|
bestrr = 0x7fffffff;
|
||||||
mode = bestmode = 0;
|
mode = bestmode = 0;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
dm.dmSize = sizeof(DEVMODE);
|
dm.dmSize = sizeof(DEVMODE);
|
||||||
@ -84,7 +107,9 @@ int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh )
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
match = dm.dmBitsPerPel - *bpp;
|
match = dm.dmBitsPerPel - *bpp;
|
||||||
if( match < 0 ) match = -match;
|
if (match < 0)
|
||||||
|
match = -match;
|
||||||
|
|
||||||
match = (match << 25) |
|
match = (match << 25) |
|
||||||
((dm.dmPelsWidth - *w) *
|
((dm.dmPelsWidth - *w) *
|
||||||
(dm.dmPelsWidth - *w) +
|
(dm.dmPelsWidth - *w) +
|
||||||
@ -115,7 +140,7 @@ int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh )
|
|||||||
|
|
||||||
// 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,35 +156,6 @@ 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
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -171,7 +167,7 @@ void _glfwSetVideoModeMODE( int mode )
|
|||||||
|
|
||||||
// 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;
|
||||||
@ -190,9 +186,7 @@ void _glfwSetVideoModeMODE( int mode )
|
|||||||
// 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;
|
||||||
@ -221,9 +215,9 @@ void _glfwSetVideoMode( int *w, int *h, int r, int g, int b, int refresh )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//**** GLFW user functions ****
|
////// GLFW platform API //////
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Get a list of available video modes
|
// Get a list of available video modes
|
||||||
@ -238,6 +232,7 @@ 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
|
||||||
@ -258,14 +253,11 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
|
|||||||
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)
|
||||||
@ -281,9 +273,8 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
|
|||||||
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;
|
||||||
@ -310,7 +301,7 @@ void _glfwPlatformGetDesktopMode( GLFWvidmode *mode )
|
|||||||
|
|
||||||
// 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;
|
||||||
|
@ -31,9 +31,9 @@
|
|||||||
#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
|
||||||
@ -49,11 +49,9 @@ int _glfwPlatformExtensionSupported( const char *extension )
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@ -61,11 +59,9 @@ int _glfwPlatformExtensionSupported( const char *extension )
|
|||||||
if (extensions != NULL)
|
if (extensions != NULL)
|
||||||
{
|
{
|
||||||
if (_glfwStringInExtensionString(extension, extensions))
|
if (_glfwStringInExtensionString(extension, extensions))
|
||||||
{
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,11 @@
|
|||||||
#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
|
||||||
@ -62,11 +57,12 @@ static int _glfwInitLibraries( void )
|
|||||||
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;
|
||||||
@ -74,9 +70,7 @@ static int _glfwInitLibraries( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)
|
||||||
@ -92,10 +86,11 @@ static int _glfwInitLibraries( void )
|
|||||||
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;
|
||||||
@ -103,9 +98,7 @@ static int _glfwInitLibraries( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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,7 +109,7 @@ 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
|
||||||
@ -142,16 +135,15 @@ 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
|
||||||
@ -172,49 +164,33 @@ int _glfwPlatformInit( void )
|
|||||||
// 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)
|
||||||
@ -230,9 +206,7 @@ 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)
|
||||||
@ -247,7 +221,7 @@ int _glfwPlatformInit( void )
|
|||||||
_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();
|
||||||
|
@ -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,19 +64,19 @@ 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
|
||||||
@ -92,19 +86,12 @@ 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));
|
||||||
@ -137,13 +124,8 @@ int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
|
|||||||
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));
|
||||||
@ -157,37 +139,23 @@ int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,13 +171,8 @@ int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons,
|
|||||||
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));
|
||||||
|
@ -31,9 +31,9 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//**** GLFW internal functions ****
|
////// GLFW internal API //////
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Initialise timer
|
// Initialise timer
|
||||||
@ -69,9 +69,9 @@ void _glfwInitTimer( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//**** Platform implementation functions ****
|
////// GLFW platform API //////
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Return timer value in seconds
|
// Return timer value in seconds
|
||||||
@ -88,9 +88,7 @@ double _glfwPlatformGetTime( void )
|
|||||||
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;
|
||||||
@ -111,8 +109,6 @@ void _glfwPlatformSetTime( double t )
|
|||||||
_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);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -31,14 +31,9 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//************************************************************************
|
|
||||||
//**** GLFW internal functions ****
|
|
||||||
//************************************************************************
|
|
||||||
|
|
||||||
// We use versioned window class names in order not to cause conflicts
|
// We use versioned window class names in order not to cause conflicts
|
||||||
// between applications using different versions of GLFW
|
// between applications using different versions of GLFW
|
||||||
#define _GLFW_WNDCLASSNAME "GLFW27"
|
#define _GLFW_WNDCLASSNAME "GLFW30"
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -120,7 +115,7 @@ static void setForegroundWindow( HWND hWnd )
|
|||||||
while (hWnd != GetForegroundWindow() && try_count <= 3);
|
while (hWnd != GetForegroundWindow() && try_count <= 3);
|
||||||
|
|
||||||
// Restore the system minimize/restore animation setting
|
// Restore the system minimize/restore animation setting
|
||||||
(void) setMinMaxAnimations( old_animate );
|
setMinMaxAnimations(old_animate);
|
||||||
|
|
||||||
// Try to modify the system settings (since this is now hopefully the
|
// Try to modify the system settings (since this is now hopefully the
|
||||||
// foreground process, we are probably allowed to do this)
|
// foreground process, we are probably allowed to do this)
|
||||||
@ -161,13 +156,9 @@ static _GLFWfbconfig *getFBConfigs( unsigned int *found )
|
|||||||
*found = 0;
|
*found = 0;
|
||||||
|
|
||||||
if (_glfwWin.has_WGL_ARB_pixel_format)
|
if (_glfwWin.has_WGL_ARB_pixel_format)
|
||||||
{
|
|
||||||
count = getPixelFormatAttrib(1, WGL_NUMBER_PIXEL_FORMATS_ARB);
|
count = getPixelFormatAttrib(1, WGL_NUMBER_PIXEL_FORMATS_ARB);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
count = _glfw_DescribePixelFormat(_glfwWin.DC, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
|
count = _glfw_DescribePixelFormat(_glfwWin.DC, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
|
||||||
}
|
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
{
|
{
|
||||||
@ -178,7 +169,7 @@ static _GLFWfbconfig *getFBConfigs( unsigned int *found )
|
|||||||
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Out of memory");
|
fprintf(stderr, "Out of memory\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,19 +179,17 @@ static _GLFWfbconfig *getFBConfigs( unsigned int *found )
|
|||||||
{
|
{
|
||||||
// Get pixel format attributes through WGL_ARB_pixel_format
|
// Get pixel format attributes through WGL_ARB_pixel_format
|
||||||
|
|
||||||
|
// Only consider doublebuffered OpenGL pixel formats for windows
|
||||||
if (!getPixelFormatAttrib(i, WGL_SUPPORT_OPENGL_ARB) ||
|
if (!getPixelFormatAttrib(i, WGL_SUPPORT_OPENGL_ARB) ||
|
||||||
!getPixelFormatAttrib(i, WGL_DRAW_TO_WINDOW_ARB) ||
|
!getPixelFormatAttrib(i, WGL_DRAW_TO_WINDOW_ARB) ||
|
||||||
!getPixelFormatAttrib(i, WGL_DOUBLE_BUFFER_ARB))
|
!getPixelFormatAttrib(i, WGL_DOUBLE_BUFFER_ARB))
|
||||||
{
|
{
|
||||||
// Only consider doublebuffered OpenGL pixel formats for windows
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( getPixelFormatAttrib( i, WGL_PIXEL_TYPE_ARB ) != WGL_TYPE_RGBA_ARB )
|
|
||||||
{
|
|
||||||
// Only consider RGBA pixel formats
|
// Only consider RGBA pixel formats
|
||||||
|
if (getPixelFormatAttrib(i, WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
result[*found].redBits = getPixelFormatAttrib(i, WGL_RED_BITS_ARB);
|
result[*found].redBits = getPixelFormatAttrib(i, WGL_RED_BITS_ARB);
|
||||||
result[*found].greenBits = getPixelFormatAttrib(i, WGL_GREEN_BITS_ARB);
|
result[*found].greenBits = getPixelFormatAttrib(i, WGL_GREEN_BITS_ARB);
|
||||||
@ -219,28 +208,22 @@ static _GLFWfbconfig *getFBConfigs( unsigned int *found )
|
|||||||
result[*found].stereo = getPixelFormatAttrib(i, WGL_STEREO_ARB);
|
result[*found].stereo = getPixelFormatAttrib(i, WGL_STEREO_ARB);
|
||||||
|
|
||||||
if (_glfwWin.has_WGL_ARB_multisample)
|
if (_glfwWin.has_WGL_ARB_multisample)
|
||||||
{
|
|
||||||
result[*found].samples = getPixelFormatAttrib(i, WGL_SAMPLES_ARB);
|
result[*found].samples = getPixelFormatAttrib(i, WGL_SAMPLES_ARB);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
result[*found].samples = 0;
|
result[*found].samples = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Get pixel format attributes through old-fashioned PFDs
|
// Get pixel format attributes through old-fashioned PFDs
|
||||||
|
|
||||||
if (!_glfw_DescribePixelFormat(_glfwWin.DC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
|
if (!_glfw_DescribePixelFormat(_glfwWin.DC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
|
// Only consider doublebuffered OpenGL pixel formats for windows
|
||||||
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
|
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
|
||||||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
|
!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
|
||||||
!(pfd.dwFlags & PFD_DOUBLEBUFFER))
|
!(pfd.dwFlags & PFD_DOUBLEBUFFER))
|
||||||
{
|
{
|
||||||
// Only consider doublebuffered OpenGL pixel formats for windows
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,11 +233,9 @@ static _GLFWfbconfig *getFBConfigs( unsigned int *found )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pfd.iPixelType != PFD_TYPE_RGBA )
|
|
||||||
{
|
|
||||||
// Only RGBA pixel formats considered
|
// Only RGBA pixel formats considered
|
||||||
|
if (pfd.iPixelType != PFD_TYPE_RGBA)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
result[*found].redBits = pfd.cRedBits;
|
result[*found].redBits = pfd.cRedBits;
|
||||||
result[*found].greenBits = pfd.cGreenBits;
|
result[*found].greenBits = pfd.cGreenBits;
|
||||||
@ -295,14 +276,10 @@ static HGLRC createContext( HDC dc, const _GLFWwndconfig* wndconfig, int pixelFo
|
|||||||
int flags, i = 0, attribs[7];
|
int flags, i = 0, attribs[7];
|
||||||
|
|
||||||
if (!_glfw_DescribePixelFormat(dc, pixelFormat, sizeof(pfd), &pfd))
|
if (!_glfw_DescribePixelFormat(dc, pixelFormat, sizeof(pfd), &pfd))
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (!_glfw_SetPixelFormat(dc, pixelFormat, &pfd))
|
if (!_glfw_SetPixelFormat(dc, pixelFormat, &pfd))
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfwWin.has_WGL_ARB_create_context)
|
if (_glfwWin.has_WGL_ARB_create_context)
|
||||||
{
|
{
|
||||||
@ -323,14 +300,10 @@ static HGLRC createContext( HDC dc, const _GLFWwndconfig* wndconfig, int pixelFo
|
|||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
if (wndconfig->glForward)
|
if (wndconfig->glForward)
|
||||||
{
|
|
||||||
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||||
}
|
|
||||||
|
|
||||||
if (wndconfig->glDebug)
|
if (wndconfig->glDebug)
|
||||||
{
|
|
||||||
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
|
||||||
}
|
|
||||||
|
|
||||||
attribs[i++] = WGL_CONTEXT_FLAGS_ARB;
|
attribs[i++] = WGL_CONTEXT_FLAGS_ARB;
|
||||||
attribs[i++] = flags;
|
attribs[i++] = flags;
|
||||||
@ -339,13 +312,9 @@ static HGLRC createContext( HDC dc, const _GLFWwndconfig* wndconfig, int pixelFo
|
|||||||
if (wndconfig->glProfile)
|
if (wndconfig->glProfile)
|
||||||
{
|
{
|
||||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||||
{
|
|
||||||
flags = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
flags = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
flags = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
flags = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
}
|
|
||||||
|
|
||||||
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB;
|
||||||
attribs[i++] = flags;
|
attribs[i++] = flags;
|
||||||
@ -408,9 +377,7 @@ static int translateKey( WPARAM wParam, LPARAM lParam )
|
|||||||
// right)
|
// right)
|
||||||
scan_code = MapVirtualKey(VK_RSHIFT, 0);
|
scan_code = MapVirtualKey(VK_RSHIFT, 0);
|
||||||
if (((lParam & 0x01ff0000) >> 16) == scan_code)
|
if (((lParam & 0x01ff0000) >> 16) == scan_code)
|
||||||
{
|
|
||||||
return GLFW_KEY_RSHIFT;
|
return GLFW_KEY_RSHIFT;
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_KEY_LSHIFT;
|
return GLFW_KEY_LSHIFT;
|
||||||
}
|
}
|
||||||
@ -420,9 +387,7 @@ static int translateKey( WPARAM wParam, LPARAM lParam )
|
|||||||
{
|
{
|
||||||
// Is this an extended key (i.e. right key)?
|
// Is this an extended key (i.e. right key)?
|
||||||
if (lParam & 0x01000000)
|
if (lParam & 0x01000000)
|
||||||
{
|
|
||||||
return GLFW_KEY_RCTRL;
|
return GLFW_KEY_RCTRL;
|
||||||
}
|
|
||||||
|
|
||||||
// Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
|
// Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
|
||||||
// want the RALT message, so we try to see if the next message
|
// want the RALT message, so we try to see if the next message
|
||||||
@ -452,9 +417,7 @@ static int translateKey( WPARAM wParam, LPARAM lParam )
|
|||||||
{
|
{
|
||||||
// Is this an extended key (i.e. right key)?
|
// Is this an extended key (i.e. right key)?
|
||||||
if (lParam & 0x01000000)
|
if (lParam & 0x01000000)
|
||||||
{
|
|
||||||
return GLFW_KEY_RALT;
|
return GLFW_KEY_RALT;
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_KEY_LALT;
|
return GLFW_KEY_LALT;
|
||||||
}
|
}
|
||||||
@ -464,9 +427,7 @@ static int translateKey( WPARAM wParam, LPARAM lParam )
|
|||||||
{
|
{
|
||||||
// Is this an extended key (i.e. right key)?
|
// Is this an extended key (i.e. right key)?
|
||||||
if (lParam & 0x01000000)
|
if (lParam & 0x01000000)
|
||||||
{
|
|
||||||
return GLFW_KEY_KP_ENTER;
|
return GLFW_KEY_KP_ENTER;
|
||||||
}
|
|
||||||
|
|
||||||
return GLFW_KEY_ENTER;
|
return GLFW_KEY_ENTER;
|
||||||
}
|
}
|
||||||
@ -545,13 +506,9 @@ static int translateKey( WPARAM wParam, LPARAM lParam )
|
|||||||
|
|
||||||
// Make sure that the character is uppercase
|
// Make sure that the character is uppercase
|
||||||
if (_glfwLibrary.Sys.hasUnicode)
|
if (_glfwLibrary.Sys.hasUnicode)
|
||||||
{
|
|
||||||
wParam = (WPARAM) CharUpperW((LPWSTR) wParam);
|
wParam = (WPARAM) CharUpperW((LPWSTR) wParam);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
wParam = (WPARAM) CharUpperA((LPSTR) wParam);
|
wParam = (WPARAM) CharUpperA((LPSTR) wParam);
|
||||||
}
|
|
||||||
|
|
||||||
// Valid ISO-8859-1 character?
|
// Valid ISO-8859-1 character?
|
||||||
if ((wParam >= 32 && wParam <= 126) ||
|
if ((wParam >= 32 && wParam <= 126) ||
|
||||||
@ -617,15 +574,11 @@ static void translateChar( DWORD wParam, DWORD lParam, int action )
|
|||||||
{
|
{
|
||||||
// Get next character from buffer
|
// Get next character from buffer
|
||||||
if (unicode)
|
if (unicode)
|
||||||
{
|
|
||||||
_glfwInputChar((int) unicode_buf[i], action);
|
_glfwInputChar((int) unicode_buf[i], action);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_glfwInputChar((int) char_buf[i], action);
|
_glfwInputChar((int) char_buf[i], action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -698,9 +651,8 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
// Lock mouse, if necessary
|
// Lock mouse, if necessary
|
||||||
if (_glfwWin.oldMouseLockValid && _glfwWin.oldMouseLock)
|
if (_glfwWin.oldMouseLockValid && _glfwWin.oldMouseLock)
|
||||||
{
|
|
||||||
glfwDisable(GLFW_MOUSE_CURSOR);
|
glfwDisable(GLFW_MOUSE_CURSOR);
|
||||||
}
|
|
||||||
_glfwWin.oldMouseLockValid = GL_FALSE;
|
_glfwWin.oldMouseLockValid = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -717,15 +669,13 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
if (_glfwWin.fullscreen)
|
if (_glfwWin.fullscreen)
|
||||||
{
|
{
|
||||||
// Disallow screen saver and screen blanking if we are
|
// We are running in fullscreen mode, so disallow
|
||||||
// running in fullscreen mode
|
// screen saver and screen blanking
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// User trying to access application menu using ALT?
|
// User trying to access application menu using ALT?
|
||||||
case SC_KEYMENU:
|
case SC_KEYMENU:
|
||||||
@ -748,9 +698,8 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
_glfwInputKey(translateKey(wParam, lParam), GLFW_PRESS);
|
_glfwInputKey(translateKey(wParam, lParam), GLFW_PRESS);
|
||||||
|
|
||||||
if (_glfwWin.charCallback)
|
if (_glfwWin.charCallback)
|
||||||
{
|
|
||||||
translateChar((DWORD) wParam, (DWORD) lParam, GLFW_PRESS);
|
translateChar((DWORD) wParam, (DWORD) lParam, GLFW_PRESS);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -764,30 +713,35 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
_glfwInputKey(GLFW_KEY_RSHIFT, GLFW_RELEASE);
|
_glfwInputKey(GLFW_KEY_RSHIFT, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_glfwInputKey(translateKey(wParam, lParam), GLFW_RELEASE);
|
_glfwInputKey(translateKey(wParam, lParam), GLFW_RELEASE);
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfwWin.charCallback)
|
if (_glfwWin.charCallback)
|
||||||
{
|
|
||||||
translateChar((DWORD) wParam, (DWORD) lParam, GLFW_RELEASE);
|
translateChar((DWORD) wParam, (DWORD) lParam, GLFW_RELEASE);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
{
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
|
{
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
|
{
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_XBUTTONDOWN:
|
case WM_XBUTTONDOWN:
|
||||||
{
|
{
|
||||||
if (HIWORD(wParam) == XBUTTON1)
|
if (HIWORD(wParam) == XBUTTON1)
|
||||||
@ -800,21 +754,31 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_5, GLFW_PRESS);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_5, GLFW_PRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
|
{
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
|
{
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
|
{
|
||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_MIDDLE, GLFW_RELEASE);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_XBUTTONUP:
|
case WM_XBUTTONUP:
|
||||||
{
|
{
|
||||||
if (HIWORD(wParam) == XBUTTON1)
|
if (HIWORD(wParam) == XBUTTON1)
|
||||||
@ -827,6 +791,7 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
ReleaseCapture();
|
ReleaseCapture();
|
||||||
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_5, GLFW_RELEASE);
|
_glfwInputMouseClick(GLFW_MOUSE_BUTTON_5, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,6 +818,7 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
_glfwInput.MousePosX = NewMouseX;
|
_glfwInput.MousePosX = NewMouseX;
|
||||||
_glfwInput.MousePosY = NewMouseY;
|
_glfwInput.MousePosY = NewMouseY;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInput.OldMouseX = NewMouseX;
|
_glfwInput.OldMouseX = NewMouseX;
|
||||||
_glfwInput.OldMouseY = NewMouseY;
|
_glfwInput.OldMouseY = NewMouseY;
|
||||||
_glfwInput.MouseMoved = GL_TRUE;
|
_glfwInput.MouseMoved = GL_TRUE;
|
||||||
@ -863,6 +829,7 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
_glfwInput.MousePosY);
|
_glfwInput.MousePosY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,10 +840,10 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
wheelDelta = (((int)wParam) >> 16) / WHEEL_DELTA;
|
wheelDelta = (((int)wParam) >> 16) / WHEEL_DELTA;
|
||||||
_glfwInput.WheelPos += wheelDelta;
|
_glfwInput.WheelPos += wheelDelta;
|
||||||
|
|
||||||
if (_glfwWin.mouseWheelCallback)
|
if (_glfwWin.mouseWheelCallback)
|
||||||
{
|
|
||||||
_glfwWin.mouseWheelCallback(_glfwInput.WheelPos);
|
_glfwWin.mouseWheelCallback(_glfwInput.WheelPos);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -892,15 +859,12 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
RECT ClipWindowRect;
|
RECT ClipWindowRect;
|
||||||
if (GetWindowRect(_glfwWin.window, &ClipWindowRect))
|
if (GetWindowRect(_glfwWin.window, &ClipWindowRect))
|
||||||
{
|
|
||||||
ClipCursor(&ClipWindowRect);
|
ClipCursor(&ClipWindowRect);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfwWin.windowSizeCallback)
|
if (_glfwWin.windowSizeCallback)
|
||||||
{
|
|
||||||
_glfwWin.windowSizeCallback(LOWORD(lParam), HIWORD(lParam));
|
_glfwWin.windowSizeCallback(LOWORD(lParam), HIWORD(lParam));
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,10 +875,8 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
{
|
{
|
||||||
RECT ClipWindowRect;
|
RECT ClipWindowRect;
|
||||||
if (GetWindowRect(_glfwWin.window, &ClipWindowRect))
|
if (GetWindowRect(_glfwWin.window, &ClipWindowRect))
|
||||||
{
|
|
||||||
ClipCursor(&ClipWindowRect);
|
ClipCursor(&ClipWindowRect);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,9 +884,8 @@ static LRESULT CALLBACK windowProc( HWND hWnd, UINT uMsg,
|
|||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
{
|
{
|
||||||
if (_glfwWin.windowRefreshCallback)
|
if (_glfwWin.windowRefreshCallback)
|
||||||
{
|
|
||||||
_glfwWin.windowRefreshCallback();
|
_glfwWin.windowRefreshCallback();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -996,15 +957,11 @@ static void initWGLExtensions( void )
|
|||||||
_glfwWin.GetExtensionsStringARB = (WGLGETEXTENSIONSSTRINGARB_T)
|
_glfwWin.GetExtensionsStringARB = (WGLGETEXTENSIONSSTRINGARB_T)
|
||||||
wglGetProcAddress("wglGetExtensionsStringARB");
|
wglGetProcAddress("wglGetExtensionsStringARB");
|
||||||
if (!_glfwWin.GetExtensionsStringARB)
|
if (!_glfwWin.GetExtensionsStringARB)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfwPlatformExtensionSupported("WGL_ARB_multisample"))
|
if (_glfwPlatformExtensionSupported("WGL_ARB_multisample"))
|
||||||
{
|
|
||||||
_glfwWin.has_WGL_ARB_multisample = GL_TRUE;
|
_glfwWin.has_WGL_ARB_multisample = GL_TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context"))
|
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context"))
|
||||||
{
|
{
|
||||||
@ -1155,13 +1112,9 @@ static int createWindow( const _GLFWwndconfig *wndconfig,
|
|||||||
// the top of the display). Fullscreen windows are always opened in
|
// the top of the display). Fullscreen windows are always opened in
|
||||||
// the upper left corner regardless of the desktop working area.
|
// the upper left corner regardless of the desktop working area.
|
||||||
if (_glfwWin.fullscreen)
|
if (_glfwWin.fullscreen)
|
||||||
{
|
|
||||||
wa.left = wa.top = 0;
|
wa.left = wa.top = 0;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0);
|
||||||
}
|
|
||||||
|
|
||||||
_glfwWin.window = CreateWindowEx(_glfwWin.dwExStyle, // Extended style
|
_glfwWin.window = CreateWindowEx(_glfwWin.dwExStyle, // Extended style
|
||||||
_GLFW_WNDCLASSNAME, // Class name
|
_GLFW_WNDCLASSNAME, // Class name
|
||||||
@ -1255,9 +1208,9 @@ static void destroyWindow( void )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//**** Platform implementation functions ****
|
////// GLFW platform API //////
|
||||||
//************************************************************************
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Here is where the window is created, and the OpenGL rendering context is
|
// Here is where the window is created, and the OpenGL rendering context is
|
||||||
@ -1393,7 +1346,7 @@ void _glfwPlatformCloseWindow( void )
|
|||||||
|
|
||||||
void _glfwPlatformSetWindowTitle(const char* title)
|
void _glfwPlatformSetWindowTitle(const char* title)
|
||||||
{
|
{
|
||||||
(void) SetWindowText( _glfwWin.window, title );
|
SetWindowText(_glfwWin.window, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1427,10 +1380,8 @@ void _glfwPlatformSetWindowSize( int width, int height )
|
|||||||
&refresh);
|
&refresh);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
mode = _glfwWin.modeID;
|
mode = _glfwWin.modeID;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If we are in windowed mode, adjust the window size to
|
// If we are in windowed mode, adjust the window size to
|
||||||
@ -1538,9 +1489,8 @@ void _glfwPlatformRestoreWindow( void )
|
|||||||
|
|
||||||
// Lock mouse, if necessary
|
// Lock mouse, if necessary
|
||||||
if (_glfwWin.oldMouseLockValid && _glfwWin.oldMouseLock)
|
if (_glfwWin.oldMouseLockValid && _glfwWin.oldMouseLock)
|
||||||
{
|
|
||||||
glfwDisable(GLFW_MOUSE_CURSOR);
|
glfwDisable(GLFW_MOUSE_CURSOR);
|
||||||
}
|
|
||||||
_glfwWin.oldMouseLockValid = GL_FALSE;
|
_glfwWin.oldMouseLockValid = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1562,10 +1512,8 @@ void _glfwPlatformSwapBuffers( void )
|
|||||||
void _glfwPlatformSwapInterval(int interval)
|
void _glfwPlatformSwapInterval(int interval)
|
||||||
{
|
{
|
||||||
if (_glfwWin.has_WGL_EXT_swap_control)
|
if (_glfwWin.has_WGL_EXT_swap_control)
|
||||||
{
|
|
||||||
_glfwWin.SwapIntervalEXT(interval);
|
_glfwWin.SwapIntervalEXT(interval);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -1589,9 +1537,7 @@ void _glfwPlatformRefreshWindowParams( void )
|
|||||||
_glfwWin.accelerated = GL_TRUE;
|
_glfwWin.accelerated = GL_TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_glfwWin.accelerated = GL_FALSE;
|
_glfwWin.accelerated = GL_FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
_glfwWin.redBits = getPixelFormatAttrib(pixelFormat, WGL_RED_BITS_ARB);
|
_glfwWin.redBits = getPixelFormatAttrib(pixelFormat, WGL_RED_BITS_ARB);
|
||||||
_glfwWin.greenBits = getPixelFormatAttrib(pixelFormat, WGL_GREEN_BITS_ARB);
|
_glfwWin.greenBits = getPixelFormatAttrib(pixelFormat, WGL_GREEN_BITS_ARB);
|
||||||
@ -1615,10 +1561,8 @@ void _glfwPlatformRefreshWindowParams( void )
|
|||||||
// Should we force 1 to 0 here for consistency, or keep 1 for transparency?
|
// Should we force 1 to 0 here for consistency, or keep 1 for transparency?
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_glfwWin.samples = 0;
|
_glfwWin.samples = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_glfw_DescribePixelFormat(_glfwWin.DC, pixelFormat,
|
_glfw_DescribePixelFormat(_glfwWin.DC, pixelFormat,
|
||||||
@ -1655,15 +1599,11 @@ void _glfwPlatformRefreshWindowParams( void )
|
|||||||
{
|
{
|
||||||
_glfwWin.refreshRate = dm.dmDisplayFrequency;
|
_glfwWin.refreshRate = dm.dmDisplayFrequency;
|
||||||
if (_glfwWin.refreshRate <= 1)
|
if (_glfwWin.refreshRate <= 1)
|
||||||
{
|
|
||||||
_glfwWin.refreshRate = 0;
|
_glfwWin.refreshRate = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_glfwWin.refreshRate = 0;
|
_glfwWin.refreshRate = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -1696,15 +1636,19 @@ void _glfwPlatformPollEvents( void )
|
|||||||
{
|
{
|
||||||
// QUIT-message (from close window)?
|
// QUIT-message (from close window)?
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
|
{
|
||||||
winclosed = GL_TRUE;
|
winclosed = GL_TRUE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Ok, send it to the window message handler
|
// Ok, send it to the window message handler
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
|
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
|
||||||
// This is the only async event handling in GLFW, but it solves some
|
// This is the only async event handling in GLFW, but it solves some
|
||||||
@ -1721,14 +1665,11 @@ void _glfwPlatformPollEvents( void )
|
|||||||
// See if this differs from our belief of what has happened
|
// See if this differs from our belief of what has happened
|
||||||
// (we only have to check for lost key up events)
|
// (we only have to check for lost key up events)
|
||||||
if (!lshift_down && _glfwInput.Key[ GLFW_KEY_LSHIFT ] == 1)
|
if (!lshift_down && _glfwInput.Key[ GLFW_KEY_LSHIFT ] == 1)
|
||||||
{
|
|
||||||
_glfwInputKey(GLFW_KEY_LSHIFT, GLFW_RELEASE);
|
_glfwInputKey(GLFW_KEY_LSHIFT, GLFW_RELEASE);
|
||||||
}
|
|
||||||
if (!rshift_down && _glfwInput.Key[ GLFW_KEY_RSHIFT ] == 1)
|
if (!rshift_down && _glfwInput.Key[ GLFW_KEY_RSHIFT ] == 1)
|
||||||
{
|
|
||||||
_glfwInputKey(GLFW_KEY_RSHIFT, GLFW_RELEASE);
|
_glfwInputKey(GLFW_KEY_RSHIFT, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Did we have mouse movement in locked cursor mode?
|
// Did we have mouse movement in locked cursor mode?
|
||||||
if (_glfwInput.MouseMoved && _glfwWin.mouseLock)
|
if (_glfwInput.MouseMoved && _glfwWin.mouseLock)
|
||||||
@ -1744,10 +1685,8 @@ void _glfwPlatformPollEvents( void )
|
|||||||
winclosed = _glfwWin.windowCloseCallback();
|
winclosed = _glfwWin.windowCloseCallback();
|
||||||
}
|
}
|
||||||
if (winclosed)
|
if (winclosed)
|
||||||
{
|
|
||||||
glfwCloseWindow();
|
glfwCloseWindow();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -1774,9 +1713,7 @@ void _glfwPlatformHideMouseCursor( void )
|
|||||||
|
|
||||||
// Clip cursor to the window
|
// Clip cursor to the window
|
||||||
if (GetWindowRect(_glfwWin.window, &ClipWindowRect))
|
if (GetWindowRect(_glfwWin.window, &ClipWindowRect))
|
||||||
{
|
|
||||||
ClipCursor(&ClipWindowRect);
|
ClipCursor(&ClipWindowRect);
|
||||||
}
|
|
||||||
|
|
||||||
// Capture cursor to user window
|
// Capture cursor to user window
|
||||||
SetCapture(_glfwWin.window);
|
SetCapture(_glfwWin.window);
|
||||||
|
Loading…
Reference in New Issue
Block a user