2010-09-07 11:34:51 -04:00
|
|
|
//========================================================================
|
2014-01-21 19:32:00 -05:00
|
|
|
// GLFW 3.1 Win32 - www.glfw.org
|
2010-09-07 11:34:51 -04:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
|
|
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
// arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
// in a product, an acknowledgment in the product documentation would
|
|
|
|
// be appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not
|
|
|
|
// be misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
// distribution.
|
|
|
|
//
|
|
|
|
//========================================================================
|
|
|
|
|
2012-11-27 06:58:59 -05:00
|
|
|
#ifndef _win32_platform_h_
|
|
|
|
#define _win32_platform_h_
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
// We don't need all the fancy stuff
|
2012-03-29 17:41:05 -04:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
#define NOMINMAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VC_EXTRALEAN
|
|
|
|
#define VC_EXTRALEAN
|
|
|
|
#endif
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2011-07-27 11:09:17 -04:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
|
|
|
|
2014-08-20 11:49:58 -04:00
|
|
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
|
|
|
// example to allow applications to correctly declare a GL_ARB_debug_output
|
|
|
|
// callback) but windows.h assumes no one will define APIENTRY before it does
|
2012-01-18 12:44:28 -05:00
|
|
|
#undef APIENTRY
|
|
|
|
|
2012-02-04 20:41:52 -05:00
|
|
|
// GLFW on Windows is Unicode only and does not work in MBCS mode
|
|
|
|
#ifndef UNICODE
|
|
|
|
#define UNICODE
|
|
|
|
#endif
|
|
|
|
|
2013-09-03 07:38:16 -04:00
|
|
|
// GLFW requires Windows XP or later
|
2013-09-13 06:27:43 -04:00
|
|
|
#if WINVER < 0x0501
|
|
|
|
#undef WINVER
|
2012-03-29 19:55:28 -04:00
|
|
|
#define WINVER 0x0501
|
2012-03-22 09:58:14 -04:00
|
|
|
#endif
|
2013-09-13 06:27:43 -04:00
|
|
|
#if _WIN32_WINNT < 0x0501
|
|
|
|
#undef _WIN32_WINNT
|
2013-09-03 07:38:16 -04:00
|
|
|
#define _WIN32_WINNT 0x0501
|
|
|
|
#endif
|
2012-02-03 14:34:24 -05:00
|
|
|
|
2014-03-31 16:33:22 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
|
|
|
#include <dbt.h>
|
|
|
|
|
2014-03-06 15:05:55 -05:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#include <malloc.h>
|
|
|
|
#define strdup _strdup
|
|
|
|
#endif
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2014-09-02 13:42:43 -04:00
|
|
|
// HACK: Define macros that some older windows.h variants don't
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2010-09-26 20:32:41 -04:00
|
|
|
#ifndef WM_MOUSEHWHEEL
|
2012-02-04 20:43:49 -05:00
|
|
|
#define WM_MOUSEHWHEEL 0x020E
|
2010-09-07 11:34:51 -04:00
|
|
|
#endif
|
2013-03-11 15:54:32 -04:00
|
|
|
#ifndef WM_DWMCOMPOSITIONCHANGED
|
|
|
|
#define WM_DWMCOMPOSITIONCHANGED 0x031E
|
|
|
|
#endif
|
2014-02-10 09:03:23 -05:00
|
|
|
#ifndef WM_COPYGLOBALDATA
|
|
|
|
#define WM_COPYGLOBALDATA 0x0049
|
|
|
|
#endif
|
2014-03-06 17:33:09 -05:00
|
|
|
#ifndef WM_UNICHAR
|
|
|
|
#define WM_UNICHAR 0x0109
|
|
|
|
#endif
|
|
|
|
#ifndef UNICODE_NOCHAR
|
|
|
|
#define UNICODE_NOCHAR 0xFFFF
|
|
|
|
#endif
|
2014-02-10 09:03:23 -05:00
|
|
|
|
2014-02-10 15:12:20 -05:00
|
|
|
#if WINVER < 0x0601
|
2014-02-10 09:03:23 -05:00
|
|
|
typedef struct tagCHANGEFILTERSTRUCT
|
|
|
|
{
|
|
|
|
DWORD cbSize;
|
|
|
|
DWORD ExtStatus;
|
2014-02-10 15:12:20 -05:00
|
|
|
|
2014-02-10 09:03:23 -05:00
|
|
|
} CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT;
|
2014-02-10 15:12:20 -05:00
|
|
|
#ifndef MSGFLT_ALLOW
|
|
|
|
#define MSGFLT_ALLOW 1
|
|
|
|
#endif
|
|
|
|
#endif /*Windows 7*/
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
// winmm.dll function pointer typedefs
|
2014-08-15 08:50:41 -04:00
|
|
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T)(UINT,LPJOYCAPS,UINT);
|
|
|
|
typedef MMRESULT (WINAPI * JOYGETPOS_T)(UINT,LPJOYINFO);
|
|
|
|
typedef MMRESULT (WINAPI * JOYGETPOSEX_T)(UINT,LPJOYINFOEX);
|
|
|
|
typedef DWORD (WINAPI * TIMEGETTIME_T)(void);
|
|
|
|
#define _glfw_joyGetDevCaps _glfw.win32.winmm.joyGetDevCaps
|
|
|
|
#define _glfw_joyGetPos _glfw.win32.winmm.joyGetPos
|
|
|
|
#define _glfw_joyGetPosEx _glfw.win32.winmm.joyGetPosEx
|
|
|
|
#define _glfw_timeGetTime _glfw.win32.winmm.timeGetTime
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-03-10 14:23:42 -04:00
|
|
|
// user32.dll function pointer typedefs
|
|
|
|
typedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);
|
2014-02-10 09:03:23 -05:00
|
|
|
typedef BOOL (WINAPI * CHANGEWINDOWMESSAGEFILTEREX_T)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);
|
2013-03-10 14:23:42 -04:00
|
|
|
#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
|
2014-02-10 09:03:23 -05:00
|
|
|
#define _glfw_ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx
|
2013-03-10 14:23:42 -04:00
|
|
|
|
2013-03-11 15:54:32 -04:00
|
|
|
// dwmapi.dll function pointer typedefs
|
|
|
|
typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);
|
|
|
|
#define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2012-12-13 16:43:23 -05:00
|
|
|
#define _GLFW_RECREATION_NOT_NEEDED 0
|
|
|
|
#define _GLFW_RECREATION_REQUIRED 1
|
|
|
|
#define _GLFW_RECREATION_IMPOSSIBLE 2
|
|
|
|
|
2010-09-13 20:17:18 -04:00
|
|
|
|
2014-03-30 08:37:20 -04:00
|
|
|
#include "win32_tls.h"
|
|
|
|
|
2012-11-27 09:02:26 -05:00
|
|
|
#if defined(_GLFW_WGL)
|
2014-04-08 10:25:35 -04:00
|
|
|
#include "wgl_context.h"
|
2012-11-27 09:02:26 -05:00
|
|
|
#elif defined(_GLFW_EGL)
|
2013-01-01 19:40:42 -05:00
|
|
|
#define _GLFW_EGL_NATIVE_WINDOW window->win32.handle
|
2013-03-24 16:19:53 -04:00
|
|
|
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
|
2014-04-08 10:25:35 -04:00
|
|
|
#include "egl_context.h"
|
2012-12-02 13:01:20 -05:00
|
|
|
#else
|
|
|
|
#error "No supported context creation API selected"
|
2012-11-27 06:58:59 -05:00
|
|
|
#endif
|
2010-09-10 16:26:17 -04:00
|
|
|
|
2014-03-19 10:27:49 -04:00
|
|
|
#include "winmm_joystick.h"
|
|
|
|
|
2013-01-01 19:40:42 -05:00
|
|
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
|
|
|
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
|
2014-03-27 12:19:22 -04:00
|
|
|
#define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimeWin32 win32_time
|
2013-01-01 19:40:42 -05:00
|
|
|
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
|
2013-12-04 08:19:22 -05:00
|
|
|
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32
|
2010-09-10 16:26:17 -04:00
|
|
|
|
|
|
|
|
2014-09-02 13:42:43 -04:00
|
|
|
// Win32-specific per-window data
|
|
|
|
//
|
2010-09-10 16:26:17 -04:00
|
|
|
typedef struct _GLFWwindowWin32
|
|
|
|
{
|
2014-09-02 13:42:43 -04:00
|
|
|
HWND handle;
|
|
|
|
DWORD dwStyle;
|
|
|
|
DWORD dwExStyle;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-01-02 10:48:02 -05:00
|
|
|
GLboolean cursorCentered;
|
|
|
|
GLboolean cursorInside;
|
2013-04-14 09:36:10 -04:00
|
|
|
GLboolean cursorHidden;
|
2013-11-13 06:19:43 -05:00
|
|
|
int oldCursorX, oldCursorY;
|
2014-09-02 13:42:43 -04:00
|
|
|
|
2010-09-10 16:26:17 -04:00
|
|
|
} _GLFWwindowWin32;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
2014-09-02 13:42:43 -04:00
|
|
|
// Win32-specific global data
|
|
|
|
//
|
2010-09-10 16:26:17 -04:00
|
|
|
typedef struct _GLFWlibraryWin32
|
|
|
|
{
|
2013-01-02 10:48:02 -05:00
|
|
|
DWORD foregroundLockTimeout;
|
|
|
|
char* clipboardString;
|
2010-09-10 16:26:17 -04:00
|
|
|
|
2010-09-13 22:27:02 -04:00
|
|
|
// winmm.dll
|
|
|
|
struct {
|
2013-01-02 10:48:02 -05:00
|
|
|
HINSTANCE instance;
|
|
|
|
JOYGETDEVCAPS_T joyGetDevCaps;
|
|
|
|
JOYGETPOS_T joyGetPos;
|
|
|
|
JOYGETPOSEX_T joyGetPosEx;
|
|
|
|
TIMEGETTIME_T timeGetTime;
|
2010-09-13 22:27:02 -04:00
|
|
|
} winmm;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-03-10 14:23:42 -04:00
|
|
|
// user32.dll
|
|
|
|
struct {
|
2013-03-11 15:54:32 -04:00
|
|
|
HINSTANCE instance;
|
2013-03-10 14:23:42 -04:00
|
|
|
SETPROCESSDPIAWARE_T SetProcessDPIAware;
|
2014-02-10 09:03:23 -05:00
|
|
|
CHANGEWINDOWMESSAGEFILTEREX_T ChangeWindowMessageFilterEx;
|
2013-03-10 14:23:42 -04:00
|
|
|
} user32;
|
|
|
|
|
2013-03-11 15:54:32 -04:00
|
|
|
// dwmapi.dll
|
|
|
|
struct {
|
|
|
|
HINSTANCE instance;
|
|
|
|
DWMISCOMPOSITIONENABLED_T DwmIsCompositionEnabled;
|
|
|
|
} dwmapi;
|
|
|
|
|
2010-09-10 16:26:17 -04:00
|
|
|
} _GLFWlibraryWin32;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2012-09-12 14:46:54 -04:00
|
|
|
|
2014-09-02 13:42:43 -04:00
|
|
|
// Win32-specific per-monitor data
|
|
|
|
//
|
2011-10-03 03:24:35 -04:00
|
|
|
typedef struct _GLFWmonitorWin32
|
2011-10-02 16:13:47 -04:00
|
|
|
{
|
2013-02-20 09:44:37 -05:00
|
|
|
// This size matches the static size of DISPLAY_DEVICE.DeviceName
|
2014-09-12 11:00:05 -04:00
|
|
|
WCHAR adapterName[32];
|
|
|
|
WCHAR displayName[32];
|
2014-09-12 11:03:44 -04:00
|
|
|
char nativeName[64];
|
2014-02-13 08:23:16 -05:00
|
|
|
GLboolean modeChanged;
|
2011-10-06 17:28:56 -04:00
|
|
|
|
2011-10-03 03:24:35 -04:00
|
|
|
} _GLFWmonitorWin32;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2012-09-12 14:46:54 -04:00
|
|
|
|
2014-09-02 13:42:43 -04:00
|
|
|
// Win32-specific per-cursor data
|
|
|
|
//
|
2013-12-04 08:19:22 -05:00
|
|
|
typedef struct _GLFWcursorWin32
|
|
|
|
{
|
|
|
|
HCURSOR handle;
|
2014-09-02 13:42:43 -04:00
|
|
|
|
2013-12-04 08:19:22 -05:00
|
|
|
} _GLFWcursorWin32;
|
|
|
|
|
|
|
|
|
2014-09-02 13:42:43 -04:00
|
|
|
// Win32-specific global timer data
|
|
|
|
//
|
2014-03-27 12:19:22 -04:00
|
|
|
typedef struct _GLFWtimeWin32
|
|
|
|
{
|
|
|
|
GLboolean hasPC;
|
|
|
|
double resolution;
|
|
|
|
unsigned __int64 base;
|
|
|
|
|
|
|
|
} _GLFWtimeWin32;
|
|
|
|
|
|
|
|
|
2014-08-31 08:17:31 -04:00
|
|
|
GLboolean _glfwRegisterWindowClass(void);
|
|
|
|
void _glfwUnregisterWindowClass(void);
|
|
|
|
|
2013-03-11 15:54:32 -04:00
|
|
|
BOOL _glfwIsCompositionEnabled(void);
|
|
|
|
|
2012-02-04 20:07:50 -05:00
|
|
|
WCHAR* _glfwCreateWideStringFromUTF8(const char* source);
|
|
|
|
char* _glfwCreateUTF8FromWideString(const WCHAR* source);
|
|
|
|
|
2010-09-10 16:26:17 -04:00
|
|
|
void _glfwInitTimer(void);
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-04-21 15:28:07 -04:00
|
|
|
GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
2013-01-02 11:29:24 -05:00
|
|
|
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2012-11-27 06:58:59 -05:00
|
|
|
#endif // _win32_platform_h_
|