feat(main): skytex on startup[
This commit is contained in:
@@ -32,11 +32,12 @@ prisma = "0.1.1"
|
||||
slog = "2.7.0"
|
||||
slog-stdlog = "4.1.1"
|
||||
xkbcommon = { version = "0.5.0", default-features = false }
|
||||
stardust-xr = "0.1.0"
|
||||
stardust-xr = "0.2.0"
|
||||
stardust-xr-schemas = "0.1.0"
|
||||
stereokit = {default-features = false, features = ["linux-egl"], version = "0.2.0"}
|
||||
wayland-backend = "=0.1.0-beta.9"
|
||||
wayland-scanner = "=0.30.0-beta.9"
|
||||
directories = "4.0.1"
|
||||
|
||||
[dependencies.smithay]
|
||||
git = "https://github.com/technobaboo/smithay.git"
|
||||
|
||||
34
src/main.rs
34
src/main.rs
@@ -14,9 +14,12 @@ use crate::wayland::Wayland;
|
||||
use self::core::eventloop::EventLoop;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use directories::ProjectDirs;
|
||||
use slog::Drain;
|
||||
use std::sync::Arc;
|
||||
use stereokit::input::Handed;
|
||||
use stereokit::render::SphericalHarmonics;
|
||||
use stereokit::texture::Texture;
|
||||
use stereokit::{lifecycle::DisplayMode, Settings};
|
||||
use tokio::{runtime::Handle, sync::oneshot};
|
||||
|
||||
@@ -37,7 +40,9 @@ fn main() -> Result<()> {
|
||||
let log = ::slog::Logger::root(::slog_stdlog::StdLog.fuse(), slog::o!());
|
||||
slog_stdlog::init()?;
|
||||
|
||||
let stereokit = Settings::default()
|
||||
let project_dirs = ProjectDirs::from("", "", "stardust").unwrap();
|
||||
|
||||
let mut stereokit = Settings::default()
|
||||
.app_name("Stardust XR")
|
||||
.overlay_app(cli_args.overlay)
|
||||
.overlay_priority(u32::MAX)
|
||||
@@ -51,6 +56,33 @@ fn main() -> Result<()> {
|
||||
.expect("StereoKit failed to initialize");
|
||||
println!("Init StereoKit");
|
||||
|
||||
{
|
||||
let skytex_path = project_dirs.config_dir().join("skytex.hdr");
|
||||
if let Some((tex, light)) = skytex_path
|
||||
.exists()
|
||||
.then(|| {
|
||||
Texture::from_cubemap_equirectangular(
|
||||
&stereokit,
|
||||
skytex_path.to_str().unwrap(),
|
||||
true,
|
||||
100,
|
||||
)
|
||||
})
|
||||
.flatten()
|
||||
{
|
||||
stereokit.set_skytex(&tex);
|
||||
stereokit.set_skylight(&light);
|
||||
} else if let Some(tex) = Texture::cubemap_from_spherical_harmonics(
|
||||
&stereokit,
|
||||
&SphericalHarmonics::default(),
|
||||
16,
|
||||
0.0,
|
||||
0.0,
|
||||
) {
|
||||
stereokit.set_skytex(&tex);
|
||||
}
|
||||
}
|
||||
|
||||
let mouse_pointer = cli_args.flatscreen.then(MousePointer::new);
|
||||
let mut hands =
|
||||
(!cli_args.flatscreen).then(|| [SkHand::new(Handed::Left), SkHand::new(Handed::Right)]);
|
||||
|
||||
Reference in New Issue
Block a user