mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
Win32 port work dump.
This commit is contained in:
parent
a4365f5a8e
commit
3f986541dd
|
@ -261,6 +261,11 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
|
||||||
#endif // _GLFW_NO_DLOAD_WINMM
|
#endif // _GLFW_NO_DLOAD_WINMM
|
||||||
|
|
||||||
|
|
||||||
|
// We use versioned window class names in order not to cause conflicts
|
||||||
|
// between applications using different versions of GLFW
|
||||||
|
#define _GLFW_WNDCLASSNAME "GLFW30"
|
||||||
|
|
||||||
|
|
||||||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
|
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
|
||||||
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryWin32 Win32
|
#define _GLFW_PLATFORM_LIBRARY_STATE _GLFWlibraryWin32 Win32
|
||||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
|
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
|
||||||
|
@ -305,7 +310,6 @@ typedef struct _GLFWwindowWin32
|
||||||
{
|
{
|
||||||
// Platform specific window resources
|
// Platform specific window resources
|
||||||
HWND handle; // Window handle
|
HWND handle; // Window handle
|
||||||
ATOM classAtom; // Window class atom
|
|
||||||
DWORD dwStyle; // Window styles used for window creation
|
DWORD dwStyle; // Window styles used for window creation
|
||||||
DWORD dwExStyle; // --"--
|
DWORD dwExStyle; // --"--
|
||||||
|
|
||||||
|
@ -325,6 +329,7 @@ typedef struct _GLFWwindowWin32
|
||||||
typedef struct _GLFWlibraryWin32
|
typedef struct _GLFWlibraryWin32
|
||||||
{
|
{
|
||||||
HINSTANCE instance; // Instance of the application
|
HINSTANCE instance; // Instance of the application
|
||||||
|
ATOM classAtom; // Window class atom
|
||||||
HHOOK keyboardHook; // Keyboard hook handle
|
HHOOK keyboardHook; // Keyboard hook handle
|
||||||
DWORD foregroundLockTimeout;
|
DWORD foregroundLockTimeout;
|
||||||
|
|
||||||
|
|
|
@ -191,6 +191,12 @@ int _glfwPlatformTerminate(void)
|
||||||
while (_glfwLibrary.windowListHead)
|
while (_glfwLibrary.windowListHead)
|
||||||
glfwCloseWindow(_glfwLibrary.windowListHead);
|
glfwCloseWindow(_glfwLibrary.windowListHead);
|
||||||
|
|
||||||
|
if (_glfwLibrary.Win32.classAtom)
|
||||||
|
{
|
||||||
|
UnregisterClass(_GLFW_WNDCLASSNAME, _glfwLibrary.Win32.instance);
|
||||||
|
_glfwLibrary.Win32.classAtom = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Remove keyboard hook
|
// TODO: Remove keyboard hook
|
||||||
|
|
||||||
freeLibraries();
|
freeLibraries();
|
||||||
|
|
|
@ -34,11 +34,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
// We use versioned window class names in order not to cause conflicts
|
|
||||||
// between applications using different versions of GLFW
|
|
||||||
#define _GLFW_WNDCLASSNAME "GLFW30"
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Convert BPP to RGB bits based on "best guess"
|
// Convert BPP to RGB bits based on "best guess"
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -320,18 +315,25 @@ static HGLRC createContext(_GLFWwindow* window,
|
||||||
const _GLFWwndconfig* wndconfig,
|
const _GLFWwndconfig* wndconfig,
|
||||||
int pixelFormat)
|
int pixelFormat)
|
||||||
{
|
{
|
||||||
|
HGLRC context;
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
int flags, i = 0, attribs[7];
|
int flags, i = 0, attribs[7];
|
||||||
|
|
||||||
if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
|
if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INTERNAL_ERROR);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
|
if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INTERNAL_ERROR);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (window->WGL.has_WGL_ARB_create_context)
|
if (window->WGL.has_WGL_ARB_create_context)
|
||||||
{
|
{
|
||||||
// Use the newer wglCreateContextAttribsARB
|
// Use the newer wglCreateContextAttribsARB creation method
|
||||||
|
|
||||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||||
{
|
{
|
||||||
|
@ -370,10 +372,24 @@ static HGLRC createContext(_GLFWwindow* window,
|
||||||
|
|
||||||
attribs[i++] = 0;
|
attribs[i++] = 0;
|
||||||
|
|
||||||
return window->WGL.CreateContextAttribsARB(window->WGL.DC, NULL, attribs);
|
context = window->WGL.CreateContextAttribsARB(window->WGL.DC, NULL, attribs);
|
||||||
|
if (!context)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INTERNAL_ERROR);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context = wglCreateContext(window->WGL.DC);
|
||||||
|
if (!context)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INTERNAL_ERROR);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return wglCreateContext(window->WGL.DC);
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -615,7 +631,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
{
|
{
|
||||||
CREATESTRUCT* cs = (CREATESTRUCT*) lParam;
|
CREATESTRUCT* cs = (CREATESTRUCT*) lParam;
|
||||||
SetWindowLongPtr(hWnd, 0, cs->lpCreateParams);
|
SetWindowLongPtr(hWnd, 0, (LONG_PTR) cs->lpCreateParams);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,9 +730,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
{
|
{
|
||||||
// Translate this to WM_QUIT so that we can handle all cases in the
|
// Flag this window for closing (handled in glfwPollEvents)
|
||||||
// same place
|
window->closed = GL_TRUE;
|
||||||
PostQuitMessage(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1021,6 +1036,7 @@ static void initWGLExtensions(_GLFWwindow* window)
|
||||||
static ATOM registerWindowClass(void)
|
static ATOM registerWindowClass(void)
|
||||||
{
|
{
|
||||||
WNDCLASS wc;
|
WNDCLASS wc;
|
||||||
|
ATOM classAtom;
|
||||||
|
|
||||||
// Set window class parameters
|
// Set window class parameters
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw on...
|
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw on...
|
||||||
|
@ -1041,7 +1057,14 @@ static ATOM registerWindowClass(void)
|
||||||
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RegisterClass(&wc);
|
classAtom = RegisterClass(&wc);
|
||||||
|
if (!classAtom)
|
||||||
|
{
|
||||||
|
_glfwSetError(GLFW_INTERNAL_ERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return classAtom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1231,9 +1254,12 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||||
|
|
||||||
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
|
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
|
||||||
|
|
||||||
window->Win32.classAtom = registerWindowClass();
|
if (!_glfwLibrary.Win32.classAtom)
|
||||||
if (!window->Win32.classAtom)
|
{
|
||||||
|
_glfwLibrary.Win32.classAtom = registerWindowClass();
|
||||||
|
if (!_glfwLibrary.Win32.classAtom)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
|
@ -1334,17 +1360,8 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
destroyWindow(window);
|
destroyWindow(window);
|
||||||
|
|
||||||
if (window->Win32.classAtom)
|
|
||||||
{
|
|
||||||
UnregisterClass(_GLFW_WNDCLASSNAME, _glfwLibrary.Win32.instance);
|
|
||||||
window->Win32.classAtom = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
_glfwRestoreVideoMode();
|
||||||
// Restore original desktop resolution
|
|
||||||
ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user