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
use super::{GL::window::*, *};
use crate::math::*;

impl Frame for Window {
	fn ClearColor(&self, args: impl ClearArgs) {
		let (attach, c) = args.get();
		GL!(glClearFramebuff(0, gl::COLOR, attach, c.as_ptr()));
	}
	fn ClearDepth<T>(&self, d: T)
	where
		f32: Cast<T>,
	{
		GL!(glClearFramebuff(0, gl::DEPTH, 0, &f32(d) as *const f32));
	}
	fn size(&self) -> uVec2 {
		self.info().size
	}
	fn aspect(&self) -> Vec2 {
		self.info().aspect
	}
	fn pixel(&self) -> f32 {
		self.info().pixel
	}
	fn bind(&self) -> Binding<Framebuff> {
		let (w, h) = self.size();
		self.Viewport((0, 0, w, h));
		self.Bind()
	}
}
impl Window {
	pub fn Viewport(&self, args: impl WINSize) {
		let (x, y, w, h) = args.get();
		GL::Viewport::Set((x, y, i32(w), i32(h)));
	}
	pub fn Bind(&self) -> Binding<Framebuff> {
		Binding::<Framebuff>::zero()
	}
}

pub struct FrameInfo {
	pub size: uVec2,
	pub aspect: Vec2,
	pub pixel: f32,
}
impl FrameInfo {
	pub fn new((w, h): uVec2) -> Self {
		let size = (w, h);
		let (w, h, min) = Vec3((w, h, w.min(h)));
		let aspect = (w, h).div(min);
		let pixel = 2. / min;
		Self { size, aspect, pixel }
	}
}