Skip to content

Commit

Permalink
Merge pull request servo#11 from MortimerGoro/separate_crates
Browse files Browse the repository at this point in the history
Separate rust-webvr traits to a different crate
  • Loading branch information
MortimerGoro committed Aug 30, 2017
2 parents 2eaf4be + 2ff925e commit cab969e
Show file tree
Hide file tree
Showing 61 changed files with 122 additions and 98 deletions.
48 changes: 4 additions & 44 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,45 +1,5 @@
[package]
name = "rust-webvr"
version = "0.7.0"
authors = ["Imanol Fernandez <[email protected]>"]

homepage = "https://github.com/MortimerGoro/rust-webvr"
repository = "https://github.com/MortimerGoro/rust-webvr"
keywords = ["webvr", "openvr", "oculus", "headset", "vr"]
license = "MIT"

description = '''Safe rust API that provides a way to interact with Virtual Reality headsets
and integration with vendor specific SDKs like OpenVR and Oculus. The API is inspired on the
easy to use WebVR API but adapted to Rust design patterns'''

exclude = [
"examples/*",
[workspace]
members = [
"rust-webvr",
"rust-webvr-api",
]

build = "build.rs"

[package.metadata.android]
package-name = "rust.webvr"

[features]
default = ["openvr", "mock"]
openvr = ["libloading"]
mock = []
googlevr = ["gvr-sys"]
oculusvr = ["ovr-mobile-sys"]
serde-serialization = ["serde", "serde_derive"]

[dependencies]
log = "0.3"
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
time = "0.1"
libloading = { version = "0.4", optional = true, default-features = false }
gvr-sys = { version = "0.5", optional = true }
ovr-mobile-sys = { version = "0.3.1", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = "0.2.2"

[build-dependencies]
gl_generator = "0.5.0"
27 changes: 27 additions & 0 deletions rust-webvr-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "rust-webvr-api"
version = "0.8.0"
authors = ["Imanol Fernandez <[email protected]>"]

homepage = "https://github.com/MortimerGoro/rust-webvr"
repository = "https://github.com/MortimerGoro/rust-webvr"
keywords = ["webvr", "openvr", "oculus", "headset", "vr"]
license = "MIT"

description = '''Safe rust API that provides a way to interact with Virtual Reality headsets
and integration with vendor specific SDKs like OpenVR and Oculus. The API is inspired on the
easy to use WebVR API but adapted to Rust design patterns'''

[features]
default = ["utils", "jni_utils"]
utils = ["time"]
jni_utils = ["android_injected_glue"]
serde-serialization = ["serde", "serde_derive"]

[dependencies]
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
time = { version = "0.1", optional = true }

[target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = { version = "0.2.2", optional = true }
3 changes: 1 addition & 2 deletions src/api/jni_utils.rs → rust-webvr-api/src/jni_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg(any(feature = "googlevr", feature= "oculusvr"))]
#![cfg(target_os = "android")]
#[cfg(all(feature = "jni_utils", target_os = "android"))]

use android_injected_glue as android;
use android_injected_glue::ffi as ndk;
Expand Down
30 changes: 8 additions & 22 deletions src/lib.rs → rust-webvr-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,19 @@ macro_rules! identity_matrix {
() => ([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]);
}

#[cfg(any(feature = "googlevr", feature= "oculusvr"))]
#[cfg(target_os = "android")]
extern crate android_injected_glue;
#[cfg(feature = "googlevr")]
extern crate gvr_sys;
#[cfg(feature = "openvr")]
extern crate libloading;
#[macro_use]
extern crate log;
#[cfg(feature = "oculusvr")]
extern crate ovr_mobile_sys;
#[cfg(feature = "serde-serialization")]
#[macro_use]
extern crate serde_derive;
#[cfg(all(feature = "jni_utils", target_os = "android"))]
pub extern crate android_injected_glue;

#[cfg(feature = "utils")]
extern crate time;

#[cfg(any(feature = "googlevr", feature= "oculusvr"))]
mod gl {
include!(concat!(env!("OUT_DIR"), "/gles_bindings.rs"));
}
#[cfg(all(feature = "jni_utils", target_os = "android"))]
pub mod jni_utils;
#[cfg(feature = "utils")]
pub mod utils;

pub mod vr_display;
pub mod vr_service;
pub mod vr_manager;
pub mod vr_display_data;
pub mod vr_display_capabilities;
pub mod vr_eye;
Expand All @@ -42,7 +31,6 @@ pub mod vr_gamepad;

pub use vr_display::{VRDisplay,VRDisplayPtr};
pub use vr_service::{VRService,VRServiceCreator};
pub use vr_manager::VRServiceManager;
pub use vr_display_data::VRDisplayData;
pub use vr_display_capabilities::VRDisplayCapabilities;
pub use vr_eye::VREye;
Expand All @@ -56,5 +44,3 @@ pub use vr_event::{VREvent, VRDisplayEvent, VRDisplayEventReason, VRGamepadEvent
pub use vr_field_view::VRFieldOfView;
pub use vr_gamepad::{VRGamepad, VRGamepadPtr, VRGamepadHand,
VRGamepadData, VRGamepadState, VRGamepadButton};

pub mod api;
2 changes: 2 additions & 0 deletions src/api/utils.rs → rust-webvr-api/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "utils")]

use std::mem;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
use std::sync::atomic::Ordering::SeqCst;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions rust-webvr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "rust-webvr"
version = "0.8.0"
authors = ["Imanol Fernandez <[email protected]>"]

homepage = "https://github.com/MortimerGoro/rust-webvr"
repository = "https://github.com/MortimerGoro/rust-webvr"
keywords = ["webvr", "openvr", "oculus", "headset", "vr"]
license = "MIT"

description = '''Safe rust API that provides a way to interact with Virtual Reality headsets
and integration with vendor specific SDKs like OpenVR and Oculus. The API is inspired on the
easy to use WebVR API but adapted to Rust design patterns'''

exclude = [
"examples/*",
]

build = "build.rs"

[features]
default = ["openvr", "mock"]
openvr = ["libloading"]
mock = []
googlevr = ["gvr-sys"]
oculusvr = ["ovr-mobile-sys"]

[dependencies]
rust-webvr-api = "0.8" #{ path = "../rust-webvr-api" }
log = "0.3"
time = "0.1"
libloading = { version = "0.4", optional = true, default-features = false }
gvr-sys = { version = "0.5", optional = true }
ovr-mobile-sys = { version = "0.3.1", optional = true }

[build-dependencies]
gl_generator = "0.5.0"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
use {VRDisplay, VRDisplayData, VRDisplayCapabilities, VRFramebuffer, VRFramebufferAttributes,
VREvent, VRDisplayEvent, VREyeParameters, VRFrameData, VRLayer, VRViewport};
use super::service::GoogleVRService;
use super::super::utils;
use rust_webvr_api::utils;
#[cfg(target_os="android")]
use super::jni_utils::JNIScope;
use rust_webvr_api::jni_utils::JNIScope;
use gl;
use gvr_sys as gvr;
use gvr_sys::gvr_feature::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(feature = "googlevr")]
use {VRGamepad, VRGamepadData, VRGamepadHand, VRGamepadState, VRGamepadButton};
use super::super::utils;
use rust_webvr_api::utils;
use gvr_sys as gvr;
use gvr_sys::gvr_controller_api_status::*;
use gvr_sys::gvr_controller_button::*;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
mod display;
mod gamepad;
mod service;
#[cfg(target_os = "android")]
use super::jni_utils;

use {VRService, VRServiceCreator};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {VRService, VRDisplay, VRDisplayPtr, VREvent, VRGamepadPtr};
use super::display::{GoogleVRDisplay, GoogleVRDisplayPtr};
use super::gamepad::{GoogleVRGamepad, GoogleVRGamepadPtr};
#[cfg(target_os="android")]
use super::jni_utils::JNIScope;
use rust_webvr_api::jni_utils::JNIScope;
#[cfg(target_os="android")]
use android_injected_glue::ffi as ndk;
use gvr_sys as gvr;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {VRDisplay, VRDisplayData, VRFramebuffer, VRFramebufferAttributes, VRFrameData, VRStageParameters, VRLayer, VRViewport};
use super::super::utils;
use rust_webvr_api::utils;
use std::sync::Arc;
use std::cell::RefCell;
pub type MockVRDisplayPtr = Arc<RefCell<MockVRDisplay>>;
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 6 additions & 14 deletions src/api/mod.rs → rust-webvr/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
mod utils;

#[cfg(target_os="windows")]
#[cfg(feature = "openvr")]
mod openvr;
#[cfg(target_os="windows")]
#[cfg(feature = "openvr")]
pub use self::openvr::OpenVRServiceCreator;

#[cfg(feature = "mock")]
mod mock;
#[cfg(feature = "mock")]
pub use self::mock::MockServiceCreator;

#[cfg(target_os = "android")]
#[cfg(any(feature = "googlevr", feature= "oculusvr"))]
mod jni_utils;
#[cfg(all(target_os="windows", feature = "openvr"))]
mod openvr;
#[cfg(all(target_os="windows", feature = "openvr"))]
pub use self::openvr::OpenVRServiceCreator;

#[cfg(feature = "googlevr")]
#[cfg(all(feature = "googlevr", target_os= "android"))]
mod googlevr;
#[cfg(feature = "googlevr")]
#[cfg(all(feature = "googlevr", target_os= "android"))]
pub use self::googlevr::GoogleVRServiceCreator;
#[cfg(all(feature = "googlevr", target_os= "android"))]
pub use self::googlevr::jni::*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ use std::ptr;
use std::str;
use std::sync::{Arc, Condvar, Mutex};
use super::gamepad::{OculusVRGamepad, OculusVRGamepadPtr};
use super::jni_utils::JNIScope;
use rust_webvr_api::jni_utils::JNIScope;
use super::service::{OVRJava, OVRServiceJava};
use super::super::utils;
use rust_webvr_api::utils;

pub type OculusVRDisplayPtr = Arc<RefCell<OculusVRDisplay>>;

extern {
fn eglGetCurrentContext() -> *mut c_void;
fn eglGetCurrentDisplay() -> *mut c_void;
fn eglGetProcAddress(proc_name: *const c_char) -> *mut c_void;
fn ANativeWindow_fromSurface(env: *mut c_void, surface: *mut c_void) -> *mut c_void;
}

Expand Down Expand Up @@ -157,8 +156,9 @@ impl VRDisplay for OculusVRDisplay {
}

fn get_framebuffers(&self) -> Vec<VRFramebuffer> {
self.eye_framebuffers.iter().map(|fbo| {
self.eye_framebuffers.iter().enumerate().map(|(index, fbo)| {
VRFramebuffer {
id: index as u32,
attributes: fbo.attributes,
viewport: VRViewport::new(0, 0, fbo.width as i32, fbo.height as i32)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::mem;
use std::ptr;
use std::sync::Arc;
use super::display::{ovr_quat_to_array, ovr_vec3_to_array};
use super::super::utils;
use rust_webvr_api::utils;

pub type OculusVRGamepadPtr = Arc<RefCell<OculusVRGamepad>>;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
mod display;
mod gamepad;
mod service;
use super::jni_utils;

use {VRService, VRServiceCreator};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ovr_mobile_sys as ovr;
use std::mem;
use std::ptr;
use super::display::{OculusVRDisplay, OculusVRDisplayPtr};
use super::jni_utils::JNIScope;
use rust_webvr_api::jni_utils::JNIScope;

const SERVICE_CLASS_NAME:&'static str = "com/rust/webvr/OVRService";

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::binding::ETrackingUniverseOrigin::*;
use super::binding::EGraphicsAPIConvention::*;
use super::library::OpenVRLibrary;
use super::constants;
use super::super::utils;
use rust_webvr_api::utils;
use std::ffi::CString;
use std::sync::Arc;
use std::cell::RefCell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::binding::ETrackingUniverseOrigin::*;
use super::binding::EVRButtonId;
use super::binding::EVRButtonId::*;
use super::display::OpenVRDisplay;
use super::super::utils;
use rust_webvr_api::utils;
use std::cell::RefCell;
use std::mem;
use std::sync::Arc;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions rust-webvr/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
extern crate rust_webvr_api;
#[cfg(all(feature = "googlevr", target_os= "android"))]
extern crate gvr_sys;
#[cfg(feature = "openvr")]
extern crate libloading;
#[macro_use]
extern crate log;
#[cfg(all(feature = "oculusvr", target_os= "android"))]
extern crate ovr_mobile_sys;
#[cfg(feature = "serde-serialization")]
#[macro_use]
extern crate serde_derive;
extern crate time;

#[cfg(any(feature = "googlevr", feature= "oculusvr"))]
mod gl {
include!(concat!(env!("OUT_DIR"), "/gles_bindings.rs"));
}

pub mod api;
mod vr_manager;

pub use rust_webvr_api::*;
pub use vr_manager::VRServiceManager;
File renamed without changes.

0 comments on commit cab969e

Please sign in to comment.