first draft version of the mini engine

This commit is contained in:
2026-10-04 20:19:09 +02:00
parent 61d67adf5d
commit 725fa9a16a
10 changed files with 2486 additions and 153 deletions
+78
View File
@@ -0,0 +1,78 @@
#pragma once
#include <SDL3/SDL.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#define WINDOW_WIDTH 1280
#define WINDOW_HEIGHT 720
#define DEFAULT_WINDOW_NAME "SDL Playground"
#define WINDOW_NAME_LENGTH 128
#define TARGET_FRAME 1.0 / 60.0
typedef struct {
char window_name[WINDOW_NAME_LENGTH];
uint16_t width, height;
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *texture;
} engine_sdl_state_t;
typedef struct {
/**
* this function runs inside of the SDL_PollEvent loop
* useful for user input, quitting the program and so on
*/
void (*engine_poll_events)(void);
/**
* meant as the "area" for manupulating the framebuffer;
* after this is executed, the contents of
* game_state->framebuffer get drawn
*/
void (*engine_update_framebuffer)(void);
engine_sdl_state_t *sdl_state;
} engine_internal_state_t;
typedef struct {
uint32_t framebuffer[WINDOW_WIDTH * WINDOW_HEIGHT];
SDL_Event event;
bool is_running;
uint16_t width, height;
} game_state_t;
extern engine_internal_state_t *internal_state;
extern game_state_t *game_state;
engine_sdl_state_t*
engine_sdl_init();
void
engine_sdl_destroy(
engine_sdl_state_t *state
);
bool
engine_init(
void (*engine_poll_events)(void),
void (*engine_update_framebuffer)(void)
);
void
engine_start();
void
engine_stop();
void
put_pixel(
unsigned int x,
unsigned int y,
uint32_t color
);
void
clear_framebuffer(
uint32_t color
);