From 6e692ea9cff3fa644bda40f7416f6678175c8513 Mon Sep 17 00:00:00 2001 From: Jeff Hutchinson Date: Fri, 25 Mar 2016 13:41:38 -0400 Subject: [PATCH] torque windows integration of epoxy --- Engine/source/gfx/gl/gfxGLDevice.cpp | 4 ++-- Engine/source/gfx/gl/tGL/tGL.cpp | 12 +++++++++--- Engine/source/gfx/gl/tGL/tWGL.h | 4 ++-- Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp | 2 +- Engine/source/platformWin32/WinPlatformGL.cpp | 8 ++++---- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Engine/source/gfx/gl/gfxGLDevice.cpp b/Engine/source/gfx/gl/gfxGLDevice.cpp index 01bbd02ea..862cde345 100644 --- a/Engine/source/gfx/gl/gfxGLDevice.cpp +++ b/Engine/source/gfx/gl/gfxGLDevice.cpp @@ -81,8 +81,8 @@ void loadGLExtensions(void *context) GL::gglPerformExtensionBinds(context); } -void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id, - GLenum severity, GLsizei length, const GLchar* message, void* userParam) +void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, + const GLchar *message, const void *userParam) { if (severity == GL_DEBUG_SEVERITY_HIGH) Con::errorf("OPENGL: %s", message); diff --git a/Engine/source/gfx/gl/tGL/tGL.cpp b/Engine/source/gfx/gl/tGL/tGL.cpp index 8d62a7fd1..d56faa05e 100644 --- a/Engine/source/gfx/gl/tGL/tGL.cpp +++ b/Engine/source/gfx/gl/tGL/tGL.cpp @@ -25,13 +25,19 @@ #include "core/strings/stringFunctions.h" #include "console/console.h" +#ifdef TORQUE_OS_WIN + #include "tWGL.h" +#endif + namespace GL { void gglPerformBinds() { - glewExperimental = GL_TRUE; - GLenum err = glewInit(); - AssertFatal(GLEW_OK == err, avar("Error: %s\n", glewGetErrorString(err)) ); + // JTH: epoxy has one oddity with windows. You need to bind the context + // after creating the context to udpate the internals of epoxy. +#ifdef TORQUE_OS_WIN + epoxy_handle_external_wglMakeCurrent(); +#endif } void gglPerformExtensionBinds(void *context) diff --git a/Engine/source/gfx/gl/tGL/tWGL.h b/Engine/source/gfx/gl/tGL/tWGL.h index af905dca0..18025e886 100644 --- a/Engine/source/gfx/gl/tGL/tWGL.h +++ b/Engine/source/gfx/gl/tGL/tWGL.h @@ -28,9 +28,9 @@ #ifdef TORQUE_OPENGL #include "tGL.h" -#include "GL/wglew.h" +#include -#define gglHasWExtension(EXTENSION) WGLEW_##EXTENSION +#define gglHasWExtension(window, EXTENSION) epoxy_has_wgl_extension(window, "WGL_" # EXTENSION) #endif //TORQUE_OPENGL diff --git a/Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp b/Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp index 6d4d09d0b..045b2aa6f 100644 --- a/Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp +++ b/Engine/source/gfx/gl/win32/gfxGLDevice.win.cpp @@ -272,7 +272,7 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window ) int debugFlag = 0; #endif - if( gglHasWExtension(ARB_create_context) ) + if( gglHasWExtension(hdcGL, ARB_create_context) ) { int const create_attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, OGL_MAJOR, diff --git a/Engine/source/platformWin32/WinPlatformGL.cpp b/Engine/source/platformWin32/WinPlatformGL.cpp index a85245ef1..a30212bad 100644 --- a/Engine/source/platformWin32/WinPlatformGL.cpp +++ b/Engine/source/platformWin32/WinPlatformGL.cpp @@ -5,10 +5,10 @@ void PlatformGL::setVSync(const int i) { - if (WGLEW_EXT_swap_control) - { - wglSwapIntervalEXT(i); - } + if (gglHasWExtension(wglGetCurrentDC(), EXT_swap_control)) + { + wglSwapIntervalEXT(i); + } } #endif