diff --git a/imgui-glow-renderer/Cargo.toml b/imgui-glow-renderer/Cargo.toml index 67d7a7e..8505cb5 100644 --- a/imgui-glow-renderer/Cargo.toml +++ b/imgui-glow-renderer/Cargo.toml @@ -27,6 +27,7 @@ image = "0.23" # feature. default = [ "gl_extensions_support", + "debug_message_insert_support", "bind_vertex_array_support", "vertex_offset_support", "clip_origin_support", @@ -36,6 +37,8 @@ default = [ ] # Enable checking for OpenGL extensions gl_extensions_support = [] +# Support for `glPrimitiveRestartIndex` +debug_message_insert_support = [] # Support for `glBindVertexArray` bind_vertex_array_support = [] # Support for `glDrawElementsBaseVertex` diff --git a/imgui-glow-renderer/src/lib.rs b/imgui-glow-renderer/src/lib.rs index 4f55953..0034623 100644 --- a/imgui-glow-renderer/src/lib.rs +++ b/imgui-glow-renderer/src/lib.rs @@ -1183,9 +1183,10 @@ fn prepare_font_atlas( Ok(gl_texture) } -fn gl_debug_message(context: &G, message: impl AsRef) { +#[cfg(feature = "debug_message_insert_support")] +fn gl_debug_message(gl: &G, message: impl AsRef) { unsafe { - context.debug_message_insert( + gl.debug_message_insert( glow::DEBUG_SOURCE_APPLICATION, glow::DEBUG_TYPE_MARKER, 0, @@ -1195,6 +1196,9 @@ fn gl_debug_message(context: &G, message: impl AsRef) }; } +#[cfg(not(feature = "debug_message_insert_support"))] +fn gl_debug_message(_gl: &G, _message: impl AsRef) {} + fn calculate_matrix(draw_data: &imgui::DrawData, clip_origin_is_lower_left: bool) -> [f32; 16] { #![allow(clippy::deprecated_cfg_attr)] diff --git a/imgui-glow-renderer/src/versions.rs b/imgui-glow-renderer/src/versions.rs index 96c50aa..0e28e8a 100644 --- a/imgui-glow-renderer/src/versions.rs +++ b/imgui-glow-renderer/src/versions.rs @@ -65,6 +65,13 @@ impl GlVersion { } } + /// Debug messages are provided by `glDebugMessageInsert`, which is only + /// present in OpenGL >= 4.3 + #[cfg(feature = "debug_message_insert_support")] + pub fn debug_message_insert_support(self) -> bool { + self >= Self::gl(4, 3) + } + /// Vertex array binding is provided by `glBindVertexArray`, which is /// not present in OpenGL (ES) <3.0 #[cfg(feature = "bind_vertex_array_support")] @@ -76,7 +83,7 @@ impl GlVersion { /// only present from OpenGL 3.2 and above. #[cfg(feature = "vertex_offset_support")] pub fn vertex_offset_support(self) -> bool { - !self.is_gles && self >= Self::gl(3, 2) + self >= Self::gl(3, 2) } /// Vertex arrays (e.g. `glBindVertexArray`) are supported from OpenGL 3.0