summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/framebuffer.c12
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
57static 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
57void framebuffer_present(const Pixel* pixels) { 63void 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
61void framebuffer_clear(Pixel colour) { 68void 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;