grafix_toolbox/kit/opengl/
geom.rs

1pub use {camera::*, mesh::*, model::*};
2
3pub mod Screen {
4	struct Model {
5		vao: Vao<u8>,
6		_xyuv: AttrArr<i8>,
7	}
8	pub fn Draw() {
9		GLSave!(DEPTH_TEST);
10		GLDisable!(DEPTH_TEST);
11		LeakyStatic!(Model, {
12			#[rustfmt::skip]
13			let _xyuv = AttrArr::new(&[ -1, -1, 0, 0,  3, -1, 2, 0,  -1, 3, 0, 2 ][..]);
14			let mut vao = Vao::new();
15			vao.AttribFmt(&_xyuv, (0, 4));
16			Model { vao, _xyuv }
17		})
18		.vao
19		.Bind()
20		.DrawUnindexed(3);
21		GLRestore!(DEPTH_TEST);
22	}
23	use super::*;
24}
25
26pub mod Skybox {
27	struct Model {
28		vao: Vao<u8>,
29		_idx: IdxArr<u8>,
30		_xyz: AttrArr<i8>,
31	}
32	pub fn Draw() {
33		LeakyStatic!(Model, {
34			#[rustfmt::skip]
35			let _idx = IdxArr::new(&[ 0, 1, 3,  3, 1, 2,
36									  4, 5, 7,  7, 5, 6,
37									  0, 1, 4,  4, 1, 5,
38									  3, 2, 7,  7, 2, 6,
39									  2, 1, 6,  6, 1, 5,
40									  3, 7, 0,  0, 7, 4, ][..]);
41			#[rustfmt::skip]
42			let _xyz = AttrArr::new(&[ -1,  1, 1,   1,  1, 1,   1,  1, -1,  -1,  1, -1,
43									   -1, -1, 1,   1, -1, 1,   1, -1, -1,  -1, -1, -1 ][..]);
44			let mut vao = Vao::new();
45			vao.BindIdxs(&_idx);
46			vao.AttribFmt(&_xyz, (0, 3));
47			Model { vao, _idx, _xyz }
48		})
49		.vao
50		.Bind()
51		.Draw(36);
52	}
53	use super::*;
54}
55
56mod camera;
57mod mesh;
58mod model;
59
60use crate::{lib::*, *};
61use GL::buffer::*;
62
63SHADER!(
64	vs_mesh__2d_screen,
65	r"layout(location = 0) in vec4 Position;
66	out vec2 glUV;
67
68	void main() {
69		gl_Position = vec4(Position.xy, 0, 1);
70		glUV = Position.zw;
71	}"
72);
73
74SHADER!(
75	ps_mesh__2d_screen,
76	r"in vec2 glUV;
77	layout(location = 0) out vec4 glFragColor;
78	uniform sampler2D tex;
79
80	void main() { glFragColor = texture(tex, glUV); }"
81);