refactor file structure
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
SDL_Event event;
|
||||
bool is_running;
|
||||
bool framebuffer_dirty;
|
||||
SDL_Rect dirty_rect;
|
||||
uint16_t width, height;
|
||||
uint32_t *framebuffer;
|
||||
} game_state_t;
|
||||
|
||||
extern game_state_t *game_state;
|
||||
|
||||
bool
|
||||
engine_init(
|
||||
uint32_t window_width,
|
||||
uint32_t window_height,
|
||||
const char window_name[],
|
||||
void (*engine_poll_events)(void),
|
||||
void (*engine_update_framebuffer)(void)
|
||||
);
|
||||
|
||||
void
|
||||
engine_start();
|
||||
|
||||
void
|
||||
engine_stop();
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void
|
||||
put_pixel(
|
||||
unsigned int x,
|
||||
unsigned int y,
|
||||
uint32_t color
|
||||
);
|
||||
|
||||
void
|
||||
clear_framebuffer(
|
||||
uint32_t color
|
||||
);
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void
|
||||
put_rect(
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t w,
|
||||
uint32_t h,
|
||||
uint32_t color
|
||||
);
|
||||
|
||||
void
|
||||
clear_rect(int x, int y, int w, int h, uint32_t color);
|
||||
|
||||
void
|
||||
mark_dirty_rect(int x, int y, int w, int h);
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void
|
||||
put_char(
|
||||
char c,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t size,
|
||||
uint32_t fg_color,
|
||||
uint32_t bg_color
|
||||
);
|
||||
|
||||
void
|
||||
put_string(
|
||||
const char *text,
|
||||
uint32_t x,
|
||||
uint32_t y,
|
||||
uint32_t size,
|
||||
uint32_t spacing,
|
||||
uint32_t line_spacing,
|
||||
uint32_t fg_color,
|
||||
uint32_t bg_color
|
||||
);
|
||||
Reference in New Issue
Block a user