mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Improve OpenGL error detection and reporting in egui_glow
May help to diagnose https://github.com/emilk/egui/issues/1087
This commit is contained in:
@@ -10,7 +10,7 @@ use glow::HasContext;
|
||||
use memoffset::offset_of;
|
||||
|
||||
use crate::misc_util::{
|
||||
as_u8_slice, compile_shader, glow_debug_print, link_program, srgbtexture2d,
|
||||
as_u8_slice, check_for_gl_error, compile_shader, glow_print, link_program, srgb_texture2d,
|
||||
};
|
||||
use crate::post_process::PostProcess;
|
||||
use crate::shader_version::ShaderVersion;
|
||||
@@ -93,11 +93,13 @@ impl Painter {
|
||||
pp_fb_extent: Option<[i32; 2]>,
|
||||
shader_prefix: &str,
|
||||
) -> Result<Painter, String> {
|
||||
check_for_gl_error(gl, "before Painter::new");
|
||||
|
||||
let support_vao = crate::misc_util::supports_vao(gl);
|
||||
let shader_version = ShaderVersion::get(gl);
|
||||
let is_webgl_1 = shader_version == ShaderVersion::Es100;
|
||||
let header = shader_version.version();
|
||||
glow_debug_print(format!("Shader header: {:?}", header));
|
||||
glow_print(format!("Shader header: {:?}", header));
|
||||
let srgb_support = gl.supported_extensions().contains("EXT_sRGB");
|
||||
|
||||
let (post_process, srgb_support_define) = match (shader_version, srgb_support) {
|
||||
@@ -105,7 +107,7 @@ impl Painter {
|
||||
(ShaderVersion::Es300, _) | (ShaderVersion::Es100, true) => unsafe {
|
||||
//Add sRGB support marker for fragment shader
|
||||
if let Some([width, height]) = pp_fb_extent {
|
||||
glow_debug_print("WebGL with sRGB enabled so turn on post process");
|
||||
glow_print("WebGL with sRGB enabled so turn on post process");
|
||||
//install post process to correct sRGB color
|
||||
(
|
||||
Some(PostProcess::new(
|
||||
@@ -119,7 +121,7 @@ impl Painter {
|
||||
"#define SRGB_SUPPORTED",
|
||||
)
|
||||
} else {
|
||||
glow_debug_print("WebGL or OpenGL ES detected but PostProcess disabled because dimension is None");
|
||||
glow_print("WebGL or OpenGL ES detected but PostProcess disabled because dimension is None");
|
||||
(None, "")
|
||||
}
|
||||
},
|
||||
@@ -201,7 +203,7 @@ impl Painter {
|
||||
vertex_array.add_new_attribute(gl, position_buffer_info);
|
||||
vertex_array.add_new_attribute(gl, tex_coord_buffer_info);
|
||||
vertex_array.add_new_attribute(gl, color_buffer_info);
|
||||
assert_eq!(gl.get_error(), glow::NO_ERROR, "OpenGL error occurred!");
|
||||
check_for_gl_error(gl, "after Painter::new");
|
||||
|
||||
Ok(Painter {
|
||||
program,
|
||||
@@ -244,7 +246,7 @@ impl Painter {
|
||||
|
||||
if let Some(old_tex) = std::mem::replace(
|
||||
&mut self.egui_texture,
|
||||
Some(srgbtexture2d(
|
||||
Some(srgb_texture2d(
|
||||
gl,
|
||||
self.is_webgl_1,
|
||||
self.srgb_support,
|
||||
@@ -346,7 +348,7 @@ impl Painter {
|
||||
|
||||
gl.disable(glow::SCISSOR_TEST);
|
||||
|
||||
assert_eq!(glow::NO_ERROR, gl.get_error(), "GL error occurred!");
|
||||
check_for_gl_error(gl, "painting");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,7 +439,7 @@ impl Painter {
|
||||
.flat_map(|srgba| Vec::from(srgba.to_array()))
|
||||
.collect();
|
||||
|
||||
let gl_texture = srgbtexture2d(
|
||||
let gl_texture = srgb_texture2d(
|
||||
gl,
|
||||
self.is_webgl_1,
|
||||
self.srgb_support,
|
||||
|
||||
Reference in New Issue
Block a user