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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
use bitflags::bitflags;
use crate::data_types::dimens::Dimens;
use crate::vector::Vec2;
pub mod buffer;
pub mod glsl;
pub mod shader;
pub mod texture;
pub mod vertex_array;
mod util;
#[cfg(feature = "debug")]
pub mod debug;
pub fn set_viewport(position: Vec2<u32>, size: Dimens<u32>)
{
unsafe {
#[allow(clippy::cast_possible_wrap)]
gl::Viewport(
position.x as i32,
position.y as i32,
size.width as i32,
size.height as i32,
);
}
}
pub fn clear_buffers(mask: BufferClearMask)
{
unsafe {
gl::Clear(mask.bits());
}
}
pub fn set_polygon_mode(face: impl Into<PolygonModeFace>, mode: impl Into<PolygonMode>)
{
unsafe {
gl::PolygonMode(face.into() as u32, mode.into() as u32);
}
}
pub fn enable(capacity: Capability)
{
unsafe {
gl::Enable(capacity as u32);
}
}
bitflags! {
#[derive(Debug, Clone, Copy)]
pub struct BufferClearMask: u32 {
const COLOR = gl::COLOR_BUFFER_BIT;
const DEPTH = gl::DEPTH_BUFFER_BIT;
const STENCIL = gl::STENCIL_BUFFER_BIT;
}
}
#[derive(Debug)]
#[repr(u32)]
pub enum Capability
{
DepthTest = gl::DEPTH_TEST,
MultiSample = gl::MULTISAMPLE,
}
#[derive(Debug)]
#[repr(u32)]
pub enum PolygonMode
{
Point = gl::POINT,
Line = gl::LINE,
Fill = gl::FILL,
}
impl From<crate::draw_flags::PolygonMode> for PolygonMode
{
fn from(mode: crate::draw_flags::PolygonMode) -> Self
{
match mode {
crate::draw_flags::PolygonMode::Point => Self::Point,
crate::draw_flags::PolygonMode::Fill => Self::Fill,
crate::draw_flags::PolygonMode::Line => Self::Line,
}
}
}
#[derive(Debug)]
#[repr(u32)]
pub enum PolygonModeFace
{
Front = gl::FRONT,
Back = gl::BACK,
FrontAndBack = gl::FRONT_AND_BACK,
}
impl From<crate::draw_flags::PolygonModeFace> for PolygonModeFace
{
fn from(face: crate::draw_flags::PolygonModeFace) -> Self
{
match face {
crate::draw_flags::PolygonModeFace::Front => Self::Front,
crate::draw_flags::PolygonModeFace::Back => Self::Back,
crate::draw_flags::PolygonModeFace::FrontAndBack => Self::FrontAndBack,
}
}
}
|