This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathext_interface.h
91 lines (78 loc) · 1.82 KB
/
ext_interface.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef EXT_INTERFACE_H
#define EXT_INTERFACE_H
#include "ext_lib.h"
#include "ext_cursor.h"
#include "ext_input.h"
#include "ext_matrix.h"
#include "ext_view.h"
#include "ext_theme.h"
#include "ext_collision.h"
extern f32 gPixelRatio;
extern f32 gPixelScale;
extern void (*gUiInitFunc)();
extern void (*gUiNanoFunc)(void*);
extern void (*gUiDestFunc)();
typedef enum {
WIN_MAXIMIZE,
WIN_MINIMIZE,
} WindowParam;
typedef void (*WindowFunction)(void*);
typedef void (*DropCallback)(GLFWwindow*, s32, char* item[]);
typedef enum {
APP_RESIZE_CALLBACK = 1 << 0,
APP_CLOSED = 1 << 3,
} WindowState;
typedef struct Window {
char title[64];
GLFWwindow* glfw;
WindowFunction updateCall;
WindowFunction drawCall;
Input* input;
void* context;
void* vg;
Vec2s dim;
Vec2s bufDim;
Vec2s prevDim;
WindowState state;
bool tick;
struct {
f32 tickMod;
} private;
} Window;
GLFWwindow* GET_GLFWWINDOW(void);
Window* GET_WINDOW();
void* GET_CONTEXT();
Input* GET_INPUT();
void glViewportRect(s32 x, s32 y, s32 w, s32 h);
void* Window_Init(
const char* title,
Window* window,
Input* input,
void* context,
WindowFunction
updateCall,
WindowFunction drawCall,
DropCallback dropCallback,
u32 x, u32 y,
u32 samples
);
void Window_Close(Window* window);
void Window_Update(Window* window);
void Window_SetParam(Window* window, u32 num, ...);
#define GUI_INITIALIZE( \
mainContext, title, \
width, height, antialias, \
Update, Draw, DropCallback) \
\
(mainContext)->vg = Window_Init( \
title, \
&(mainContext)->window, &(mainContext)->input, \
(mainContext), (void*)Update, \
(void*)Draw, DropCallback, \
width, height, antialias \
);
#define Window_SetParam(window, ...) do { \
ctassert((NARGS(__VA_ARGS__) % 2) == 0); \
Window_SetParam(app, NARGS(__VA_ARGS__), __VA_ARGS__); \
} while (0)
#endif