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
92
93
94
|
use gl::*;
use glm;
use glw;
use math;
use sdl2::*;
use time;
use trace;
type Vertex = struct {
position: [3]u16,
normal: [3]i8,
texcoord: [2]u16,
flags: u8,
};
type VertexFlags = enum u8 {
U_EXCL = 1 << 0,
V_EXCL = 1 << 1,
};
fn render_init(assets: *Pack) void = {
const t = time::now(time::clock::MONOTONIC);
const u = time::now(time::clock::PROCESS_CPU);
load_textures(assets);
trace::debug(&trace::root, "texture loading took rt {} ms / cpu {} ms",
time::diff(t, time::now(time::clock::MONOTONIC)) / 1000000,
time::diff(u, time::now(time::clock::PROCESS_CPU)) / 1000000);
const t = time::now(time::clock::MONOTONIC);
const u = time::now(time::clock::PROCESS_CPU);
load_atlases(assets);
trace::debug(&trace::root, "atlas loading took rt {} ms / cpu {} ms",
time::diff(t, time::now(time::clock::MONOTONIC)) / 1000000,
time::diff(u, time::now(time::clock::PROCESS_CPU)) / 1000000);
const t = time::now(time::clock::MONOTONIC);
const u = time::now(time::clock::PROCESS_CPU);
load_fonts(assets);
trace::debug(&trace::root, "font loading took rt {} ms / cpu {} ms",
time::diff(t, time::now(time::clock::MONOTONIC)) / 1000000,
time::diff(u, time::now(time::clock::PROCESS_CPU)) / 1000000);
const t = time::now(time::clock::MONOTONIC);
const u = time::now(time::clock::PROCESS_CPU);
load_models(assets);
trace::debug(&trace::root, "model loading took rt {} ms / cpu {} ms",
time::diff(t, time::now(time::clock::MONOTONIC)) / 1000000,
time::diff(u, time::now(time::clock::PROCESS_CPU)) / 1000000);
const t = time::now(time::clock::MONOTONIC);
const u = time::now(time::clock::PROCESS_CPU);
load_render_bstates(assets);
trace::debug(&trace::root, "render bstate loading took rt {} ms / cpu {} ms",
time::diff(t, time::now(time::clock::MONOTONIC)) / 1000000,
time::diff(u, time::now(time::clock::PROCESS_CPU)) / 1000000);
const t = time::now(time::clock::MONOTONIC);
const u = time::now(time::clock::PROCESS_CPU);
shaders_init();
trace::debug(&trace::root, "shader loading took rt {} ms / cpu {} ms",
time::diff(t, time::now(time::clock::MONOTONIC)) / 1000000,
time::diff(u, time::now(time::clock::PROCESS_CPU)) / 1000000);
hud_load();
};
fn render_destroy() void = {
// TODO:
// shaders_finish();
// render_bstates_finish();
// models_finish();
// atlases_finish();
finish_textures();
};
fn render_wait_screen(text: str) void = {
let (width, height) = drawable_size();
glViewport(0, 0, width: i32, height: i32);
let gui_width = width / gui_scale();
let gui_height = height / gui_scale();
glClearColor(0.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const font = fonts_find("minecraft:default") as *Font;
const metrics = font_measure(font, text);
const text_trans = glm::translation_make(&[
(gui_width: f32 - metrics.width) / 2.0,
gui_height: f32 / 2.0,
0.0]);
const text_trans = glm::m4_mul(gui_proj(), &text_trans);
render_text_shadow(text, font, &text_trans, [255...]);
};
|