2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
2013-07-29 18:53:17 +00:00
|
|
|
// GLFW 3.0 Win32 - www.glfw.org
|
2010-09-07 15:34:51 +00: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 11:58:59 +00:00
|
|
|
#ifndef _win32_platform_h_
|
|
|
|
#define _win32_platform_h_
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
// We don't need all the fancy stuff
|
2012-03-29 21:41:05 +00:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
#define NOMINMAX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef VC_EXTRALEAN
|
|
|
|
#define VC_EXTRALEAN
|
|
|
|
#endif
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2011-07-27 15:09:17 +00:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
|
|
|
|
2012-01-18 17:44:28 +00:00
|
|
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (to
|
|
|
|
// correctly declare a GL_ARB_debug_output callback, for example) but windows.h
|
|
|
|
// thinks it is the only one that gets to do so
|
|
|
|
#undef APIENTRY
|
|
|
|
|
2012-02-05 01:41:52 +00:00
|
|
|
// GLFW on Windows is Unicode only and does not work in MBCS mode
|
|
|
|
#ifndef UNICODE
|
|
|
|
#define UNICODE
|
|
|
|
#endif
|
|
|
|
|
2013-09-03 11:38:16 +00:00
|
|
|
// GLFW requires Windows XP or later
|
2013-09-13 10:27:43 +00:00
|
|
|
#if WINVER < 0x0501
|
|
|
|
#undef WINVER
|
2012-03-29 23:55:28 +00:00
|
|
|
#define WINVER 0x0501
|
2012-03-22 13:58:14 +00:00
|
|
|
#endif
|
2013-09-13 10:27:43 +00:00
|
|
|
#if _WIN32_WINNT < 0x0501
|
|
|
|
#undef _WIN32_WINNT
|
2013-09-03 11:38:16 +00:00
|
|
|
#define _WIN32_WINNT 0x0501
|
|
|
|
#endif
|
2012-02-03 19:34:24 +00:00
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
2012-01-31 22:47:01 +00:00
|
|
|
#include <dbt.h>
|
2010-09-14 02:55:41 +00:00
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
//========================================================================
|
2010-09-14 02:55:41 +00:00
|
|
|
// Hack: Define things that some windows.h variants don't
|
2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
|
|
|
|
2010-09-27 00:32:41 +00:00
|
|
|
#ifndef WM_MOUSEHWHEEL
|
2012-02-05 01:43:49 +00:00
|
|
|
#define WM_MOUSEHWHEEL 0x020E
|
2010-09-07 15:34:51 +00:00
|
|
|
#endif
|
2013-03-11 19:54:32 +00:00
|
|
|
#ifndef WM_DWMCOMPOSITIONCHANGED
|
|
|
|
#define WM_DWMCOMPOSITIONCHANGED 0x031E
|
|
|
|
#endif
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// DLLs that are loaded at glfwInit()
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
// winmm.dll function pointer typedefs
|
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2012-02-03 19:34:24 +00:00
|
|
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T) (UINT,LPJOYCAPS,UINT);
|
2010-09-07 15:34:51 +00:00
|
|
|
typedef MMRESULT (WINAPI * JOYGETPOS_T) (UINT,LPJOYINFO);
|
|
|
|
typedef MMRESULT (WINAPI * JOYGETPOSEX_T) (UINT,LPJOYINFOEX);
|
|
|
|
typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
|
|
|
|
#endif // _GLFW_NO_DLOAD_WINMM
|
|
|
|
|
|
|
|
|
|
|
|
// winmm.dll shortcuts
|
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2013-01-02 00:40:42 +00:00
|
|
|
#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 15:34:51 +00:00
|
|
|
#else
|
2012-02-05 01:43:49 +00:00
|
|
|
#define _glfw_joyGetDevCaps joyGetDevCaps
|
|
|
|
#define _glfw_joyGetPos joyGetPos
|
|
|
|
#define _glfw_joyGetPosEx joyGetPosEx
|
|
|
|
#define _glfw_timeGetTime timeGetTime
|
2010-09-07 15:34:51 +00:00
|
|
|
#endif // _GLFW_NO_DLOAD_WINMM
|
|
|
|
|
2013-03-10 18:23:42 +00:00
|
|
|
// user32.dll function pointer typedefs
|
|
|
|
typedef BOOL (WINAPI * SETPROCESSDPIAWARE_T)(void);
|
|
|
|
#define _glfw_SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware
|
|
|
|
|
2013-03-11 19:54:32 +00:00
|
|
|
// dwmapi.dll function pointer typedefs
|
|
|
|
typedef HRESULT (WINAPI * DWMISCOMPOSITIONENABLED_T)(BOOL*);
|
|
|
|
#define _glfw_DwmIsCompositionEnabled _glfw.win32.dwmapi.DwmIsCompositionEnabled
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2010-09-14 00:17:18 +00:00
|
|
|
// We use versioned window class names in order not to cause conflicts
|
|
|
|
// between applications using different versions of GLFW
|
2012-02-03 19:34:24 +00:00
|
|
|
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
2010-09-14 00:17:18 +00:00
|
|
|
|
2012-12-13 21:43:23 +00:00
|
|
|
#define _GLFW_RECREATION_NOT_NEEDED 0
|
|
|
|
#define _GLFW_RECREATION_REQUIRED 1
|
|
|
|
#define _GLFW_RECREATION_IMPOSSIBLE 2
|
|
|
|
|
2010-09-14 00:17:18 +00:00
|
|
|
|
2012-11-27 14:02:26 +00:00
|
|
|
#if defined(_GLFW_WGL)
|
2012-11-27 11:58:59 +00:00
|
|
|
#include "wgl_platform.h"
|
2012-11-27 14:02:26 +00:00
|
|
|
#elif defined(_GLFW_EGL)
|
2013-01-02 00:40:42 +00:00
|
|
|
#define _GLFW_EGL_NATIVE_WINDOW window->win32.handle
|
2013-03-24 20:19:53 +00:00
|
|
|
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
|
2012-11-27 11:58:59 +00:00
|
|
|
#include "egl_platform.h"
|
2012-12-02 18:01:20 +00:00
|
|
|
#else
|
|
|
|
#error "No supported context creation API selected"
|
2012-11-27 11:58:59 +00:00
|
|
|
#endif
|
2010-09-10 20:26:17 +00:00
|
|
|
|
2013-01-02 00:40:42 +00:00
|
|
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
|
|
|
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
|
|
|
|
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
|
2010-09-10 20:26:17 +00:00
|
|
|
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
|
|
|
// GLFW platform specific types
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Platform-specific window structure
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
typedef struct _GLFWwindowWin32
|
|
|
|
{
|
|
|
|
// Platform specific window resources
|
2013-01-02 15:48:02 +00:00
|
|
|
HWND handle; // Window handle
|
|
|
|
DWORD dwStyle; // Window styles used for window creation
|
|
|
|
DWORD dwExStyle; // --"--
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
// Various platform specific internal variables
|
2013-01-02 15:48:02 +00:00
|
|
|
GLboolean cursorCentered;
|
|
|
|
GLboolean cursorInside;
|
2013-04-14 13:36:10 +00:00
|
|
|
GLboolean cursorHidden;
|
2013-04-21 14:28:46 +00:00
|
|
|
double oldCursorX, oldCursorY;
|
2010-09-10 20:26:17 +00:00
|
|
|
} _GLFWwindowWin32;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2012-04-22 13:53:02 +00:00
|
|
|
// Platform-specific library global data for Win32
|
2010-09-07 15:34:51 +00:00
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 20:26:17 +00:00
|
|
|
typedef struct _GLFWlibraryWin32
|
|
|
|
{
|
2013-01-02 15:48:02 +00:00
|
|
|
ATOM classAtom;
|
|
|
|
DWORD foregroundLockTimeout;
|
|
|
|
char* clipboardString;
|
2010-09-10 20:26:17 +00:00
|
|
|
|
|
|
|
// Timer data
|
|
|
|
struct {
|
2013-01-02 15:48:02 +00:00
|
|
|
GLboolean hasPC;
|
|
|
|
double resolution;
|
2013-10-28 11:07:09 +00:00
|
|
|
unsigned __int64 base;
|
2010-09-10 20:26:17 +00:00
|
|
|
} timer;
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2010-09-14 02:27:02 +00:00
|
|
|
// winmm.dll
|
|
|
|
struct {
|
2013-01-02 15:48:02 +00:00
|
|
|
HINSTANCE instance;
|
|
|
|
JOYGETDEVCAPS_T joyGetDevCaps;
|
|
|
|
JOYGETPOS_T joyGetPos;
|
|
|
|
JOYGETPOSEX_T joyGetPosEx;
|
|
|
|
TIMEGETTIME_T timeGetTime;
|
2010-09-14 02:27:02 +00:00
|
|
|
} winmm;
|
2010-09-07 15:34:51 +00:00
|
|
|
#endif // _GLFW_NO_DLOAD_WINMM
|
|
|
|
|
2013-03-10 18:23:42 +00:00
|
|
|
// user32.dll
|
|
|
|
struct {
|
2013-03-11 19:54:32 +00:00
|
|
|
HINSTANCE instance;
|
2013-03-10 18:23:42 +00:00
|
|
|
SETPROCESSDPIAWARE_T SetProcessDPIAware;
|
|
|
|
} user32;
|
|
|
|
|
2013-03-11 19:54:32 +00:00
|
|
|
// dwmapi.dll
|
|
|
|
struct {
|
|
|
|
HINSTANCE instance;
|
|
|
|
DWMISCOMPOSITIONENABLED_T DwmIsCompositionEnabled;
|
|
|
|
} dwmapi;
|
|
|
|
|
2013-01-02 00:52:28 +00:00
|
|
|
struct {
|
2013-04-24 17:25:42 +00:00
|
|
|
float axes[6];
|
|
|
|
unsigned char buttons[36]; // 32 buttons plus one hat
|
2013-01-02 00:52:28 +00:00
|
|
|
char* name;
|
|
|
|
} joystick[GLFW_JOYSTICK_LAST + 1];
|
2012-11-08 15:26:15 +00:00
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
} _GLFWlibraryWin32;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-09-12 18:46:54 +00:00
|
|
|
|
2011-10-02 20:13:47 +00:00
|
|
|
//------------------------------------------------------------------------
|
2011-10-03 07:24:35 +00:00
|
|
|
// Platform-specific monitor structure
|
2011-10-02 20:13:47 +00:00
|
|
|
//------------------------------------------------------------------------
|
2011-10-03 07:24:35 +00:00
|
|
|
typedef struct _GLFWmonitorWin32
|
2011-10-02 20:13:47 +00:00
|
|
|
{
|
2013-02-20 14:44:37 +00:00
|
|
|
// This size matches the static size of DISPLAY_DEVICE.DeviceName
|
|
|
|
WCHAR name[32];
|
2011-10-06 21:28:56 +00:00
|
|
|
|
2011-10-03 07:24:35 +00:00
|
|
|
} _GLFWmonitorWin32;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-09-12 18:46:54 +00:00
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
|
|
|
// Prototypes for platform specific internal functions
|
|
|
|
//========================================================================
|
|
|
|
|
2013-03-11 19:54:32 +00:00
|
|
|
// Desktop compositing
|
|
|
|
BOOL _glfwIsCompositionEnabled(void);
|
|
|
|
|
2012-02-05 01:07:50 +00:00
|
|
|
// Wide strings
|
|
|
|
WCHAR* _glfwCreateWideStringFromUTF8(const char* source);
|
|
|
|
char* _glfwCreateUTF8FromWideString(const WCHAR* source);
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
// Time
|
2010-09-10 20:26:17 +00:00
|
|
|
void _glfwInitTimer(void);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-01-02 00:52:28 +00:00
|
|
|
// Joystick input
|
|
|
|
void _glfwInitJoysticks(void);
|
|
|
|
void _glfwTerminateJoysticks(void);
|
|
|
|
|
2012-07-31 20:48:28 +00:00
|
|
|
// OpenGL support
|
2013-02-04 07:26:17 +00:00
|
|
|
int _glfwInitContextAPI(void);
|
|
|
|
void _glfwTerminateContextAPI(void);
|
2012-07-31 20:48:28 +00:00
|
|
|
int _glfwCreateContext(_GLFWwindow* window,
|
|
|
|
const _GLFWwndconfig* wndconfig,
|
|
|
|
const _GLFWfbconfig* fbconfig);
|
|
|
|
void _glfwDestroyContext(_GLFWwindow* window);
|
2012-12-13 21:43:23 +00:00
|
|
|
int _glfwAnalyzeContext(const _GLFWwindow* window,
|
|
|
|
const _GLFWwndconfig* wndconfig,
|
|
|
|
const _GLFWfbconfig* fbconfig);
|
2012-07-31 20:48:28 +00:00
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
// Fullscreen support
|
2013-04-21 19:28:07 +00:00
|
|
|
GLboolean _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
2013-01-02 16:29:24 +00:00
|
|
|
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
2012-11-27 11:58:59 +00:00
|
|
|
#endif // _win32_platform_h_
|