me.fier.engine/src/engine.c

38 lines
1.0 KiB
C
Raw Normal View History

2023-06-12 14:05:07 +00:00
// MEMORY
void * engine_memory_alloc(void * pnt,size_t size) {
2023-05-14 10:21:03 +00:00
void * mem = realloc(pnt,size);
if (mem == NULL) {
printf("ERROR: Could not allocate memory.\n");
exit(1);
}
return mem;
}
2023-06-12 14:05:07 +00:00
void engine_memory_free(void * pnt) {
2023-05-14 10:21:03 +00:00
free(pnt);
}
2023-05-15 13:28:58 +00:00
2023-06-12 14:05:07 +00:00
// TEXTURES
struct ENGINE_TEXTURE { int width; int height; struct ENGINE_FRONTEND_TEXTURE * fe_texture; };
// COLOR
struct ENGINE_COLOR { char r; char g; char b; char a; };
// WINDOWS
struct ENGINE_WINDOW { struct ENGINE_TEXTURE * texture; struct ENGINE_FRONTEND_WINDOW * fe_window; };
// EVENTS
struct ENGINE_EVENT { char type; void * data; };
static char ENGINE_EVENT_TYPE_UNKNOWN = 0;
struct ENGINE_EVENT_UNKNOWN { };
static char ENGINE_EVENT_TYPE_NONE = 1;
struct ENGINE_EVENT_NONE { };
static char ENGINE_EVENT_TYPE_EXIT = 2;
struct ENGINE_EVENT_EXIT { };
static char ENGINE_EVENT_TYPE_INPUT_KB = 3;
struct ENGINE_EVENT_INPUT_KB { char key; char pressed; };
2023-05-15 13:28:58 +00:00
void engine_event_free(struct ENGINE_EVENT * event) {
2023-06-12 14:05:07 +00:00
engine_memory_free(event->data);
engine_memory_free(event);
}