#include "stw_context.h"
#include "stw_pixelformat.h"
#include "stw_wgl.h"
+#include "stw_ext_context.h"
+static void
+overrideOpenGL32EntryPoints(void);
+
WINGDIAPI BOOL APIENTRY
wglCopyContext(
HGLRC hglrcSrc,
wglCreateContext(
HDC hdc )
{
+ overrideOpenGL32EntryPoints();
return (HGLRC) DrvCreateContext(hdc);
}
HDC hdc,
int iLayerPlane )
{
+ overrideOpenGL32EntryPoints();
return (HGLRC) DrvCreateLayerContext( hdc, iLayerPlane );
}
return FALSE;
}
+
+
+/* When this library is used as a opengl32.dll drop-in replacement, ensure we
+ * use the wglCreate/Destroy entrypoints above, and not the true opengl32.dll,
+ * which could happen if this library's name is not opengl32.dll exactly.
+ *
+ * For example, Qt 5.4 bundles this as opengl32sw.dll:
+ * https://blog.qt.io/blog/2014/11/27/qt-weekly-21-dynamic-opengl-implementation-loading-in-qt-5-4/
+ */
+static void
+overrideOpenGL32EntryPoints(void)
+{
+ wglCreateContext_func = &wglCreateContext;
+ wglDeleteContext_func = &wglDeleteContext;
+}