25#ifndef TGUI_OPENGL_HPP
26#define TGUI_OPENGL_HPP
28#include <TGUI/Config.hpp>
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wold-style-cast"
33#elif defined(_MSC_VER)
34 #if defined(__clang__)
35 #pragma clang diagnostic push
36 #pragma clang diagnostic ignored "-Wold-style-cast"
37 #pragma clang diagnostic ignored "-Wlanguage-extension-token"
41#if TGUI_USE_SYSTEM_GLAD
42 #if TGUI_HAS_RENDERER_BACKEND_OPENGL3
45 #define tgui_gladLoadGL gladLoadGL
46 #define TGUI_GLAD_GL_VERSION_3_3 GLAD_GL_VERSION_3_3
47 #define TGUI_GLAD_GL_VERSION_4_0 GLAD_GL_VERSION_4_0
48 #define TGUI_GLAD_GL_VERSION_4_1 GLAD_GL_VERSION_4_1
49 #define TGUI_GLAD_GL_VERSION_4_2 GLAD_GL_VERSION_4_2
50 #define TGUI_GLAD_GL_VERSION_4_3 GLAD_GL_VERSION_4_3
51 #define TGUI_GLAD_GL_VERSION_4_4 GLAD_GL_VERSION_4_4
52 #define TGUI_GLAD_GL_VERSION_4_5 GLAD_GL_VERSION_4_5
53 #define TGUI_GLAD_GL_VERSION_4_6 GLAD_GL_VERSION_4_6
56 #if TGUI_HAS_RENDERER_BACKEND_GLES2
57 #include <glad/gles2.h>
59 #define tgui_gladLoadGLES2 gladLoadGLES2
60 #define TGUI_GLAD_GL_ES_VERSION_2_0 GLAD_GL_ES_VERSION_2_0
61 #define TGUI_GLAD_GL_ES_VERSION_3_0 GLAD_GL_ES_VERSION_3_0
62 #define TGUI_GLAD_GL_ES_VERSION_3_1 GLAD_GL_ES_VERSION_3_1
63 #define TGUI_GLAD_GL_ES_VERSION_3_2 GLAD_GL_ES_VERSION_3_2
67 #include <TGUI/extlibs/glad/gl.h>
71 #pragma GCC diagnostic pop
72#elif defined(_MSC_VER)
73 #if defined(__clang__)
74 #pragma clang diagnostic pop
83 #define TGUI_GL_CHECK(expr) \
87 priv::checkAndLogErrorOpenGL(__FILE__, __LINE__, #expr); \
90 #define TGUI_GL_CHECK(expr) expr
95#if !defined(NDEBUG) && !defined(TGUI_NO_RUNTIME_WARNINGS)
96 inline void checkAndLogErrorOpenGL(
const char* file,
unsigned int line,
const char* expression)
98 const GLenum errorCode = glGetError();
99 if (errorCode == GL_NO_ERROR)
105 case GL_INVALID_ENUM:
106 error =
"GL_INVALID_ENUM";
108 case GL_INVALID_VALUE:
109 error =
"GL_INVALID_VALUE";
111 case GL_INVALID_OPERATION:
112 error =
"GL_INVALID_OPERATION";
114 case GL_STACK_OVERFLOW:
115 error =
"GL_STACK_OVERFLOW";
117 case GL_STACK_UNDERFLOW:
118 error =
"GL_STACK_UNDERFLOW";
120 case GL_OUT_OF_MEMORY:
121 error =
"GL_OUT_OF_MEMORY";
124 error =
"Unknown error";
128 const std::string fileStr = file;
130 "An internal OpenGL call failed in " + fileStr.substr(fileStr.find_last_of(
"\\/") + 1) +
"(" + std::to_string(line)
131 +
")." +
"\nExpression:\n " + expression +
"\nError description:\n " + error +
"\n");
134 inline void checkAndLogErrorOpenGL(
const char*,
unsigned int,
const char*)