-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsimple.c
89 lines (83 loc) · 1.76 KB
/
simple.c
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
#include <aurora/aurora.h>
#include <aurora/event.h>
#include <aurora/main.h>
#include <dolphin/gx.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static void log_callback(AuroraLogLevel level, const char* message, unsigned int len) {
const char* levelStr;
FILE* out = stdout;
switch (level) {
case LOG_DEBUG:
levelStr = "DEBUG";
break;
case LOG_INFO:
levelStr = "INFO";
break;
case LOG_WARNING:
levelStr = "WARNING";
break;
case LOG_ERROR:
levelStr = "ERROR";
out = stderr;
break;
case LOG_FATAL:
levelStr = "FATAL";
out = stderr;
break;
}
fprintf(out, "[%s: %s]\n", levelStr, message);
if (level == LOG_FATAL) {
fflush(out);
abort();
}
}
static void draw() {
GXSetCopyClear(
(GXColor){
.r = 0,
.g = 0,
.b = 100,
.a = 255,
},
GX_MAX_Z24);
}
int main(int argc, char* argv[]) {
const AuroraConfig config = {
.appName = "Demo",
.logCallback = &log_callback,
};
AuroraInfo initInfo = aurora_initialize(argc, argv, &config);
bool exiting = false;
bool paused = false;
while (!exiting) {
const AuroraEvent* event = aurora_update();
while (event != NULL && event->type != AURORA_NONE) {
switch (event->type) {
case AURORA_EXIT:
exiting = true;
break;
case AURORA_PAUSED:
paused = true;
break;
case AURORA_UNPAUSED:
paused = false;
break;
case AURORA_WINDOW_RESIZED:
initInfo.windowSize = event->windowSize;
break;
default:
break;
}
++event;
}
if (exiting || paused || !aurora_begin_frame()) {
continue;
}
draw();
aurora_end_frame();
}
aurora_shutdown();
return 0;
}