Win32 port work dump.

This commit is contained in:
Camilla Berglund 2010-09-14 01:05:03 +02:00
parent a76e891295
commit 24e789b38a
3 changed files with 56 additions and 55 deletions

View File

@ -336,11 +336,6 @@ typedef struct _GLFWlibraryWin32
__int64 t0_64; __int64 t0_64;
} timer; } timer;
// System information
struct {
int winVer;
} 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
struct { struct {

View File

@ -30,6 +30,8 @@
#include "internal.h" #include "internal.h"
#include <stdlib.h>
#ifdef __BORLANDC__ #ifdef __BORLANDC__
// With the Borland C++ compiler, we want to disable FPU exceptions // With the Borland C++ compiler, we want to disable FPU exceptions
#include <float.h> #include <float.h>
@ -59,11 +61,11 @@ static GLboolean initLibraries(void)
_glfwLibrary.Win32.libs.SwapBuffers = (SWAPBUFFERS_T) _glfwLibrary.Win32.libs.SwapBuffers = (SWAPBUFFERS_T)
GetProcAddress(_glfwLibrary.Win32.libs.gdi32, "SwapBuffers"); GetProcAddress(_glfwLibrary.Win32.libs.gdi32, "SwapBuffers");
if (_glfwLibrary.Win32.libs.ChoosePixelFormat && if (!_glfwLibrary.Win32.libs.ChoosePixelFormat ||
_glfwLibrary.Win32.libs.DescribePixelFormat && !_glfwLibrary.Win32.libs.DescribePixelFormat ||
_glfwLibrary.Win32.libs.GetPixelFormat && !_glfwLibrary.Win32.libs.GetPixelFormat ||
_glfwLibrary.Win32.libs.SetPixelFormat && !_glfwLibrary.Win32.libs.SetPixelFormat ||
_glfwLibrary.Win32.libs.SwapBuffers) !_glfwLibrary.Win32.libs.SwapBuffers)
{ {
FreeLibrary(_glfwLibrary.Win32.libs.gdi32); FreeLibrary(_glfwLibrary.Win32.libs.gdi32);
_glfwLibrary.Win32.libs.gdi32 = NULL; _glfwLibrary.Win32.libs.gdi32 = NULL;
@ -89,10 +91,10 @@ static GLboolean initLibraries(void)
_glfwLibrary.Win32.libs.timeGetTime = (TIMEGETTIME_T) _glfwLibrary.Win32.libs.timeGetTime = (TIMEGETTIME_T)
GetProcAddress(_glfwLibrary.Win32.libs.winmm, "timeGetTime"); GetProcAddress(_glfwLibrary.Win32.libs.winmm, "timeGetTime");
if (_glfwLibrary.Win32.libs.joyGetDevCapsA && if (!_glfwLibrary.Win32.libs.joyGetDevCapsA ||
_glfwLibrary.Win32.libs.joyGetPos && !_glfwLibrary.Win32.libs.joyGetPos ||
_glfwLibrary.Win32.libs.joyGetPosEx && !_glfwLibrary.Win32.libs.joyGetPosEx ||
_glfwLibrary.Win32.libs.timeGetTime) !_glfwLibrary.Win32.libs.timeGetTime)
{ {
FreeLibrary(_glfwLibrary.Win32.libs.winmm); FreeLibrary(_glfwLibrary.Win32.libs.winmm);
_glfwLibrary.Win32.libs.winmm = NULL; _glfwLibrary.Win32.libs.winmm = NULL;
@ -153,8 +155,6 @@ static void glfw_atexit(void)
int _glfwPlatformInit(void) int _glfwPlatformInit(void)
{ {
OSVERSIONINFO osi;
// To make SetForegroundWindow work as we want, we need to fiddle // To make SetForegroundWindow work as we want, we need to fiddle
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
// as possible in the hope of still being the foreground process) // as possible in the hope of still being the foreground process)
@ -163,38 +163,7 @@ int _glfwPlatformInit(void)
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID) 0, SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID) 0,
SPIF_SENDCHANGE); SPIF_SENDCHANGE);
// Check which OS version we are running if (!initLibraries())
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())
return GL_FALSE; return GL_FALSE;
#ifdef __BORLANDC__ #ifdef __BORLANDC__
@ -224,7 +193,7 @@ int _glfwPlatformTerminate(void)
// TODO: Remove keyboard hook // TODO: Remove keyboard hook
_glfwFreeLibraries(); freeLibraries();
// Restore previous FOREGROUNDLOCKTIMEOUT system setting // Restore previous FOREGROUNDLOCKTIMEOUT system setting
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
@ -234,3 +203,36 @@ int _glfwPlatformTerminate(void)
return GL_TRUE; 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;
}

View File

@ -31,6 +31,7 @@
#include "internal.h" #include "internal.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
// We use versioned window class names in order not to cause conflicts // 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) switch (uMsg)
{ {
case WM_CREATE:
{
CREATESTRUCT* cs = (CREATESTRUCT*) lParam;
SetWindowLongPtr(hWnd, 0, cs->lpCreateParams);
break;
}
// Window activate message? (iconification?) // Window activate message? (iconification?)
case WM_ACTIVATE: case WM_ACTIVATE:
{ {
@ -1143,7 +1151,7 @@ static int createWindow(_GLFWwindow* window,
NULL, // No parent window NULL, // No parent window
NULL, // No menu NULL, // No menu
_glfwLibrary.Win32.instance, _glfwLibrary.Win32.instance,
NULL); // No lParam to WM_CREATE window); // Pass GLFW window to WM_CREATE
if (!window->Win32.handle) if (!window->Win32.handle)
{ {
@ -1166,11 +1174,7 @@ static int createWindow(_GLFWwindow* window,
if (!window->WGL.context) if (!window->WGL.context)
return GL_FALSE; return GL_FALSE;
if (!wglMakeCurrent(window->WGL.DC, window->WGL.context)) glfwMakeWindowCurrent(window);
{
_glfwSetError(GLFW_INTERNAL_ERROR);
return GL_FALSE;
}
initWGLExtensions(window); initWGLExtensions(window);