-
Notifications
You must be signed in to change notification settings - Fork 404
/
Copy pathmain.rs
148 lines (135 loc) · 6.67 KB
/
main.rs
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
extern crate gl_generator;
extern crate khronos_api;
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::io::Write;
use std::path::Path;
use gl_generator::generators::Generator;
mod textures;
fn main() {
let dest = env::var("OUT_DIR").unwrap();
let dest = Path::new(&dest);
textures::build_texture_file(&mut File::create(&dest.join("textures.rs")).unwrap());
// There is a `#[derive(Clone)]` line in the bindings that triggers a stack overflow
// in rustc (https://github.com/rust-lang/rust/issues/26467).
// Therefore we write the bindings to memory first, then remove this line, and then copy
// to the file.
let mut gl_bindings = Vec::new();
generate_gl_bindings(&mut gl_bindings);
let gl_bindings = String::from_utf8(gl_bindings).unwrap();
let gl_bindings = gl_bindings.replace("#[derive(Clone)]", "");
let mut file_output = File::create(&dest.join("gl_bindings.rs")).unwrap();
file_output.write_all(&gl_bindings.into_bytes()).unwrap();
}
fn generate_gl_bindings<W>(dest: &mut W) where W: Write {
let gl_registry = {
let reader = BufReader::new(khronos_api::GL_XML);
let ns = gl_generator::registry::Ns::Gl;
let filter = gl_generator::registry::Filter {
fallbacks: gl_generator::Fallbacks::None,
api: gl_generator::registry::Ns::Gl.to_string(),
extensions: vec![
"GL_AMD_depth_clamp_separate".to_string(),
"GL_APPLE_vertex_array_object".to_string(),
"GL_ARB_bindless_texture".to_string(),
"GL_ARB_buffer_storage".to_string(),
"GL_ARB_compute_shader".to_string(),
"GL_ARB_copy_buffer".to_string(),
"GL_ARB_debug_output".to_string(),
"GL_ARB_depth_texture".to_string(),
"GL_ARB_direct_state_access".to_string(),
"GL_ARB_draw_buffers".to_string(),
"GL_ARB_ES2_compatibility".to_string(),
"GL_ARB_ES3_compatibility".to_string(),
"GL_ARB_ES3_1_compatibility".to_string(),
"GL_ARB_ES3_2_compatibility".to_string(),
"GL_ARB_framebuffer_sRGB".to_string(),
"GL_ARB_geometry_shader4".to_string(),
"GL_ARB_gpu_shader_fp64".to_string(),
"GL_ARB_gpu_shader_int64".to_string(),
"GL_ARB_invalidate_subdata".to_string(),
"GL_ARB_multi_draw_indirect".to_string(),
"GL_ARB_occlusion_query".to_string(),
"GL_ARB_pixel_buffer_object".to_string(),
"GL_ARB_robustness".to_string(),
"GL_ARB_shader_image_load_store".to_string(),
"GL_ARB_shader_objects".to_string(),
"GL_ARB_texture_buffer_object".to_string(),
"GL_ARB_texture_float".to_string(),
"GL_ARB_texture_multisample".to_string(),
"GL_ARB_texture_rg".to_string(),
"GL_ARB_texture_rgb10_a2ui".to_string(),
"GL_ARB_transform_feedback3".to_string(),
"GL_ARB_vertex_buffer_object".to_string(),
"GL_ARB_vertex_shader".to_string(),
"GL_ATI_draw_buffers".to_string(),
"GL_ATI_meminfo".to_string(),
"GL_EXT_debug_marker".to_string(),
"GL_EXT_direct_state_access".to_string(),
"GL_EXT_framebuffer_blit".to_string(),
"GL_EXT_framebuffer_multisample".to_string(),
"GL_EXT_framebuffer_object".to_string(),
"GL_EXT_framebuffer_sRGB".to_string(),
"GL_EXT_gpu_shader4".to_string(),
"GL_EXT_packed_depth_stencil".to_string(),
"GL_EXT_provoking_vertex".to_string(),
"GL_EXT_texture_array".to_string(),
"GL_EXT_texture_buffer_object".to_string(),
"GL_EXT_texture_compression_s3tc".to_string(),
"GL_EXT_texture_filter_anisotropic".to_string(),
"GL_EXT_texture_integer".to_string(),
"GL_EXT_texture_sRGB".to_string(),
"GL_EXT_transform_feedback".to_string(),
"GL_GREMEDY_string_marker".to_string(),
"GL_KHR_robustness".to_string(),
"GL_NVX_gpu_memory_info".to_string(),
"GL_NV_conditional_render".to_string(),
"GL_NV_vertex_attrib_integer_64bit".to_string(),
],
version: "4.5".to_string(),
profile: "compatibility".to_string(),
};
gl_generator::registry::Registry::from_xml(reader, ns, Some(filter))
};
let gles_registry = {
let reader = BufReader::new(khronos_api::GL_XML);
let ns = gl_generator::registry::Ns::Gles2;
let filter = gl_generator::registry::Filter {
fallbacks: gl_generator::Fallbacks::None,
api: gl_generator::registry::Ns::Gles2.to_string(),
extensions: vec![
"GL_ANGLE_framebuffer_multisample".to_string(),
"GL_APPLE_framebuffer_multisample".to_string(),
"GL_APPLE_sync".to_string(),
"GL_ARM_rgba8".to_string(),
"GL_EXT_buffer_storage".to_string(),
"GL_EXT_disjoint_timer_query".to_string(),
"GL_EXT_multi_draw_indirect".to_string(),
"GL_EXT_multisampled_render_to_texture".to_string(),
"GL_EXT_occlusion_query_boolean".to_string(),
"GL_EXT_primitive_bounding_box".to_string(),
"GL_EXT_robustness".to_string(),
"GL_KHR_debug".to_string(),
"GL_NV_copy_buffer".to_string(),
"GL_NV_framebuffer_multisample".to_string(),
"GL_NV_internalformat_sample_query".to_string(),
"GL_NV_pixel_buffer_object".to_string(),
"GL_OES_depth_texture".to_string(),
"GL_OES_draw_elements_base_vertex".to_string(),
"GL_OES_packed_depth_stencil".to_string(),
"GL_OES_primitive_bounding_box".to_string(),
"GL_OES_rgb8_rgba8".to_string(),
"GL_OES_texture_buffer".to_string(),
"GL_OES_texture_npot".to_string(),
"GL_OES_vertex_array_object".to_string(),
"GL_OES_vertex_type_10_10_10_2".to_string(),
],
version: "3.2".to_string(),
profile: "compatibility".to_string(),
};
gl_generator::registry::Registry::from_xml(reader, ns, Some(filter))
};
gl_generator::StructGenerator.write(&(gl_registry + gles_registry),
gl_generator::registry::Ns::Gl, dest).unwrap();
}