Replaced the GLee OpenGL function loader with a modified version of GLAD (resolves issue #728.)

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2014-08-18 21:35:52 -03:00
parent 0c1b73e2ca
commit 5f6ee50541
12 changed files with 18236 additions and 50038 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+18 -18
View File
@@ -275,7 +275,7 @@ struct FramebufferStrategyPackedEXT : public FramebufferStrategy
virtual bool createMSAABuffer(int width, int height, int &samples, GLenum internalformat, GLuint &buffer)
{
if (!GLEE_EXT_framebuffer_multisample)
if (!GLAD_EXT_framebuffer_multisample)
return false;
glGenRenderbuffersEXT(1, &buffer);
@@ -406,11 +406,11 @@ static void getStrategy()
{
if (!strategy)
{
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object)
strategy = &strategyGL3;
else if (GLEE_EXT_framebuffer_object && GLEE_EXT_packed_depth_stencil)
else if (GLAD_EXT_framebuffer_object && GLAD_EXT_packed_depth_stencil)
strategy = &strategyPackedEXT;
else if (GLEE_EXT_framebuffer_object && strategyEXT.isSupported())
else if (GLAD_EXT_framebuffer_object && strategyEXT.isSupported())
strategy = &strategyEXT;
else
strategy = &strategyNone;
@@ -550,8 +550,8 @@ bool Canvas::loadVolatile()
}
int max_samples = 0;
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object
|| GLEE_EXT_framebuffer_multisample)
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object
|| GLAD_EXT_framebuffer_multisample)
{
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
}
@@ -803,7 +803,7 @@ void Canvas::clear(Color c)
// We don't need to worry about multiple FBO attachments or global clear
// color state when OpenGL 3.0+ is supported.
if (GLEE_VERSION_3_0)
if (GLAD_VERSION_3_0)
{
glClearBufferfv(GL_COLOR, 0, glcolor);
@@ -873,9 +873,9 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image)
GLubyte *pixels = new GLubyte[size];
// Our texture is attached to 'resolve_fbo' when we use MSAA.
if (msaa_samples > 1 && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object))
if (msaa_samples > 1 && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (msaa_samples > 1 && GLEE_EXT_framebuffer_multisample)
else if (msaa_samples > 1 && GLAD_EXT_framebuffer_multisample)
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo);
else
strategy->bindFBO(fbo);
@@ -900,9 +900,9 @@ void Canvas::getPixel(unsigned char* pixel_rgba, int x, int y)
resolveMSAA();
// Our texture is attached to 'resolve_fbo' when we use MSAA.
if (msaa_samples > 1 && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object))
if (msaa_samples > 1 && (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (msaa_samples > 1 && GLEE_EXT_framebuffer_multisample)
else if (msaa_samples > 1 && GLAD_EXT_framebuffer_multisample)
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, resolve_fbo);
else if (current != this)
strategy->bindFBO(fbo);
@@ -928,14 +928,14 @@ bool Canvas::resolveMSAA()
previous = current->fbo;
// Do the MSAA resolve by blitting the MSAA renderbuffer to the texture.
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object)
{
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo);
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
else if (GLEE_EXT_framebuffer_multisample && GLEE_EXT_framebuffer_blit)
else if (GLAD_EXT_framebuffer_multisample && GLAD_EXT_framebuffer_blit)
{
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, fbo);
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, resolve_fbo);
@@ -1047,18 +1047,18 @@ bool Canvas::isFormatSupported(Canvas::Format format)
supported = true;
break;
case FORMAT_RGB565:
supported = GLEE_VERSION_4_2 || GLEE_ARB_ES2_compatibility;
supported = GLAD_VERSION_4_2 || GLAD_ARB_ES2_compatibility;
break;
case FORMAT_RG11B10F:
supported = GLEE_VERSION_3_0 || GLEE_EXT_packed_float;
supported = GLAD_VERSION_3_0 || GLAD_EXT_packed_float;
break;
case FORMAT_RGBA16F:
case FORMAT_RGBA32F:
supported = GLEE_VERSION_3_0 || GLEE_ARB_texture_float;
supported = GLAD_VERSION_3_0 || GLAD_ARB_texture_float;
break;
case FORMAT_SRGB:
supported = GLEE_VERSION_3_0 || ((GLEE_ARB_framebuffer_sRGB || GLEE_EXT_framebuffer_sRGB)
&& (GLEE_VERSION_2_1 || GLEE_EXT_texture_sRGB));
supported = GLAD_VERSION_3_0 || ((GLAD_ARB_framebuffer_sRGB || GLAD_EXT_framebuffer_sRGB)
&& (GLAD_VERSION_2_1 || GLAD_EXT_texture_sRGB));
break;
default:
supported = false;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -197,7 +197,7 @@ bool Graphics::setMode(int width, int height, bool &sRGB)
gl.initContext();
// Does the system meet LOVE's minimum requirements for graphics?
if (!(GLEE_VERSION_2_0 && Shader::isSupported() && Canvas::isSupported())
if (!(GLAD_VERSION_2_0 && Shader::isSupported() && Canvas::isSupported())
&& !displayedMinReqWarning)
{
love::window::Window::MessageBoxType type = love::window::Window::MESSAGEBOX_ERROR;
@@ -245,7 +245,7 @@ bool Graphics::setMode(int width, int height, bool &sRGB)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// Set whether drawing converts input from linear -> sRGB colorspace.
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_sRGB || GLEE_EXT_framebuffer_sRGB)
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_sRGB || GLAD_EXT_framebuffer_sRGB)
{
if (sRGB)
glEnable(GL_FRAMEBUFFER_SRGB);
@@ -259,7 +259,7 @@ bool Graphics::setMode(int width, int height, bool &sRGB)
bool enabledebug = false;
if (GLEE_VERSION_3_0)
if (GLAD_VERSION_3_0)
{
// Enable OpenGL's debug output if a debug context has been created.
GLint flags = 0;
@@ -297,7 +297,7 @@ void Graphics::unSetMode()
created = false;
}
static void APIENTRY debugCB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei /*len*/, const GLchar *msg, GLvoid* /*usr*/)
static void APIENTRY debugCB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei /*len*/, const GLchar *msg, const GLvoid* /*usr*/)
{
// Human-readable strings for the debug info.
const char *sourceStr = OpenGL::debugSourceString(source);
@@ -312,14 +312,14 @@ void Graphics::setDebug(bool enable)
{
// Make sure debug output is supported. The AMD ext. is a bit different
// so we don't make use of it, since AMD drivers now support KHR_debug.
if (!(GLEE_VERSION_4_3 || GLEE_KHR_debug || GLEE_ARB_debug_output))
if (!(GLAD_VERSION_4_3 || GLAD_KHR_debug || GLAD_ARB_debug_output))
return;
// Ugly hack to reduce code duplication.
if (GLEE_ARB_debug_output && !(GLEE_VERSION_4_3 || GLEE_KHR_debug))
if (GLAD_ARB_debug_output && !(GLAD_VERSION_4_3 || GLAD_KHR_debug))
{
glDebugMessageCallback = (GLEEPFNGLDEBUGMESSAGECALLBACKPROC) glDebugMessageCallbackARB;
glDebugMessageControl = (GLEEPFNGLDEBUGMESSAGECONTROLPROC) glDebugMessageControlARB;
fp_glDebugMessageCallback = (pfn_glDebugMessageCallback) fp_glDebugMessageCallbackARB;
fp_glDebugMessageControl = (pfn_glDebugMessageControl) fp_glDebugMessageControlARB;
}
if (!enable)
@@ -328,7 +328,7 @@ void Graphics::setDebug(bool enable)
glDebugMessageCallback(nullptr, nullptr);
// We can disable debug output entirely with KHR_debug.
if (GLEE_VERSION_4_3 || GLEE_KHR_debug)
if (GLAD_VERSION_4_3 || GLAD_KHR_debug)
glDisable(GL_DEBUG_OUTPUT);
return;
@@ -346,7 +346,7 @@ void Graphics::setDebug(bool enable)
glDebugMessageControl(GL_DEBUG_SOURCE_API, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR, GL_DONT_CARE, 0, 0, GL_FALSE);
glDebugMessageControl(GL_DEBUG_SOURCE_SHADER_COMPILER, GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR, GL_DONT_CARE, 0, 0, GL_FALSE);
if (GLEE_VERSION_4_3 || GLEE_KHR_debug)
if (GLAD_VERSION_4_3 || GLAD_KHR_debug)
glEnable(GL_DEBUG_OUTPUT);
::printf("OpenGL debug output enabled (LOVE_GRAPHICS_DEBUG=1)\n");
@@ -1219,8 +1219,8 @@ double Graphics::getSystemLimit(SystemLimit limittype) const
limit = (double) gl.getMaxRenderTargets();
break;
case Graphics::LIMIT_CANVAS_MSAA:
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object
|| GLEE_EXT_framebuffer_multisample)
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object
|| GLAD_EXT_framebuffer_multisample)
{
GLint intlimit = 0;
glGetIntegerv(GL_MAX_SAMPLES, &intlimit);
+6 -6
View File
@@ -233,7 +233,7 @@ void Image::uploadImageData()
"image does not have power-of-two dimensions.");
}
if (!GLEE_VERSION_3_0 && !GLEE_ARB_framebuffer_object)
if (!GLAD_VERSION_3_0 && !GLAD_ARB_framebuffer_object)
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
}
@@ -254,7 +254,7 @@ void Image::uploadImageData()
if (flags.mipmaps)
{
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
if (GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object)
{
// Driver bug: http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation
if (gl.getVendor() == OpenGL::VENDOR_ATI_AMD)
@@ -471,7 +471,7 @@ GLenum Image::getCompressedFormat(image::CompressedData::Format cformat) const
bool Image::hasAnisotropicFilteringSupport()
{
return GLEE_EXT_texture_filter_anisotropic;
return GLAD_EXT_texture_filter_anisotropic;
}
bool Image::hasCompressedTextureSupport(image::CompressedData::Format format)
@@ -481,12 +481,12 @@ bool Image::hasCompressedTextureSupport(image::CompressedData::Format format)
case image::CompressedData::FORMAT_DXT1:
case image::CompressedData::FORMAT_DXT3:
case image::CompressedData::FORMAT_DXT5:
return GLEE_EXT_texture_compression_s3tc;
return GLAD_EXT_texture_compression_s3tc;
case image::CompressedData::FORMAT_BC4:
case image::CompressedData::FORMAT_BC4s:
case image::CompressedData::FORMAT_BC5:
case image::CompressedData::FORMAT_BC5s:
return (GLEE_VERSION_3_0 || GLEE_ARB_texture_compression_rgtc || GLEE_EXT_texture_compression_rgtc);
return (GLAD_VERSION_3_0 || GLAD_ARB_texture_compression_rgtc || GLAD_EXT_texture_compression_rgtc);
default:
break;
}
@@ -496,7 +496,7 @@ bool Image::hasCompressedTextureSupport(image::CompressedData::Format format)
bool Image::hasSRGBSupport()
{
return GLEE_VERSION_2_1 || GLEE_EXT_texture_sRGB;
return GLAD_VERSION_2_1 || GLAD_EXT_texture_sRGB;
}
bool Image::getConstant(const char *in, FlagType &out)
+12 -7
View File
@@ -52,16 +52,21 @@ OpenGL::OpenGL()
matrices.projection.reserve(2);
}
void OpenGL::initContext()
bool OpenGL::initContext()
{
if (contextInitialized)
return;
return true;
if (!gladLoadGL())
return false;
initOpenGLFunctions();
initVendor();
initMatrices();
contextInitialized = true;
return true;
}
void OpenGL::setupContext()
@@ -173,7 +178,7 @@ void OpenGL::initOpenGLFunctions()
void OpenGL::initMaxValues()
{
// We'll need this value to clamp anisotropy.
if (GLEE_EXT_texture_filter_anisotropic)
if (GLAD_EXT_texture_filter_anisotropic)
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
else
maxAnisotropy = 1.0f;
@@ -292,7 +297,7 @@ void OpenGL::drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsize
{
Shader *shader = Shader::current;
if (GLEE_ARB_draw_instanced)
if (GLAD_ARB_draw_instanced)
glDrawArraysInstancedARB(mode, first, count, primcount);
else
{
@@ -316,7 +321,7 @@ void OpenGL::drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, cons
{
Shader *shader = Shader::current;
if (GLEE_ARB_draw_instanced)
if (GLAD_ARB_draw_instanced)
glDrawElementsInstancedARB(mode, count, type, indices, primcount);
else
{
@@ -498,7 +503,7 @@ void OpenGL::setTextureFilter(graphics::Texture::Filter &f)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gmin);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gmag);
if (GLEE_EXT_texture_filter_anisotropic)
if (GLAD_EXT_texture_filter_anisotropic)
{
f.anisotropy = std::min(std::max(f.anisotropy, 1.0f), maxAnisotropy);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, f.anisotropy);
@@ -553,7 +558,7 @@ graphics::Texture::Filter OpenGL::getTextureFilter()
break;
}
if (GLEE_EXT_texture_filter_anisotropic)
if (GLAD_EXT_texture_filter_anisotropic)
glGetTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &f.anisotropy);
return f;
+9 -3
View File
@@ -21,13 +21,14 @@
#ifndef LOVE_GRAPHICS_OPENGL_OPENGL_H
#define LOVE_GRAPHICS_OPENGL_OPENGL_H
#include "GLee.h"
// LOVE
#include "graphics/Color.h"
#include "graphics/Texture.h"
#include "common/Matrix.h"
// GLAD
#include "libraries/glad/gladfuncs.hpp"
// C++
#include <vector>
#include <stack>
@@ -42,6 +43,11 @@ namespace graphics
namespace opengl
{
// Awful, but the library uses the namespace in order to use the functions sanely
// with proper autocomplete in IDEs while having name mangling safety -
// no clashes with other GL libraries when linking, etc.
using namespace glad;
/**
* Thin layer between OpenGL and the rest of the program.
* Internally shadows some OpenGL context state for improved efficiency and
@@ -138,7 +144,7 @@ public:
/**
* Initializes the active OpenGL context.
**/
void initContext();
bool initContext();
/**
* Sets up some required context state based on current and default OpenGL