blob: 8edbe582ce34dedfa537e6bde5bb852ed5a9fd79 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#ifndef MIC_APP_H
#define MIC_APP_H
#include "shorthand.h"
#include "platform.h"
#define LT_MEMORY_SIZE GB(2)
#define ST_MEMORY_SIZE MB(100)
typedef struct AppState {
// Long and short term memory.
char *lt_memory;
char *st_memory;
} AppState;
// Function pointers for the AppAPI.
typedef struct AppAPI {
// Initialization code. Meant to be called exactly once before other API
// interactions. Returns the success or failure of the initialization
// process.
bool (*init)(AppState *state, PlatformAPI platform);
// Resource deallocation and cleanup. Meant to be called exactly once at the
// end of the app.
void (*destroy)(AppState *state, PlatformAPI platform);
// In case of hot code reloading, these functions handle the necessary
// resource setup and reloading.
void (*reload)(AppState *state, PlatformAPI platform);
void (*unload)(AppState *state, PlatformAPI platform);
// Main update/step function for the app. Returns if the app should keep
// running.
bool (*step)(AppState *state, PlatformAPI platform);
} AppAPI;
#endif // MIC_APP_H
|