From 9f945b3fe2361205ba6a58f92dc976ded7bccb60 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 18 Dec 2000 12:42:31 +0000 Subject: Fixes for win2k crash git-svn-id: http://svn.leocad.org/trunk@183 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- win/win_gl.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 7 deletions(-) (limited to 'win/win_gl.cpp') diff --git a/win/win_gl.cpp b/win/win_gl.cpp index 4310c55..58af6cd 100755 --- a/win/win_gl.cpp +++ b/win/win_gl.cpp @@ -6,15 +6,16 @@ #include "opengl.h" static HMODULE gl_module; +static bool gl_ignore_GDI = false; // ============================================================================ // Function pointers -WGLCHOOSEPIXELFORMAT pfnwglChoosePixelFormat; -WGLDESCRIBEPIXELFORMAT pfnwglDescribePixelFormat; -WGLGETPIXELFORMAT pfnwglGetPixelFormat; -WGLSETPIXELFORMAT pfnwglSetPixelFormat; -WGLSWAPBUFFERS pfnwglSwapBuffers; +static WGLCHOOSEPIXELFORMAT pfnwglChoosePixelFormat; +static WGLDESCRIBEPIXELFORMAT pfnwglDescribePixelFormat; +static WGLGETPIXELFORMAT pfnwglGetPixelFormat; +static WGLSETPIXELFORMAT pfnwglSetPixelFormat; +static WGLSWAPBUFFERS pfnwglSwapBuffers; WGLCOPYCONTEXT pfnwglCopyContext; WGLCREATECONTEXT pfnwglCreateContext; WGLCREATELAYERCONTEXT pfnwglCreateLayerContext; @@ -38,6 +39,46 @@ WGLSETDEVICEGAMMARAMPEXT pfnwglSetDeviceGammaRampEXT; // ============================================================================ // Global functions +BOOL OpenGLSwapBuffers (HDC hdc) +{ + if (!gl_ignore_GDI) + return SwapBuffers (hdc); + else + return pfnwglSwapBuffers (hdc); +} + +int OpenGLChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR * ppfd) +{ + if (!gl_ignore_GDI) + return ChoosePixelFormat (hdc, ppfd); + else + return pfnwglChoosePixelFormat (hdc, ppfd); +} + +int OpenGLDescribePixelFormat(HDC hdc, int iPixelFormat, UINT nBytes, LPPIXELFORMATDESCRIPTOR ppfd) +{ + if (!gl_ignore_GDI) + return DescribePixelFormat (hdc, iPixelFormat, nBytes, ppfd); + else + return pfnwglDescribePixelFormat (hdc, iPixelFormat, nBytes, ppfd); +} + +BOOL OpenGLSetPixelFormat(HDC hdc, int iPixelFormat, CONST PIXELFORMATDESCRIPTOR * ppfd) +{ + if (!gl_ignore_GDI) + return SetPixelFormat (hdc, iPixelFormat, ppfd); + else + return pfnwglSetPixelFormat (hdc, iPixelFormat, ppfd); +} + +int OpenGLGetPixelFormat(HDC hdc) +{ + if (!gl_ignore_GDI) + return GetPixelFormat (hdc); + else + return pfnwglGetPixelFormat (hdc); +} + void* Sys_GLGetProc (const char *symbol) { return GetProcAddress (gl_module, symbol); @@ -51,13 +92,24 @@ void* Sys_GLGetExtension (const char *symbol) bool Sys_GLOpenLibrary (const char* libname) { if (libname) - gl_module = LoadLibrary (libname); + { + gl_module = LoadLibrary (libname); + + if (strcmp(libname, "opengl32.dll")) + gl_ignore_GDI = true; + } if (gl_module == NULL) + { gl_module = LoadLibrary ("opengl32.dll"); + gl_ignore_GDI = false; + } if (gl_module == NULL) - gl_module = LoadLibrary ("opengl.dll"); + { + gl_module = LoadLibrary ("opengl.dll"); + gl_ignore_GDI = true; + } if (gl_module == NULL) return false; -- cgit v1.2.3