grafix_toolbox/kit/opengl/frame/
screen.rs1use super::{GL::window::*, *};
2use crate::math::*;
3
4impl<W: Window> Frame for W {
5 fn ClearColor(&self, args: impl ClearArgs) {
6 let (attach, c) = args.get();
7 GL!(glClearFramebuff(0, gl::COLOR, attach, c.as_ptr()));
8 }
9 fn ClearDepth<A>(&self, d: A)
10 where
11 f32: Cast<A>,
12 {
13 GL!(glClearFramebuff(0, gl::DEPTH, 0, &f32(d) as *const f32));
14 }
15 fn size(&self) -> uVec2 {
16 self.info().size
17 }
18 fn aspect(&self) -> Vec2 {
19 self.info().aspect
20 }
21 fn pixel(&self) -> f32 {
22 self.info().pixel
23 }
24 fn bind(&self) -> Bind<FramebuffT> {
25 let (w, h) = vec2(self.size());
26 GL::Viewport::Set((0, 0, w, h));
27 Bind::<FramebuffT>::zero()
28 }
29}
30
31pub struct FrameInfo {
32 pub size: uVec2,
33 pub aspect: Vec2,
34 pub pixel: f32,
35}
36impl FrameInfo {
37 pub fn new(size: uVec2) -> Self {
38 let s = Vec2(size);
39 let aspect = s.div(s.min_comp());
40 let pixel = 2. / s.min_comp();
41 Self { size, aspect, pixel }
42 }
43}