aboutsummaryrefslogtreecommitdiff
path: root/pixel-client/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-25 17:53:48 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-25 17:53:48 +0200
commit11006f4456a57f2fb8df7431dcb22deeb3797c1f (patch)
tree540bbe9fde50ffd5bbcc166a631e605dae8f1627 /pixel-client/src
parent5bf5a200ada9ba03ca2a12c1503318a97166d7c7 (diff)
downloadhurrycurry-11006f4456a57f2fb8df7431dcb22deeb3797c1f.tar
hurrycurry-11006f4456a57f2fb8df7431dcb22deeb3797c1f.tar.bz2
hurrycurry-11006f4456a57f2fb8df7431dcb22deeb3797c1f.tar.zst
Show sprite count
Diffstat (limited to 'pixel-client/src')
-rw-r--r--pixel-client/src/profiler.rs2
-rw-r--r--pixel-client/src/render/font.rs4
-rw-r--r--pixel-client/src/render/mod.rs4
3 files changed, 9 insertions, 1 deletions
diff --git a/pixel-client/src/profiler.rs b/pixel-client/src/profiler.rs
index 8d3f4689..98bf8196 100644
--- a/pixel-client/src/profiler.rs
+++ b/pixel-client/src/profiler.rs
@@ -45,7 +45,7 @@ impl ProfilerOverlay {
}
let size = renderer.draw_text(
Vec2::ZERO,
- &format!("FPS: {:.0}", self.fps),
+ &format!("FPS: {:.0}\nSprites: {}", self.fps, renderer.num_sprites()),
0.3,
Some([255, 150, 255, 255]),
);
diff --git a/pixel-client/src/render/font.rs b/pixel-client/src/render/font.rs
index 95cb3fab..f1e7f4d3 100644
--- a/pixel-client/src/render/font.rs
+++ b/pixel-client/src/render/font.rs
@@ -52,6 +52,10 @@ impl<'a> Renderer<'a> {
let mut cursor = position;
let mut line_height = 0f32;
for c in text.chars() {
+ if c == '\n' {
+ cursor.y += line_height;
+ cursor.x = position.x
+ }
if (c as u32) < 128 {
let r = self.font_textures.glyphs[c as usize];
let size = Vec2::new(r.width() as f32, r.height() as f32) * scale;
diff --git a/pixel-client/src/render/mod.rs b/pixel-client/src/render/mod.rs
index 74c282f3..7bd063a7 100644
--- a/pixel-client/src/render/mod.rs
+++ b/pixel-client/src/render/mod.rs
@@ -185,4 +185,8 @@ impl<'a> Renderer<'a> {
canvas.copy_f(&self.texture, src, dst).unwrap();
}
}
+
+ pub fn num_sprites(&self) -> usize {
+ self.sprites.len()
+ }
}