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
use super::control::{consts::Get, funcs::*};
use crate::lib::*;

CONST!(MAX_TEXTURE_IMAGE_UNITS, i32);
CONST!(MAX_COMBINED_TEXTURE_IMAGE_UNITS, i32);
CONST!(MAX_TEXTURE_BUFFER_SIZE, i32);
CONST!(MAX_TEXTURE_SIZE, i32);
CONST!(MAX_UNIFORM_BUFFER_BINDINGS, i32);
CONST!(MAX_SHADER_STORAGE_BUFFER_BINDINGS, i32);
CONST!(MAX_UNIFORM_BLOCK_SIZE, i32);
CONST!(MAX_SHADER_STORAGE_BLOCK_SIZE, i32);

FUNC!(gl, Viewport, i32, i32, i32, i32);
FUNC!(gl, BlendFunc, GLenum, GLenum);
FUNC!(gl, BlendFuncSeparate, GLenum, GLenum, GLenum, GLenum);
FUNC!(gl, BlendEquation, GLenum);
FUNC!(gl, DepthFunc, GLenum);
FUNC!(ext, PixelStorePack, i32);
FUNC!(ext, PixelStoreUnpack, i32);

mod ext {
	pub unsafe fn PixelStorePack(v: i32) {
		gl::PixelStorei(gl::PACK_ALIGNMENT, v)
	}
	pub unsafe fn PixelStoreUnpack(v: i32) {
		gl::PixelStorei(gl::UNPACK_ALIGNMENT, v)
	}
}

SWITCH!(DEPTH_WRITEMASK, gl::DepthMask(gl::TRUE), gl::DepthMask(gl::FALSE), DEFAULT_TRUE);
pub use DEPTH_WRITEMASK as DEPTH_WRITABLE;

SWITCH!(MULTISAMPLE, DEFAULT_TRUE);

SWITCH!(DEBUG_OUTPUT);
SWITCH!(DEBUG_OUTPUT_SYNCHRONOUS);

SWITCH!(DEPTH_TEST);
SWITCH!(BLEND);
SWITCH!(CULL_FACE);
SWITCH!(TEXTURE_CUBE_MAP_SEAMLESS);
SWITCH!(PROGRAM_POINT_SIZE);
SWITCH!(SAMPLE_SHADING);

#[macro_export]
macro_rules! GLEnable {
($f: ty) => {{ use $crate::GL::states::*; <$f>::Enable(); }};
($f: ty, $($n: ty),+) => {{
	use $crate::GL::states::*;
	<$f>::Enable();
	GLEnable!($($n),+);
}};
}

#[macro_export]
macro_rules! GLDisable {
($f: ty) => {{ use $crate::GL::states::*; <$f>::Disable(); }};
($f: ty, $($n: ty),+) => {{
	use $crate::GL::states::*;
	<$f>::Disable();
	GLDisable!($($n),+);
}};
}

#[macro_export]
macro_rules! GLSave {
($f: ty) => {{ use $crate::GL::states::*; <$f>::Save(); }};
($f: ty, $($n: ty),+) => {{
	use $crate::GL::states::*;
	<$f>::Save();
	GLSave!($($n),+);
}};
}

#[macro_export]
macro_rules! GLRestore {
($f: ty) => {{ use $crate::GL::states::*; <$f>::Restore(); }};
($f: ty, $($n: ty),+) => {{
	use $crate::GL::states::*;
	<$f>::Restore();
	GLRestore!($($n),+);
}};
}