torque windows integration of epoxy

This commit is contained in:
Jeff Hutchinson 2016-03-25 13:41:38 -04:00
parent b89d2a116e
commit 6e692ea9cf
5 changed files with 18 additions and 12 deletions

View file

@ -81,8 +81,8 @@ void loadGLExtensions(void *context)
GL::gglPerformExtensionBinds(context); GL::gglPerformExtensionBinds(context);
} }
void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id, void STDCALL glDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
GLenum severity, GLsizei length, const GLchar* message, void* userParam) const GLchar *message, const void *userParam)
{ {
if (severity == GL_DEBUG_SEVERITY_HIGH) if (severity == GL_DEBUG_SEVERITY_HIGH)
Con::errorf("OPENGL: %s", message); Con::errorf("OPENGL: %s", message);

View file

@ -25,13 +25,19 @@
#include "core/strings/stringFunctions.h" #include "core/strings/stringFunctions.h"
#include "console/console.h" #include "console/console.h"
#ifdef TORQUE_OS_WIN
#include "tWGL.h"
#endif
namespace GL namespace GL
{ {
void gglPerformBinds() void gglPerformBinds()
{ {
glewExperimental = GL_TRUE; // JTH: epoxy has one oddity with windows. You need to bind the context
GLenum err = glewInit(); // after creating the context to udpate the internals of epoxy.
AssertFatal(GLEW_OK == err, avar("Error: %s\n", glewGetErrorString(err)) ); #ifdef TORQUE_OS_WIN
epoxy_handle_external_wglMakeCurrent();
#endif
} }
void gglPerformExtensionBinds(void *context) void gglPerformExtensionBinds(void *context)

View file

@ -28,9 +28,9 @@
#ifdef TORQUE_OPENGL #ifdef TORQUE_OPENGL
#include "tGL.h" #include "tGL.h"
#include "GL/wglew.h" #include <epoxy/wgl.h>
#define gglHasWExtension(EXTENSION) WGLEW_##EXTENSION #define gglHasWExtension(window, EXTENSION) epoxy_has_wgl_extension(window, "WGL_" # EXTENSION)
#endif //TORQUE_OPENGL #endif //TORQUE_OPENGL

View file

@ -272,7 +272,7 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
int debugFlag = 0; int debugFlag = 0;
#endif #endif
if( gglHasWExtension(ARB_create_context) ) if( gglHasWExtension(hdcGL, ARB_create_context) )
{ {
int const create_attribs[] = { int const create_attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, OGL_MAJOR, WGL_CONTEXT_MAJOR_VERSION_ARB, OGL_MAJOR,

View file

@ -5,10 +5,10 @@
void PlatformGL::setVSync(const int i) void PlatformGL::setVSync(const int i)
{ {
if (WGLEW_EXT_swap_control) if (gglHasWExtension(wglGetCurrentDC(), EXT_swap_control))
{ {
wglSwapIntervalEXT(i); wglSwapIntervalEXT(i);
} }
} }
#endif #endif