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
pub use {camera::*, mesh::*, model::*};

pub mod Screen {
	use super::*;
	struct Model {
		vao: Vao<u8>,
		_xyuv: AttrArr<i8>,
	}
	pub fn Draw() {
		GLSave!(DEPTH_TEST);
		GLDisable!(DEPTH_TEST);
		LocalStatic!(Model, {
			#[rustfmt::skip]
			let _xyuv = AttrArr::new(&[ -1, -1, 0, 0,  3, -1, 2, 0,  -1, 3, 0, 2 ][..]);
			let mut vao = Vao::new();
			vao.AttribFmt(&_xyuv, (0, 4));
			Model { vao, _xyuv }
		})
		.vao
		.Bind()
		.DrawUnindexed(3);
		GLRestore!(DEPTH_TEST);
	}
}

pub mod Skybox {
	use super::*;
	struct Model {
		vao: Vao<u8>,
		_idx: IdxArr<u8>,
		_xyz: AttrArr<i8>,
	}
	pub fn Draw() {
		LocalStatic!(Model, {
			#[rustfmt::skip]
			let _idx = IdxArr::new(&[ 0, 1, 3,  3, 1, 2,
									  4, 5, 7,  7, 5, 6,
									  0, 1, 4,  4, 1, 5,
									  3, 2, 7,  7, 2, 6,
									  2, 1, 6,  6, 1, 5,
									  3, 7, 0,  0, 7, 4, ][..]);
			#[rustfmt::skip]
			let _xyz = AttrArr::new(&[ -1,  1, 1,   1,  1, 1,   1,  1, -1,  -1,  1, -1,
									   -1, -1, 1,   1, -1, 1,   1, -1, -1,  -1, -1, -1 ][..]);
			let mut vao = Vao::new();
			vao.BindIdxs(&_idx);
			vao.AttribFmt(&_xyz, (0, 3));
			Model { vao, _idx, _xyz }
		})
		.vao
		.Bind()
		.Draw(36);
	}
}

mod camera;
mod mesh;
mod model;

use crate::{lib::*, *};
use GL::buffer::*;

SHADER!(
	vs_mesh__2d_screen,
	r"layout(location = 0) in vec4 Position;
	out vec2 glUV;

	void main() {
		gl_Position = vec4(Position.xy, 0, 1);
		glUV = Position.zw;
	}"
);

SHADER!(
	ps_mesh__2d_screen,
	r"in vec2 glUV;
	layout(location = 0) out vec4 glFragColor;
	uniform sampler2D tex;

	void main() { glFragColor = texture(tex, glUV); }"
);