2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
|
|
|
// GLFW - An OpenGL framework
|
|
|
|
// Platform: Win32/WGL
|
2010-09-07 15:41:26 +00:00
|
|
|
// API version: 3.0
|
2010-09-07 15:34:51 +00: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_
|
|
|
|
|
|
|
|
|
|
|
|
// This is the Windows version of GLFW
|
|
|
|
#define _GLFW_WIN32
|
|
|
|
|
|
|
|
// We don't need all the fancy stuff
|
|
|
|
#define NOMINMAX
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#define VC_EXTRALEAN
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <mmsystem.h>
|
2010-09-14 02:55:41 +00:00
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
#include "../../include/GL/glfw3.h"
|
2010-09-20 18:55:14 +00:00
|
|
|
#include "../../include/GL/wglext.h"
|
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
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
// Some old versions of w32api (used by MinGW and Cygwin) define
|
|
|
|
// WH_KEYBOARD_LL without typedef:ing KBDLLHOOKSTRUCT (!)
|
|
|
|
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
|
|
|
#include <w32api.h>
|
|
|
|
#if defined(WH_KEYBOARD_LL) && (__W32API_MAJOR_VERSION == 1) && (__W32API_MINOR_VERSION <= 2)
|
|
|
|
#undef WH_KEYBOARD_LL
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// ** NOTE ** If this gives you compiler errors and you are using MinGW
|
|
|
|
// (or Dev-C++), update to w32api version 1.3 or later:
|
|
|
|
// http://sourceforge.net/project/showfiles.php?group_id=2435
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
#ifndef WH_KEYBOARD_LL
|
|
|
|
#define WH_KEYBOARD_LL 13
|
|
|
|
typedef struct tagKBDLLHOOKSTRUCT {
|
|
|
|
DWORD vkCode;
|
|
|
|
DWORD scanCode;
|
|
|
|
DWORD flags;
|
|
|
|
DWORD time;
|
|
|
|
DWORD dwExtraInfo;
|
|
|
|
} KBDLLHOOKSTRUCT, FAR *LPKBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
|
|
|
|
#endif // WH_KEYBOARD_LL
|
|
|
|
|
|
|
|
#ifndef LLKHF_ALTDOWN
|
|
|
|
#define LLKHF_ALTDOWN 0x00000020
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SPI_SETSCREENSAVERRUNNING
|
|
|
|
#define SPI_SETSCREENSAVERRUNNING 97
|
|
|
|
#endif
|
|
|
|
#ifndef SPI_GETANIMATION
|
|
|
|
#define SPI_GETANIMATION 72
|
|
|
|
#endif
|
|
|
|
#ifndef SPI_SETANIMATION
|
|
|
|
#define SPI_SETANIMATION 73
|
|
|
|
#endif
|
|
|
|
#ifndef SPI_GETFOREGROUNDLOCKTIMEOUT
|
|
|
|
#define SPI_GETFOREGROUNDLOCKTIMEOUT 0x2000
|
|
|
|
#endif
|
|
|
|
#ifndef SPI_SETFOREGROUNDLOCKTIMEOUT
|
|
|
|
#define SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CDS_FULLSCREEN
|
|
|
|
#define CDS_FULLSCREEN 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PFD_GENERIC_ACCELERATED
|
|
|
|
#define PFD_GENERIC_ACCELERATED 0x00001000
|
|
|
|
#endif
|
|
|
|
#ifndef PFD_DEPTH_DONTCARE
|
|
|
|
#define PFD_DEPTH_DONTCARE 0x20000000
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ENUM_CURRENT_SETTINGS
|
|
|
|
#define ENUM_CURRENT_SETTINGS -1
|
|
|
|
#endif
|
|
|
|
#ifndef ENUM_REGISTRY_SETTINGS
|
|
|
|
#define ENUM_REGISTRY_SETTINGS -2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WM_MOUSEWHEEL
|
|
|
|
#define WM_MOUSEWHEEL 0x020A
|
|
|
|
#endif
|
|
|
|
#ifndef WHEEL_DELTA
|
|
|
|
#define WHEEL_DELTA 120
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WM_XBUTTONDOWN
|
|
|
|
#define WM_XBUTTONDOWN 0x020B
|
|
|
|
#endif
|
|
|
|
#ifndef WM_XBUTTONUP
|
|
|
|
#define WM_XBUTTONUP 0x020C
|
|
|
|
#endif
|
|
|
|
#ifndef XBUTTON1
|
|
|
|
#define XBUTTON1 1
|
|
|
|
#endif
|
|
|
|
#ifndef XBUTTON2
|
|
|
|
#define XBUTTON2 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GL_VERSION_3_0
|
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
typedef const GLubyte* (APIENTRY *PFNGLGETSTRINGIPROC) (GLenum, GLuint);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
#endif /*GL_VERSION_3_0*/
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// DLLs that are loaded at glfwInit()
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
// gdi32.dll function pointer typedefs
|
|
|
|
#ifndef _GLFW_NO_DLOAD_GDI32
|
|
|
|
typedef int (WINAPI * CHOOSEPIXELFORMAT_T) (HDC,CONST PIXELFORMATDESCRIPTOR*);
|
|
|
|
typedef int (WINAPI * DESCRIBEPIXELFORMAT_T) (HDC,int,UINT,LPPIXELFORMATDESCRIPTOR);
|
|
|
|
typedef int (WINAPI * GETPIXELFORMAT_T) (HDC);
|
|
|
|
typedef BOOL (WINAPI * SETPIXELFORMAT_T) (HDC,int,const PIXELFORMATDESCRIPTOR*);
|
|
|
|
typedef BOOL (WINAPI * SWAPBUFFERS_T) (HDC);
|
|
|
|
#endif // _GLFW_NO_DLOAD_GDI32
|
|
|
|
|
|
|
|
// winmm.dll function pointer typedefs
|
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
|
|
|
typedef MMRESULT (WINAPI * JOYGETDEVCAPSA_T) (UINT,LPJOYCAPSA,UINT);
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
// gdi32.dll shortcuts
|
|
|
|
#ifndef _GLFW_NO_DLOAD_GDI32
|
2010-09-14 02:27:02 +00:00
|
|
|
#define _glfw_ChoosePixelFormat _glfwLibrary.Win32.gdi.ChoosePixelFormat
|
|
|
|
#define _glfw_DescribePixelFormat _glfwLibrary.Win32.gdi.DescribePixelFormat
|
|
|
|
#define _glfw_GetPixelFormat _glfwLibrary.Win32.gdi.GetPixelFormat
|
|
|
|
#define _glfw_SetPixelFormat _glfwLibrary.Win32.gdi.SetPixelFormat
|
|
|
|
#define _glfw_SwapBuffers _glfwLibrary.Win32.gdi.SwapBuffers
|
2010-09-07 15:34:51 +00:00
|
|
|
#else
|
|
|
|
#define _glfw_ChoosePixelFormat ChoosePixelFormat
|
|
|
|
#define _glfw_DescribePixelFormat DescribePixelFormat
|
|
|
|
#define _glfw_GetPixelFormat GetPixelFormat
|
|
|
|
#define _glfw_SetPixelFormat SetPixelFormat
|
|
|
|
#define _glfw_SwapBuffers SwapBuffers
|
|
|
|
#endif // _GLFW_NO_DLOAD_GDI32
|
|
|
|
|
|
|
|
// winmm.dll shortcuts
|
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2010-09-14 02:27:02 +00:00
|
|
|
#define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCapsA
|
|
|
|
#define _glfw_joyGetPos _glfwLibrary.Win32.winmm.joyGetPos
|
|
|
|
#define _glfw_joyGetPosEx _glfwLibrary.Win32.winmm.joyGetPosEx
|
|
|
|
#define _glfw_timeGetTime _glfwLibrary.Win32.winmm.timeGetTime
|
2010-09-07 15:34:51 +00:00
|
|
|
#else
|
|
|
|
#define _glfw_joyGetDevCaps joyGetDevCapsA
|
|
|
|
#define _glfw_joyGetPos joyGetPos
|
|
|
|
#define _glfw_joyGetPosEx joyGetPosEx
|
|
|
|
#define _glfw_timeGetTime timeGetTime
|
|
|
|
#endif // _GLFW_NO_DLOAD_WINMM
|
|
|
|
|
|
|
|
|
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
|
|
|
|
#define _GLFW_WNDCLASSNAME "GLFW30"
|
|
|
|
|
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
|
|
|
|
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryWin32 Win32
|
|
|
|
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
|
|
|
|
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
|
|
|
// GLFW platform specific types
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Pointer length integer
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
typedef INT_PTR GLFWintptr;
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 20:26:17 +00:00
|
|
|
// Platform-specific OpenGL context structure
|
2010-09-07 15:34:51 +00:00
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 20:26:17 +00:00
|
|
|
typedef struct _GLFWcontextWGL
|
|
|
|
{
|
2010-09-07 15:34:51 +00:00
|
|
|
// Platform specific window resources
|
|
|
|
HDC DC; // Private GDI device context
|
|
|
|
HGLRC context; // Permanent rendering context
|
|
|
|
|
|
|
|
// Platform specific extensions (context specific)
|
2010-09-20 18:39:44 +00:00
|
|
|
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
|
|
|
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
|
|
|
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
|
|
|
PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
|
|
|
|
PFNWGLCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
|
|
|
|
GLboolean has_WGL_EXT_swap_control;
|
|
|
|
GLboolean has_WGL_ARB_multisample;
|
|
|
|
GLboolean has_WGL_ARB_pixel_format;
|
|
|
|
GLboolean has_WGL_ARB_create_context;
|
2010-09-10 20:26:17 +00: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 15:34:51 +00:00
|
|
|
|
|
|
|
// Various platform specific internal variables
|
|
|
|
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
2010-09-10 20:26:17 +00:00
|
|
|
int mouseMoved;
|
|
|
|
int oldMouseX, oldMouseY;
|
|
|
|
} _GLFWwindowWin32;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 20:26:17 +00:00
|
|
|
// Platform-specific library global data
|
2010-09-07 15:34:51 +00:00
|
|
|
//------------------------------------------------------------------------
|
2010-09-10 20:26:17 +00:00
|
|
|
typedef struct _GLFWlibraryWin32
|
|
|
|
{
|
2010-09-12 14:26:00 +00:00
|
|
|
HINSTANCE instance; // Instance of the application
|
2010-09-14 00:17:18 +00:00
|
|
|
ATOM classAtom; // Window class atom
|
2010-09-12 14:26:00 +00:00
|
|
|
HHOOK keyboardHook; // Keyboard hook handle
|
|
|
|
DWORD foregroundLockTimeout;
|
2010-09-10 20:26:17 +00:00
|
|
|
|
2010-09-18 23:24:51 +00:00
|
|
|
// Default monitor
|
|
|
|
struct {
|
|
|
|
int modeChanged;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int bitsPerPixel;
|
|
|
|
int refreshRate;
|
|
|
|
} monitor;
|
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
// Timer data
|
|
|
|
struct {
|
2010-09-14 02:35:36 +00:00
|
|
|
int hasPerformanceCounter;
|
|
|
|
double resolution;
|
2010-09-10 20:26:17 +00:00
|
|
|
unsigned int t0_32;
|
|
|
|
__int64 t0_64;
|
|
|
|
} timer;
|
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
#ifndef _GLFW_NO_DLOAD_GDI32
|
2010-09-14 02:27:02 +00:00
|
|
|
// gdi32.dll
|
|
|
|
struct {
|
|
|
|
HINSTANCE instance;
|
2010-09-10 20:26:17 +00:00
|
|
|
CHOOSEPIXELFORMAT_T ChoosePixelFormat;
|
|
|
|
DESCRIBEPIXELFORMAT_T DescribePixelFormat;
|
|
|
|
GETPIXELFORMAT_T GetPixelFormat;
|
|
|
|
SETPIXELFORMAT_T SetPixelFormat;
|
|
|
|
SWAPBUFFERS_T SwapBuffers;
|
2010-09-14 02:27:02 +00:00
|
|
|
} gdi;
|
2010-09-07 15:34:51 +00:00
|
|
|
#endif // _GLFW_NO_DLOAD_GDI32
|
|
|
|
|
|
|
|
#ifndef _GLFW_NO_DLOAD_WINMM
|
2010-09-14 02:27:02 +00:00
|
|
|
// winmm.dll
|
|
|
|
struct {
|
2010-09-14 02:28:51 +00:00
|
|
|
HINSTANCE instance;
|
2010-09-10 20:26:17 +00:00
|
|
|
JOYGETDEVCAPSA_T joyGetDevCapsA;
|
|
|
|
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
|
|
|
|
|
2010-09-10 20:26:17 +00:00
|
|
|
} _GLFWlibraryWin32;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// Prototypes for platform specific internal functions
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
// Time
|
2010-09-10 20:26:17 +00:00
|
|
|
void _glfwInitTimer(void);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
// Fullscreen support
|
2010-09-13 21:50:04 +00:00
|
|
|
void _glfwSetVideoMode(int* width, int* height,
|
|
|
|
int* bpp, int* refreshRate,
|
|
|
|
GLboolean exactBPP);
|
|
|
|
void _glfwRestoreVideoMode(void);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif // _platform_h_
|