Compare commits

...

7 Commits

Author SHA1 Message Date
Eric-Paul I a4b246095a Made first major changes; missing integration and optimization 2023-03-09 18:04:47 +01:00
Eric-Paul I ed98984164 Starting new graphics subsystem 2023-03-09 12:58:59 +01:00
Eric-Paul I 72e1a8ecd0 Changed name 'position' to vector. 2023-03-09 06:40:39 +01:00
Eric-Paul I 3ac01ad142 Altered and added definitions in the graphics driver 2023-03-09 06:39:14 +01:00
Eric-Paul I ddcb64daea Changed position_T to some vectors 2023-03-09 03:34:45 +01:00
Eric-Paul I 73796b2686 Preparing for rewriting renderer. 2023-03-09 03:30:29 +01:00
Eric-Paul I e1978a052d Changed the log prefixes 2023-03-09 03:30:16 +01:00
20 changed files with 269 additions and 701 deletions

View File

@ -0,0 +1,12 @@
#ifndef NOX_GRAPHICS_COMMAND_QUEUE_H
#define NOX_GRAPHICS_COMMAND_QUEUE_H
#include <utils/math.h>
#include <utils/memory.h>
#include <utils/stdtypes.h>
// TODO
#endif

View File

@ -0,0 +1,12 @@
#ifndef NOX_GRAPHICS_DEFAULT_IMPLEMENTATION_H
#define NOX_GRAPHICS_DEFAULT_IMPLEMENTATION_H
#include <utils/math.h>
#include <utils/memory.h>
#include <utils/stdtypes.h>
// TODO
#endif

View File

@ -0,0 +1,35 @@
#ifndef NOX_GRAPHICS_DRIVER_H
#define NOX_GRAPHICS_DRIVER_H
#include <boot/boot_info.h>
#include <utils/math.h>
#include <utils/memory.h>
#include <utils/stdtypes.h>
#include <drivers/gfx/pixelbuffer.h>
typedef struct framebuffer_t {
uint32_t pixel_width;
uint32_t pixel_height;
uint8_t pixel_stride;
void *memory_mapping;
pixelbuffer_T *root_pixelbuffer;
} framebuffer_T;
typedef struct graphics_driver_t {
uint32_t num_framebuffers;
framebuffer_T *framebuffers;
} graphics_driver_T;
graphics_driver_T * create_graphics_driver_from_boot_info(boot_info_T *boot_info);
void delete_graphics_driver(graphics_driver_T *driver);
#endif

View File

@ -0,0 +1,51 @@
#ifndef NOX_PIXELBUFFER_H
#define NOX_PIXELBUFFER_H
#include <utils/math.h>
#include <utils/memory.h>
#include <utils/stdtypes.h>
#include <drivers/gfx/utility.h>
typedef struct pixelbuffer_t pixelbuffer_T;
struct pixelbuffer_t {
//
// Other relevant state
//
pixelbuffer_T *parent;
// root_pixelbuffer: The first pixelbuffer for a screen, it represents the whole screen
// from a drawing perspective. In the root pixelbuffers themselves, this is NULL.
pixelbuffer_T *root_pixelbuffer;
//
// Dimensions of the pixelbuffers' area
//
uint32_t relative_start_x;
uint32_t relative_start_y;
uint32_t absolute_start_x;
uint32_t absolute_start_y;
uint32_t pixel_width;
uint32_t pixel_height;
//
// Information necessary for drawing
//
// pixel_stride: The distance between pixels in 'mapped_region', in bytes.
uint8_t pixel_stride;
void *memory_mapping;
};
pixelbuffer_T * create_pixelbuffer (pixelbuffer_T *parent);
void delete_pixelbuffer (pixelbuffer_T *pixelbuffer);
void graphics_set_pixel (pixelbuffer_T *pixelbuffer,
uint32_t relative_x, uint32_t relative_y, pixel_T pixel);
#endif

View File

@ -0,0 +1,12 @@
#ifndef NOX_GRAPHICS_STRINGIFY_ENUMS_H
#define NOX_GRAPHICS_STRINGIFY_ENUMS_H
#include <utils/math.h>
#include <utils/memory.h>
#include <utils/stdtypes.h>
// TODO
#endif

View File

@ -0,0 +1,19 @@
#ifndef NOX_GRAPHICS_UTILITY_H
#define NOX_GRAPHICS_UTILITY_H
#include <utils/math.h>
#include <utils/memory.h>
#include <utils/stdtypes.h>
typedef struct
{
uint16_t red;
uint16_t green;
uint16_t blue;
uint16_t alpha;
} pixel_T;
#endif

View File

@ -1,55 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NOX_COLOR_H
#define NOX_COLOR_H
#include "utils/stdtypes.h"
// Colors from https://gogh-co.github.io/Gogh/
typedef enum {
COLOR_PAL_GREY_DARK,
COLOR_PAL_PINK,
COLOR_PAL_GREEN_SIGNAL,
COLOR_PAL_ORANGE,
COLOR_PAL_BLUE,
COLOR_PAL_PURPLE,
COLOR_PAL_GREEN,
COLOR_PAL_GREY_LIGHT,
COLOR_PAL_RED,
COLOR_PAL_ENUM_END
} color_palette_E;
typedef struct {
uint8_t alpha;
uint8_t red;
uint8_t green;
uint8_t blue;
} color_argb_T;
extern color_argb_T g_color_palette[COLOR_PAL_ENUM_END];
color_argb_T color_argb_blend_alpha(color_argb_T background, color_argb_T foreground);
#endif //NOX_COLOR_H

View File

@ -1,38 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NOX_FONT_H
#define NOX_FONT_H
#include "utils/stdtypes.h"
typedef struct {
uint8_t width;
uint8_t height;
uint8_t glyph_size;
uint8_t* buffer;
} font_T;
extern font_T g_font;
#endif //NOX_FONT_H

View File

@ -1,41 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NOX_FRAMEBUFFER_H
#define NOX_FRAMEBUFFER_H
#include "utils/stdtypes.h"
typedef struct {
void* address;
uint64_t width;
uint64_t height;
uint64_t pitch;
uint16_t bits_per_pixel;
uint8_t bytes_per_pixel;
uint8_t shift_red;
uint8_t shift_green;
uint8_t shift_blue;
} framebuffer_T;
#endif //NOX_FRAMEBUFFER_H

View File

@ -1,82 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef NOX_RENDERER_H
#define NOX_RENDERER_H
#include "utils/stdtypes.h"
#include "utils/string.h"
#include "utils/math.h"
#include "drivers/graphics/color.h"
#include "drivers/graphics/font.h"
#include "drivers/graphics/framebuffer.h"
#include "boot/boot_info.h"
typedef enum {
GRAPHICS_BUFFER_STANDARD,
GRAPHICS_BUFFER_OVERLAY,
GRAPHICS_BUFFER_ENUM_MAX
} graphics_buffer_layer_E;
typedef struct graphics_buffer_T graphics_buffer_T;
struct graphics_buffer_T {
color_argb_T* buffer;
uint32_t width;
uint32_t height;
uint32_t pos_x;
uint32_t pos_y;
bool blocked;
bool render;
graphics_buffer_layer_E layer;
graphics_buffer_T* prev;
graphics_buffer_T* next;
};
typedef struct {
framebuffer_T framebuffer;
uint32_t* back_buffer;
uint64_t buffer_size;
graphics_buffer_T** graphics_buffer_layers;
font_T font;
bool initialized;
bool blocked;
} graphics_renderer_T;
graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer);
void graphics_buffer_show (graphics_buffer_T* graphics_buffer);
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer);
void graphics_buffer_destruct (graphics_buffer_T* graphics_buffer);
void graphics_buffer_shift_up (graphics_buffer_T* graphics_buffer, uint16_t shift);
void graphics_buffer_set_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color);
color_argb_T graphics_buffer_get_pixel (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y);
void graphics_buffer_draw_char (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, char chr);
position_T graphics_buffer_draw_string (graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, string_t string);
void graphics_renderer_init (boot_info_T* boot_info);
void graphics_renderer_update ();
graphics_buffer_T* graphics_renderer_get_top_buffer (graphics_buffer_layer_E layer);
uint32_t graphics_renderer_get_width ();
uint32_t graphics_renderer_get_height ();
#endif //NOX_RENDERER_H

View File

@ -33,9 +33,28 @@
#define FLOOR_TO(a, b) ((a) - ((a) % (b)))
typedef struct {
uint64_t x;
uint64_t y;
} position_T;
} math_vector_2i_T;
typedef struct {
uint64_t x;
uint64_t y;
uint64_t z;
} math_vector_3i_T;
typedef struct {
uint64_t x;
uint64_t y;
uint64_t z;
uint64_t w;
} math_vector_4i_T;
uint64_t pow (uint64_t base, uint64_t exp);
uint64_t abs (int64_t n);

View File

@ -0,0 +1,2 @@
// TODO

View File

@ -0,0 +1,2 @@
// TODO

View File

@ -0,0 +1,52 @@
#include <drivers/gfx/graphics_driver.h>
pixelbuffer_T * create_root_pixelbuffer(graphics_driver_T *driver, framebuffer_T *framebuffer) {
pixelbuffer_T *pixelbuffer = memory_allocate(sizeof(pixelbuffer_T));
pixelbuffer->parent = NULL;
pixelbuffer->root_pixelbuffer = NULL;
pixelbuffer->relative_start_x = 0;
pixelbuffer->relative_start_y = 0;
pixelbuffer->absolute_start_x = 0;
pixelbuffer->absolute_start_y = 0;
pixelbuffer->pixel_width = framebuffer->pixel_width;
pixelbuffer->pixel_height = framebuffer->pixel_height;
pixelbuffer->pixel_stride = framebuffer->pixel_stride;
pixelbuffer->memory_mapping = framebuffer->memory_mapping;
return pixelbuffer;
}
framebuffer_T convert_limine_framebuffer_to_noxos_framebuffer(graphics_driver_T *driver, struct limine_framebuffer *limine_framebuffer) {
framebuffer_T noxos_framebuffer;
noxos_framebuffer.pixel_width = limine_framebuffer->width;
noxos_framebuffer.pixel_height = limine_framebuffer->height;
noxos_framebuffer.pixel_stride = limine_framebuffer->bpp / 8; // TODO: Check: Is this right?
noxos_framebuffer.memory_mapping = limine_framebuffer->address;
noxos_framebuffer.root_pixelbuffer = create_root_pixelbuffer(driver, &noxos_framebuffer);
return noxos_framebuffer;
}
graphics_driver_T * create_graphics_driver_from_boot_info(boot_info_T *boot_info) {
graphics_driver_T *driver = memory_allocate(sizeof(graphics_driver_T));
driver->num_framebuffers = boot_info->framebuffer->framebuffer_count;
driver->framebuffers = memory_allocate(sizeof(framebuffer_T) * driver->num_framebuffers);
uint32_t framebuffer_index = 0;
while(framebuffer_index > boot_info->framebuffer->framebuffer_count)
{
driver->framebuffers[framebuffer_index] = convert_limine_framebuffer_to_noxos_framebuffer(
driver, &boot_info->framebuffer->framebuffers[framebuffer_index]);
++framebuffer_index;
}
return driver;
}
void delete_graphics_driver(graphics_driver_T *driver) {
// TODO
}

View File

@ -0,0 +1,44 @@
#include <drivers/gfx/pixelbuffer.h>
pixelbuffer_T * find_root_pixelbuffer(pixelbuffer_T *current) {
if(current->parent == NULL) return current;
return find_root_pixelbuffer(current->parent);
}
pixelbuffer_T * create_pixelbuffer(pixelbuffer_T *parent) {
pixelbuffer_T *pixelbuffer = memory_allocate(sizeof(pixelbuffer_T));
pixelbuffer->parent = parent;
pixelbuffer->root_pixelbuffer = find_root_pixelbuffer(parent);
pixelbuffer->memory_mapping = parent->memory_mapping;
pixelbuffer->absolute_start_x = parent->absolute_start_x;
pixelbuffer->absolute_start_y = parent->absolute_start_y;
pixelbuffer->relative_start_x = 0;
pixelbuffer->relative_start_y = 0;
pixelbuffer->pixel_width = 1;
pixelbuffer->pixel_height = 1;
pixelbuffer->pixel_stride = pixelbuffer->root_pixelbuffer->pixel_stride;
return pixelbuffer;
}
void delete_pixelbuffer(pixelbuffer_T *pixelbuffer) {
// TODO
}
void graphics_set_pixel(pixelbuffer_T *pixelbuffer,
uint32_t relative_x, uint32_t relative_y, pixel_T pixel)
{
// TODO: Check if these values are inside the pixelbuffers' range!
uint8_t *output_address = pixelbuffer->memory_mapping
+ ((relative_y * pixelbuffer->pixel_width + relative_x) + pixelbuffer->pixel_stride);
output_address[0] = pixel.red;
output_address[1] = pixel.green;
output_address[2] = pixel.blue;
}

View File

@ -0,0 +1,2 @@
// TODO

View File

@ -1,45 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "drivers/graphics/color.h"
color_argb_T g_color_palette[COLOR_PAL_ENUM_END] = {
{0xFF, 0x36, 0x36, 0x36}, // GREY_DARK
{0xFF, 0xFF, 0x08, 0x83}, // PINK
{0xFF, 0x83, 0xff, 0x08}, // GREEN_SIGNAL
{0xFF, 0xFF, 0x83, 0x08}, // ORANGE
{0xFF, 0x08, 0x83, 0xFF}, // BLUE
{0xFF, 0x83, 0x08, 0xFF}, // PURPLE
{0xFF, 0x08, 0xFF, 0x83}, // GREEN
{0xFF, 0xB6, 0xB6, 0xB6}, // GREY_LIGHT
{0xFF, 0xFF, 0x00, 0x00}, // RED
};
color_argb_T color_argb_blend_alpha(color_argb_T background, color_argb_T foreground) {
color_argb_T color;
color.red = ((foreground.red * foreground.alpha) + (background.red * (0xFF - foreground.alpha))) / 0xFF;
color.green = ((foreground.green * foreground.alpha) + (background.green * (0xFF - foreground.alpha))) / 0xFF;
color.blue = ((foreground.blue * foreground.alpha) + (background.blue * (0xFF - foreground.alpha))) / 0xFF;
return color;
}

View File

@ -1,184 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
// Font copyright header:
/**
* 8x8 monochrome bitmap fonts for rendering
* Author: Daniel Hepper <daniel@hepper.net>
*
* License: Public Domain
*
* Based on:
* // Summary: font8x8.h
* // 8x8 monochrome bitmap fonts for rendering
* //
* // Author:
* // Marcel Sondaar
* // International Business Machines (public domain VGA fonts)
* //
* // License:
* // Public Domain
*
* Fetched from: http://dimensionalrift.homelinux.net/combuster/mos3/?p=viewsource&file=/modules/gfx/font8_8.asm
**/
#include "drivers/graphics/font.h"
uint8_t font8x8_basic[128][8] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0003
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0004
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0005
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0006
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0007
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0008
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0009
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+000F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0010
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0011
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0012
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0013
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0014
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0015
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0016
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0017
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0018
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0019
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001A
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001B
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001C
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001D
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001E
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+001F
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space)
{ 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!)
{ 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (")
{ 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#)
{ 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($)
{ 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%)
{ 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&)
{ 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (')
{ 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (()
{ 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ())
{ 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*)
{ 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,)
{ 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.)
{ 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/)
{ 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0)
{ 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1)
{ 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2)
{ 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3)
{ 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4)
{ 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5)
{ 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6)
{ 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7)
{ 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8)
{ 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:)
{ 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;)
{ 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<)
{ 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=)
{ 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>)
{ 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?)
{ 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@)
{ 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A)
{ 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B)
{ 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C)
{ 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E)
{ 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F)
{ 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G)
{ 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H)
{ 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I)
{ 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J)
{ 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K)
{ 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L)
{ 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M)
{ 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N)
{ 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O)
{ 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P)
{ 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q)
{ 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R)
{ 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S)
{ 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U)
{ 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V)
{ 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W)
{ 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X)
{ 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y)
{ 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z)
{ 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([)
{ 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\)
{ 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (])
{ 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_)
{ 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`)
{ 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a)
{ 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b)
{ 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c)
{ 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d)
{ 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e)
{ 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g)
{ 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h)
{ 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i)
{ 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j)
{ 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k)
{ 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l)
{ 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m)
{ 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n)
{ 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o)
{ 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p)
{ 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q)
{ 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r)
{ 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s)
{ 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v)
{ 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w)
{ 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x)
{ 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y)
{ 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z)
{ 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({)
{ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|)
{ 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (})
{ 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // U+007F
};
font_T g_font = {
8,
8,
8,
(uint8_t*)font8x8_basic
};

View File

@ -1,250 +0,0 @@
/*
* Copyright 2023 Antifallobst <antifallobst@systemausfall.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the Software), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "drivers/graphics/renderer.h"
#include "utils/memory.h"
#include "utils/core.h"
graphics_renderer_T g_renderer;
graphics_buffer_T* graphics_buffer_request(uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer) {
graphics_buffer_T* graphics_buffer = memory_allocate(sizeof(graphics_buffer_T));
graphics_buffer->pos_x = pos_x;
graphics_buffer->pos_y = pos_y;
graphics_buffer->width = width;
graphics_buffer->height = height;
graphics_buffer->blocked = false;
graphics_buffer->render = true;
graphics_buffer->layer = layer;
graphics_buffer->buffer = memory_allocate(width * height * sizeof(color_argb_T));
memory_set(graphics_buffer->buffer, 0, width * height * sizeof(color_argb_T));
graphics_buffer_T* top_buffer = graphics_renderer_get_top_buffer(layer);
graphics_buffer->prev = top_buffer;
graphics_buffer->next = NULL;
if (top_buffer == NULL) {
g_renderer.graphics_buffer_layers[layer] = graphics_buffer;
} else {
top_buffer->next = graphics_buffer;
}
return graphics_buffer;
}
void graphics_buffer_show (graphics_buffer_T* graphics_buffer) {
graphics_buffer->render = true;
}
void graphics_buffer_hide (graphics_buffer_T* graphics_buffer) {
graphics_buffer->render = false;
}
void graphics_buffer_destruct(graphics_buffer_T* graphics_buffer) {
if (graphics_buffer->prev != NULL) {
graphics_buffer->prev->next = graphics_buffer->next;
} else {
g_renderer.graphics_buffer_layers[graphics_buffer->layer] = graphics_buffer->next;
}
if (graphics_buffer->next != NULL) {
graphics_buffer->next->prev = graphics_buffer->prev;
}
memory_free(graphics_buffer->buffer);
memory_free(graphics_buffer);
}
void graphics_buffer_shift_up(graphics_buffer_T* graphics_buffer, uint16_t shift) {
memory_copy(&graphics_buffer->buffer[graphics_buffer->width * shift],
graphics_buffer->buffer,
graphics_buffer->width * (graphics_buffer->height - shift) * sizeof(color_argb_T));
memory_set(&graphics_buffer->buffer[graphics_buffer->width * (graphics_buffer->height - shift)],
0,
graphics_buffer->width * shift * sizeof(color_argb_T));
}
void graphics_buffer_set_pixel(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color) {
graphics_buffer->buffer[y * graphics_buffer->width + x] = color;
}
color_argb_T graphics_buffer_get_pixel(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y) {
return graphics_buffer->buffer[y * graphics_buffer->width + x];
}
// this function is not thread safe, consider using `graphics_buffer_draw_string` instead
void graphics_buffer_draw_char(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, char chr) {
uint8_t* glyph = &g_renderer.font.buffer[g_renderer.font.glyph_size * chr];
for (int y_pos = 0; y_pos < g_renderer.font.height; y_pos++){
for (int x_pos = 0; x_pos < g_renderer.font.width; x_pos++){
if (*glyph & (1 << x_pos)) {
graphics_buffer_set_pixel(graphics_buffer, x + x_pos, y + y_pos, color);
} else {
graphics_buffer_set_pixel(graphics_buffer, x + x_pos, y + y_pos, (color_argb_T){0x00, 0x00, 0x00, 0x00});
}
}
glyph++;
}
}
position_T graphics_buffer_draw_string(graphics_buffer_T* graphics_buffer, uint32_t x, uint32_t y, color_argb_T color, string_t string) {
CORE_INTERRUPTABLE_HALT_WHILE(graphics_buffer->blocked)
graphics_buffer->blocked = true;
position_T pos = (position_T){x, y};
uint64_t strlen = string_length(string);
for (int i = 0; i < strlen; i++) {
switch (string[i]) {
case '\n': {
pos.x = 0;
pos.y += g_renderer.font.height;
break;
}
case '\r': {
pos.x = 0;
break;
}
default: {
if (pos.x + g_renderer.font.width >= graphics_buffer->width) {
pos.x = 0;
pos.y += g_renderer.font.height;
}
if (pos.y + g_renderer.font.height >= graphics_buffer->height) {
pos.y -= g_renderer.font.height;
graphics_buffer_shift_up(graphics_buffer, g_renderer.font.height);
}
graphics_buffer_draw_char(graphics_buffer, pos.x, pos.y, color, string[i]);
pos.x += g_renderer.font.width;
break;
}
}
}
graphics_buffer->blocked = false;
return pos;
}
void graphics_renderer_init(boot_info_T* boot_info_T) {
struct limine_framebuffer* framebuffer = boot_info_T->framebuffer->framebuffers[0];
g_renderer.framebuffer.address = framebuffer->address;
g_renderer.framebuffer.width = framebuffer->width;
g_renderer.framebuffer.height = framebuffer->height;
g_renderer.framebuffer.pitch = framebuffer->pitch;
g_renderer.framebuffer.bits_per_pixel = framebuffer->bpp;
g_renderer.framebuffer.bytes_per_pixel = CEIL_TO(framebuffer->bpp, 8) / 8;
g_renderer.framebuffer.shift_red = framebuffer->red_mask_shift;
g_renderer.framebuffer.shift_green = framebuffer->green_mask_shift;
g_renderer.framebuffer.shift_blue = framebuffer->blue_mask_shift;
g_renderer.buffer_size = g_renderer.framebuffer.width * g_renderer.framebuffer.height * g_renderer.framebuffer.bytes_per_pixel;
g_renderer.back_buffer = memory_allocate(g_renderer.buffer_size);
g_renderer.graphics_buffer_layers = memory_allocate(GRAPHICS_BUFFER_ENUM_MAX * sizeof(graphics_buffer_T*));
g_renderer.font = g_font;
g_renderer.blocked = false;
memory_set(g_renderer.graphics_buffer_layers, 0, GRAPHICS_BUFFER_ENUM_MAX * sizeof(graphics_buffer_T*));
memory_set(g_renderer.back_buffer, 0, g_renderer.buffer_size);
g_renderer.initialized = true;
}
bool graphics_renderer_is_initialized() {
return g_renderer.initialized;
}
void graphics_renderer_update_graphics_buffer(graphics_buffer_T* graphics_buffer) {
if (!graphics_buffer->render) { return; }
uint32_t size_x = MIN(graphics_buffer->pos_x + graphics_buffer->width, g_renderer.framebuffer.width);
uint32_t size_y = MIN(graphics_buffer->pos_y + graphics_buffer->height, g_renderer.framebuffer.height);
for (uint32_t y = graphics_buffer->pos_y; y < size_y; y++) {
for (uint32_t x = graphics_buffer->pos_x; x < size_x; x++) {
color_argb_T color = graphics_buffer->buffer[(y - graphics_buffer->pos_y) * graphics_buffer->width + (x - graphics_buffer->pos_x)];
color_argb_T original;
original.alpha = 0xFF;
original.red = (g_renderer.back_buffer[y * g_renderer.framebuffer.width + x] >> g_renderer.framebuffer.shift_red) & 0xFF;
original.green = (g_renderer.back_buffer[y * g_renderer.framebuffer.width + x] >> g_renderer.framebuffer.shift_green) & 0xFF;
original.blue = (g_renderer.back_buffer[y * g_renderer.framebuffer.width + x] >> g_renderer.framebuffer.shift_blue) & 0xFF;
// apply transparency
color = color_argb_blend_alpha(original, color);
// write into back_buffer
g_renderer.back_buffer[y * g_renderer.framebuffer.width + x] = (color.red << g_renderer.framebuffer.shift_red) |
(color.green << g_renderer.framebuffer.shift_green) |
(color.blue << g_renderer.framebuffer.shift_blue);
}
}
}
void graphics_renderer_update() {
CORE_INTERRUPTABLE_HALT_WHILE(g_renderer.blocked)
g_renderer.blocked = true;
memory_set(g_renderer.back_buffer, 0, g_renderer.buffer_size);
graphics_buffer_T* graphics_buffer = g_renderer.graphics_buffer_layers[GRAPHICS_BUFFER_STANDARD];
while (graphics_buffer != NULL) {
graphics_renderer_update_graphics_buffer(graphics_buffer);
graphics_buffer = graphics_buffer->next;
}
graphics_buffer = g_renderer.graphics_buffer_layers[GRAPHICS_BUFFER_OVERLAY];
while (graphics_buffer != NULL) {
graphics_renderer_update_graphics_buffer(graphics_buffer);
graphics_buffer = graphics_buffer->next;
}
// swap back_buffer into framebuffer
memory_copy(g_renderer.back_buffer, g_renderer.framebuffer.address, g_renderer.buffer_size);
g_renderer.blocked = false;
}
graphics_buffer_T* graphics_renderer_get_top_buffer(graphics_buffer_layer_E layer) {
if (g_renderer.graphics_buffer_layers[layer] == NULL) {
return NULL;
}
graphics_buffer_T* graphics_buffer = g_renderer.graphics_buffer_layers[layer];
while (graphics_buffer->next != NULL) {
graphics_buffer = graphics_buffer->next;
}
return graphics_buffer;
}
uint32_t graphics_renderer_get_width() {
return g_renderer.framebuffer.width;
}
uint32_t graphics_renderer_get_height() {
return g_renderer.framebuffer.height;
}

View File

@ -26,12 +26,13 @@
#include "utils/core.h"
#include "drivers/graphics/renderer.h"
// TODO: Range-check the usage of this, otherwise could crash.
string_t g_log_prefixes[LOG_ENUM_END] = {
"", // LOG_NONE
"[ Info ] ",
"[ Debug ] ",
"[ Warning ] ",
"[ Error ] ",
"# ",
"? ",
"! ",
"!!! ",
};
color_palette_E g_log_colors[LOG_ENUM_END] = {