summaryrefslogtreecommitdiff
path: root/win/win_gl.cpp
diff options
context:
space:
mode:
authorleo2000-12-18 12:42:31 +0000
committerleo2000-12-18 12:42:31 +0000
commit9f945b3fe2361205ba6a58f92dc976ded7bccb60 (patch)
tree54db9efd1c083ac06128e4f9d8f1f4e2044d832c /win/win_gl.cpp
parente679694a7bcb61ffee8351bad0396944716b81d4 (diff)
Fixes for win2k crash
git-svn-id: http://svn.leocad.org/trunk@183 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'win/win_gl.cpp')
-rwxr-xr-xwin/win_gl.cpp66
1 files changed, 59 insertions, 7 deletions
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;