Renamed lib directory to src.

This commit is contained in:
Camilla Berglund
2010-09-09 20:01:43 +02:00
parent 950a3beda2
commit 445bf1ea33
56 changed files with 11 additions and 11 deletions
+55
View File
@@ -0,0 +1,55 @@
if(CYGWIN)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
# These lines are intended to remove the --export-all-symbols
# flag added in the Modules/Platform/CYGWIN.cmake file of the
# CMake distribution.
# This is a HACK. If you have trouble _linking_ the GLFW
# _shared_ library on Cygwin, try disabling this.
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
endif(CYGWIN)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/lib)
set(libglfw_SOURCES
${common_SOURCES}
win32_enable.c
win32_fullscreen.c
win32_glext.c
win32_init.c
win32_joystick.c
win32_time.c
win32_window.c
win32_dllmain.c)
add_library(libglfwStatic STATIC ${libglfw_SOURCES})
add_library(libglfwShared SHARED glfwdll.def ${libglfw_SOURCES})
target_link_libraries(libglfwShared ${OPENGL_gl_LIBRARY})
set_target_properties(libglfwShared PROPERTIES
DEFINE_SYMBOL GLFW_BUILD_DLL
PREFIX ""
IMPORT_PREFIX ""
IMPORT_SUFFIX "dll.lib")
set_target_properties(libglfwStatic libglfwShared PROPERTIES
CLEAN_DIRECT_OUTPUT 1
OUTPUT_NAME glfw)
if(CYGWIN)
# Build for the regular Win32 environment (not Cygwin)
set_target_properties(libglfwStatic libglfwShared PROPERTIES COMPILE_FLAGS "-mwin32 -mno-cygwin")
set_target_properties(libglfwStatic libglfwShared PROPERTIES LINK_FLAGS "-mwin32 -mno-cygwin")
endif(CYGWIN)
install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
if(CYGWIN)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
endif(CYGWIN)
+46
View File
@@ -0,0 +1,46 @@
LIBRARY GLFW.DLL
EXPORTS
glfwCloseWindow
glfwDisable
glfwEnable
glfwExtensionSupported
glfwGetDesktopMode
glfwGetGLVersion
glfwGetJoystickButtons
glfwGetJoystickParam
glfwGetJoystickPos
glfwGetKey
glfwGetMouseButton
glfwGetMousePos
glfwGetMouseWheel
glfwGetProcAddress
glfwGetTime
glfwGetVersion
glfwGetVideoModes
glfwGetWindowParam
glfwGetWindowSize
glfwIconifyWindow
glfwInit
glfwOpenWindow
glfwOpenWindowHint
glfwPollEvents
glfwRestoreWindow
glfwSetCharCallback
glfwSetKeyCallback
glfwSetMouseButtonCallback
glfwSetMousePos
glfwSetMousePosCallback
glfwSetMouseWheel
glfwSetMouseWheelCallback
glfwSetTime
glfwSetWindowCloseCallback
glfwSetWindowRefreshCallback
glfwSetWindowPos
glfwSetWindowSize
glfwSetWindowSizeCallback
glfwSetWindowTitle
glfwSwapBuffers
glfwSwapInterval
glfwTerminate
glfwWaitEvents
+46
View File
@@ -0,0 +1,46 @@
LIBRARY GLFW.DLL
EXPORTS
glfwCloseWindow = glfwCloseWindow@0
glfwDisable = glfwDisable@4
glfwEnable = glfwEnable@4
glfwExtensionSupported = glfwExtensionSupported@4
glfwGetDesktopMode = glfwGetDesktopMode@4
glfwGetGLVersion = glfwGetGLVersion@12
glfwGetJoystickButtons = glfwGetJoystickButtons@12
glfwGetJoystickParam = glfwGetJoystickParam@8
glfwGetJoystickPos = glfwGetJoystickPos@12
glfwGetKey = glfwGetKey@4
glfwGetMouseButton = glfwGetMouseButton@4
glfwGetMousePos = glfwGetMousePos@8
glfwGetMouseWheel = glfwGetMouseWheel@0
glfwGetProcAddress = glfwGetProcAddress@4
glfwGetTime = glfwGetTime@0
glfwGetVersion = glfwGetVersion@12
glfwGetVideoModes = glfwGetVideoModes@8
glfwGetWindowParam = glfwGetWindowParam@4
glfwGetWindowSize = glfwGetWindowSize@8
glfwIconifyWindow = glfwIconifyWindow@0
glfwInit = glfwInit@0
glfwOpenWindow = glfwOpenWindow@36
glfwOpenWindowHint = glfwOpenWindowHint@8
glfwPollEvents = glfwPollEvents@0
glfwRestoreWindow = glfwRestoreWindow@0
glfwSetCharCallback = glfwSetCharCallback@4
glfwSetKeyCallback = glfwSetKeyCallback@4
glfwSetMouseButtonCallback = glfwSetMouseButtonCallback@4
glfwSetMousePos = glfwSetMousePos@8
glfwSetMousePosCallback = glfwSetMousePosCallback@4
glfwSetMouseWheel = glfwSetMouseWheel@4
glfwSetMouseWheelCallback = glfwSetMouseWheelCallback@4
glfwSetTime = glfwSetTime@8
glfwSetWindowCloseCallback = glfwSetWindowCloseCallback@4
glfwSetWindowRefreshCallback = glfwSetWindowRefreshCallback@4
glfwSetWindowPos = glfwSetWindowPos@8
glfwSetWindowSize = glfwSetWindowSize@8
glfwSetWindowSizeCallback = glfwSetWindowSizeCallback@4
glfwSetWindowTitle = glfwSetWindowTitle@4
glfwSwapBuffers = glfwSwapBuffers@0
glfwSwapInterval = glfwSwapInterval@4
glfwTerminate = glfwTerminate@0
glfwWaitEvents = glfwWaitEvents@0
+46
View File
@@ -0,0 +1,46 @@
LIBRARY GLFW.DLL
EXPORTS
glfwCloseWindow@0
glfwDisable@4
glfwEnable@4
glfwExtensionSupported@4
glfwGetDesktopMode@4
glfwGetGLVersion@12
glfwGetJoystickButtons@12
glfwGetJoystickParam@8
glfwGetJoystickPos@12
glfwGetKey@4
glfwGetMouseButton@4
glfwGetMousePos@8
glfwGetMouseWheel@0
glfwGetProcAddress@4
glfwGetTime@0
glfwGetVersion@12
glfwGetVideoModes@8
glfwGetWindowParam@4
glfwGetWindowSize@8
glfwIconifyWindow@0
glfwInit@0
glfwOpenWindow@36
glfwOpenWindowHint@8
glfwPollEvents@0
glfwRestoreWindow@0
glfwSetCharCallback@4
glfwSetKeyCallback@4
glfwSetMouseButtonCallback@4
glfwSetMousePos@8
glfwSetMousePosCallback@4
glfwSetMouseWheel@4
glfwSetMouseWheelCallback@4
glfwSetTime@8
glfwSetWindowCloseCallback@4
glfwSetWindowRefreshCallback@4
glfwSetWindowPos@8
glfwSetWindowSize@8
glfwSetWindowSizeCallback@4
glfwSetWindowTitle@4
glfwSwapBuffers@0
glfwSwapInterval@4
glfwTerminate@0
glfwWaitEvents@0
+11
View File
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: GLFW
Description: A portable framework for OpenGL development
Version: 3.0
URL: http://www.glfw.org/
Libs: -L${libdir} -lglfw @GLFW_LIBRARIES@
Cflags: -I${includedir} -mwin32
+477
View File
@@ -0,0 +1,477 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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 files
#include <windows.h>
#include <mmsystem.h>
#include "../../include/GL/glfw.h"
//========================================================================
// Hack: Define things that some <windows.h>'s do not define
//========================================================================
// 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 WGL_ARB_pixel_format
// wglSwapIntervalEXT typedef (Win32 buffer-swap interval control)
typedef int (APIENTRY * WGLSWAPINTERVALEXT_T) (int);
// wglGetPixelFormatAttribivARB typedef
typedef BOOL (WINAPI * WGLGETPIXELFORMATATTRIBIVARB_T) (HDC, int, int, UINT, const int *, int *);
// wglGetExtensionStringEXT typedef
typedef const char *(APIENTRY * WGLGETEXTENSIONSSTRINGEXT_T)( void );
// wglGetExtensionStringARB typedef
typedef const char *(APIENTRY * WGLGETEXTENSIONSSTRINGARB_T)( HDC );
/* Constants for wglGetPixelFormatAttribivARB */
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
/* Constants for WGL_ACCELERATION_ARB */
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
/* Constants for WGL_PIXEL_TYPE_ARB */
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#endif /*WGL_ARB_pixel_format*/
#ifndef WGL_ARB_create_context
/* wglCreateContextAttribsARB */
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC, HGLRC, const int *);
/* Tokens for wglCreateContextAttribsARB attributes */
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
/* Bits for WGL_CONTEXT_FLAGS_ARB */
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
/* Bits for WGL_CONTEXT_PROFILE_MASK_ARB */
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#endif /*WGL_ARB_create_context*/
#ifndef GL_VERSION_3_0
typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC) (GLenum, GLuint);
#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
#define _glfw_ChoosePixelFormat _glfwLibrary.Libs.ChoosePixelFormat
#define _glfw_DescribePixelFormat _glfwLibrary.Libs.DescribePixelFormat
#define _glfw_GetPixelFormat _glfwLibrary.Libs.GetPixelFormat
#define _glfw_SetPixelFormat _glfwLibrary.Libs.SetPixelFormat
#define _glfw_SwapBuffers _glfwLibrary.Libs.SwapBuffers
#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
#define _glfw_joyGetDevCaps _glfwLibrary.Libs.joyGetDevCapsA
#define _glfw_joyGetPos _glfwLibrary.Libs.joyGetPos
#define _glfw_joyGetPosEx _glfwLibrary.Libs.joyGetPosEx
#define _glfw_timeGetTime _glfwLibrary.Libs.timeGetTime
#else
#define _glfw_joyGetDevCaps joyGetDevCapsA
#define _glfw_joyGetPos joyGetPos
#define _glfw_joyGetPosEx joyGetPosEx
#define _glfw_timeGetTime timeGetTime
#endif // _GLFW_NO_DLOAD_WINMM
//========================================================================
// GLFW platform specific types
//========================================================================
//------------------------------------------------------------------------
// Pointer length integer
//------------------------------------------------------------------------
typedef INT_PTR GLFWintptr;
//------------------------------------------------------------------------
// Window structure
//------------------------------------------------------------------------
typedef struct _GLFWwin_struct _GLFWwin;
struct _GLFWwin_struct {
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
// User callback functions
GLFWwindowsizefun windowSizeCallback;
GLFWwindowclosefun windowCloseCallback;
GLFWwindowrefreshfun windowRefreshCallback;
GLFWmousebuttonfun mouseButtonCallback;
GLFWmouseposfun mousePosCallback;
GLFWmousewheelfun mouseWheelCallback;
GLFWkeyfun keyCallback;
GLFWcharfun charCallback;
// User selected window settings
int fullscreen; // Fullscreen flag
int mouseLock; // Mouse-lock flag
int sysKeysDisabled; // System keys disabled flag
int windowNoResize; // Resize- and maximize gadgets disabled flag
int refreshRate; // Vertical monitor refresh rate
// Window status & parameters
int opened; // Flag telling if window is opened or not
int active; // Application active flag
int iconified; // Window iconified flag
int width, height; // Window width and heigth
int accelerated; // GL_TRUE if window is HW accelerated
// Framebuffer attributes
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
int accumRedBits;
int accumGreenBits;
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
int stereo;
int samples;
// OpenGL extensions and context attributes
int glMajor, glMinor, glRevision;
int glForward, glDebug, glProfile;
PFNGLGETSTRINGIPROC GetStringi;
// ========= PLATFORM SPECIFIC PART ======================================
// Platform specific window resources
HDC DC; // Private GDI device context
HGLRC context; // Permanent rendering context
HWND window; // Window handle
ATOM classAtom; // Window class atom
int modeID; // Mode ID for fullscreen mode
HHOOK keyboardHook; // Keyboard hook handle
DWORD dwStyle; // Window styles used for window creation
DWORD dwExStyle; // --"--
// Platform specific extensions (context specific)
WGLSWAPINTERVALEXT_T SwapIntervalEXT;
WGLGETPIXELFORMATATTRIBIVARB_T GetPixelFormatAttribivARB;
WGLGETEXTENSIONSSTRINGEXT_T GetExtensionsStringEXT;
WGLGETEXTENSIONSSTRINGARB_T 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;
// Various platform specific internal variables
int oldMouseLock; // Old mouse-lock flag (used for remembering
// mouse-lock state when iconifying)
int oldMouseLockValid;
int desiredRefreshRate; // Desired vertical monitor refresh rate
};
GLFWGLOBAL _GLFWwin _glfwWin;
//------------------------------------------------------------------------
// User input status (most of this should go in _GLFWwin)
//------------------------------------------------------------------------
GLFWGLOBAL struct {
// ========= PLATFORM INDEPENDENT MANDATORY PART =========================
// Mouse status
int MousePosX, MousePosY;
int WheelPos;
char MouseButton[ GLFW_MOUSE_BUTTON_LAST+1 ];
// Keyboard status
char Key[ GLFW_KEY_LAST+1 ];
int LastChar;
// User selected settings
int StickyKeys;
int StickyMouseButtons;
int KeyRepeat;
// ========= PLATFORM SPECIFIC PART ======================================
// Platform specific internal variables
int MouseMoved, OldMouseX, OldMouseY;
} _glfwInput;
//------------------------------------------------------------------------
// Library global data
//------------------------------------------------------------------------
GLFWGLOBAL struct {
// Window opening hints
_GLFWhints hints;
// ========= PLATFORM SPECIFIC PART ======================================
HINSTANCE instance; // Instance of the application
// Timer data
struct {
int HasPerformanceCounter;
double Resolution;
unsigned int t0_32;
__int64 t0_64;
} Timer;
// System information
struct {
int winVer;
int hasUnicode;
DWORD foregroundLockTimeout;
} Sys;
#if !defined(_GLFW_NO_DLOAD_WINMM) || !defined(_GLFW_NO_DLOAD_GDI32)
// Library handles and function pointers
struct {
#ifndef _GLFW_NO_DLOAD_GDI32
// gdi32.dll
HINSTANCE gdi32;
CHOOSEPIXELFORMAT_T ChoosePixelFormat;
DESCRIBEPIXELFORMAT_T DescribePixelFormat;
GETPIXELFORMAT_T GetPixelFormat;
SETPIXELFORMAT_T SetPixelFormat;
SWAPBUFFERS_T SwapBuffers;
#endif // _GLFW_NO_DLOAD_GDI32
// winmm.dll
#ifndef _GLFW_NO_DLOAD_WINMM
HINSTANCE winmm;
JOYGETDEVCAPSA_T joyGetDevCapsA;
JOYGETPOS_T joyGetPos;
JOYGETPOSEX_T joyGetPosEx;
TIMEGETTIME_T timeGetTime;
#endif // _GLFW_NO_DLOAD_WINMM
} Libs;
#endif
} _glfwLibrary;
//========================================================================
// Various Windows version constants
//========================================================================
#define _GLFW_WIN_UNKNOWN 0x0000 // Earlier than 95 or NT4
#define _GLFW_WIN_95 0x0001
#define _GLFW_WIN_98 0x0002
#define _GLFW_WIN_ME 0x0003
#define _GLFW_WIN_UNKNOWN_9x 0x0004 // Later than ME
#define _GLFW_WIN_NT4 0x0101
#define _GLFW_WIN_2K 0x0102
#define _GLFW_WIN_XP 0x0103
#define _GLFW_WIN_NET_SERVER 0x0104
#define _GLFW_WIN_UNKNOWN_NT 0x0105 // Later than .NET Server
//========================================================================
// Prototypes for platform specific internal functions
//========================================================================
// Time
void _glfwInitTimer( void );
// Fullscreen support
int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh );
int _glfwGetClosestVideoMode( int *w, int *h, int *r, int *g, int *b, int *refresh );
void _glfwSetVideoModeMODE( int mode );
void _glfwSetVideoMode( int *w, int *h, int r, int g, int b, int refresh );
#endif // _platform_h_
+49
View File
@@ -0,0 +1,49 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
#if defined(GLFW_BUILD_DLL)
//========================================================================
// GLFW DLL entry point
//========================================================================
BOOL WINAPI DllMain( HINSTANCE instance, DWORD reason, LPVOID reserved )
{
// NOTE: Some compilers complains about instance and x never being used -
// never mind that (we don't want to use them)!
return TRUE;
}
#endif // GLFW_BUILD_DLL
+155
View File
@@ -0,0 +1,155 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
//************************************************************************
//**** GLFW internal functions ****
//************************************************************************
//========================================================================
// Low level keyboard hook (system callback) function
// Used to disable system keys under Windows NT
//========================================================================
static LRESULT CALLBACK keyboardHook( int nCode, WPARAM wParam, LPARAM lParam )
{
BOOL syskeys = FALSE;
PKBDLLHOOKSTRUCT p;
// We are only looking for keyboard events - interpret lParam as a
// pointer to a KBDLLHOOKSTRUCT
p = (PKBDLLHOOKSTRUCT) lParam;
if( nCode == HC_ACTION )
{
// We have a keyboard event
switch( wParam )
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
// Detect: ALT+TAB, ALT+ESC, ALT+F4, CTRL+ESC,
// LWIN, RWIN, APPS (mysterious menu key)
syskeys = ( p->vkCode == VK_TAB &&
p->flags & LLKHF_ALTDOWN ) ||
( p->vkCode == VK_ESCAPE &&
p->flags & LLKHF_ALTDOWN ) ||
( p->vkCode == VK_F4 &&
p->flags & LLKHF_ALTDOWN ) ||
( p->vkCode == VK_ESCAPE &&
(GetKeyState(VK_CONTROL) & 0x8000)) ||
p->vkCode == VK_LWIN ||
p->vkCode == VK_RWIN ||
p->vkCode == VK_APPS;
break;
default:
break;
}
}
// Was it a system key combination (e.g. ALT+TAB)?
if( syskeys )
{
// Pass the key event to our window message loop
if( _glfwWin.opened )
{
PostMessage( _glfwWin.window, (UINT) wParam, p->vkCode, 0 );
}
// We've taken care of it - don't let the system know about this
// key event
return 1;
}
else
{
// It's a harmless key press, let the system deal with it
return CallNextHookEx( _glfwWin.keyboardHook, nCode, wParam, lParam );
}
}
//************************************************************************
//**** Platform implementation functions ****
//************************************************************************
//========================================================================
// Enable system keys
//========================================================================
void _glfwPlatformEnableSystemKeys( void )
{
BOOL dummy;
// Use different methods depending on operating system version
if( _glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4 )
{
if( _glfwWin.keyboardHook != NULL )
{
UnhookWindowsHookEx( _glfwWin.keyboardHook );
_glfwWin.keyboardHook = NULL;
}
}
else
{
(void) SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, FALSE, &dummy, 0 );
}
}
//========================================================================
// Disable system keys
//========================================================================
void _glfwPlatformDisableSystemKeys( void )
{
BOOL dummy;
// Use different methods depending on operating system version
if( _glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4 )
{
// Under Windows NT, install a low level keyboard hook
_glfwWin.keyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL,
keyboardHook,
_glfwLibrary.instance,
0 );
}
else
{
// Under Windows 95/98/ME, fool Windows that a screensaver
// is running => prevents ALT+TAB, CTRL+ESC and CTRL+ALT+DEL
(void) SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, TRUE, &dummy, 0 );
}
}
+320
View File
@@ -0,0 +1,320 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
//************************************************************************
//**** GLFW internal functions ****
//************************************************************************
//========================================================================
// Convert BPP to RGB bits based on "best guess"
//========================================================================
static void bpp2rgb( int bpp, int *r, int *g, int *b )
{
int delta;
// We assume that by 32 they really meant 24
if( bpp == 32 )
{
bpp = 24;
}
// Convert "bits per pixel" to red, green & blue sizes
*r = *g = *b = bpp / 3;
delta = bpp - (*r * 3);
if( delta >= 1 )
{
*g = *g + 1;
}
if( delta == 2 )
{
*r = *r + 1;
}
}
//========================================================================
// Return closest video mode by dimensions, refresh rate and bits per pixel
//========================================================================
int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh )
{
int mode, bestmode, match, bestmatch, rr, bestrr, success;
DEVMODE dm;
// Find best match
bestmatch = 0x7fffffff;
bestrr = 0x7fffffff;
mode = bestmode = 0;
do
{
dm.dmSize = sizeof( DEVMODE );
success = EnumDisplaySettings( NULL, mode, &dm );
if( success )
{
match = dm.dmBitsPerPel - *bpp;
if( match < 0 ) match = -match;
match = ( match << 25 ) |
( (dm.dmPelsWidth - *w) *
(dm.dmPelsWidth - *w) +
(dm.dmPelsHeight - *h) *
(dm.dmPelsHeight - *h) );
if( match < bestmatch )
{
bestmatch = match;
bestmode = mode;
bestrr = (dm.dmDisplayFrequency - *refresh) *
(dm.dmDisplayFrequency - *refresh);
}
else if( match == bestmatch && *refresh > 0 )
{
rr = (dm.dmDisplayFrequency - *refresh) *
(dm.dmDisplayFrequency - *refresh);
if( rr < bestrr )
{
bestmatch = match;
bestmode = mode;
bestrr = rr;
}
}
}
mode ++;
}
while( success );
// Get the parameters for the best matching display mode
dm.dmSize = sizeof( DEVMODE );
(void) EnumDisplaySettings( NULL, bestmode, &dm );
// Fill out actual width and height
*w = dm.dmPelsWidth;
*h = dm.dmPelsHeight;
// Return bits per pixel
*bpp = dm.dmBitsPerPel;
// Return vertical refresh rate
*refresh = dm.dmDisplayFrequency;
return bestmode;
}
//========================================================================
// Return closest video mode by dimensions, refresh rate and channel sizes
//========================================================================
static int getClosestVideoMode( int *w, int *h,
int *r, int *g, int *b,
int *refresh )
{
int bpp, bestmode;
// Colorbits = sum of red/green/blue bits
bpp = *r + *g + *b;
// If colorbits < 15 (e.g. 0) or >= 24, default to 32 bpp
if( bpp < 15 || bpp >= 24 )
{
bpp = 32;
}
// Find best match
bestmode = _glfwGetClosestVideoModeBPP( w, h, &bpp, refresh );
// Convert "bits per pixel" to red, green & blue sizes
bpp2rgb( bpp, r, g, b );
return bestmode;
}
//========================================================================
// Change the current video mode
//========================================================================
void _glfwSetVideoModeMODE( int mode )
{
DEVMODE dm;
int success;
// Get the parameters for the best matching display mode
dm.dmSize = sizeof( DEVMODE );
(void) EnumDisplaySettings( NULL, mode, &dm );
// Set which fields we want to specify
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
// Do we have a prefered refresh rate?
if( _glfwWin.desiredRefreshRate > 0 )
{
dm.dmFields = dm.dmFields | DM_DISPLAYFREQUENCY;
dm.dmDisplayFrequency = _glfwWin.desiredRefreshRate;
}
// Change display setting
dm.dmSize = sizeof( DEVMODE );
success = ChangeDisplaySettings( &dm, CDS_FULLSCREEN );
// If the mode change was not possible, query the current display
// settings (we'll use the desktop resolution for fullscreen mode)
if( success == DISP_CHANGE_SUCCESSFUL )
{
_glfwWin.modeID = mode;
}
else
{
_glfwWin.modeID = ENUM_REGISTRY_SETTINGS;
EnumDisplaySettings( NULL, ENUM_REGISTRY_SETTINGS, &dm );
}
// Set the window size to that of the display mode
_glfwWin.width = dm.dmPelsWidth;
_glfwWin.height = dm.dmPelsHeight;
}
//========================================================================
// Change the current video mode
//========================================================================
void _glfwSetVideoMode( int *w, int *h, int r, int g, int b, int refresh )
{
int bestmode;
// Find a best match mode
bestmode = getClosestVideoMode( w, h, &r, &g, &b, &refresh );
// Change mode
_glfwSetVideoModeMODE( bestmode );
}
//************************************************************************
//**** GLFW user functions ****
//************************************************************************
//========================================================================
// Get a list of available video modes
//========================================================================
int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
{
int count, success, mode, i, j;
int m1, m2, bpp, r, g, b;
DEVMODE dm;
// Loop through all video modes and extract all the UNIQUE modes
count = 0;
mode = 0;
do
{
// Get video mode properties
dm.dmSize = sizeof( DEVMODE );
success = EnumDisplaySettings( NULL, mode, &dm );
// Is it a valid mode? (only list depths >= 15 bpp)
if( success && dm.dmBitsPerPel >= 15 )
{
// Convert to RGB, and back to bpp ("mask out" alpha bits etc)
bpp2rgb( dm.dmBitsPerPel, &r, &g, &b );
bpp = r + g + b;
// Mode "code" for this mode
m1 = (bpp << 25) | (dm.dmPelsWidth * dm.dmPelsHeight);
// Insert mode in list (sorted), and avoid duplicates
for( i = 0; i < count; i ++ )
{
// Mode "code" for already listed mode
bpp = list[i].redBits + list[i].greenBits +
list[i].blueBits;
m2 = (bpp << 25) | (list[i].width * list[i].height);
if( m1 <= m2 )
{
break;
}
}
// New entry at the end of the list?
if( i >= count )
{
list[count].width = dm.dmPelsWidth;
list[count].height = dm.dmPelsHeight;
list[count].redBits = r;
list[count].greenBits = g;
list[count].blueBits = b;
count ++;
}
// Insert new entry in the list?
else if( m1 < m2 )
{
for( j = count; j > i; j -- )
{
list[j] = list[j-1];
}
list[i].width = dm.dmPelsWidth;
list[i].height = dm.dmPelsHeight;
list[i].redBits = r;
list[i].greenBits = g;
list[i].blueBits = b;
count ++;
}
}
mode ++;
}
while( success && (count < maxcount) );
return count;
}
//========================================================================
// Get the desktop video mode
//========================================================================
void _glfwPlatformGetDesktopMode( GLFWvidmode *mode )
{
DEVMODE dm;
// Get desktop display mode
dm.dmSize = sizeof( DEVMODE );
(void) EnumDisplaySettings( NULL, ENUM_REGISTRY_SETTINGS, &dm );
// Return desktop mode parameters
mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight;
bpp2rgb( dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits );
}
+82
View File
@@ -0,0 +1,82 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
//************************************************************************
//**** Platform implementation functions ****
//************************************************************************
//========================================================================
// Check if the current context supports the specified WGL extension
//========================================================================
int _glfwPlatformExtensionSupported( const char *extension )
{
const GLubyte *extensions;
if( _glfwWin.GetExtensionsStringEXT != NULL )
{
extensions = (GLubyte *) _glfwWin.GetExtensionsStringEXT();
if( extensions != NULL )
{
if( _glfwStringInExtensionString( extension, extensions ) )
{
return GL_TRUE;
}
}
}
if( _glfwWin.GetExtensionsStringARB != NULL )
{
extensions = (GLubyte *) _glfwWin.GetExtensionsStringARB( _glfwWin.DC );
if( extensions != NULL )
{
if( _glfwStringInExtensionString( extension, extensions ) )
{
return GL_TRUE;
}
}
}
return GL_FALSE;
}
//========================================================================
// Get the function pointer to an OpenGL function
//========================================================================
void *_glfwPlatformGetProcAddress( const char *procname )
{
return (void *) wglGetProcAddress( procname );
}
+281
View File
@@ -0,0 +1,281 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
// With the Borland C++ compiler, we want to disable FPU exceptions
#ifdef __BORLANDC__
#include <float.h>
#endif // __BORLANDC__
//************************************************************************
//**** GLFW internal functions ****
//************************************************************************
//========================================================================
// Load necessary libraries (DLLs)
//========================================================================
static int _glfwInitLibraries( void )
{
// gdi32.dll (OpenGL pixel format functions & SwapBuffers)
#ifndef _GLFW_NO_DLOAD_GDI32
_glfwLibrary.Libs.gdi32 = LoadLibrary( "gdi32.dll" );
if( _glfwLibrary.Libs.gdi32 != NULL )
{
_glfwLibrary.Libs.ChoosePixelFormat = (CHOOSEPIXELFORMAT_T)
GetProcAddress( _glfwLibrary.Libs.gdi32, "ChoosePixelFormat" );
_glfwLibrary.Libs.DescribePixelFormat = (DESCRIBEPIXELFORMAT_T)
GetProcAddress( _glfwLibrary.Libs.gdi32, "DescribePixelFormat" );
_glfwLibrary.Libs.GetPixelFormat = (GETPIXELFORMAT_T)
GetProcAddress( _glfwLibrary.Libs.gdi32, "GetPixelFormat" );
_glfwLibrary.Libs.SetPixelFormat = (SETPIXELFORMAT_T)
GetProcAddress( _glfwLibrary.Libs.gdi32, "SetPixelFormat" );
_glfwLibrary.Libs.SwapBuffers = (SWAPBUFFERS_T)
GetProcAddress( _glfwLibrary.Libs.gdi32, "SwapBuffers" );
if( _glfwLibrary.Libs.ChoosePixelFormat == NULL ||
_glfwLibrary.Libs.DescribePixelFormat == NULL ||
_glfwLibrary.Libs.GetPixelFormat == NULL ||
_glfwLibrary.Libs.SetPixelFormat == NULL ||
_glfwLibrary.Libs.SwapBuffers == NULL )
{
FreeLibrary( _glfwLibrary.Libs.gdi32 );
_glfwLibrary.Libs.gdi32 = NULL;
return GL_FALSE;
}
}
else
{
return GL_FALSE;
}
#endif // _GLFW_NO_DLOAD_GDI32
// winmm.dll (for joystick and timer support)
#ifndef _GLFW_NO_DLOAD_WINMM
_glfwLibrary.Libs.winmm = LoadLibrary( "winmm.dll" );
if( _glfwLibrary.Libs.winmm != NULL )
{
_glfwLibrary.Libs.joyGetDevCapsA = (JOYGETDEVCAPSA_T)
GetProcAddress( _glfwLibrary.Libs.winmm, "joyGetDevCapsA" );
_glfwLibrary.Libs.joyGetPos = (JOYGETPOS_T)
GetProcAddress( _glfwLibrary.Libs.winmm, "joyGetPos" );
_glfwLibrary.Libs.joyGetPosEx = (JOYGETPOSEX_T)
GetProcAddress( _glfwLibrary.Libs.winmm, "joyGetPosEx" );
_glfwLibrary.Libs.timeGetTime = (TIMEGETTIME_T)
GetProcAddress( _glfwLibrary.Libs.winmm, "timeGetTime" );
if( _glfwLibrary.Libs.joyGetDevCapsA == NULL ||
_glfwLibrary.Libs.joyGetPos == NULL ||
_glfwLibrary.Libs.joyGetPosEx == NULL ||
_glfwLibrary.Libs.timeGetTime == NULL )
{
FreeLibrary( _glfwLibrary.Libs.winmm );
_glfwLibrary.Libs.winmm = NULL;
return GL_FALSE;
}
}
else
{
return GL_FALSE;
}
#endif // _GLFW_NO_DLOAD_WINMM
return GL_TRUE;
}
//========================================================================
// Unload used libraries (DLLs)
//========================================================================
static void _glfwFreeLibraries( void )
{
// gdi32.dll
#ifndef _GLFW_NO_DLOAD_GDI32
if( _glfwLibrary.Libs.gdi32 != NULL )
{
FreeLibrary( _glfwLibrary.Libs.gdi32 );
_glfwLibrary.Libs.gdi32 = NULL;
}
#endif // _GLFW_NO_DLOAD_GDI32
// winmm.dll
#ifndef _GLFW_NO_DLOAD_WINMM
if( _glfwLibrary.Libs.winmm != NULL )
{
FreeLibrary( _glfwLibrary.Libs.winmm );
_glfwLibrary.Libs.winmm = NULL;
}
#endif // _GLFW_NO_DLOAD_WINMM
}
//========================================================================
// Terminate GLFW when exiting application
//========================================================================
void _glfwTerminate_atexit( void )
{
glfwTerminate();
}
//************************************************************************
//**** Platform implementation functions ****
//************************************************************************
//========================================================================
// Initialize various GLFW state
//========================================================================
int _glfwPlatformInit( void )
{
OSVERSIONINFO osi;
// To make SetForegroundWindow() work as we want, we need to fiddle
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
// as possible in the hope of still being the foreground process)
SystemParametersInfo( SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
&_glfwLibrary.Sys.foregroundLockTimeout, 0 );
SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID)0,
SPIF_SENDCHANGE );
// Check which OS version we are running
osi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &osi );
_glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN;
if( osi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
{
if( osi.dwMajorVersion == 4 && osi.dwMinorVersion < 10 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_95;
}
else if( osi.dwMajorVersion == 4 && osi.dwMinorVersion < 90 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_98;
}
else if( osi.dwMajorVersion == 4 && osi.dwMinorVersion == 90 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_ME;
}
else if( osi.dwMajorVersion >= 4 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN_9x;
}
}
else if( osi.dwPlatformId == VER_PLATFORM_WIN32_NT )
{
if( osi.dwMajorVersion == 4 && osi.dwMinorVersion == 0 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_NT4;
}
else if( osi.dwMajorVersion == 5 && osi.dwMinorVersion == 0 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_2K;
}
else if( osi.dwMajorVersion == 5 && osi.dwMinorVersion == 1 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_XP;
}
else if( osi.dwMajorVersion == 5 && osi.dwMinorVersion == 2 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_NET_SERVER;
}
else if( osi.dwMajorVersion >= 5 )
{
_glfwLibrary.Sys.winVer = _GLFW_WIN_UNKNOWN_NT;
}
}
// Do we have Unicode support?
if( _glfwLibrary.Sys.winVer >= _GLFW_WIN_NT4 )
{
// Windows NT/2000/XP/.NET has Unicode support
_glfwLibrary.Sys.hasUnicode = GL_TRUE;
}
else
{
// Windows 9x/ME does not have Unicode support
_glfwLibrary.Sys.hasUnicode = GL_FALSE;
}
// Load libraries (DLLs)
if( !_glfwInitLibraries() )
{
return GL_FALSE;
}
// With the Borland C++ compiler, we want to disable FPU exceptions
// (this is recommended for OpenGL applications under Windows)
#ifdef __BORLANDC__
_control87( MCW_EM, MCW_EM );
#endif
// Retrieve GLFW instance handle
_glfwLibrary.instance = GetModuleHandle( NULL );
// System keys are not disabled
_glfwWin.keyboardHook = NULL;
// Install atexit() routine
atexit( _glfwTerminate_atexit );
// Start the timer
_glfwInitTimer();
return GL_TRUE;
}
//========================================================================
// Close window and shut down library
//========================================================================
int _glfwPlatformTerminate( void )
{
// Close OpenGL window
glfwCloseWindow();
// Enable system keys again (if they were disabled)
glfwEnable( GLFW_SYSTEM_KEYS );
// Unload libraries (DLLs)
_glfwFreeLibraries();
// Restore FOREGROUNDLOCKTIMEOUT system setting
SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
(LPVOID)_glfwLibrary.Sys.foregroundLockTimeout,
SPIF_SENDCHANGE );
return GL_TRUE;
}
+233
View File
@@ -0,0 +1,233 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
//************************************************************************
//**** GLFW internal functions ****
//************************************************************************
//========================================================================
// Return GL_TRUE if joystick is present, else return GL_FALSE.
//========================================================================
static int _glfwJoystickPresent( int joy )
{
JOYINFO ji;
// Windows NT 4.0 MMSYSTEM only supports 2 sticks (other Windows
// versions support 16 sticks)
if( _glfwLibrary.Sys.winVer == _GLFW_WIN_NT4 && joy > GLFW_JOYSTICK_2 )
{
return GL_FALSE;
}
// Is it a valid stick ID (Windows don't support more than 16 sticks)?
if( joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_16 )
{
return GL_FALSE;
}
// Is the joystick present?
if( _glfw_joyGetPos( joy - GLFW_JOYSTICK_1, &ji ) != JOYERR_NOERROR )
{
return GL_FALSE;
}
return GL_TRUE;
}
//========================================================================
// Calculate joystick position
//========================================================================
static float _glfwCalcJoystickPos( DWORD pos, DWORD min, DWORD max )
{
float fpos = (float) pos;
float fmin = (float) min;
float fmax = (float) max;
return (2.0f*(fpos - fmin) / (fmax - fmin)) - 1.0f;
}
//************************************************************************
//**** Platform implementation functions ****
//************************************************************************
//========================================================================
// Determine joystick capabilities
//========================================================================
int _glfwPlatformGetJoystickParam( int joy, int param )
{
JOYCAPS jc;
// return 0;
// Is joystick present?
if( !_glfwJoystickPresent( joy ) )
{
return 0;
}
// We got this far, the joystick is present
if( param == GLFW_PRESENT )
{
return GL_TRUE;
}
// Get joystick capabilities
_glfw_joyGetDevCaps( joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS) );
switch( param )
{
case GLFW_AXES:
// Return number of joystick axes
return jc.wNumAxes;
case GLFW_BUTTONS:
// Return number of joystick axes
return jc.wNumButtons;
default:
break;
}
return 0;
}
//========================================================================
// Get joystick axis positions
//========================================================================
int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
{
JOYCAPS jc;
JOYINFOEX ji;
int axis;
// return 0;
// Is joystick present?
if( !_glfwJoystickPresent( joy ) )
{
return 0;
}
// Get joystick capabilities
_glfw_joyGetDevCaps( joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS) );
// Get joystick state
ji.dwSize = sizeof( JOYINFOEX );
ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNZ |
JOY_RETURNR | JOY_RETURNU | JOY_RETURNV;
_glfw_joyGetPosEx( joy - GLFW_JOYSTICK_1, &ji );
// Get position values for all axes
axis = 0;
if( axis < numaxes )
{
pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwXpos, jc.wXmin,
jc.wXmax );
}
if( axis < numaxes )
{
pos[ axis++ ] = -_glfwCalcJoystickPos( ji.dwYpos, jc.wYmin,
jc.wYmax );
}
if( axis < numaxes && jc.wCaps & JOYCAPS_HASZ )
{
pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwZpos, jc.wZmin,
jc.wZmax );
}
if( axis < numaxes && jc.wCaps & JOYCAPS_HASR )
{
pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwRpos, jc.wRmin,
jc.wRmax );
}
if( axis < numaxes && jc.wCaps & JOYCAPS_HASU )
{
pos[ axis++ ] = _glfwCalcJoystickPos( ji.dwUpos, jc.wUmin,
jc.wUmax );
}
if( axis < numaxes && jc.wCaps & JOYCAPS_HASV )
{
pos[ axis++ ] = -_glfwCalcJoystickPos( ji.dwVpos, jc.wVmin,
jc.wVmax );
}
// Return number of returned axes
return axis;
}
//========================================================================
// Get joystick button states
//========================================================================
int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons,
int numbuttons )
{
JOYCAPS jc;
JOYINFOEX ji;
int button;
// return 0;
// Is joystick present?
if( !_glfwJoystickPresent( joy ) )
{
return 0;
}
// Get joystick capabilities
_glfw_joyGetDevCaps( joy - GLFW_JOYSTICK_1, &jc, sizeof(JOYCAPS) );
// Get joystick state
ji.dwSize = sizeof( JOYINFOEX );
ji.dwFlags = JOY_RETURNBUTTONS;
_glfw_joyGetPosEx( joy - GLFW_JOYSTICK_1, &ji );
// Get states of all requested buttons
button = 0;
while( button < numbuttons && button < (int) jc.wNumButtons )
{
buttons[ button ] = (unsigned char)
(ji.dwButtons & (1UL << button) ? GLFW_PRESS : GLFW_RELEASE);
button ++;
}
return button;
}
+118
View File
@@ -0,0 +1,118 @@
//========================================================================
// GLFW - An OpenGL framework
// Platform: Win32/WGL
// API version: 3.0
// 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.
//
//========================================================================
#include "internal.h"
//************************************************************************
//**** GLFW internal functions ****
//************************************************************************
//========================================================================
// Initialise timer
//========================================================================
void _glfwInitTimer( void )
{
__int64 freq;
// Check if we have a performance counter
if( QueryPerformanceFrequency( (LARGE_INTEGER *)&freq ) )
{
// Performance counter is available => use it!
_glfwLibrary.Timer.HasPerformanceCounter = GL_TRUE;
// Counter resolution is 1 / counter frequency
_glfwLibrary.Timer.Resolution = 1.0 / (double)freq;
// Set start time for timer
QueryPerformanceCounter( (LARGE_INTEGER *)&_glfwLibrary.Timer.t0_64 );
}
else
{
// No performace counter available => use the tick counter
_glfwLibrary.Timer.HasPerformanceCounter = GL_FALSE;
// Counter resolution is 1 ms
_glfwLibrary.Timer.Resolution = 0.001;
// Set start time for timer
_glfwLibrary.Timer.t0_32 = _glfw_timeGetTime();
}
}
//************************************************************************
//**** Platform implementation functions ****
//************************************************************************
//========================================================================
// Return timer value in seconds
//========================================================================
double _glfwPlatformGetTime( void )
{
double t;
__int64 t_64;
if( _glfwLibrary.Timer.HasPerformanceCounter )
{
QueryPerformanceCounter( (LARGE_INTEGER *)&t_64 );
t = (double)(t_64 - _glfwLibrary.Timer.t0_64);
}
else
{
t = (double)(_glfw_timeGetTime() - _glfwLibrary.Timer.t0_32);
}
// Calculate the current time in seconds
return t * _glfwLibrary.Timer.Resolution;
}
//========================================================================
// Set timer value in seconds
//========================================================================
void _glfwPlatformSetTime( double t )
{
__int64 t_64;
if( _glfwLibrary.Timer.HasPerformanceCounter )
{
QueryPerformanceCounter( (LARGE_INTEGER *)&t_64 );
_glfwLibrary.Timer.t0_64 = t_64 - (__int64)(t/_glfwLibrary.Timer.Resolution);
}
else
{
_glfwLibrary.Timer.t0_32 = _glfw_timeGetTime() - (int)(t*1000.0);
}
}
File diff suppressed because it is too large Load Diff