aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/framebuffer.cpp
blob: a07d61a82459d6fcfbcb72f1f877ddca7b9c6c56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <framebuffer.h>
#include <stdint.h>
#include <stddef.h>

Framebuffer::Framebuffer(uint32_t* addr, const uint64_t width, const uint64_t height) 
    : addr {addr}, width {width}, height {height} {
    clear();
}

void Framebuffer::clear() {
    for (size_t y = 0; y < height; y++) {
        for (size_t x = 0; x < width; x++) {
            const size_t i = y * width + x;
            addr[i] = 0x000000;
        }
    }
}

void Framebuffer::drawpixel(const uint64_t x, const uint64_t y, const uint32_t color) {
    const size_t pos = y * width + x;
    addr[pos] = color;
}