Skip to content

Commit

Permalink
some rendering fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Glowman554 committed Jul 31, 2024
1 parent 72a183a commit e8c058c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/boot/limine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ extern "C" void limine_entry() {
.buffer_size = (size_t) framebuffer_request.response->framebuffers[0]->width * framebuffer_request.response->framebuffers[0]->height * 4,
.width = framebuffer_request.response->framebuffers[0]->width,
.height = framebuffer_request.response->framebuffers[0]->height,
.pitch = framebuffer_request.response->framebuffers[0]->pitch,
};

boot::boot_info.command_line = kernel_file_request.response->kernel_file->cmdline;
Expand Down
3 changes: 2 additions & 1 deletion core/boot/stivale2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ extern "C" void stivale2_entry(stivale2_struct* bootinfo) {
.base_address = (void*) framebuffer_tag->framebuffer_addr,
.buffer_size = (size_t) framebuffer_tag->framebuffer_width * framebuffer_tag->framebuffer_height * 4,
.width = framebuffer_tag->framebuffer_width,
.height = framebuffer_tag->framebuffer_height
.height = framebuffer_tag->framebuffer_height,
.pitch = framebuffer_tag->framebuffer_pitch,
};

stivale2_struct_tag_cmdline* cmdline_tag = stivale2_tag_find<stivale2_struct_tag_cmdline>(bootinfo, STIVALE2_STRUCT_TAG_CMDLINE_ID);
Expand Down
1 change: 1 addition & 0 deletions core/include/renderer/framebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ namespace renderer {
size_t buffer_size;
uint32_t width;
uint32_t height;
uint32_t pitch;
};
}
2 changes: 1 addition & 1 deletion core/renderer/font_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void font_renderer::putchar(char c) {
for (unsigned long y = cursor_position.y; y < cursor_position.y + 16; y++){
for (unsigned long x = cursor_position.x; x < cursor_position.x + 8; x++){
if ((*font_ptr & (0b10000000 >> (x - cursor_position.x))) > 0){
*(unsigned int*)(pix_ptr + x + (y * target_frame_buffer->width)) = color;
*(unsigned int*)(pix_ptr + x + (y * (target_frame_buffer->pitch / 4))) = color;
}
}
font_ptr++;
Expand Down
6 changes: 3 additions & 3 deletions core/renderer/render2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ render2d::render2d(framebuffer_t* target_framebuffer) {
}

void render2d::put_pix(uint32_t x, uint32_t y, uint32_t colour) {
*(uint32_t*)((uint64_t)target->base_address + (x * 4) + (y * 4 * target->width)) = colour;
*(uint32_t*)((uint64_t)target->base_address + x + (y * (target->pitch / 4))) = colour;
}

void render2d::load_bitmap(uint8_t data[], int y) {
Expand Down Expand Up @@ -48,7 +48,7 @@ void render2d::load_bitmap(uint8_t data[], int y) {

for (int i = src_height; 0 < i; i--) {
for(int j = 0; j < width; j++) {
int where = (j + (i * target->width)) * 4 + location;
int where = (j + (i * target->pitch / 4)) * 4 + location;
for (int c = 2; 0 <= c; c--) {
uint8_t g = logo_data[((j * src_width) / width + (((src_height - i) * src_height) / src_height) * src_width) * bit_count + c];
uint8_t* screen = (uint8_t*) target->base_address;
Expand Down Expand Up @@ -90,7 +90,7 @@ void render2d::load_bitmap(uint8_t data[], int y, int x) {

for (int i = src_height; 0 < i; i--) {
for(int j = 0; j < width; j++) {
int where = (j + (i * target->width)) * 4 + location;
int where = (j + (i * target->pitch / 4)) * 4 + location;
for (int c = 2; 0 <= c; c--) {
uint8_t g = logo_data[((j * src_width) / width + (((src_height - i) * src_height) / src_height) * src_width) * bit_count + c];
uint8_t* screen = (uint8_t*) target->base_address;
Expand Down

0 comments on commit e8c058c

Please sign in to comment.