Begun adaptation of Win32 port to new API.

This commit is contained in:
Camilla Berglund 2010-09-10 22:26:17 +02:00
parent 4cbe749932
commit cf2df6e478

View File

@ -43,7 +43,7 @@
// Include files // Include files
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #include <mmsystem.h>
#include "../../include/GL/glfw.h" #include "../../include/GL/glfw3.h"
//======================================================================== //========================================================================
@ -138,11 +138,11 @@ typedef struct tagKBDLLHOOKSTRUCT {
// wglSwapIntervalEXT typedef (Win32 buffer-swap interval control) // wglSwapIntervalEXT typedef (Win32 buffer-swap interval control)
typedef int (APIENTRY * WGLSWAPINTERVALEXT_T) (int); typedef int (APIENTRY * WGLSWAPINTERVALEXT_T) (int);
// wglGetPixelFormatAttribivARB typedef // wglGetPixelFormatAttribivARB typedef
typedef BOOL (WINAPI * WGLGETPIXELFORMATATTRIBIVARB_T) (HDC, int, int, UINT, const int *, int *); typedef BOOL (WINAPI * WGLGETPIXELFORMATATTRIBIVARB_T) (HDC, int, int, UINT, const int* , int* );
// wglGetExtensionStringEXT typedef // wglGetExtensionStringEXT typedef
typedef const char *(APIENTRY * WGLGETEXTENSIONSSTRINGEXT_T)( void ); typedef const char* (APIENTRY * WGLGETEXTENSIONSSTRINGEXT_T)(void);
// wglGetExtensionStringARB typedef // wglGetExtensionStringARB typedef
typedef const char *(APIENTRY * WGLGETEXTENSIONSSTRINGARB_T)( HDC ); typedef const char* (APIENTRY * WGLGETEXTENSIONSSTRINGARB_T)(HDC);
/* Constants for wglGetPixelFormatAttribivARB */ /* Constants for wglGetPixelFormatAttribivARB */
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
@ -183,7 +183,7 @@ typedef const char *(APIENTRY * WGLGETEXTENSIONSSTRINGARB_T)( HDC );
#ifndef WGL_ARB_create_context #ifndef WGL_ARB_create_context
/* wglCreateContextAttribsARB */ /* wglCreateContextAttribsARB */
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC, HGLRC, const int *); typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC, HGLRC, const int* );
/* Tokens for wglCreateContextAttribsARB attributes */ /* Tokens for wglCreateContextAttribsARB attributes */
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
@ -205,7 +205,7 @@ typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC, HGLRC, const in
#ifndef GL_VERSION_3_0 #ifndef GL_VERSION_3_0
typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC) (GLenum, GLuint); typedef const GLubyte* (APIENTRY *PFNGLGETSTRINGIPROC) (GLenum, GLuint);
#endif /*GL_VERSION_3_0*/ #endif /*GL_VERSION_3_0*/
@ -261,6 +261,11 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
#endif // _GLFW_NO_DLOAD_WINMM #endif // _GLFW_NO_DLOAD_WINMM
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryWin32 Win32
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
//======================================================================== //========================================================================
// GLFW platform specific types // GLFW platform specific types
//======================================================================== //========================================================================
@ -272,71 +277,13 @@ typedef INT_PTR GLFWintptr;
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Window structure // Platform-specific OpenGL context structure
//------------------------------------------------------------------------ //------------------------------------------------------------------------
typedef struct _GLFWwin_struct _GLFWwin; typedef struct _GLFWcontextWGL
{
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 // Platform specific window resources
HDC DC; // Private GDI device context HDC DC; // Private GDI device context
HGLRC context; // Permanent rendering 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) // Platform specific extensions (context specific)
WGLSWAPINTERVALEXT_T SwapIntervalEXT; WGLSWAPINTERVALEXT_T SwapIntervalEXT;
@ -348,59 +295,39 @@ struct _GLFWwin_struct {
GLboolean has_WGL_ARB_multisample; GLboolean has_WGL_ARB_multisample;
GLboolean has_WGL_ARB_pixel_format; GLboolean has_WGL_ARB_pixel_format;
GLboolean has_WGL_ARB_create_context; GLboolean has_WGL_ARB_create_context;
} _GLFWcontextWGL;
//------------------------------------------------------------------------
// Platform-specific window structure
//------------------------------------------------------------------------
typedef struct _GLFWwindowWin32
{
// Platform specific window resources
HWND handle; // 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; // --"--
// Various platform specific internal variables // Various platform specific internal variables
int oldMouseLock; // Old mouse-lock flag (used for remembering int oldMouseLock; // Old mouse-lock flag (used for remembering
// mouse-lock state when iconifying) // mouse-lock state when iconifying)
int oldMouseLockValid; int oldMouseLockValid;
int desiredRefreshRate; // Desired vertical monitor refresh rate int desiredRefreshRate; // Desired vertical monitor refresh rate
int mouseMoved;
}; int oldMouseX, oldMouseY;
} _GLFWwindowWin32;
GLFWGLOBAL _GLFWwin _glfwWin;
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// User input status (most of this should go in _GLFWwin) // Platform-specific library global data
//------------------------------------------------------------------------ //------------------------------------------------------------------------
GLFWGLOBAL struct { typedef struct _GLFWlibraryWin32
{
// ========= PLATFORM INDEPENDENT MANDATORY PART ========================= // Instance of the application
HINSTANCE instance;
// 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 // Timer data
struct { struct {
@ -408,14 +335,14 @@ GLFWGLOBAL struct {
double Resolution; double Resolution;
unsigned int t0_32; unsigned int t0_32;
__int64 t0_64; __int64 t0_64;
} Timer; } timer;
// System information // System information
struct { struct {
int winVer; int winVer;
int hasUnicode; int hasUnicode;
DWORD foregroundLockTimeout; DWORD foregroundLockTimeout;
} Sys; } sys;
#if !defined(_GLFW_NO_DLOAD_WINMM) || !defined(_GLFW_NO_DLOAD_GDI32) #if !defined(_GLFW_NO_DLOAD_WINMM) || !defined(_GLFW_NO_DLOAD_GDI32)
// Library handles and function pointers // Library handles and function pointers
@ -438,10 +365,10 @@ GLFWGLOBAL struct {
JOYGETPOSEX_T joyGetPosEx; JOYGETPOSEX_T joyGetPosEx;
TIMEGETTIME_T timeGetTime; TIMEGETTIME_T timeGetTime;
#endif // _GLFW_NO_DLOAD_WINMM #endif // _GLFW_NO_DLOAD_WINMM
} Libs; } libs;
#endif #endif
} _glfwLibrary; } _GLFWlibraryWin32;
//======================================================================== //========================================================================
@ -465,13 +392,13 @@ GLFWGLOBAL struct {
//======================================================================== //========================================================================
// Time // Time
void _glfwInitTimer( void ); void _glfwInitTimer(void);
// Fullscreen support // Fullscreen support
int _glfwGetClosestVideoModeBPP( int *w, int *h, int *bpp, int *refresh ); int _glfwGetClosestVideoModeBPP(int* w, int* h, int* bpp, int* refresh);
int _glfwGetClosestVideoMode( int *w, int *h, int *r, int *g, int *b, int *refresh ); int _glfwGetClosestVideoMode(int* w, int* h, int* r, int* g, int* b, int* refresh);
void _glfwSetVideoModeMODE( int mode ); void _glfwSetVideoModeMODE(int mode);
void _glfwSetVideoMode( int *w, int *h, int r, int g, int b, int refresh ); void _glfwSetVideoMode(int* w, int* h, int r, int g, int b, int refresh);
#endif // _platform_h_ #endif // _platform_h_