Browse Source

Better error message when trying to upload too large texture

Closes https://github.com/emilk/egui/issues/1370
pull/1384/head
Emil Ernerfeldt 3 years ago
parent
commit
f6af7bda27
  1. 15
      egui_glow/src/painter.rs

15
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,

Loading…
Cancel
Save