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
#[cfg(feature = "glutin")]
mod glutin_target {
use glutin;
use libc;
use RenderTarget;
use HmdDisplay;
use HmdDisplayId;
pub struct GlutinRenderTarget<'a> {
#[allow(dead_code)]
window: &'a glutin::Window,
multisample: u32
}
impl<'a> GlutinRenderTarget<'a> {
pub fn new(window: &'a glutin::Window,
multisample: u32) -> GlutinRenderTarget<'a> {
GlutinRenderTarget {
window: window,
multisample: multisample
}
}
}
impl<'a> RenderTarget for GlutinRenderTarget<'a> {
fn get_multisample(&self) -> u32 {
self.multisample
}
#[cfg(windows)]
unsafe fn get_native_window(&self) -> *const libc::c_void {
self.window.platform_window()
}
#[cfg(not(windows))]
unsafe fn get_native_window(&self) -> *const libc::c_void {
use std::ptr;
ptr::null()
}
}
impl PartialEq<glutin::NativeMonitorId> for HmdDisplayId {
fn eq(&self, other: &glutin::NativeMonitorId) -> bool {
match (self, other) {
(&HmdDisplayId::Numeric(ref s), &glutin::NativeMonitorId::Numeric(ref o)) => s == o,
(&HmdDisplayId::Name(ref s), &glutin::NativeMonitorId::Name(ref o)) => s == o,
_ => false
}
}
}
impl PartialEq<HmdDisplayId> for glutin::NativeMonitorId {
fn eq(&self, other: &HmdDisplayId) -> bool {
other == self
}
}
pub fn find_glutin_monitor(display: &HmdDisplay) -> Option<glutin::MonitorID> {
for mon in glutin::get_available_monitors() {
if mon.get_native_identifier() == display.id {
return Some(mon);
}
}
None
}
}
#[cfg(feature = "glutin")]
pub use target::glutin_target::{GlutinRenderTarget, find_glutin_monitor};