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
+13 -2
View File
@@ -265,8 +265,6 @@ set(LOVE_SRC_MODULE_GRAPHICS_OPENGL
src/modules/graphics/opengl/Canvas.h
src/modules/graphics/opengl/Font.cpp
src/modules/graphics/opengl/Font.h
src/modules/graphics/opengl/GLee.c
src/modules/graphics/opengl/GLee.h
src/modules/graphics/opengl/Graphics.cpp
src/modules/graphics/opengl/Graphics.h
src/modules/graphics/opengl/Image.cpp
@@ -932,6 +930,18 @@ add_library(love_3p_enet ${LOVE_SRC_3P_ENET})
target_link_libraries(love_3p_enet ${MEGA_LUA})
target_include_directories(love_3p_enet PUBLIC src/libraries/enet/libenet/include)
#
# GLAD
#
set(LOVE_SRC_3P_GLAD
src/libraries/glad/glad.cpp
src/libraries/glad/glad.hpp
src/libraries/glad/gladfuncs.hpp
)
add_library(love_3p_glad ${LOVE_SRC_3P_GLAD})
#
# LodePNG
#
@@ -1067,6 +1077,7 @@ set(LOVE_3P
love_3p_box2d
love_3p_ddsparse
love_3p_enet
love_3p_glad
love_3p_lodepng
love_3p_luasocket
love_3p_noise1234
@@ -116,7 +116,6 @@
FA08F61A16C753F600F007B5 /* Volatile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B731754147B27AF73AC5358 /* Volatile.cpp */; };
FA08F61B16C7541400F007B5 /* Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4AD52074367950B735707CE1 /* Canvas.cpp */; };
FA08F61C16C7541400F007B5 /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 583037E9238A6EF00DD20B1A /* Font.cpp */; };
FA08F61D16C7541400F007B5 /* GLee.c in Sources */ = {isa = PBXBuildFile; fileRef = 5725505310E75ECC5044583A /* GLee.c */; };
FA08F61E16C7541400F007B5 /* Graphics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 11773415762F3A38421C6DB3 /* Graphics.cpp */; };
FA08F61F16C7541400F007B5 /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 56D6030A0B8F7397715062B9 /* Image.cpp */; };
FA08F62016C7541400F007B5 /* OpenGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E406F8328543EC63EB922C6 /* OpenGL.cpp */; };
@@ -213,6 +212,9 @@
FA0A4BF9182E260200E1E4D2 /* wrap_MotorJoint.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0A4BF7182E260200E1E4D2 /* wrap_MotorJoint.h */; };
FA0A4BFA182E26F500E1E4D2 /* wrap_MotorJoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0A4BF6182E260200E1E4D2 /* wrap_MotorJoint.cpp */; };
FA0CDE3D1710F9A50056E8D7 /* FormatHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0CDE3B1710F9A50056E8D7 /* FormatHandler.h */; };
FA0F0D5A19A2CFEB0010A75B /* glad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0F0D5719A2CFEB0010A75B /* glad.cpp */; };
FA0F0D5B19A2CFEB0010A75B /* glad.hpp in Headers */ = {isa = PBXBuildFile; fileRef = FA0F0D5819A2CFEB0010A75B /* glad.hpp */; };
FA0F0D5C19A2CFEB0010A75B /* gladfuncs.hpp in Headers */ = {isa = PBXBuildFile; fileRef = FA0F0D5919A2CFEB0010A75B /* gladfuncs.hpp */; };
FA1EF7C41799FEAC00FF380C /* wrap_System.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA34E7D4174B55AF00E04D3F /* wrap_System.cpp */; };
FA1EF7C51799FEB200FF380C /* wrap_System.h in Headers */ = {isa = PBXBuildFile; fileRef = FA34E7D5174B55AF00E04D3F /* wrap_System.h */; };
FA317EBA18F28B6D00B0BCD7 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FA317EB918F28B6D00B0BCD7 /* libz.dylib */; };
@@ -386,7 +388,6 @@
0B0728FA73B107B37A956A09 /* wrap_Image.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Image.cpp; sourceTree = "<group>"; };
0B4020CD058D70F569DF6129 /* wrap_PrismaticJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_PrismaticJoint.cpp; sourceTree = "<group>"; };
0B727D416262392743091BC3 /* TrueTypeRasterizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TrueTypeRasterizer.h; sourceTree = "<group>"; };
0B930B8571276AA86AB87D80 /* GLee.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GLee.h; sourceTree = "<group>"; };
0BEB72033ACA25550ADA76C4 /* b64.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b64.h; sourceTree = "<group>"; };
0C30420F7FD3038C721223A5 /* TrueTypeRasterizer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TrueTypeRasterizer.cpp; sourceTree = "<group>"; };
0C5C6C6E47851D1308411DE6 /* SoundData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundData.cpp; sourceTree = "<group>"; };
@@ -408,7 +409,7 @@
112814480BBF2ED06EED15BF /* GlyphData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GlyphData.h; sourceTree = "<group>"; };
113269E55FCF208D2D6754BC /* Timer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Timer.cpp; sourceTree = "<group>"; };
11745DE315E859F71E881D76 /* wrap_Rasterizer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Rasterizer.cpp; sourceTree = "<group>"; };
11773415762F3A38421C6DB3 /* Graphics.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Graphics.cpp; sourceTree = "<group>"; };
11773415762F3A38421C6DB3 /* Graphics.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = Graphics.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
11CF30E73CEA2D8D0A1B17D3 /* b2DynamicTree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2DynamicTree.h; sourceTree = "<group>"; };
11D141087979064B441B787D /* File.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = File.cpp; sourceTree = "<group>"; };
11D62E873092729B497B447F /* b2RevoluteJoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2RevoluteJoint.cpp; sourceTree = "<group>"; };
@@ -593,7 +594,7 @@
4A774BC26B7235E410D40C8E /* FLACDecoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FLACDecoder.cpp; sourceTree = "<group>"; };
4A80315175C5625804AA4A56 /* VorbisDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VorbisDecoder.h; sourceTree = "<group>"; };
4ABD4A7B5CB6678E39490982 /* io.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = io.h; sourceTree = "<group>"; };
4AD52074367950B735707CE1 /* Canvas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Canvas.cpp; sourceTree = "<group>"; };
4AD52074367950B735707CE1 /* Canvas.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = Canvas.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
4B002CBD52493ED9347C6EBA /* url.lua.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = url.lua.h; sourceTree = "<group>"; };
4B41232F7AF7793540F46C58 /* timeout.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = timeout.c; sourceTree = "<group>"; };
4B5F4DF8110020A96B5D3EAB /* b2BroadPhase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = b2BroadPhase.cpp; sourceTree = "<group>"; };
@@ -633,7 +634,6 @@
561D4A4722E36BAA16D17CC8 /* EdgeShape.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EdgeShape.h; sourceTree = "<group>"; };
567C0A0C58931DE54733011B /* b2StackAllocator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = b2StackAllocator.h; sourceTree = "<group>"; };
56D6030A0B8F7397715062B9 /* Image.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Image.cpp; sourceTree = "<group>"; };
5725505310E75ECC5044583A /* GLee.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = GLee.c; sourceTree = "<group>"; };
577B66502A5360AE60733B10 /* VertexBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VertexBuffer.h; sourceTree = "<group>"; };
57E6429235C547BE26B73C6C /* version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
583037E9238A6EF00DD20B1A /* Font.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Font.cpp; sourceTree = "<group>"; };
@@ -772,6 +772,9 @@
FA0A4BF6182E260200E1E4D2 /* wrap_MotorJoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_MotorJoint.cpp; sourceTree = "<group>"; };
FA0A4BF7182E260200E1E4D2 /* wrap_MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_MotorJoint.h; sourceTree = "<group>"; };
FA0CDE3B1710F9A50056E8D7 /* FormatHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatHandler.h; sourceTree = "<group>"; };
FA0F0D5719A2CFEB0010A75B /* glad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = glad.cpp; sourceTree = "<group>"; };
FA0F0D5819A2CFEB0010A75B /* glad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = glad.hpp; sourceTree = "<group>"; };
FA0F0D5919A2CFEB0010A75B /* gladfuncs.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = gladfuncs.hpp; sourceTree = "<group>"; };
FA317EB918F28B6D00B0BCD7 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
FA34E7CB174B513F00E04D3F /* System.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = System.cpp; sourceTree = "<group>"; };
FA34E7CC174B513F00E04D3F /* System.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = System.h; sourceTree = "<group>"; };
@@ -1413,6 +1416,7 @@
63287ED84D0F2EEB65D249A3 /* Box2D */,
FAE010D7170DDE99006F29D0 /* ddsparse */,
FA5FDC5E1788D548002F0ED2 /* enet */,
FA0F0D5619A2CFEB0010A75B /* glad */,
FA4BBCDB18A5DC5D0027707D /* lodepng */,
3AED1DE005A53DDB07902760 /* luasocket */,
FA0354691731F3A700284828 /* noise1234 */,
@@ -1689,8 +1693,6 @@
23573F2F4F7D56312E663E24 /* Canvas.h */,
583037E9238A6EF00DD20B1A /* Font.cpp */,
7EFA04373ADC5CC24DCB5824 /* Font.h */,
5725505310E75ECC5044583A /* GLee.c */,
0B930B8571276AA86AB87D80 /* GLee.h */,
11773415762F3A38421C6DB3 /* Graphics.cpp */,
389E3CEC356050A27784290E /* Graphics.h */,
56D6030A0B8F7397715062B9 /* Image.cpp */,
@@ -1833,6 +1835,16 @@
name = Resources;
sourceTree = "<group>";
};
FA0F0D5619A2CFEB0010A75B /* glad */ = {
isa = PBXGroup;
children = (
FA0F0D5719A2CFEB0010A75B /* glad.cpp */,
FA0F0D5819A2CFEB0010A75B /* glad.hpp */,
FA0F0D5919A2CFEB0010A75B /* gladfuncs.hpp */,
);
path = glad;
sourceTree = "<group>";
};
FA34E7CA174B512200E04D3F /* system */ = {
isa = PBXGroup;
children = (
@@ -2033,6 +2045,7 @@
FAEC808B1710FEA60057279A /* ImageData.h in Headers */,
FA4B5B7A1936B688006C6D93 /* stb_image.h in Headers */,
FAEC808F1711E76C0057279A /* CompressedData.h in Headers */,
FA0F0D5B19A2CFEB0010A75B /* glad.hpp in Headers */,
FA636D8B171B70920065623F /* RandomGenerator.h in Headers */,
FA636D8F171B72A70065623F /* wrap_RandomGenerator.h in Headers */,
FAC86E641724552C00EED715 /* wrap_Quad.h in Headers */,
@@ -2060,6 +2073,7 @@
FA0A4BF1182E0C2800E1E4D2 /* b2MotorJoint.h in Headers */,
FA5FDC851788D548002F0ED2 /* utility.h in Headers */,
FAF6704D18184FF800DBDEEA /* wuff.h in Headers */,
FA0F0D5C19A2CFEB0010A75B /* gladfuncs.hpp in Headers */,
FA48E43718F10D00007CF0BD /* JPEGHandler.h in Headers */,
FA5FDC861788D548002F0ED2 /* win32.h in Headers */,
FA5FDC8F1788D548002F0ED2 /* lua-enet.h in Headers */,
@@ -2155,6 +2169,7 @@
FA08F5C116C7532A00F007B5 /* Reference.cpp in Sources */,
FA08F5C216C7532A00F007B5 /* runtime.cpp in Sources */,
FA08F5C316C7532A00F007B5 /* utf8.cpp in Sources */,
FA0F0D5A19A2CFEB0010A75B /* glad.cpp in Sources */,
FA08F5C416C7532A00F007B5 /* Variant.cpp in Sources */,
FA08F5C516C7532A00F007B5 /* Vector.cpp in Sources */,
FA08F5C616C7532A00F007B5 /* wrap_Data.cpp in Sources */,
@@ -2245,7 +2260,6 @@
FA08F61A16C753F600F007B5 /* Volatile.cpp in Sources */,
FA08F61B16C7541400F007B5 /* Canvas.cpp in Sources */,
FA08F61C16C7541400F007B5 /* Font.cpp in Sources */,
FA08F61D16C7541400F007B5 /* GLee.c in Sources */,
FA08F61E16C7541400F007B5 /* Graphics.cpp in Sources */,
FAF4376F17F4AC530074F9E2 /* Mesh.cpp in Sources */,
FA08F61F16C7541400F007B5 /* Image.cpp in Sources */,
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