Add Framebuffer object
This commit is contained in:
parent
15559b0a56
commit
c3ead56582
56
src/hulk/framebuffer.d
Normal file
56
src/hulk/framebuffer.d
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* HULK Framebuffer support.
|
||||
*/
|
||||
module hulk.framebuffer;
|
||||
|
||||
import hos.memory;
|
||||
|
||||
/**
|
||||
* Represent a graphical frame buffer.
|
||||
*
|
||||
* TODO: Handle other pixel formats. Currently only ARGB is supported.
|
||||
*/
|
||||
struct Framebuffer
|
||||
{
|
||||
/** Frame buffer base address. */
|
||||
private uint * m_buffer;
|
||||
|
||||
/** Frame buffer width. */
|
||||
private uint m_width;
|
||||
|
||||
/** Frame buffer height. */
|
||||
private uint m_height;
|
||||
|
||||
/** Frame buffer stride. */
|
||||
private uint m_stride;
|
||||
|
||||
/** Number of pixels in the frame buffer (whether visible or not). */
|
||||
private uint m_buffer_size;
|
||||
|
||||
/**
|
||||
* Initialize a frame buffer.
|
||||
*
|
||||
* @param buffer Frame buffer base address.
|
||||
* @param width Frame buffer width.
|
||||
* @param height Frame buffer height.
|
||||
* @param stride Frame buffer stride.
|
||||
*/
|
||||
void initialize(uint * buffer, uint width, uint height, uint stride)
|
||||
{
|
||||
m_buffer = buffer;
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_stride = stride;
|
||||
m_buffer_size = stride * height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the frame buffer to the given color.
|
||||
*
|
||||
* @param color Color to clear to.
|
||||
*/
|
||||
void clear(uint color = 0u)
|
||||
{
|
||||
memset32(m_buffer, color, m_buffer_size);
|
||||
}
|
||||
}
|
@ -5,9 +5,12 @@ module hulk.hulk;
|
||||
|
||||
import hulk.header;
|
||||
import hulk.bootinfo;
|
||||
import hulk.framebuffer;
|
||||
import hos.memory;
|
||||
import ldc.attributes;
|
||||
|
||||
private __gshared Framebuffer fb;
|
||||
|
||||
extern extern(C) __gshared ubyte _hulk_total_size;
|
||||
|
||||
@(ldc.attributes.section(".hulk_header"))
|
||||
@ -23,9 +26,12 @@ private __gshared Header hulk_header = {
|
||||
*/
|
||||
extern(C) void hulk_start(ulong rdi, ulong rsi, ulong rdx, BootInfo * bootinfo)
|
||||
{
|
||||
fb.initialize(bootinfo.fb.buffer, bootinfo.fb.width, bootinfo.fb.height, bootinfo.fb.stride);
|
||||
fb.clear(0xFF8800u);
|
||||
|
||||
for (size_t y = 100u; y < 120u; y++)
|
||||
{
|
||||
memset32(&bootinfo.fb.buffer[y * bootinfo.fb.stride + 20u], 0xFF8800u, 20u);
|
||||
memset32(&bootinfo.fb.buffer[y * bootinfo.fb.stride + 20u], 0x001199u, 20u);
|
||||
}
|
||||
|
||||
for (;;)
|
||||
|
Loading…
x
Reference in New Issue
Block a user