aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.h
blob: 16dc8a5224421826d8ca36a4b6848aac963d3bb2 (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
38
39
40
#ifndef MIC_APP_H
#define MIC_APP_H

#include <GL/glew.h>
#include <GLFW/glfw3.h>

#include "shorthand.h"
#include "platform.h"

typedef struct AppState {
    // OpenGL
    GLFWwindow *window;
    f32 vertices[12];
    u32 VBO;
    u32 VAO;
    u32 shader_program;
} 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