2010-09-07 11:34:51 -04:00
|
|
|
//========================================================================
|
2011-03-05 19:46:39 -05:00
|
|
|
// GLFW - An OpenGL library
|
2010-09-07 11:34:51 -04:00
|
|
|
// Platform: Win32/WGL
|
2010-09-07 11:41:26 -04:00
|
|
|
// API version: 3.0
|
2010-09-07 11:34:51 -04:00
|
|
|
// WWW: http://www.glfw.org/
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
#ifndef _platform_h_
|
|
|
|
#define _platform_h_
|
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2012-01-18 12:44:28 -05: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-04 20:41:52 -05:00
|
|
|
// GLFW on Windows is Unicode only and does not work in MBCS mode
|
|
|
|
#ifndef UNICODE
|
|
|
|
#define UNICODE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// GLFW requires Windows XP
|
2012-03-22 09:58:14 -04:00
|
|
|
#ifndef WINVER
|
2012-03-29 19:55:28 -04:00
|
|
|
#define WINVER 0x0501
|
2012-03-22 09:58:14 -04:00
|
|
|
#endif
|
2012-02-03 14:34:24 -05:00
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
2010-09-13 22:55:41 -04:00
|
|
|
|
2011-09-22 08:15:07 -04:00
|
|
|
// This path may need to be changed if you build GLFW using your own setup
|
|
|
|
// We ship and use our own copy of wglext.h since GLFW uses fairly new
|
|
|
|
// extensions and not all operating systems come with an up-to-date version
|
2011-09-06 11:32:41 -04:00
|
|
|
#include "../support/GL/wglext.h"
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
2010-09-13 22:55:41 -04:00
|
|
|
// Hack: Define things that some 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-26 20:32:41 -04:00
|
|
|
#endif
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// DLLs that are loaded at glfwInit()
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
// winmm.dll function pointer typedefs
|
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2012-02-03 14:34:24 -05:00
|
|
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T) (UINT,LPJOYCAPS,UINT);
|
2010-09-07 11:34:51 -04: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
|
2012-02-04 20:43:49 -05:00
|
|
|
#define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCaps
|
|
|
|
#define _glfw_joyGetPos _glfwLibrary.Win32.winmm.joyGetPos
|
|
|
|
#define _glfw_joyGetPosEx _glfwLibrary.Win32.winmm.joyGetPosEx
|
|
|
|
#define _glfw_timeGetTime _glfwLibrary.Win32.winmm.timeGetTime
|
2010-09-07 11:34:51 -04:00
|
|
|
#else
|
2012-02-04 20:43:49 -05:00
|
|
|
#define _glfw_joyGetDevCaps joyGetDevCaps
|
|
|
|
#define _glfw_joyGetPos joyGetPos
|
|
|
|
#define _glfw_joyGetPosEx joyGetPosEx
|
|
|
|
#define _glfw_timeGetTime timeGetTime
|
2010-09-07 11:34:51 -04:00
|
|
|
#endif // _GLFW_NO_DLOAD_WINMM
|
|
|
|
|
|
|
|
|
2010-09-13 20:17:18 -04:00
|
|
|
// We use versioned window class names in order not to cause conflicts
|
|
|
|
// between applications using different versions of GLFW
|
2012-02-03 14:34:24 -05:00
|
|
|
#define _GLFW_WNDCLASSNAME L"GLFW30"
|
2010-09-13 20:17:18 -04:00
|
|
|
|
|
|
|
|
2010-09-10 16:26:17 -04:00
|
|
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
|
|
|
|
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
|
2012-04-22 09:53:02 -04:00
|
|
|
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 Win32
|
|
|
|
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryWGL WGL
|
2010-09-10 16:26:17 -04:00
|
|
|
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
//========================================================================
|
|
|
|
// GLFW platform specific types
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Pointer length integer
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
typedef INT_PTR GLFWintptr;
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 16:26:17 -04:00
|
|
|
// Platform-specific OpenGL context structure
|
2010-09-07 11:34:51 -04:00
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 16:26:17 -04:00
|
|
|
typedef struct _GLFWcontextWGL
|
|
|
|
{
|
2010-09-07 11:34:51 -04:00
|
|
|
// Platform specific window resources
|
|
|
|
HDC DC; // Private GDI device context
|
|
|
|
HGLRC context; // Permanent rendering context
|
|
|
|
|
|
|
|
// Platform specific extensions (context specific)
|
2010-09-20 14:39:44 -04:00
|
|
|
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
|
|
|
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
|
|
|
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
|
|
|
PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
|
|
|
|
PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
2011-09-06 08:51:03 -04:00
|
|
|
GLboolean EXT_swap_control;
|
|
|
|
GLboolean ARB_multisample;
|
|
|
|
GLboolean ARB_pixel_format;
|
|
|
|
GLboolean ARB_create_context;
|
|
|
|
GLboolean ARB_create_context_profile;
|
|
|
|
GLboolean EXT_create_context_es2_profile;
|
|
|
|
GLboolean ARB_create_context_robustness;
|
2010-09-10 16:26:17 -04:00
|
|
|
} _GLFWcontextWGL;
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Platform-specific window structure
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
typedef struct _GLFWwindowWin32
|
|
|
|
{
|
|
|
|
// Platform specific window resources
|
|
|
|
HWND handle; // Window handle
|
|
|
|
DWORD dwStyle; // Window styles used for window creation
|
|
|
|
DWORD dwExStyle; // --"--
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
// Various platform specific internal variables
|
|
|
|
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
2011-10-04 18:47:39 -04:00
|
|
|
GLboolean cursorCentered;
|
2012-03-22 08:17:44 -04:00
|
|
|
GLboolean cursorInside;
|
2012-06-22 07:53:02 -04:00
|
|
|
int oldCursorX, oldCursorY;
|
2010-09-10 16:26:17 -04:00
|
|
|
} _GLFWwindowWin32;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2012-04-22 09:53:02 -04:00
|
|
|
// Platform-specific library global data for Win32
|
2010-09-07 11:34:51 -04:00
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 16:26:17 -04:00
|
|
|
typedef struct _GLFWlibraryWin32
|
|
|
|
{
|
2010-10-25 06:36:14 -04:00
|
|
|
HINSTANCE instance; // Instance of the application
|
|
|
|
ATOM classAtom; // Window class atom
|
|
|
|
HHOOK keyboardHook; // Keyboard hook handle
|
|
|
|
DWORD foregroundLockTimeout;
|
2012-04-11 18:51:58 -04:00
|
|
|
char* clipboardString;
|
2010-09-10 16:26:17 -04:00
|
|
|
|
2010-09-18 19:24:51 -04:00
|
|
|
// Default monitor
|
|
|
|
struct {
|
2010-10-25 06:36:14 -04:00
|
|
|
GLboolean modeChanged;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int bitsPerPixel;
|
|
|
|
int refreshRate;
|
2010-09-18 19:24:51 -04:00
|
|
|
} monitor;
|
|
|
|
|
2010-09-10 16:26:17 -04:00
|
|
|
// Timer data
|
|
|
|
struct {
|
2010-10-25 06:36:14 -04:00
|
|
|
GLboolean hasPerformanceCounter;
|
|
|
|
double resolution;
|
|
|
|
unsigned int t0_32;
|
|
|
|
__int64 t0_64;
|
2010-09-10 16:26:17 -04:00
|
|
|
} timer;
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2010-09-13 22:27:02 -04:00
|
|
|
// winmm.dll
|
|
|
|
struct {
|
2010-09-13 22:28:51 -04:00
|
|
|
HINSTANCE instance;
|
2012-02-03 14:34:24 -05:00
|
|
|
JOYGETDEVCAPS_T joyGetDevCaps;
|
2010-09-10 16:26:17 -04:00
|
|
|
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
|
|
|
#endif // _GLFW_NO_DLOAD_WINMM
|
|
|
|
|
2010-09-10 16:26:17 -04:00
|
|
|
} _GLFWlibraryWin32;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
2012-04-22 09:53:02 -04:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Platform-specific library global data for WGL
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
typedef struct _GLFWlibraryWGL
|
|
|
|
{
|
|
|
|
int dummy;
|
|
|
|
|
|
|
|
} _GLFWlibraryWGL;
|
|
|
|
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
//========================================================================
|
|
|
|
// Prototypes for platform specific internal functions
|
|
|
|
//========================================================================
|
|
|
|
|
2012-02-04 20:07:50 -05:00
|
|
|
// Wide strings
|
|
|
|
WCHAR* _glfwCreateWideStringFromUTF8(const char* source);
|
|
|
|
char* _glfwCreateUTF8FromWideString(const WCHAR* source);
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
// Time
|
2010-09-10 16:26:17 -04:00
|
|
|
void _glfwInitTimer(void);
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
// Fullscreen support
|
2010-09-13 17:50:04 -04:00
|
|
|
void _glfwSetVideoMode(int* width, int* height,
|
|
|
|
int* bpp, int* refreshRate,
|
|
|
|
GLboolean exactBPP);
|
|
|
|
void _glfwRestoreVideoMode(void);
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
|
|
|
#endif // _platform_h_
|