From f6af7bda27555b111fe551ba120be326e91e7422 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 19 Mar 2022 13:30:29 +0100 Subject: [PATCH] Better error message when trying to upload too large texture Closes https://github.com/emilk/egui/issues/1370 --- egui_glow/src/painter.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/egui_glow/src/painter.rs b/egui_glow/src/painter.rs index 8e68836c..db24433b 100644 --- a/egui_glow/src/painter.rs +++ b/egui_glow/src/painter.rs @@ -485,7 +485,20 @@ impl Painter { fn upload_texture_srgb(&mut self, pos: Option<[usize; 2]>, [w, h]: [usize; 2], data: &[u8]) { assert_eq!(data.len(), w * h * 4); - assert!(w >= 1 && h >= 1); + assert!( + w >= 1 && h >= 1, + "Got a texture image of size {}x{}. A texture must at least be one texel wide.", + w, + h + ); + assert!( + w <= self.max_texture_side && h <= self.max_texture_side, + "Got a texture image of size {}x{}, but the maximum supported texture side is only {}", + w, + h, + self.max_texture_side + ); + unsafe { self.gl.tex_parameter_i32( glow::TEXTURE_2D,