Index: ps/trunk/source/lib/external_libraries/opengles2_wrapper.h =================================================================== --- ps/trunk/source/lib/external_libraries/opengles2_wrapper.h (revision 26162) +++ ps/trunk/source/lib/external_libraries/opengles2_wrapper.h (revision 26163) @@ -1,97 +1,116 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef INCLUDED_GLES2_WRAPPER #define INCLUDED_GLES2_WRAPPER #include "lib/config2.h" // CONFIG2_GLES #if CONFIG2_GLES #include #define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING #define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE #define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER #define GL_WRITE_ONLY GL_WRITE_ONLY_OES #define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0 #define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT // Functions #define glActiveTextureARB glActiveTexture #define glBlendColorEXT glBlendColor #define glBlendEquationEXT glBlendEquation #define glCompressedTexImage2DARB glCompressedTexImage2D #define glAttachObjectARB glAttachShader #define glBindAttribLocationARB glBindAttribLocation #define glCompileShaderARB glCompileShader #define glCreateProgramObjectARB glCreateProgram #define glCreateShaderObjectARB glCreateShader #define glDisableVertexAttribArrayARB glDisableVertexAttribArray #define glEnableVertexAttribArrayARB glEnableVertexAttribArray #define glGetActiveUniformARB glGetActiveUniform #define glGetUniformLocationARB glGetUniformLocation #define glLinkProgramARB glLinkProgram #define glShaderSourceARB glShaderSource #define glUniform1fARB glUniform1f #define glUniform2fARB glUniform2f #define glUniform3fARB glUniform3f #define glUniform4fARB glUniform4f #define glUniform1iARB glUniform1i #define glUniform1fvARB glUniform1fv #define glUniformMatrix4fvARB glUniformMatrix4fv #define glUseProgramObjectARB glUseProgram #define glVertexAttribPointerARB glVertexAttribPointer #define glBindBufferARB glBindBuffer #define glBufferDataARB glBufferData #define glBufferSubDataARB glBufferSubData #define glDeleteBuffersARB glDeleteBuffers #define glGenBuffersARB glGenBuffers #define glBindFramebufferEXT glBindFramebuffer #define glCheckFramebufferStatusEXT glCheckFramebufferStatus #define glDeleteFramebuffersEXT glDeleteFramebuffers #define glFramebufferTexture2DEXT glFramebufferTexture2D #define glGenFramebuffersEXT glGenFramebuffers // Extensions // GL_OES_texture_border_clamp #define GL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER_OES #define GL_TEXTURE_BORDER_COLOR GL_TEXTURE_BORDER_COLOR_OES // GL_OES_rgb8_rgba8 #define GL_RGBA8 GL_RGBA8_OES // GL_OES_mapbuffer #define glMapBufferARB glMapBufferOES #define glUnmapBufferARB glUnmapBufferOES // GL_OES_depth32 #define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES // GL_KHR_debug #define glPopDebugGroupKHR glPopDebugGroup #define glPushDebugGroupKHR glPushDebugGroup +#define GL_DEBUG_SOURCE_API_KHR GL_DEBUG_SOURCE_API +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR GL_DEBUG_SOURCE_WINDOW_SYSTEM +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR GL_DEBUG_SOURCE_SHADER_COMPILER +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR GL_DEBUG_SOURCE_THIRD_PARTY +#define GL_DEBUG_SOURCE_APPLICATION_KHR GL_DEBUG_SOURCE_APPLICATION +#define GL_DEBUG_SOURCE_OTHER_KHR GL_DEBUG_SOURCE_OTHER +#define GL_DEBUG_TYPE_ERROR_KHR GL_DEBUG_TYPE_ERROR +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR +#define GL_DEBUG_TYPE_PORTABILITY_KHR GL_DEBUG_TYPE_PORTABILITY +#define GL_DEBUG_TYPE_PERFORMANCE_KHR GL_DEBUG_TYPE_PERFORMANCE +#define GL_DEBUG_TYPE_OTHER_KHR GL_DEBUG_TYPE_OTHER +#define GL_DEBUG_TYPE_MARKER_KHR GL_DEBUG_TYPE_MARKER +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR GL_DEBUG_TYPE_PUSH_GROUP +#define GL_DEBUG_TYPE_POP_GROUP_KHR GL_DEBUG_TYPE_POP_GROUP +#define GL_DEBUG_SEVERITY_HIGH_KHR GL_DEBUG_SEVERITY_HIGH +#define GL_DEBUG_SEVERITY_MEDIUM_KHR GL_DEBUG_SEVERITY_MEDIUM +#define GL_DEBUG_SEVERITY_LOW_KHR GL_DEBUG_SEVERITY_LOW +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR GL_DEBUG_SEVERITY_NOTIFICATION #endif // CONFIG2_GLES #endif // !INCLUDED_GLES2_WRAPPER Index: ps/trunk/source/lib/ogl.cpp =================================================================== --- ps/trunk/source/lib/ogl.cpp (revision 26162) +++ ps/trunk/source/lib/ogl.cpp (revision 26163) @@ -1,630 +1,632 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* * OpenGL helper functions. */ #include "precompiled.h" #include "lib/ogl.h" #include "lib/code_annotation.h" #include "lib/config2.h" #include "lib/debug.h" #include "lib/external_libraries/libsdl.h" #include "ps/CLogger.h" #if !CONFIG2_GLES # if OS_WIN # include # elif !OS_MACOSX && !OS_MAC # include # endif #endif #include #include #include //---------------------------------------------------------------------------- // extensions //---------------------------------------------------------------------------- static const char* exts = nullptr; static bool have_30 = false; static bool have_21 = false; static bool have_20 = false; static bool have_15 = false; static bool have_14 = false; static bool have_13 = false; static bool have_12 = false; #if KHR_DEBUG_ENABLED static bool have_KHR = false; #endif // return a C string of unspecified length containing a space-separated // list of all extensions the OpenGL implementation advertises. // (useful for crash logs). const char* ogl_ExtensionString() { ENSURE(exts && "call ogl_Init before using this function"); return exts; } // paranoia: newer drivers may forget to advertise an extension // indicating support for something that has been folded into the core. // we therefore check for all extensions known to be offered by the // GL implementation present on the user's system; ogl_HaveExtension will // take this into account. // the app can therefore just ask for extensions and not worry about this. static bool isImplementedInCore(const char* ext) { #define MATCH(known_ext)\ if(!strcmp(ext, #known_ext))\ return true; if(have_30) { MATCH(GL_EXT_gpu_shader4); MATCH(GL_NV_conditional_render); MATCH(GL_ARB_color_buffer_float); MATCH(GL_ARB_depth_buffer_float); MATCH(GL_ARB_texture_float); MATCH(GL_EXT_packed_float); MATCH(GL_EXT_texture_shared_exponent); MATCH(GL_EXT_framebuffer_object); MATCH(GL_NV_half_float); MATCH(GL_ARB_half_float_pixel); MATCH(GL_EXT_framebuffer_multisample); MATCH(GL_EXT_framebuffer_blit); MATCH(GL_EXT_texture_integer); MATCH(GL_EXT_texture_array); MATCH(GL_EXT_packed_depth_stencil); MATCH(GL_EXT_draw_buffers2); MATCH(GL_EXT_texture_compression_rgtc); MATCH(GL_EXT_transform_feedback); MATCH(GL_APPLE_vertex_array_object); MATCH(GL_EXT_framebuffer_sRGB); } if(have_21) { MATCH(GL_ARB_pixel_buffer_object); MATCH(GL_EXT_texture_sRGB); } if(have_20) { MATCH(GL_ARB_shader_objects); MATCH(GL_ARB_vertex_shader); MATCH(GL_ARB_fragment_shader); MATCH(GL_ARB_shading_language_100); MATCH(GL_ARB_draw_buffers); MATCH(GL_ARB_texture_non_power_of_two); MATCH(GL_ARB_point_sprite); MATCH(GL_EXT_blend_equation_separate); } if(have_15) { MATCH(GL_ARB_vertex_buffer_object); MATCH(GL_ARB_occlusion_query); MATCH(GL_EXT_shadow_funcs); } if(have_14) { MATCH(GL_SGIS_generate_mipmap); MATCH(GL_NV_blend_square); MATCH(GL_ARB_depth_texture); MATCH(GL_ARB_shadow); MATCH(GL_EXT_fog_coord); MATCH(GL_EXT_multi_draw_arrays); MATCH(GL_ARB_point_parameters); MATCH(GL_EXT_secondary_color); MATCH(GL_EXT_blend_func_separate); MATCH(GL_EXT_stencil_wrap); MATCH(GL_ARB_texture_env_crossbar); MATCH(GL_EXT_texture_lod_bias); MATCH(GL_ARB_texture_mirrored_repeat); MATCH(GL_ARB_window_pos); // These extensions were added to GL 1.2, but as part of the optional // imaging subset; they're only guaranteed as of GL 1.4: MATCH(GL_EXT_blend_color); MATCH(GL_EXT_blend_minmax); MATCH(GL_EXT_blend_subtract); } if(have_13) { MATCH(GL_ARB_texture_compression); MATCH(GL_ARB_texture_cube_map); MATCH(GL_ARB_multisample); MATCH(GL_ARB_multitexture); MATCH(GL_ARB_transpose_matrix); MATCH(GL_ARB_texture_env_add); MATCH(GL_ARB_texture_env_combine); MATCH(GL_ARB_texture_env_dot3); MATCH(GL_ARB_texture_border_clamp); } if(have_12) { MATCH(GL_EXT_texture3D); MATCH(GL_EXT_bgra); MATCH(GL_EXT_packed_pixels); MATCH(GL_EXT_rescale_normal); MATCH(GL_EXT_separate_specular_color); MATCH(GL_SGIS_texture_edge_clamp); MATCH(GL_SGIS_texture_lod); MATCH(GL_EXT_draw_range_elements); // Skip the extensions that only affect the imaging subset } #undef MATCH return false; } // check if the extension is supported by the OpenGL implementation. // takes subsequently added core support for some extensions into account. bool ogl_HaveExtension(const char* ext) { ENSURE(exts && "call ogl_Init before using this function"); if(isImplementedInCore(ext)) return true; const char *p = exts, *end; // make sure ext is valid & doesn't contain spaces if(!ext || ext[0] == '\0' || strchr(ext, ' ')) return false; for(;;) { p = strstr(p, ext); if(!p) return false; // string not found - extension not supported end = p + strlen(ext); // end of current substring // make sure the substring found is an entire extension string, // i.e. it starts and ends with ' ' if((p == exts || p[-1] == ' ') && // valid start AND (*end == ' ' || *end == '\0')) // valid end return true; p = end; } } static int GLVersion; #if OS_WIN static int WGLVersion; #elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC static int GLXVersion; #endif bool ogl_HaveVersion(int major, int minor) { return GLAD_MAKE_VERSION(major, minor) <= GLVersion; } // check if all given extension strings (passed as const char* parameters, // terminated by a 0 pointer) are supported by the OpenGL implementation, // as determined by ogl_HaveExtension. // returns 0 if all are present; otherwise, the first extension in the // list that's not supported (useful for reporting errors). // // note: dummy parameter is necessary to access parameter va_list. // // // rationale: this interface is more convenient than individual // ogl_HaveExtension calls and allows reporting which extension is missing. // // one disadvantage is that there is no way to indicate that either one // of 2 extensions would be acceptable, e.g. (ARB|EXT)_texture_env_dot3. // this is isn't so bad, since they wouldn't be named differently // if there weren't non-trivial changes between them. for that reason, // we refrain from equivalence checks (which would boil down to // string-matching known extensions to their equivalents). const char* ogl_HaveExtensions(int dummy, ...) { const char* ext; va_list args; va_start(args, dummy); for(;;) { ext = va_arg(args, const char*); // end of list reached; all were present => return 0. if(!ext) break; // not found => return name of missing extension. if(!ogl_HaveExtension(ext)) break; } va_end(args); return ext; } // to help when running with no hardware acceleration and only OpenGL 1.1 // (e.g. testing the game in virtual machines), we define dummy versions of // some extension functions which our graphics code assumes exist. // it will render incorrectly but at least it shouldn't crash. #if CONFIG2_GLES static void enableDummyFunctions() { } #else static void GLAD_API_PTR dummy_glDrawRangeElementsEXT(GLenum mode, GLuint, GLuint, GLsizei count, GLenum type, GLvoid* indices) { glDrawElements(mode, count, type, indices); } static void GLAD_API_PTR dummy_glActiveTextureARB(GLenum UNUSED(texture)) { } static void GLAD_API_PTR dummy_glClientActiveTextureARB(GLenum UNUSED(texture)) { } static void GLAD_API_PTR dummy_glMultiTexCoord2fARB(GLenum UNUSED(target), GLfloat s, GLfloat t) { glTexCoord2f(s, t); } static void GLAD_API_PTR dummy_glMultiTexCoord3fARB(GLenum UNUSED(target), GLfloat s, GLfloat t, GLfloat r) { glTexCoord3f(s, t, r); } static void enableDummyFunctions() { // fall back to the dummy functions when extensions (or equivalent core support) are missing if(!ogl_HaveExtension("GL_EXT_draw_range_elements")) { glDrawRangeElementsEXT = reinterpret_cast(&dummy_glDrawRangeElementsEXT); } if(!ogl_HaveExtension("GL_ARB_multitexture")) { glActiveTextureARB = reinterpret_cast(&dummy_glActiveTextureARB); glClientActiveTextureARB = reinterpret_cast(&dummy_glClientActiveTextureARB); glMultiTexCoord2fARB = reinterpret_cast(&dummy_glMultiTexCoord2fARB); glMultiTexCoord3fARB = reinterpret_cast(&dummy_glMultiTexCoord3fARB); } } #endif // #if CONFIG2_GLES //---------------------------------------------------------------------------- const char* ogl_GetErrorName(GLenum err) { #define E(e) case e: return #e; switch (err) { E(GL_INVALID_ENUM) E(GL_INVALID_VALUE) E(GL_INVALID_OPERATION) #if !CONFIG2_GLES E(GL_STACK_OVERFLOW) E(GL_STACK_UNDERFLOW) #endif E(GL_OUT_OF_MEMORY) E(GL_INVALID_FRAMEBUFFER_OPERATION) default: return "Unknown GL error"; } #undef E } static void dump_gl_error(GLenum err) { debug_printf("OGL| %s (%04x)\n", ogl_GetErrorName(err), err); } void ogl_WarnIfErrorLoc(const char *file, int line) { // glGetError may return multiple errors, so we poll it in a loop. // the debug_printf should only happen once (if this is set), though. bool error_enountered = false; GLenum first_error = 0; for(;;) { GLenum err = glGetError(); if(err == GL_NO_ERROR) break; if(!error_enountered) first_error = err; error_enountered = true; dump_gl_error(err); } if(error_enountered) debug_printf("%s:%d: OpenGL error(s) occurred: %s (%04x)\n", file, line, ogl_GetErrorName(first_error), (unsigned int)first_error); } +#if KHR_DEBUG_ENABLED void GLAD_API_PTR ogl_OnDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei UNUSED(length), const GLchar* message, const void* UNUSED(user_param)) { std::string debugSource = "unknown"; std::string debugType = "unknown"; std::string debugSeverity = "unknown"; switch (source) { case GL_DEBUG_SOURCE_API: debugSource = "the API"; break; case GL_DEBUG_SOURCE_WINDOW_SYSTEM: debugSource = "the window system"; break; case GL_DEBUG_SOURCE_SHADER_COMPILER: debugSource = "the shader compiler"; break; case GL_DEBUG_SOURCE_THIRD_PARTY: debugSource = "a third party"; break; case GL_DEBUG_SOURCE_APPLICATION: debugSource = "the application"; break; case GL_DEBUG_SOURCE_OTHER: debugSource = "somewhere"; break; } switch (type) { case GL_DEBUG_TYPE_ERROR: debugType = "error"; break; case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: debugType = "deprecated behaviour"; break; case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: debugType = "undefined behaviour"; break; case GL_DEBUG_TYPE_PORTABILITY: debugType = "portability"; break; case GL_DEBUG_TYPE_PERFORMANCE: debugType = "performance"; break; case GL_DEBUG_TYPE_OTHER: debugType = "other"; break; case GL_DEBUG_TYPE_MARKER: debugType = "marker"; break; case GL_DEBUG_TYPE_PUSH_GROUP: debugType = "push group"; break; case GL_DEBUG_TYPE_POP_GROUP: debugType = "pop group"; break; } switch (severity) { case GL_DEBUG_SEVERITY_HIGH: debugSeverity = "high"; break; case GL_DEBUG_SEVERITY_MEDIUM: debugSeverity = "medium"; break; case GL_DEBUG_SEVERITY_LOW: debugSeverity = "low"; break; case GL_DEBUG_SEVERITY_NOTIFICATION: debugSeverity = "notification"; break; } debug_printf("OpenGL | %s: %s source: %s id %u: %s\n", debugSeverity.c_str(), debugType.c_str(), debugSource.c_str(), id, message); } +#endif // ignore and reset the specified error (as returned by glGetError). // any other errors that have occurred are reported as ogl_WarnIfError would. // // this is useful for suppressing annoying error messages, e.g. // "invalid enum" for GL_CLAMP_TO_EDGE even though we've already // warned the user that their OpenGL implementation is too old. bool ogl_SquelchError(GLenum err_to_ignore) { // glGetError may return multiple errors, so we poll it in a loop. // the debug_printf should only happen once (if this is set), though. bool error_enountered = false; bool error_ignored = false; GLenum first_error = 0; for(;;) { GLenum err = glGetError(); if(err == GL_NO_ERROR) break; if(err == err_to_ignore) { error_ignored = true; continue; } if(!error_enountered) first_error = err; error_enountered = true; dump_gl_error(err); } if(error_enountered) debug_printf("OpenGL error(s) occurred: %04x\n", (unsigned int)first_error); return error_ignored; } //---------------------------------------------------------------------------- // feature and limit detect //---------------------------------------------------------------------------- GLint ogl_max_tex_size = -1; // [pixels] GLint ogl_max_tex_units = -1; // limit on GL_TEXTUREn #if OS_WIN bool ogl_Init(void* (load)(const char*), void* hdc) #elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC bool ogl_Init(void* (load)(const char*), void* display) #else bool ogl_Init(void* (load)(const char*)) #endif { GLADloadfunc loadFunc = reinterpret_cast(load); if (!loadFunc) return false; #define LOAD_ERROR(ERROR_STRING) \ if (g_Logger) \ LOGERROR(ERROR_STRING); \ else \ debug_printf(ERROR_STRING); \ #if !CONFIG2_GLES GLVersion = gladLoadGL(loadFunc); if (!GLVersion) { LOAD_ERROR("Failed to load OpenGL functions."); return false; } # if OS_WIN WGLVersion = gladLoadWGL(reinterpret_cast(hdc), loadFunc); if (!WGLVersion) { LOAD_ERROR("Failed to load WGL functions."); return false; } # elif !OS_MACOSX && !OS_MAC GLXVersion = gladLoadGLX(reinterpret_cast(display), DefaultScreen(display), loadFunc); if (!GLXVersion) { LOAD_ERROR("Failed to load GLX functions."); return false; } # endif #else GLVersion = gladLoadGLES2(loadFunc); if (!GLVersion) { LOAD_ERROR("Failed to load GLES2 functions."); return false; } #endif #undef LOAD_ERROR // cache extension list and versions for oglHave*. // note: this is less about performance (since the above are not // time-critical) than centralizing the 'OpenGL is ready' check. exts = reinterpret_cast(glGetString(GL_EXTENSIONS)); ENSURE(exts); // else: called before OpenGL is ready for use have_12 = ogl_HaveVersion(1, 2); have_13 = ogl_HaveVersion(1, 3); have_14 = ogl_HaveVersion(1, 4); have_15 = ogl_HaveVersion(1, 5); have_20 = ogl_HaveVersion(2, 0); have_21 = ogl_HaveVersion(2, 1); have_30 = ogl_HaveVersion(3, 0); enableDummyFunctions(); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &ogl_max_tex_size); #if !CONFIG2_GLES glGetIntegerv(GL_MAX_TEXTURE_UNITS, &ogl_max_tex_units); #endif glEnable(GL_TEXTURE_2D); #if KHR_DEBUG_ENABLED #if CONFIG2_GLES bool is_core = ogl_HaveVersion(3, 2); #else bool is_core = ogl_HaveVersion(4, 3); #endif have_KHR = is_core || ogl_HaveExtension("GL_KHR_debug"); if (have_KHR) { glEnable(GL_DEBUG_OUTPUT); glDebugMessageCallback(ogl_OnDebugMessage, nullptr); // Filter out our own debug group messages GLuint id = 0x0ad; glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PUSH_GROUP, GL_DONT_CARE, 1, &id, GL_FALSE); glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_POP_GROUP, GL_DONT_CARE, 1, &id, GL_FALSE); } #endif return true; } void ogl_SetVsyncEnabled(bool enabled) { #if !CONFIG2_GLES && OS_WIN int interval = enabled ? 1 : 0; if (ogl_HaveExtension("WGL_EXT_swap_control")) wglSwapIntervalEXT(interval); #elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC int interval = enabled ? 1 : 0; if (ogl_HaveExtension("GLX_SGI_swap_control")) glXSwapIntervalSGI(interval); #else UNUSED2(enabled); #endif } #if KHR_DEBUG_ENABLED ogl_DebugScopedGroup::ogl_DebugScopedGroup(const char* message) { if (!have_KHR) return; glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0x0ad, -1, message); } ogl_DebugScopedGroup::~ogl_DebugScopedGroup() { if (!have_KHR) return; glPopDebugGroup(); } #endif