Merge pull request #1567 from JeffProgrammer/epoxy

Added Epoxy in favor of GLEW
This commit is contained in:
Areloch 2016-05-05 19:40:59 -05:00
commit e8bc70e514
851 changed files with 162429 additions and 73286 deletions

View file

@ -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);

View file

@ -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)

View file

@ -22,15 +22,12 @@
#ifndef T_GL_H
#define T_GL_H
#include "GL/glew.h"
#if defined (TORQUE_OS_WIN)
// This doesn't work on Mesa drivers.
#define gglHasExtension(EXTENSION) GLEW_##EXTENSION
#else
// Slower but reliably detects extensions on Mesa.
#define gglHasExtension(EXTENSION) glewGetExtension("GL_" # EXTENSION)
#endif
#include <epoxy/gl.h>
// JTH: This is slow, we should probably check extensions once and cache them
// directly inside of some compatability table.
#define gglHasExtension(EXTENSION) epoxy_has_gl_extension("GL_" #EXTENSION)
#endif

View file

@ -28,9 +28,9 @@
#ifdef TORQUE_OPENGL
#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

View file

@ -28,9 +28,9 @@
#ifdef TORQUE_OS_LINUX
#include "tGL.h"
#include "GL/glxew.h"
#include <epoxy/glx.h>
#define gglHasXExtension(EXTENSION) GLXEW##EXTENSION
#define gglHasXExtension(display, screen, EXTENSION) epoxy_has_glx_extension(display, screen, "GLX_" # EXTENSION)
#endif //TORQUE_OS_LINUX

View file

@ -272,7 +272,12 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
int debugFlag = 0;
#endif
if( gglHasWExtension(ARB_create_context) )
// Create a temp rendering context, needed a current context to use wglCreateContextAttribsARB
HGLRC tempGLRC = wglCreateContext(hdcGL);
if (!wglMakeCurrent(hdcGL, tempGLRC))
AssertFatal(false, "Couldn't make temp GL context.");
if( gglHasWExtension(hdcGL, ARB_create_context) )
{
int const create_attribs[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, OGL_MAJOR,
@ -292,6 +297,10 @@ void GFXGLDevice::init( const GFXVideoMode &mode, PlatformWindow *window )
else
mContext = wglCreateContext( hdcGL );
// Delete temp rendering context
wglMakeCurrent(NULL, NULL);
wglDeleteContext(tempGLRC);
if( !wglMakeCurrent( hdcGL, (HGLRC)mContext ) )
AssertFatal( false , "GFXGLDevice::init - cannot make our context current. Or maybe we can't create it." );