mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
Win32 port work dump.
This commit is contained in:
parent
a76e891295
commit
24e789b38a
@ -336,11 +336,6 @@ typedef struct _GLFWlibraryWin32
|
||||
__int64 t0_64;
|
||||
} timer;
|
||||
|
||||
// System information
|
||||
struct {
|
||||
int winVer;
|
||||
} sys;
|
||||
|
||||
#if !defined(_GLFW_NO_DLOAD_WINMM) || !defined(_GLFW_NO_DLOAD_GDI32)
|
||||
// Library handles and function pointers
|
||||
struct {
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// With the Borland C++ compiler, we want to disable FPU exceptions
|
||||
#include <float.h>
|
||||
@ -59,11 +61,11 @@ static GLboolean initLibraries(void)
|
||||
_glfwLibrary.Win32.libs.SwapBuffers = (SWAPBUFFERS_T)
|
||||
GetProcAddress(_glfwLibrary.Win32.libs.gdi32, "SwapBuffers");
|
||||
|
||||
if (_glfwLibrary.Win32.libs.ChoosePixelFormat &&
|
||||
_glfwLibrary.Win32.libs.DescribePixelFormat &&
|
||||
_glfwLibrary.Win32.libs.GetPixelFormat &&
|
||||
_glfwLibrary.Win32.libs.SetPixelFormat &&
|
||||
_glfwLibrary.Win32.libs.SwapBuffers)
|
||||
if (!_glfwLibrary.Win32.libs.ChoosePixelFormat ||
|
||||
!_glfwLibrary.Win32.libs.DescribePixelFormat ||
|
||||
!_glfwLibrary.Win32.libs.GetPixelFormat ||
|
||||
!_glfwLibrary.Win32.libs.SetPixelFormat ||
|
||||
!_glfwLibrary.Win32.libs.SwapBuffers)
|
||||
{
|
||||
FreeLibrary(_glfwLibrary.Win32.libs.gdi32);
|
||||
_glfwLibrary.Win32.libs.gdi32 = NULL;
|
||||
@ -89,10 +91,10 @@ static GLboolean initLibraries(void)
|
||||
_glfwLibrary.Win32.libs.timeGetTime = (TIMEGETTIME_T)
|
||||
GetProcAddress(_glfwLibrary.Win32.libs.winmm, "timeGetTime");
|
||||
|
||||
if (_glfwLibrary.Win32.libs.joyGetDevCapsA &&
|
||||
_glfwLibrary.Win32.libs.joyGetPos &&
|
||||
_glfwLibrary.Win32.libs.joyGetPosEx &&
|
||||
_glfwLibrary.Win32.libs.timeGetTime)
|
||||
if (!_glfwLibrary.Win32.libs.joyGetDevCapsA ||
|
||||
!_glfwLibrary.Win32.libs.joyGetPos ||
|
||||
!_glfwLibrary.Win32.libs.joyGetPosEx ||
|
||||
!_glfwLibrary.Win32.libs.timeGetTime)
|
||||
{
|
||||
FreeLibrary(_glfwLibrary.Win32.libs.winmm);
|
||||
_glfwLibrary.Win32.libs.winmm = NULL;
|
||||
@ -153,8 +155,6 @@ static void glfw_atexit(void)
|
||||
|
||||
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)
|
||||
@ -163,38 +163,7 @@ int _glfwPlatformInit(void)
|
||||
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID) 0,
|
||||
SPIF_SENDCHANGE);
|
||||
|
||||
// Check which OS version we are running
|
||||
osi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&osi);
|
||||
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_UNKNOWN;
|
||||
|
||||
if (osi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
||||
{
|
||||
if (osi.dwMajorVersion == 4 && osi.dwMinorVersion < 10)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_95;
|
||||
else if (osi.dwMajorVersion == 4 && osi.dwMinorVersion < 90)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_98;
|
||||
else if (osi.dwMajorVersion == 4 && osi.dwMinorVersion == 90)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_ME;
|
||||
else if (osi.dwMajorVersion >= 4)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_UNKNOWN_9x;
|
||||
}
|
||||
else if (osi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
if (osi.dwMajorVersion == 4 && osi.dwMinorVersion == 0)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_NT4;
|
||||
else if (osi.dwMajorVersion == 5 && osi.dwMinorVersion == 0)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_2K;
|
||||
else if (osi.dwMajorVersion == 5 && osi.dwMinorVersion == 1)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_XP;
|
||||
else if (osi.dwMajorVersion == 5 && osi.dwMinorVersion == 2)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_NET_SERVER;
|
||||
else if (osi.dwMajorVersion >= 5)
|
||||
_glfwLibrary.Win32.sys.winVer = _GLFW_WIN_UNKNOWN_NT;
|
||||
}
|
||||
|
||||
if (!_glfwInitLibraries())
|
||||
if (!initLibraries())
|
||||
return GL_FALSE;
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
@ -224,7 +193,7 @@ int _glfwPlatformTerminate(void)
|
||||
|
||||
// TODO: Remove keyboard hook
|
||||
|
||||
_glfwFreeLibraries();
|
||||
freeLibraries();
|
||||
|
||||
// Restore previous FOREGROUNDLOCKTIMEOUT system setting
|
||||
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
|
||||
@ -234,3 +203,36 @@ int _glfwPlatformTerminate(void)
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Get the GLFW version string
|
||||
//========================================================================
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
{
|
||||
const char* version = "GLFW "
|
||||
#if defined(__MINGW32__)
|
||||
" MinGW"
|
||||
#elif defined(__CYGWIN__)
|
||||
" Cygwin"
|
||||
#elif defined(_MSC_VER)
|
||||
" Visual C++"
|
||||
#elif defined(__BORLANDC__)
|
||||
" Borland C"
|
||||
#else
|
||||
" (unknown compiler)"
|
||||
#endif
|
||||
#if defined(GLFW_BUILD_DLL)
|
||||
" DLL"
|
||||
#endif
|
||||
#if !defined(_GLFW_NO_DLOAD_GDI32)
|
||||
" load(gdi32)"
|
||||
#endif
|
||||
#if !defined(_GLFW_NO_DLOAD_WINMM)
|
||||
" load(winmm)"
|
||||
#endif
|
||||
;
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
// We use versioned window class names in order not to cause conflicts
|
||||
@ -611,6 +612,13 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
CREATESTRUCT* cs = (CREATESTRUCT*) lParam;
|
||||
SetWindowLongPtr(hWnd, 0, cs->lpCreateParams);
|
||||
break;
|
||||
}
|
||||
|
||||
// Window activate message? (iconification?)
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
@ -1143,7 +1151,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
NULL, // No parent window
|
||||
NULL, // No menu
|
||||
_glfwLibrary.Win32.instance,
|
||||
NULL); // No lParam to WM_CREATE
|
||||
window); // Pass GLFW window to WM_CREATE
|
||||
|
||||
if (!window->Win32.handle)
|
||||
{
|
||||
@ -1166,11 +1174,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
if (!window->WGL.context)
|
||||
return GL_FALSE;
|
||||
|
||||
if (!wglMakeCurrent(window->WGL.DC, window->WGL.context))
|
||||
{
|
||||
_glfwSetError(GLFW_INTERNAL_ERROR);
|
||||
return GL_FALSE;
|
||||
}
|
||||
glfwMakeWindowCurrent(window);
|
||||
|
||||
initWGLExtensions(window);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user