Skip to content

Commit a1abc4a

Browse files
committed
Fix: debug callback in opengl plugin
with preprocesor macro in readme
1 parent 933937f commit a1abc4a

6 files changed

Lines changed: 42 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 4.0.0)
33
project(cae
44
VERSION 0.0.0
55
DESCRIPTION "Cross-API graphics engine"
6+
HOMEPAGE_URL "https://bobis33.github.io/Cross-API-Engine/"
67
LANGUAGES C CXX
78
)
89

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ This section targets engine developers and contributors.
8383
- `CAE_CLANG_FORMAT` (default: `OFF`): Enable clang format usage.
8484
- `CAE_BUILD_DOC` (default: `OFF`): Enable building doxygen documentation.
8585

86+
### Preprocessor macros
87+
88+
- `PLUGINS_DIR`: Path of plugins binaries directory.
89+
- `CAE_DEBUG`: Defined if build mode is debug.
90+
- `CAE_DYNAMIC_PLUGINS`: Defined if plugins are build dynamically.
91+
- `CAE_PLATFORM_WEB`: Defined if platform is Web.
92+
- `CAE_PLATFORM_ANDROID`: Defined if platform is Android.
93+
- `CAE_PLATFORM_IOS`: Defined if platform is IOS.
94+
- `CAE_PLATFORM_MACOS`: Defined if platform is macOS.
95+
- `CAE_PLATFORM_WINDOWS`: Defined if platform is Windows.
96+
- `CAE_PLATFORM_LINUX`: Defined if platform is Linux.
97+
8698
### Testing
8799

88100
Unit tests are based on [Google Test](https://github.com/google/googletest).

cmake/modules/CompileOptions.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ endfunction()
9191
if (EMSCRIPTEN)
9292
target_compile_definitions(cae-compile-options INTERFACE
9393
CAE_PLATFORM_WEB
94-
CAE_PLATFORM_EMSCRIPTEN
9594
)
9695
elseif (ANDROID)
9796
target_compile_definitions(cae-compile-options INTERFACE CAE_PLATFORM_ANDROID)

plugins/Renderer/OpenGL/src/context/EGLContext.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "OPGL/Context/EGLContext.hpp"
44

5+
#include "Utils/Logger.hpp"
6+
57
#include <stdexcept>
68

79
cae::EGLContext_::~EGLContext_()
@@ -85,6 +87,17 @@ void cae::EGLContext_::initialize(const NativeWindowHandle &window)
8587
{
8688
throw std::runtime_error("Failed to initialize GLAD");
8789
}
90+
#ifdef CAE_DEBUG
91+
if (gl.Enable != nullptr)
92+
{
93+
gl.Enable(GL_DEBUG_OUTPUT);
94+
95+
gl.DebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
96+
const GLchar *message, const void *userParam)
97+
{ utl::Logger::log("[GL DEBUG] " + std::string(message), utl::LogLevel::WARNING); },
98+
nullptr);
99+
}
100+
#endif
88101
}
89102

90103
void cae::EGLContext_::swapBuffers()

plugins/Renderer/OpenGL/src/context/NSGLContext.mm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include "OPGL/Context/NSGLContext.hpp"
44

5+
#include "Utils/Logger.hpp"
6+
57
#import <AppKit/AppKit.h>
68

79
cae::NSGLContext::~NSGLContext() {
@@ -33,6 +35,17 @@
3335
if (!gladLoadGLContext(&gl, nullptr)) {
3436
throw std::runtime_error("Failed to initialize GLAD");
3537
}
38+
#ifdef CAE_DEBUG
39+
if (gl.Enable != nullptr)
40+
{
41+
gl.Enable(GL_DEBUG_OUTPUT);
42+
43+
gl.DebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
44+
const GLchar *message, const void *userParam)
45+
{ utl::Logger::log("[GL DEBUG] " + std::string(message), utl::LogLevel::WARNING); },
46+
nullptr);
47+
}
48+
#endif
3649
}
3750

3851
void cae::NSGLContext::swapBuffers() {

plugins/Renderer/OpenGL/src/context/WGLContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,17 @@ void cae::WGLContext::initialize(const NativeWindowHandle &window)
143143
{
144144
throw std::runtime_error("Failed to initialize GLAD MX (Windows)");
145145
}
146+
#ifdef CAE_DEBUG
146147
if (gl.Enable != nullptr)
147148
{
148149
gl.Enable(GL_DEBUG_OUTPUT);
149-
#ifdef CAE_DEBUG
150150
gl.DebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
151151
const GLchar *message, const void *userParam)
152152
{ utl::Logger::log("[GL DEBUG] " + std::string(message), utl::LogLevel::WARNING); },
153153
nullptr);
154-
#endif
155154
}
155+
#endif
156+
156157
}
157158

158159
void cae::WGLContext::swapBuffers()

0 commit comments

Comments
 (0)