Skip to content
Permalink
Browse files

Pass events loop to glwindow test webvr implementation

  • Loading branch information...
asajeffrey committed Jun 14, 2019
1 parent 18477d1 commit 1e5e3c95c93236f6564cccd38b95f2c60e855ff2

Some generated files are not rendered by default. Learn more.

@@ -22,8 +22,8 @@ gleam = "0.6"
ipc-channel = "0.11.2"
log = "0.4"
msg = {path = "../msg"}
rust-webvr = {version = "0.11.4", features = ["mock", "openvr", "vrexternal"]}
rust-webvr-api = "0.11.4"
rust-webvr = {version = "0.12", features = ["mock", "openvr", "vrexternal"]}
rust-webvr-api = "0.12"
script_traits = {path = "../script_traits"}
servo_config = {path = "../config"}
webvr_traits = {path = "../webvr_traits" }
@@ -13,5 +13,5 @@ path = "lib.rs"
[dependencies]
ipc-channel = "0.11"
msg = {path = "../msg"}
rust-webvr-api = {version = "0.11.4", features = ["ipc"]}
rust-webvr-api = {version = "0.12", features = ["ipc"]}
serde = "1.0"
@@ -54,7 +54,7 @@ lazy_static = "1"
libservo = {path = "../../components/servo"}
libc = "0.2"
log = "0.4"
rust-webvr = { version = "0.11", features = ["glwindow"] }
rust-webvr = { version = "0.12", features = ["glwindow"] }
tinyfiledialogs = "3.0"

[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
@@ -8,6 +8,7 @@ use crate::app;
use crate::events_loop::EventsLoop;
use gleam::gl;
use glutin;
use glutin::EventsLoopClosed;
use glutin::dpi::LogicalSize;
use rust_webvr::GlWindowVRService;
use servo::compositing::windowing::EmbedderMethods;
@@ -46,6 +47,10 @@ impl EmbedderMethods for EmbedderCallbacks {
let name = String::from("Test VR Display");
let size = opts::get().initial_window_size.to_f64();
let size = LogicalSize::new(size.width, size.height);
let events_loop_clone = self.events_loop.clone();
let events_loop_factory = Box::new(move || {
events_loop_clone.borrow_mut().take().ok_or(EventsLoopClosed)
});
let window_builder = glutin::WindowBuilder::new()
.with_title(name.clone())
.with_dimensions(size)
@@ -57,7 +62,7 @@ impl EmbedderMethods for EmbedderCallbacks {
.build_windowed(window_builder, &*self.events_loop.borrow().as_winit())
.expect("Failed to create window.");
let gl = self.gl.clone();
let (service, heartbeat) = GlWindowVRService::new(name, context, gl);
let (service, heartbeat) = GlWindowVRService::new(name, context, events_loop_factory, gl);

services.register(Box::new(service));
heartbeats.push(Box::new(heartbeat));
@@ -44,6 +44,9 @@ impl EventsLoop {
pub fn as_winit(&self) -> &glutin::EventsLoop {
&self.0.as_ref().expect("Can't access winit event loop while using the fake headless event loop")
}
pub fn take(&mut self) -> Option<glutin::EventsLoop> {
self.0.take()
}
pub fn poll_events<F>(&mut self, callback: F) where F: FnMut(glutin::Event) {
if let Some(ref mut events_loop) = self.0 {
events_loop.poll_events(callback);
@@ -19,7 +19,7 @@ raqote_backend = ["simpleservo/raqote_backend"]
[dependencies]
libservo = { path = "../../components/servo", features = ["no_static_freetype"] }
simpleservo = { path = "../libsimpleservo/api", features = ["no_static_freetype"] }
rust-webvr = { version = "0.11", features = ["magicleap"] }
rust-webvr = { version = "0.12", features = ["magicleap"] }
libc = "0.2"
log = "0.4"
servo-egl = "0.2"

0 comments on commit 1e5e3c9

Please sign in to comment.
You can’t perform that action at this time.