noxos (docs): merged 'drivers/graphics' docs from .wiki
This commit is contained in:
parent
e9a4e07c50
commit
d560627b2d
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: "graphics"
|
||||
summary: "a small rendering infrastructure"
|
||||
---
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: "graphics"
|
||||
---
|
||||
|
||||
The graphics renderer is just for the development time.
|
||||
As soon as the kernel supports modules, the renderer will be a module, or even an userspace program.
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
title: "color.h"
|
||||
summary: "provides basic color definitions and operations"
|
||||
---
|
||||
|
||||
# `color_palette_E` - enum
|
||||
Indexes for [g_color_palette](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/color.h/#g_color_palette---global-variable). The color palette was designed by [gogh](https://gogh-co.github.io/Gogh/).
|
||||
- **Grey Dark**
|
||||
- **Pink**
|
||||
- **Signal Green**
|
||||
- **Orange**
|
||||
- **Blue**
|
||||
- **Purple**
|
||||
- **Green**
|
||||
- **Grey Light**
|
||||
- **Red**
|
||||
|
||||
# `color_argb_T` - struct
|
||||
| Name | Type | Description |
|
||||
|-------|---------|---------------------------------|
|
||||
| alpha | uint8_t | Transparency value of the color |
|
||||
| red | uint8_t | Red value of the color |
|
||||
| green | uint8_t | Green value of the color |
|
||||
| blue | uint8_t | Blue value of the color |
|
||||
|
||||
# `color_argb_blend_alpha(background, foreground)` - function (color_argb_T)
|
||||
Blends **_background_** and **_foreground_** with the _alpha_ value of **_foreground_**.
|
||||
|
||||
# `g_color_palette` - global variable
|
||||
An array of standard colors.
|
||||
This array is indexed using [color_palette_E](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/color.h/#color_palette_e---enum).
|
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: "font.h"
|
||||
summary: "basic bitmap font definitions"
|
||||
---
|
||||
|
||||
# `font_T` - struct
|
||||
|
||||
| Name | Type | Description |
|
||||
|------------|----------|------------------------------------------------|
|
||||
| width | uint8_t | The width of each char (in pixels) |
|
||||
| height | uint8_t | The height of each char (in pixels) |
|
||||
| glyph_size | uint8_t | The amount of bytes a char takes in the buffer |
|
||||
| buffer | uint8_t* | The buffer, where the char bitmaps lay |
|
||||
|
||||
# `g_font` - global variable
|
||||
A globally usable 8x8 font.
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
title: "framebuffer.h"
|
||||
summary: "framebuffer definitions"
|
||||
---
|
||||
|
||||
#### `framebuffer_T` - struct
|
||||
|
||||
| Name | Type | Description |
|
||||
|-----------------|----------|-----------------------------------------------------|
|
||||
| address | void* | The address of the framebuffer |
|
||||
| width | uint64_t | The pixel width of the framebuffer |
|
||||
| height | uint64_t | The pixel height of the framebuffer |
|
||||
| pitch | uint64_t | The number of bytes in each row |
|
||||
| bits_per_pixel | uint16_t | The amount of bits a pixel consumes in the buffer |
|
||||
| bytes_per_pixel | uint8_t | The amount of bytes a pixel consumes in the buffer |
|
||||
| shift_red | uint8_t | How many bits the red value is shifted in a pixel |
|
||||
| shift_green | uint8_t | How many bits the green value is shifted in a pixel |
|
||||
| shift_blue | uint8_t | How many bits the blue value is shifted in a pixel |
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
---
|
||||
title: "renderer.h"
|
||||
summary: "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](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/color.h/#color_argb_t---struct)* | 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](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/renderer.h/#graphics_buffer_layer_e---enum) | The layer, on which the buffer will be rendered |
|
||||
| prev | [graphics_buffer_T](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/renderer.h/#graphics_buffer_t---struct)* | The previous buffer in the rendering queue |
|
||||
| next | [graphics_buffer_T](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/renderer.h/#graphics_buffer_t---struct)* | The next buffer in the rendering queue |
|
||||
|
||||
#### `graphics_renderer_T` - struct
|
||||
|
||||
| Name | Type | Description |
|
||||
|------------------------|----------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| framebuffer | [framebuffer_T](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/framebuffer.h/#framebuffer_t---struct) | 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](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/renderer.h/#graphics_buffer_t---struct)** | List of pointers to the first [graphics_buffer_T](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/renderer.h/#graphics_buffer_t---struct) of every layer |
|
||||
| font | [font_T](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/font.h/#font_t---struct) | 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](https://nerdcult.net/projects/noxos/docs/codebase/drivers/graphics/renderer.h/#graphics_renderer_update---function-void) |
|
||||
|
||||
|
||||
#### `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.
|
Reference in New Issue