Removed dynamic loading of gdi32.

This commit is contained in:
Camilla Berglund 2012-03-30 02:28:15 +02:00
parent 532e0dd2f6
commit 2753577dbd
7 changed files with 16 additions and 108 deletions

View File

@ -54,7 +54,6 @@ if (_GLFW_WIN32_WGL)
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR}) list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY}) list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
set(_GLFW_NO_DLOAD_GDI32 ${BUILD_SHARED_LIBS})
set(_GLFW_NO_DLOAD_WINMM ${BUILD_SHARED_LIBS}) set(_GLFW_NO_DLOAD_WINMM ${BUILD_SHARED_LIBS})
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)

View File

@ -45,8 +45,6 @@
// Define this to 1 if building as a shared library / dynamic library / DLL // Define this to 1 if building as a shared library / dynamic library / DLL
#cmakedefine _GLFW_BUILD_DLL 1 #cmakedefine _GLFW_BUILD_DLL 1
// Define this to 1 to disable dynamic loading of gdi32
#cmakedefine _GLFW_NO_DLOAD_GDI32 1
// Define this to 1 to disable dynamic loading of winmm // Define this to 1 to disable dynamic loading of winmm
#cmakedefine _GLFW_NO_DLOAD_WINMM 1 #cmakedefine _GLFW_NO_DLOAD_WINMM 1

View File

@ -42,7 +42,7 @@
void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp) void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
{ {
_glfw_GetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp); GetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp);
} }
@ -52,6 +52,6 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
{ {
_glfw_SetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp); SetDeviceGammaRamp(GetDC(GetDesktopWindow()), (WORD*) ramp);
} }

View File

@ -44,40 +44,6 @@
static GLboolean initLibraries(void) static GLboolean initLibraries(void)
{ {
#ifndef _GLFW_NO_DLOAD_GDI32
// gdi32.dll (OpenGL pixel format functions & SwapBuffers)
_glfwLibrary.Win32.gdi.instance = LoadLibrary(L"gdi32.dll");
if (!_glfwLibrary.Win32.gdi.instance)
return GL_FALSE;
_glfwLibrary.Win32.gdi.ChoosePixelFormat = (CHOOSEPIXELFORMAT_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "ChoosePixelFormat");
_glfwLibrary.Win32.gdi.DescribePixelFormat = (DESCRIBEPIXELFORMAT_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "DescribePixelFormat");
_glfwLibrary.Win32.gdi.GetPixelFormat = (GETPIXELFORMAT_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "GetPixelFormat");
_glfwLibrary.Win32.gdi.SetPixelFormat = (SETPIXELFORMAT_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "SetPixelFormat");
_glfwLibrary.Win32.gdi.SwapBuffers = (SWAPBUFFERS_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "SwapBuffers");
_glfwLibrary.Win32.gdi.GetDeviceGammaRamp = (GETDEVICEGAMMARAMP_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "GetDeviceGammaRamp");
_glfwLibrary.Win32.gdi.SetDeviceGammaRamp = (SETDEVICEGAMMARAMP_T)
GetProcAddress(_glfwLibrary.Win32.gdi.instance, "SetDeviceGammaRamp");
if (!_glfwLibrary.Win32.gdi.ChoosePixelFormat ||
!_glfwLibrary.Win32.gdi.DescribePixelFormat ||
!_glfwLibrary.Win32.gdi.GetPixelFormat ||
!_glfwLibrary.Win32.gdi.SetPixelFormat ||
!_glfwLibrary.Win32.gdi.SwapBuffers ||
!_glfwLibrary.Win32.gdi.GetDeviceGammaRamp ||
!_glfwLibrary.Win32.gdi.SetDeviceGammaRamp)
{
return GL_FALSE;
}
#endif // _GLFW_NO_DLOAD_GDI32
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
// winmm.dll (for joystick and timer support) // winmm.dll (for joystick and timer support)
@ -113,14 +79,6 @@ static GLboolean initLibraries(void)
static void freeLibraries(void) static void freeLibraries(void)
{ {
#ifndef _GLFW_NO_DLOAD_GDI32
if (_glfwLibrary.Win32.gdi.instance != NULL)
{
FreeLibrary(_glfwLibrary.Win32.gdi.instance);
_glfwLibrary.Win32.gdi.instance = NULL;
}
#endif // _GLFW_NO_DLOAD_GDI32
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
if (_glfwLibrary.Win32.winmm.instance != NULL) if (_glfwLibrary.Win32.winmm.instance != NULL)
{ {
@ -274,9 +232,6 @@ const char* _glfwPlatformGetVersionString(void)
#if defined(_GLFW_BUILD_DLL) #if defined(_GLFW_BUILD_DLL)
" DLL" " DLL"
#endif #endif
#if !defined(_GLFW_NO_DLOAD_GDI32)
" load(gdi32)"
#endif
#if !defined(_GLFW_NO_DLOAD_WINMM) #if !defined(_GLFW_NO_DLOAD_WINMM)
" load(winmm)" " load(winmm)"
#endif #endif

View File

@ -56,7 +56,7 @@ void _glfwPlatformSwapBuffers(void)
{ {
_GLFWwindow* window = _glfwLibrary.currentWindow; _GLFWwindow* window = _glfwLibrary.currentWindow;
_glfw_SwapBuffers(window->WGL.DC); SwapBuffers(window->WGL.DC);
} }

View File

@ -82,17 +82,6 @@
// DLLs that are loaded at glfwInit() // 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);
typedef BOOL (WINAPI * GETDEVICEGAMMARAMP_T) (HDC,PVOID);
typedef BOOL (WINAPI * SETDEVICEGAMMARAMP_T) (HDC,PVOID);
#endif // _GLFW_NO_DLOAD_GDI32
// winmm.dll function pointer typedefs // winmm.dll function pointer typedefs
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T) (UINT,LPJOYCAPS,UINT); typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T) (UINT,LPJOYCAPS,UINT);
@ -102,25 +91,6 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
#endif // _GLFW_NO_DLOAD_WINMM #endif // _GLFW_NO_DLOAD_WINMM
// gdi32.dll shortcuts
#ifndef _GLFW_NO_DLOAD_GDI32
#define _glfw_ChoosePixelFormat _glfwLibrary.Win32.gdi.ChoosePixelFormat
#define _glfw_DescribePixelFormat _glfwLibrary.Win32.gdi.DescribePixelFormat
#define _glfw_GetPixelFormat _glfwLibrary.Win32.gdi.GetPixelFormat
#define _glfw_SetPixelFormat _glfwLibrary.Win32.gdi.SetPixelFormat
#define _glfw_SwapBuffers _glfwLibrary.Win32.gdi.SwapBuffers
#define _glfw_GetDeviceGammaRamp _glfwLibrary.Win32.gdi.GetDeviceGammaRamp
#define _glfw_SetDeviceGammaRamp _glfwLibrary.Win32.gdi.SetDeviceGammaRamp
#else
#define _glfw_ChoosePixelFormat ChoosePixelFormat
#define _glfw_DescribePixelFormat DescribePixelFormat
#define _glfw_GetPixelFormat GetPixelFormat
#define _glfw_SetPixelFormat SetPixelFormat
#define _glfw_SwapBuffers SwapBuffers
#define _glfw_GetDeviceGammaRamp GetDeviceGammaRamp
#define _glfw_SetDeviceGammaRamp SetDeviceGammaRamp
#endif // _GLFW_NO_DLOAD_GDI32
// winmm.dll shortcuts // winmm.dll shortcuts
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
#define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCaps #define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCaps
@ -225,20 +195,6 @@ typedef struct _GLFWlibraryWin32
__int64 t0_64; __int64 t0_64;
} timer; } timer;
#ifndef _GLFW_NO_DLOAD_GDI32
// gdi32.dll
struct {
HINSTANCE instance;
CHOOSEPIXELFORMAT_T ChoosePixelFormat;
DESCRIBEPIXELFORMAT_T DescribePixelFormat;
GETPIXELFORMAT_T GetPixelFormat;
SETPIXELFORMAT_T SetPixelFormat;
SWAPBUFFERS_T SwapBuffers;
GETDEVICEGAMMARAMP_T GetDeviceGammaRamp;
SETDEVICEGAMMARAMP_T SetDeviceGammaRamp;
} gdi;
#endif // _GLFW_NO_DLOAD_GDI32
#ifndef _GLFW_NO_DLOAD_WINMM #ifndef _GLFW_NO_DLOAD_WINMM
// winmm.dll // winmm.dll
struct { struct {

View File

@ -159,7 +159,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
count = getPixelFormatAttrib(window, 1, WGL_NUMBER_PIXEL_FORMATS_ARB); count = getPixelFormatAttrib(window, 1, WGL_NUMBER_PIXEL_FORMATS_ARB);
else else
{ {
count = _glfw_DescribePixelFormat(window->WGL.DC, count = DescribePixelFormat(window->WGL.DC,
1, 1,
sizeof(PIXELFORMATDESCRIPTOR), sizeof(PIXELFORMATDESCRIPTOR),
NULL); NULL);
@ -243,7 +243,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{ {
// Get pixel format attributes through old-fashioned PFDs // Get pixel format attributes through old-fashioned PFDs
if (!_glfw_DescribePixelFormat(window->WGL.DC, if (!DescribePixelFormat(window->WGL.DC,
i, i,
sizeof(PIXELFORMATDESCRIPTOR), sizeof(PIXELFORMATDESCRIPTOR),
&pfd)) &pfd))
@ -311,14 +311,14 @@ static GLboolean createContext(_GLFWwindow* window,
if (wndconfig->share) if (wndconfig->share)
share = wndconfig->share->WGL.context; share = wndconfig->share->WGL.context;
if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd)) if (!DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
{ {
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"Win32/WGL: Failed to retrieve PFD for selected pixel format"); "Win32/WGL: Failed to retrieve PFD for selected pixel format");
return GL_FALSE; return GL_FALSE;
} }
if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd)) if (!SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
{ {
_glfwSetError(GLFW_OPENGL_UNAVAILABLE, _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
"Win32/WGL: Failed to set selected pixel format"); "Win32/WGL: Failed to set selected pixel format");
@ -1673,7 +1673,7 @@ void _glfwPlatformRefreshWindowParams(void)
_GLFWwindow* window = _glfwLibrary.currentWindow; _GLFWwindow* window = _glfwLibrary.currentWindow;
// Obtain a detailed description of current pixel format // Obtain a detailed description of current pixel format
pixelFormat = _glfw_GetPixelFormat(window->WGL.DC); pixelFormat = GetPixelFormat(window->WGL.DC);
if (window->WGL.ARB_pixel_format) if (window->WGL.ARB_pixel_format)
{ {
@ -1727,7 +1727,7 @@ void _glfwPlatformRefreshWindowParams(void)
} }
else else
{ {
_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, DescribePixelFormat(window->WGL.DC, pixelFormat,
sizeof(PIXELFORMATDESCRIPTOR), &pfd); sizeof(PIXELFORMATDESCRIPTOR), &pfd);
// Is current OpenGL context accelerated? // Is current OpenGL context accelerated?