Feature-gate use of glDebugMessageInsert

This commit is contained in:
John-Mark Allen 2021-07-04 17:30:37 +01:00 committed by Jack Spira
parent 10eb51260e
commit e12e0b1bed
3 changed files with 17 additions and 3 deletions

View File

@ -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`

View File

@ -1183,9 +1183,10 @@ fn prepare_font_atlas<G: Gl, T: TextureMap>(
Ok(gl_texture)
}
fn gl_debug_message<G: glow::HasContext>(context: &G, message: impl AsRef<str>) {
#[cfg(feature = "debug_message_insert_support")]
fn gl_debug_message<G: glow::HasContext>(gl: &G, message: impl AsRef<str>) {
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<G: glow::HasContext>(context: &G, message: impl AsRef<str>)
};
}
#[cfg(not(feature = "debug_message_insert_support"))]
fn gl_debug_message<G: glow::HasContext>(_gl: &G, _message: impl AsRef<str>) {}
fn calculate_matrix(draw_data: &imgui::DrawData, clip_origin_is_lower_left: bool) -> [f32; 16] {
#![allow(clippy::deprecated_cfg_attr)]

View File

@ -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