mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Remove calls to gl.getError in release builds (#1583)
This slows down the web version a lot, especially on some browsers Publish new web demo
This commit is contained in:
@@ -22,6 +22,8 @@ pub use winit::*;
|
||||
|
||||
/// Check for OpenGL error and report it using `tracing::error`.
|
||||
///
|
||||
/// Only active in debug builds!
|
||||
///
|
||||
/// ``` no_run
|
||||
/// # let glow_context = todo!();
|
||||
/// use egui_glow::check_for_gl_error;
|
||||
@@ -30,6 +32,30 @@ pub use winit::*;
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! check_for_gl_error {
|
||||
($gl: expr) => {{
|
||||
if cfg!(debug_assertions) {
|
||||
$crate::check_for_gl_error_impl($gl, file!(), line!(), "")
|
||||
}
|
||||
}};
|
||||
($gl: expr, $context: literal) => {{
|
||||
if cfg!(debug_assertions) {
|
||||
$crate::check_for_gl_error_impl($gl, file!(), line!(), $context)
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
/// Check for OpenGL error and report it using `tracing::error`.
|
||||
///
|
||||
/// WARNING: slow! Only use during setup!
|
||||
///
|
||||
/// ``` no_run
|
||||
/// # let glow_context = todo!();
|
||||
/// use egui_glow::check_for_gl_error_even_in_release;
|
||||
/// check_for_gl_error_even_in_release!(glow_context);
|
||||
/// check_for_gl_error_even_in_release!(glow_context, "during painting");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! check_for_gl_error_even_in_release {
|
||||
($gl: expr) => {{
|
||||
$crate::check_for_gl_error_impl($gl, file!(), line!(), "")
|
||||
}};
|
||||
|
||||
@@ -96,7 +96,7 @@ impl Painter {
|
||||
shader_prefix: &str,
|
||||
) -> Result<Painter, String> {
|
||||
crate::profile_function!();
|
||||
check_for_gl_error!(&gl, "before Painter::new");
|
||||
crate::check_for_gl_error_even_in_release!(&gl, "before Painter::new");
|
||||
|
||||
let max_texture_side = unsafe { gl.get_parameter_i32(glow::MAX_TEXTURE_SIZE) } as usize;
|
||||
|
||||
@@ -204,7 +204,7 @@ impl Painter {
|
||||
|
||||
let element_array_buffer = gl.create_buffer()?;
|
||||
|
||||
check_for_gl_error!(&gl, "after Painter::new");
|
||||
crate::check_for_gl_error_even_in_release!(&gl, "after Painter::new");
|
||||
|
||||
Ok(Painter {
|
||||
gl,
|
||||
|
||||
@@ -75,7 +75,7 @@ impl PostProcess {
|
||||
glow::UNSIGNED_BYTE,
|
||||
None,
|
||||
);
|
||||
check_for_gl_error!(&gl, "post process texture initialization");
|
||||
crate::check_for_gl_error_even_in_release!(&gl, "post process texture initialization");
|
||||
|
||||
gl.framebuffer_texture_2d(
|
||||
glow::FRAMEBUFFER,
|
||||
@@ -160,7 +160,7 @@ impl PostProcess {
|
||||
gl.buffer_data_u8_slice(glow::ELEMENT_ARRAY_BUFFER, &indices, glow::STATIC_DRAW);
|
||||
|
||||
gl.bind_buffer(glow::ELEMENT_ARRAY_BUFFER, None);
|
||||
check_for_gl_error!(&gl, "post process initialization");
|
||||
crate::check_for_gl_error_even_in_release!(&gl, "post process initialization");
|
||||
|
||||
Ok(PostProcess {
|
||||
gl,
|
||||
|
||||
Reference in New Issue
Block a user