From 306ac3d3121c3618c0f2b9daa2132829f56a740d Mon Sep 17 00:00:00 2001 From: Roz K Date: Fri, 30 Dec 2022 14:11:48 +0100 Subject: [PATCH] Add a parameter to enable/disable debug output. --- __init__.py | 3 +++ cpp/render.hpp | 3 ++- cpp/render/render_opengles.cpp | 9 ++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index d30461a..d3070a9 100644 --- a/__init__.py +++ b/__init__.py @@ -279,6 +279,9 @@ INSTANCE_FLAG_VISIBLE = _flag(1) BATCH_MAX_SIZE = 65536 render_initialize = _engine.rk_render_initialize +render_initialize.argtypes = ( + ctypes.c_bool,) # debug + render_terminate = _engine.rk_render_terminate _load_shader = _engine.rk_load_shader diff --git a/cpp/render.hpp b/cpp/render.hpp index a629b76..c33de92 100644 --- a/cpp/render.hpp +++ b/cpp/render.hpp @@ -80,7 +80,8 @@ union rk_mesh { }; }; -RK_EXPORT void rk_render_initialize(); +RK_EXPORT void rk_render_initialize( + rk_bool debug); RK_EXPORT void rk_render_terminate(); diff --git a/cpp/render/render_opengles.cpp b/cpp/render/render_opengles.cpp index 11404a7..1fe9ba2 100644 --- a/cpp/render/render_opengles.cpp +++ b/cpp/render/render_opengles.cpp @@ -49,7 +49,8 @@ static void rk_debug_message_callback( printf("[GL] (id=%d) %s\n", id, message); } -void rk_render_initialize() { +void rk_render_initialize( + rk_bool debug) { GLubyte const * const vendor = glGetString(GL_VENDOR); GLubyte const * const renderer = glGetString(GL_RENDERER); printf("[GL] vendor: %s, renderer: %s\n", vendor, renderer); @@ -57,8 +58,10 @@ void rk_render_initialize() { GLubyte const * const language = glGetString(GL_SHADING_LANGUAGE_VERSION); printf("[GL] version: %s, language: %s\n", version, language); - glDebugMessageCallback(rk_debug_message_callback, nullptr); - glEnable(GL_DEBUG_OUTPUT); + if (debug) { + glDebugMessageCallback(rk_debug_message_callback, nullptr); + glEnable(GL_DEBUG_OUTPUT); + } char const * const gl_exts = reinterpret_cast(glGetString(GL_EXTENSIONS)); // printf("[GL] %s\n", gl_exts);