8.8 KiB
title | summary |
---|---|
renderer.h | the renderer is maybe a bit over-engineered and slow |
The renderer has a stack of buffers, which act like canvases. You can create, move, hide and show buffers.
graphics_buffer_layer_E
- enum
- Standard - The layer, where almost everything should be on
- Overlay - This layer should be used for stuff like a mouse cursor, that should always be visible
graphics_buffer_T
- struct
Name | Type | Description |
---|---|---|
buffer | color_argb_T* | The buffer, where all the pixels are stored |
width | uint32_t | The width of the buffer |
height | uint32_t | The height of the buffer |
pos_x | uint32_t | The buffers x offset (from the top-left corner) in the renderers main buffer |
pos_y | uint32_t | The buffers y offset (from the top-left corner) in the renderers main buffer |
blocked | bool | Thread safety block variable |
render | bool | Controls, if the buffer will be rendered or not |
layer | graphics_buffer_layer_E | The layer, on which the buffer will be rendered |
prev | graphics_buffer_T* | The previous buffer in the rendering queue |
next | graphics_buffer_T* | The next buffer in the rendering queue |
graphics_renderer_T
- struct
Name | Type | Description |
---|---|---|
framebuffer | framebuffer_T | The systems framebuffer (requested from bootloader) |
back_buffer | uint32_t* | The buffer, where the final image is calculated, before sending it to the framebuffer |
buffer_size | uint64_t | The size of back_buffer (in bytes) |
graphics_buffer_layers | graphics_buffer_T** | List of pointers to the first graphics_buffer_T of every layer |
font | font_T | The font, all graphics buffers use to draw chars (could be moved to graphics_buffer_T ) |
initialized | bool | Indicates whether the renderer is initialized or not |
blocked | bool | Blocking variable that is used for thread safety in graphics_renderer_update |
graphics_buffer_request(pos_x, pos_y, width, height, layer)
- function (graphics_buffer_T*)
Allocates a graphics buffer and pushes it on top of the rendering queue of layer.
graphics_buffer_show(graphics_buffer)
- function (void)
Enables rendering for this buffer. Every created buffer will be rendered by default.
graphics_buffer_hide(graphics_buffer)
- function (void)
Disables rendering for this buffer.
graphics_buffer_destruct(graphics_buffer)
- function (void)
Removes graphics_buffer from the rendering queue and frees its memory allocations.
graphics_buffer_shift_up(graphics_buffer, shift)
- function (void)
Shifts graphics_buffer's content shift rows up.
graphics_buffer_set_pixel(graphics_buffer, x, y, color)
- function (void)
Sets a pixel with the given color at position(x | y) in graphics_buffer. x and y are graphics buffer relative.
graphics_buffer_get_pixel(graphics_buffer, x, y)
- function (color_argb_T)
Returns the color of the pixel at position(x | y) in graphics_buffer.
graphics_buffer_draw_char(graphics_buffer, x, y, color, chr)
- function (void)
Draws a character (chr) at position(x | y) in graphics_buffer. The position is the top-left corner of the char.
graphics_buffer_draw_string(graphics_buffer, x, y, color, string)
- function (position_T)
Draws string at position(x | y) in graphics_buffer. The position is the top-left corner of the string. Returns the position after the last char of the string.
graphics_renderer_init(boot_info)
- function (void)
Initializes the global graphics renderer.
Needs a pointer to boot_info
to extract information about the framebuffer.
graphics_renderer_update()
- function (void)
Updates the renderers back_buffer and swaps it into the framebuffer. To update the back_buffer, it iterates over the rendering queue and copies every buffer to the back_buffer. If there are overlapping graphics_buffers, it alpha-blends them.
graphics_renderer_get_top_buffer(layer)
- function (graphics_buffer_T*)
Returns a pointer to the graphics_buffer, that is on top of the rendering queue of layer.
graphics_renderer_get_width()
- function (uint32_t)
Returns the width of the framebuffer.
graphics_renderer_get_height()
- function (uint32_t)
Returns the height of the framebuffer.