1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2025-01-30 19:08:51 -05:00

Made use of Win32 W-suffixed symbols explicit.

This commit is contained in:
Camilla Berglund 2014-03-06 18:30:14 +01:00
parent d169557b00
commit 0701d4ce6e
5 changed files with 79 additions and 79 deletions

View File

@ -306,7 +306,7 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
// //
int _glfwInitContextAPI(void) int _glfwInitContextAPI(void)
{ {
_glfw.wgl.opengl32.instance = LoadLibrary(L"opengl32.dll"); _glfw.wgl.opengl32.instance = LoadLibraryW(L"opengl32.dll");
if (!_glfw.wgl.opengl32.instance) if (!_glfw.wgl.opengl32.instance)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "Failed to load opengl32.dll"); _glfwInputError(GLFW_PLATFORM_ERROR, "Failed to load opengl32.dll");

View File

@ -37,13 +37,13 @@ void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
HDC dc; HDC dc;
WORD values[768]; WORD values[768];
DISPLAY_DEVICE display; DISPLAY_DEVICEW display;
ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));
display.cb = sizeof(DISPLAY_DEVICE); display.cb = sizeof(DISPLAY_DEVICEW);
EnumDisplayDevices(monitor->win32.name, 0, &display, 0); EnumDisplayDevicesW(monitor->win32.name, 0, &display, 0);
dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); dc = CreateDCW(L"DISPLAY", display.DeviceString, NULL, NULL);
GetDeviceGammaRamp(dc, values); GetDeviceGammaRamp(dc, values);
DeleteDC(dc); DeleteDC(dc);
@ -71,11 +71,11 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short)); memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short));
memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short)); memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short));
ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));
display.cb = sizeof(DISPLAY_DEVICE); display.cb = sizeof(DISPLAY_DEVICEW);
EnumDisplayDevices(monitor->win32.name, 0, &display, 0); EnumDisplayDevicesW(monitor->win32.name, 0, &display, 0);
dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); dc = CreateDCW(L"DISPLAY", display.DeviceString, NULL, NULL);
SetDeviceGammaRamp(dc, values); SetDeviceGammaRamp(dc, values);
DeleteDC(dc); DeleteDC(dc);
} }

View File

@ -63,7 +63,7 @@ static GLboolean initLibraries(void)
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
// winmm.dll (for joystick and timer support) // winmm.dll (for joystick and timer support)
_glfw.win32.winmm.instance = LoadLibrary(L"winmm.dll"); _glfw.win32.winmm.instance = LoadLibraryW(L"winmm.dll");
if (!_glfw.win32.winmm.instance) if (!_glfw.win32.winmm.instance)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@ -91,7 +91,7 @@ static GLboolean initLibraries(void)
} }
#endif // _GLFW_NO_DLOAD_WINMM #endif // _GLFW_NO_DLOAD_WINMM
_glfw.win32.user32.instance = LoadLibrary(L"user32.dll"); _glfw.win32.user32.instance = LoadLibraryW(L"user32.dll");
if (_glfw.win32.user32.instance) if (_glfw.win32.user32.instance)
{ {
_glfw.win32.user32.SetProcessDPIAware = (SETPROCESSDPIAWARE_T) _glfw.win32.user32.SetProcessDPIAware = (SETPROCESSDPIAWARE_T)
@ -100,7 +100,7 @@ static GLboolean initLibraries(void)
GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx"); GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
} }
_glfw.win32.dwmapi.instance = LoadLibrary(L"dwmapi.dll"); _glfw.win32.dwmapi.instance = LoadLibraryW(L"dwmapi.dll");
if (_glfw.win32.dwmapi.instance) if (_glfw.win32.dwmapi.instance)
{ {
_glfw.win32.dwmapi.DwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED_T) _glfw.win32.dwmapi.DwmIsCompositionEnabled = (DWMISCOMPOSITIONENABLED_T)
@ -203,10 +203,10 @@ int _glfwPlatformInit(void)
// 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, SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
&_glfw.win32.foregroundLockTimeout, 0); &_glfw.win32.foregroundLockTimeout, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0), SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
SPIF_SENDCHANGE); SPIF_SENDCHANGE);
if (!initLibraries()) if (!initLibraries())
return GL_FALSE; return GL_FALSE;
@ -233,14 +233,14 @@ void _glfwPlatformTerminate(void)
{ {
if (_glfw.win32.classAtom) if (_glfw.win32.classAtom)
{ {
UnregisterClass(_GLFW_WNDCLASSNAME, GetModuleHandle(NULL)); UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
_glfw.win32.classAtom = 0; _glfw.win32.classAtom = 0;
} }
// Restore previous foreground lock timeout system setting // Restore previous foreground lock timeout system setting
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
UIntToPtr(_glfw.win32.foregroundLockTimeout), UIntToPtr(_glfw.win32.foregroundLockTimeout),
SPIF_SENDCHANGE); SPIF_SENDCHANGE);
free(_glfw.win32.clipboardString); free(_glfw.win32.clipboardString);

View File

@ -51,7 +51,7 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{ {
GLFWvidmode current; GLFWvidmode current;
const GLFWvidmode* best; const GLFWvidmode* best;
DEVMODE dm; DEVMODEW dm;
best = _glfwChooseVideoMode(monitor, desired); best = _glfwChooseVideoMode(monitor, desired);
@ -60,7 +60,7 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
return GL_TRUE; return GL_TRUE;
ZeroMemory(&dm, sizeof(dm)); ZeroMemory(&dm, sizeof(dm));
dm.dmSize = sizeof(DEVMODE); dm.dmSize = sizeof(DEVMODEW);
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
DM_DISPLAYFREQUENCY; DM_DISPLAYFREQUENCY;
dm.dmPelsWidth = best->width; dm.dmPelsWidth = best->width;
@ -71,11 +71,11 @@ GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24) if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
dm.dmBitsPerPel = 32; dm.dmBitsPerPel = 32;
if (ChangeDisplaySettingsEx(monitor->win32.name, if (ChangeDisplaySettingsExW(monitor->win32.name,
&dm, &dm,
NULL, NULL,
CDS_FULLSCREEN, CDS_FULLSCREEN,
NULL) != DISP_CHANGE_SUCCESSFUL) NULL) != DISP_CHANGE_SUCCESSFUL)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to set video mode"); _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to set video mode");
return GL_FALSE; return GL_FALSE;
@ -91,8 +91,8 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
{ {
if (monitor->win32.modeChanged) if (monitor->win32.modeChanged)
{ {
ChangeDisplaySettingsEx(monitor->win32.name, ChangeDisplaySettingsExW(monitor->win32.name,
NULL, NULL, CDS_FULLSCREEN, NULL); NULL, NULL, CDS_FULLSCREEN, NULL);
monitor->win32.modeChanged = GL_FALSE; monitor->win32.modeChanged = GL_FALSE;
} }
} }
@ -113,14 +113,14 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
for (;;) for (;;)
{ {
DISPLAY_DEVICE adapter, display; DISPLAY_DEVICEW adapter, display;
char* name; char* name;
HDC dc; HDC dc;
ZeroMemory(&adapter, sizeof(DISPLAY_DEVICE)); ZeroMemory(&adapter, sizeof(DISPLAY_DEVICEW));
adapter.cb = sizeof(DISPLAY_DEVICE); adapter.cb = sizeof(DISPLAY_DEVICEW);
if (!EnumDisplayDevices(NULL, adapterIndex, &adapter, 0)) if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
break; break;
adapterIndex++; adapterIndex++;
@ -141,11 +141,11 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
monitors = (_GLFWmonitor**) realloc(monitors, sizeof(_GLFWmonitor*) * size); monitors = (_GLFWmonitor**) realloc(monitors, sizeof(_GLFWmonitor*) * size);
} }
ZeroMemory(&display, sizeof(DISPLAY_DEVICE)); ZeroMemory(&display, sizeof(DISPLAY_DEVICEW));
display.cb = sizeof(DISPLAY_DEVICE); display.cb = sizeof(DISPLAY_DEVICEW);
EnumDisplayDevices(adapter.DeviceName, 0, &display, 0); EnumDisplayDevicesW(adapter.DeviceName, 0, &display, 0);
dc = CreateDC(L"DISPLAY", display.DeviceString, NULL, NULL); dc = CreateDCW(L"DISPLAY", display.DeviceString, NULL, NULL);
if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
primaryIndex = found; primaryIndex = found;
@ -190,14 +190,14 @@ GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos) void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{ {
DEVMODE settings; DEVMODEW settings;
ZeroMemory(&settings, sizeof(DEVMODE)); ZeroMemory(&settings, sizeof(DEVMODEW));
settings.dmSize = sizeof(DEVMODE); settings.dmSize = sizeof(DEVMODEW);
EnumDisplaySettingsEx(monitor->win32.name, EnumDisplaySettingsExW(monitor->win32.name,
ENUM_CURRENT_SETTINGS, ENUM_CURRENT_SETTINGS,
&settings, &settings,
EDS_ROTATEDMODE); EDS_ROTATEDMODE);
if (xpos) if (xpos)
*xpos = settings.dmPosition.x; *xpos = settings.dmPosition.x;
@ -216,12 +216,12 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
{ {
int i; int i;
GLFWvidmode mode; GLFWvidmode mode;
DEVMODE dm; DEVMODEW dm;
ZeroMemory(&dm, sizeof(DEVMODE)); ZeroMemory(&dm, sizeof(DEVMODEW));
dm.dmSize = sizeof(DEVMODE); dm.dmSize = sizeof(DEVMODEW);
if (!EnumDisplaySettings(monitor->win32.name, modeIndex, &dm)) if (!EnumDisplaySettingsW(monitor->win32.name, modeIndex, &dm))
break; break;
modeIndex++; modeIndex++;
@ -271,12 +271,12 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode) void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
DEVMODE dm; DEVMODEW dm;
ZeroMemory(&dm, sizeof(DEVMODE)); ZeroMemory(&dm, sizeof(DEVMODEW));
dm.dmSize = sizeof(DEVMODE); dm.dmSize = sizeof(DEVMODEW);
EnumDisplaySettings(monitor->win32.name, ENUM_CURRENT_SETTINGS, &dm); EnumDisplaySettingsW(monitor->win32.name, ENUM_CURRENT_SETTINGS, &dm);
mode->width = dm.dmPelsWidth; mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight; mode->height = dm.dmPelsHeight;

View File

@ -100,7 +100,7 @@ static void restoreCursor(_GLFWwindow* window)
if (GetCursorPos(&pos)) if (GetCursorPos(&pos))
{ {
if (WindowFromPoint(pos) == window->win32.handle) if (WindowFromPoint(pos) == window->win32.handle)
SetCursor(LoadCursor(NULL, IDC_ARROW)); SetCursor(LoadCursorW(NULL, IDC_ARROW));
} }
} }
@ -201,7 +201,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
// is a RALT message. In that case, this is a false LCTRL! // is a RALT message. In that case, this is a false LCTRL!
time = GetMessageTime(); time = GetMessageTime();
if (PeekMessage(&next, NULL, 0, 0, PM_NOREMOVE)) if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))
{ {
if (next.message == WM_KEYDOWN || if (next.message == WM_KEYDOWN ||
next.message == WM_SYSKEYDOWN || next.message == WM_SYSKEYDOWN ||
@ -369,14 +369,14 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
_GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtr(hWnd, 0); _GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0);
switch (uMsg) switch (uMsg)
{ {
case WM_CREATE: case WM_CREATE:
{ {
CREATESTRUCT* cs = (CREATESTRUCT*) lParam; CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam;
SetWindowLongPtr(hWnd, 0, (LONG_PTR) cs->lpCreateParams); SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams);
break; break;
} }
@ -755,7 +755,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
POINT pt; POINT pt;
int i; int i;
const int count = DragQueryFile(hDrop, 0xffffffff, NULL, 0); const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0);
char** names = calloc(count, sizeof(char*)); char** names = calloc(count, sizeof(char*));
// Move the mouse to the position of the drop // Move the mouse to the position of the drop
@ -764,10 +764,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
const UINT length = DragQueryFile(hDrop, i, NULL, 0); const UINT length = DragQueryFileW(hDrop, i, NULL, 0);
WCHAR* buffer = calloc(length + 1, sizeof(WCHAR)); WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
DragQueryFile(hDrop, i, buffer, length + 1); DragQueryFileW(hDrop, i, buffer, length + 1);
names[i] = _glfwCreateUTF8FromWideString(buffer); names[i] = _glfwCreateUTF8FromWideString(buffer);
free(buffer); free(buffer);
@ -812,21 +812,21 @@ static ATOM registerWindowClass(void)
wc.lpfnWndProc = (WNDPROC) windowProc; wc.lpfnWndProc = (WNDPROC) windowProc;
wc.cbClsExtra = 0; // No extra class data wc.cbClsExtra = 0; // No extra class data
wc.cbWndExtra = sizeof(void*) + sizeof(int); // Make room for one pointer wc.cbWndExtra = sizeof(void*) + sizeof(int); // Make room for one pointer
wc.hInstance = GetModuleHandle(NULL); wc.hInstance = GetModuleHandleW(NULL);
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.hbrBackground = NULL; // No background wc.hbrBackground = NULL; // No background
wc.lpszMenuName = NULL; // No menu wc.lpszMenuName = NULL; // No menu
wc.lpszClassName = _GLFW_WNDCLASSNAME; wc.lpszClassName = _GLFW_WNDCLASSNAME;
// Load user-provided icon if available // Load user-provided icon if available
wc.hIcon = LoadIcon(GetModuleHandle(NULL), L"GLFW_ICON"); wc.hIcon = LoadIconW(GetModuleHandleW(NULL), L"GLFW_ICON");
if (!wc.hIcon) if (!wc.hIcon)
{ {
// No user-provided icon found, load default icon // No user-provided icon found, load default icon
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIcon = LoadIconW(NULL, IDI_WINLOGO);
} }
classAtom = RegisterClass(&wc); classAtom = RegisterClassW(&wc);
if (!classAtom) if (!classAtom)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@ -888,16 +888,16 @@ static int createWindow(_GLFWwindow* window,
return GL_FALSE; return GL_FALSE;
} }
window->win32.handle = CreateWindowEx(window->win32.dwExStyle, window->win32.handle = CreateWindowExW(window->win32.dwExStyle,
_GLFW_WNDCLASSNAME, _GLFW_WNDCLASSNAME,
wideTitle, wideTitle,
window->win32.dwStyle, window->win32.dwStyle,
xpos, ypos, xpos, ypos,
fullWidth, fullHeight, fullWidth, fullHeight,
NULL, // No parent window NULL, // No parent window
NULL, // No window menu NULL, // No window menu
GetModuleHandle(NULL), GetModuleHandleW(NULL),
window); // Pass object to WM_CREATE window); // Pass object to WM_CREATE
free(wideTitle); free(wideTitle);
@ -1027,7 +1027,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
return; return;
} }
SetWindowText(window->win32.handle, wideTitle); SetWindowTextW(window->win32.handle, wideTitle);
free(wideTitle); free(wideTitle);
} }
@ -1118,7 +1118,7 @@ void _glfwPlatformPollEvents(void)
MSG msg; MSG msg;
_GLFWwindow* window; _GLFWwindow* window;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
{ {
if (msg.message == WM_QUIT) if (msg.message == WM_QUIT)
{ {
@ -1134,7 +1134,7 @@ void _glfwPlatformPollEvents(void)
else else
{ {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessageW(&msg);
} }
} }