1pub use self::winit::Winit;
5pub use self::glutin::Glutin;
6pub use self::glium::Glium;
7
8pub mod winit {
13 use winit;
14
15 #[derive(Debug)]
16 pub struct Winit <'a> {
17 pub event_loop_info : EventLoop <'a>,
18 pub window_info : Window <'a>
19 }
20
21 #[derive(Debug)]
22 pub struct EventLoop <'a> {
23 pub display_handle : winit::raw_window_handle::DisplayHandle <'a>,
24 }
25
26 #[derive(Debug)]
27 pub struct Window <'a> {
28 pub id : winit::window::WindowId,
29 pub window_handle : winit::raw_window_handle::WindowHandle <'a>,
30 pub title : String,
31 pub is_visible : Option <bool>,
32 pub is_resizable : bool,
33 pub is_minimized : Option <bool>,
34 pub is_maximized : bool,
35 pub fullscreen : Option <winit::window::Fullscreen>,
36 pub is_decorated : bool,
37 pub has_focus : bool,
38 pub scale_factor : f64,
39 pub inner_position : winit::dpi::PhysicalPosition <i32>,
40 pub outer_position : winit::dpi::PhysicalPosition <i32>,
41 pub inner_size : winit::dpi::PhysicalSize <u32>,
42 pub outer_size : winit::dpi::PhysicalSize <u32>,
43 pub resize_increments : Option <winit::dpi::PhysicalSize <u32>>,
44 pub theme : Option <winit::window::Theme>,
45 pub enabled_buttons : winit::window::WindowButtons,
46 pub primary_monitor : Option <winit::monitor::MonitorHandle>,
47 pub current_monitor : Option <winit::monitor::MonitorHandle>,
48 pub monitor_handles : Vec <winit::monitor::MonitorHandle>
49 }
50
51 impl <'a> Winit <'a> {
52 pub fn new (
53 event_loop : &'a winit::event_loop::EventLoop <()>,
54 window : &'a winit::window::Window
55 ) -> Self {
56 Winit {
57 event_loop_info: EventLoop::new (event_loop),
58 window_info: Window::new (window)
59 }
60 }
61 }
62
63 impl <'a> EventLoop <'a> {
64 pub fn new (event_loop : &'a winit::event_loop::EventLoop <()>) -> Self {
65 use winit::raw_window_handle::HasDisplayHandle;
66 let display_handle = event_loop.display_handle().unwrap();
67 EventLoop {
69 display_handle
71 }
72 }
73 }
74
75 impl <'a> Window <'a> {
76 pub fn new (window : &'a winit::window::Window) -> Self {
77 use winit::raw_window_handle::HasWindowHandle;
78 let id = window.id();
79 let window_handle = window.window_handle().unwrap();
80 let title = window.title();
81 let scale_factor = window.scale_factor();
82 let is_visible = window.is_visible();
83 let is_resizable = window.is_resizable();
84 let is_minimized = window.is_minimized();
85 let is_maximized = window.is_maximized();
86 let fullscreen = window.fullscreen();
87 let is_decorated = window.is_decorated();
88 let has_focus = window.has_focus();
89 let inner_position = window.inner_position().unwrap();
90 let outer_position = window.outer_position().unwrap();
91 let inner_size = window.inner_size();
92 let outer_size = window.outer_size();
93 let resize_increments = window.resize_increments();
94 let theme = window.theme();
95 let enabled_buttons = window.enabled_buttons();
96 let primary_monitor = window.primary_monitor();
97 let current_monitor = window.current_monitor();
98 let monitor_handles = window.available_monitors().collect();
99 Window {
100 id,
101 window_handle,
102 title,
103 is_visible,
104 is_resizable,
105 is_minimized,
106 is_maximized,
107 fullscreen,
108 is_decorated,
109 has_focus,
110 scale_factor,
111 inner_position,
112 outer_position,
113 inner_size,
114 outer_size,
115 resize_increments,
116 theme,
117 enabled_buttons,
118 primary_monitor,
119 current_monitor,
120 monitor_handles
121 }
122 }
123 }
124}
125
126pub mod glutin {
131 #[derive(Debug)]
132 pub struct Glutin {
133 pub gl_config_info : GlConfig
134 }
135
136 #[derive(Debug)]
137 pub struct GlConfig {
138 pub api : glutin::config::Api,
139 pub color_buffer_type : Option <glutin::config::ColorBufferType>,
140 pub config_surface_types : glutin::config::ConfigSurfaceTypes,
141 pub float_pixels : bool,
142 pub alpha_size : u8,
143 pub depth_size : u8,
144 pub stencil_size : u8,
145 pub num_samples : u8,
146 pub srgb_capable : bool,
147 pub hardward_accelerated : bool,
148 pub supports_transparency : Option <bool>,
149 pub gl_display_info : GlDisplay
150 }
151
152 #[derive(Debug)]
153 pub struct GlDisplay {
154 pub version_string : String,
155 pub supported_features : glutin::display::DisplayFeatures
156 }
157
158 impl Glutin {
159 pub fn new (gl_config : &glutin::config::Config) -> Self {
160 Glutin {
161 gl_config_info: GlConfig::new (gl_config)
162 }
163 }
164 }
165
166 impl GlConfig {
167 pub fn new (config : &glutin::config::Config) -> Self {
168 use glutin::config::GlConfig as _;
169 use glutin::display::GetGlDisplay as _;
170 let api = config.api();
171 let color_buffer_type = config.color_buffer_type();
172 let config_surface_types = config.config_surface_types();
173 let float_pixels = config.float_pixels();
174 let alpha_size = config.alpha_size();
175 let depth_size = config.depth_size();
176 let stencil_size = config.stencil_size();
177 let num_samples = config.num_samples();
178 let srgb_capable = config.srgb_capable();
179 let hardward_accelerated = config.hardware_accelerated();
180 let supports_transparency = config.supports_transparency();
181 let gl_display_info = GlDisplay::new (&config.display());
182 GlConfig {
183 api,
184 color_buffer_type,
185 config_surface_types,
186 float_pixels,
187 alpha_size,
188 depth_size,
189 stencil_size,
190 num_samples,
191 srgb_capable,
192 hardward_accelerated,
193 supports_transparency,
194 gl_display_info
195 }
196 }
197 }
198
199 impl GlDisplay {
200 pub fn new (display : &glutin::display::Display) -> Self {
201 use glutin::display::GlDisplay as _;
202 let version_string = display.version_string();
203 let supported_features = display.supported_features();
204 GlDisplay {
205 version_string,
206 supported_features
207 }
208 }
209 }
210}
211
212pub mod glium {
217 use glium::{self, CapabilitiesSource};
218
219 #[derive(Debug)]
220 pub struct Glium <'a> {
221 pub display_info : Display <'a>
222 }
223
224 #[derive(Debug)]
225 pub struct Display <'a> {
226 pub context_info : Context <'a>
227 }
228
229 #[derive(Debug)]
230 pub struct Context <'a> {
231 pub driver_uuid : Result <[u8; 16], glium::UuidError>,
232 pub device_uuids : Result <Vec <[u8; 16]>, glium::UuidError>,
233 pub opengl_version : glium::Version,
234 pub opengl_profile : Option <glium::Profile>,
235 pub supported_glsl_version : glium::Version,
236 pub opengl_version_string : String,
237 pub opengl_vendor_string : String,
238 pub opengl_renderer_string : String,
239 pub is_debug : bool,
240 pub is_forward_compatible : bool,
241 pub is_robust : bool,
242 pub is_context_loss_possible : bool,
243 pub is_context_lost : bool,
244 pub release_behavior : glium::backend::ReleaseBehavior,
245 pub max_anisotropy_support : Option <u16>,
246 pub max_viewport_dimensions : (u32, u32),
247 pub framebuffer_dimensions : (u32, u32),
248 pub free_video_memory : Option <usize>,
249 pub capabilities_source_version : glium::Version,
250 pub supported_extensions : glium::ExtensionsList,
251 pub capabilities : &'a glium::Capabilities
252 }
253
254 #[derive(Debug)]
255 pub struct Surface {
256 pub dimensions : (u32, u32),
257 pub depth_buffer_bits : Option <u16>,
258 pub stencil_buffer_bits : Option <u16>
259 }
260
261 impl <'a> Glium <'a> {
262 pub fn new (display : &'a glium::Display <glutin::surface::WindowSurface>)
263 -> Self
264 {
265 Glium {
266 display_info: Display::new (display)
267 }
268 }
269 }
270
271 impl <'a> Display <'a> {
272 pub fn new (display : &'a glium::Display <glutin::surface::WindowSurface>)
273 -> Self
274 {
275 let context_info = Context::new (display);
276 Display {
277 context_info
278 }
279 }
280 }
281
282 impl <'a> Context <'a> {
283 pub fn new (context : &'a glium::backend::Context) -> Self {
284 let driver_uuid = context.driver_uuid();
285 let device_uuids = context.device_uuids();
286 let opengl_version = *context.get_opengl_version();
287 let opengl_profile = context.get_opengl_profile();
288 let supported_glsl_version = context.get_supported_glsl_version();
289 let opengl_version_string = context.get_opengl_version_string().into();
290 let opengl_vendor_string = context.get_opengl_vendor_string().into();
291 let opengl_renderer_string = context.get_opengl_renderer_string().into();
292 let is_debug = context.is_debug();
293 let is_forward_compatible = context.is_forward_compatible();
294 let is_robust = context.is_robust();
295 let is_context_loss_possible = context.is_context_loss_possible();
296 let is_context_lost = context.is_context_lost();
297 let release_behavior = context.get_release_behavior();
298 let max_anisotropy_support = context.get_max_anisotropy_support();
299 let max_viewport_dimensions = context.get_max_viewport_dimensions();
300 let framebuffer_dimensions = context.get_framebuffer_dimensions();
301 let free_video_memory = context.get_free_video_memory();
302 let capabilities_source_version = *CapabilitiesSource::get_version (context);
303 let supported_extensions = *context.get_extensions();
304 let capabilities = context.get_capabilities();
305 Context {
306 driver_uuid,
307 device_uuids,
308 opengl_version,
309 opengl_profile,
310 supported_glsl_version,
311 opengl_version_string,
312 opengl_vendor_string,
313 opengl_renderer_string,
314 is_debug,
315 is_forward_compatible,
316 is_robust,
317 is_context_loss_possible,
318 is_context_lost,
319 release_behavior,
320 max_anisotropy_support,
321 max_viewport_dimensions,
322 framebuffer_dimensions,
323 free_video_memory,
324 capabilities_source_version,
325 supported_extensions,
326 capabilities
327 }
328 }
329 }
330
331 impl Surface {
332 pub fn new <S : glium::Surface> (surface : &S) -> Self {
333 let dimensions = surface.get_dimensions();
334 let depth_buffer_bits = surface.get_depth_buffer_bits();
335 let stencil_buffer_bits = surface.get_stencil_buffer_bits();
336 Surface {
337 dimensions,
338 depth_buffer_bits,
339 stencil_buffer_bits
340 }
341 }
342 }
343}