mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Add error message when calling .render() without .update_buffers() (#8005)
* Closes https://github.com/emilk/egui/issues/7968
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
#![expect(clippy::unwrap_used)] // TODO(emilk): avoid unwraps
|
|
||||||
|
|
||||||
use std::{borrow::Cow, num::NonZeroU64, ops::Range};
|
use std::{borrow::Cow, num::NonZeroU64, ops::Range};
|
||||||
|
|
||||||
use ahash::HashMap;
|
use ahash::HashMap;
|
||||||
@@ -516,8 +514,12 @@ impl Renderer {
|
|||||||
// Skip rendering zero-sized clip areas.
|
// Skip rendering zero-sized clip areas.
|
||||||
if let Primitive::Mesh(_) = primitive {
|
if let Primitive::Mesh(_) = primitive {
|
||||||
// If this is a mesh, we need to advance the index and vertex buffer iterators:
|
// If this is a mesh, we need to advance the index and vertex buffer iterators:
|
||||||
index_buffer_slices.next().unwrap();
|
index_buffer_slices
|
||||||
vertex_buffer_slices.next().unwrap();
|
.next()
|
||||||
|
.expect("You must call .update_buffers() before .render()");
|
||||||
|
vertex_buffer_slices
|
||||||
|
.next()
|
||||||
|
.expect("You must call .update_buffers() before .render()");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -527,8 +529,12 @@ impl Renderer {
|
|||||||
|
|
||||||
match primitive {
|
match primitive {
|
||||||
Primitive::Mesh(mesh) => {
|
Primitive::Mesh(mesh) => {
|
||||||
let index_buffer_slice = index_buffer_slices.next().unwrap();
|
let index_buffer_slice = index_buffer_slices
|
||||||
let vertex_buffer_slice = vertex_buffer_slices.next().unwrap();
|
.next()
|
||||||
|
.expect("You must call .update_buffers() before .render()");
|
||||||
|
let vertex_buffer_slice = vertex_buffer_slices
|
||||||
|
.next()
|
||||||
|
.expect("You must call .update_buffers() before .render()");
|
||||||
|
|
||||||
if let Some(Texture { bind_group, .. }) = self.textures.get(&mesh.texture_id) {
|
if let Some(Texture { bind_group, .. }) = self.textures.get(&mesh.texture_id) {
|
||||||
render_pass.set_bind_group(1, bind_group, &[]);
|
render_pass.set_bind_group(1, bind_group, &[]);
|
||||||
@@ -954,6 +960,7 @@ impl Renderer {
|
|||||||
let index_buffer_staging = queue.write_buffer_with(
|
let index_buffer_staging = queue.write_buffer_with(
|
||||||
&self.index_buffer.buffer,
|
&self.index_buffer.buffer,
|
||||||
0,
|
0,
|
||||||
|
#[expect(clippy::unwrap_used)] // Checked above
|
||||||
NonZeroU64::new(required_index_buffer_size).unwrap(),
|
NonZeroU64::new(required_index_buffer_size).unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -998,6 +1005,7 @@ impl Renderer {
|
|||||||
let vertex_buffer_staging = queue.write_buffer_with(
|
let vertex_buffer_staging = queue.write_buffer_with(
|
||||||
&self.vertex_buffer.buffer,
|
&self.vertex_buffer.buffer,
|
||||||
0,
|
0,
|
||||||
|
#[expect(clippy::unwrap_used)] // Checked above
|
||||||
NonZeroU64::new(required_vertex_buffer_size).unwrap(),
|
NonZeroU64::new(required_vertex_buffer_size).unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user