diff options
author | 3gg <3gg@shellblade.net> | 2025-10-15 19:35:34 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-10-15 19:36:41 -0700 |
commit | 2122e2fc56a9513078a02c904e793902d5ee095f (patch) | |
tree | 71abc04bc66b2c04aabbcb55afa18090bc701ea4 | |
parent | 943198a8b3f500ee5d1a0e85e6c3edaea832bf64 (diff) |
-rw-r--r-- | src/framebuffer.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/framebuffer.c b/src/framebuffer.c index dc9cc78..5cb41fd 100644 --- a/src/framebuffer.c +++ b/src/framebuffer.c | |||
@@ -54,13 +54,19 @@ const Framebuffer* framebuffer_get() { | |||
54 | return &framebuffer; | 54 | return &framebuffer; |
55 | } | 55 | } |
56 | 56 | ||
57 | static inline uint32_t framebuffer_num_pixels() { | ||
58 | const uint32_t num_channels = framebuffer.depth / 8; | ||
59 | const uint32_t num_pixels = framebuffer.size / num_channels; | ||
60 | return num_pixels; | ||
61 | } | ||
62 | |||
57 | void framebuffer_present(const Pixel* pixels) { | 63 | void framebuffer_present(const Pixel* pixels) { |
58 | memcpy(framebuffer.pixels, pixels, framebuffer.size); | 64 | const uint32_t num_pixels = framebuffer_num_pixels(); |
65 | memcpy(framebuffer.pixels, pixels, num_pixels); | ||
59 | } | 66 | } |
60 | 67 | ||
61 | void framebuffer_clear(Pixel colour) { | 68 | void framebuffer_clear(Pixel colour) { |
62 | const uint32_t num_channels = framebuffer.depth / 8; | 69 | const uint32_t num_pixels = framebuffer_num_pixels(); |
63 | const uint32_t num_pixels = framebuffer.size / num_channels; | ||
64 | volatile Pixel* fb = framebuffer.pixels; | 70 | volatile Pixel* fb = framebuffer.pixels; |
65 | for (size_t i = 0; i < num_pixels; i++) { | 71 | for (size_t i = 0; i < num_pixels; i++) { |
66 | fb->r = colour.r; | 72 | fb->r = colour.r; |