SkSettings

Struct SkSettings 

Source
#[repr(C)]
pub struct SkSettings {
Show 23 fields pub app_name: *const c_char, pub assets_folder: *const c_char, pub mode: AppMode, pub blend_preference: DisplayBlend, pub no_flatscreen_fallback: Bool32T, pub depth_mode: DepthMode, pub log_filter: LogLevel, pub color_format: TexFormat, pub overlay_app: Bool32T, pub overlay_priority: u32, pub flatscreen_pos_x: i32, pub flatscreen_pos_y: i32, pub flatscreen_width: i32, pub flatscreen_height: i32, pub disable_desktop_input_window: Bool32T, pub disable_unfocused_sleep: Bool32T, pub render_scaling: f32, pub render_multisample: i32, pub origin: OriginMode, pub omit_empty_frames: Bool32T, pub standby_mode: StandbyMode, pub android_java_vm: *mut c_void, pub android_activity: *mut c_void,
}
Expand description

StereoKit initialization settings! Setup SkSettings with your data before calling SkSetting.Init(). https://stereokit.net/Pages/StereoKit/SKSettings.html

see also Sk::init Sk::get_settings SkInfo::settings_from sk_init

§Examples

use stereokit_rust::sk::{Sk, SkSettings, AppMode, DisplayBlend, DepthMode, OriginMode, StandbyMode};
use stereokit_rust::{system::LogLevel, tex::TexFormat};

let mut settings = SkSettings::default();
settings.app_name("Test").mode(AppMode::Offscreen);
let sk = Sk::init(&settings).expect("StereoKit should initialize");
let settings = sk.get_settings();
assert_eq!(settings.mode,                        AppMode::Offscreen);
assert_eq!(settings.blend_preference,            DisplayBlend::None);
assert_eq!(settings.no_flatscreen_fallback,      0);
assert_eq!(settings.depth_mode,                  DepthMode::Default);
assert_eq!(settings.color_format,                TexFormat::None);
assert_eq!(settings.log_filter,                  LogLevel::None);
assert_eq!(settings.overlay_app,                 0);
assert_eq!(settings.overlay_priority,            0);
assert_eq!(settings.flatscreen_pos_x,            0);
assert_eq!(settings.flatscreen_pos_y,            0);
assert_eq!(settings.flatscreen_width,            1280);
assert_eq!(settings.flatscreen_height,           720);
assert_eq!(settings.disable_desktop_input_window,0);
assert_eq!(settings.disable_unfocused_sleep,     0);
assert_eq!(settings.render_scaling,              1.0);
assert_eq!(settings.render_multisample,          1);
assert_eq!(settings.origin,                      OriginMode::Local);
assert_eq!(settings.omit_empty_frames,           0);
assert_eq!(settings.standby_mode,                StandbyMode::Pause);
Sk::shutdown();

Fields§

§app_name: *const c_char§assets_folder: *const c_char§mode: AppMode§blend_preference: DisplayBlend§no_flatscreen_fallback: Bool32T§depth_mode: DepthMode§log_filter: LogLevel§color_format: TexFormat§overlay_app: Bool32T§overlay_priority: u32§flatscreen_pos_x: i32§flatscreen_pos_y: i32§flatscreen_width: i32§flatscreen_height: i32§disable_desktop_input_window: Bool32T§disable_unfocused_sleep: Bool32T§render_scaling: f32§render_multisample: i32§origin: OriginMode§omit_empty_frames: Bool32T§standby_mode: StandbyMode§android_java_vm: *mut c_void§android_activity: *mut c_void

Implementations§

Source§

impl SkSettings

Source

pub fn app_name(&mut self, app_name: impl AsRef<str>) -> &mut Self

Name of the application, this shows up an the top of the Win32 window, and is submitted to OpenXR. OpenXR caps this at 128 characters. Default is “StereoKitApp” https://stereokit.net/Pages/StereoKit/SKSettings/appName.html

Source

pub fn mode(&mut self, app_mode: AppMode) -> &mut Self

Which operation mode should we use for this app? Default is XR, and by default the app will fall back to Simulator if XR fails or is unavailable. https://stereokit.net/Pages/StereoKit/SKSettings/appMode.html

Source

pub fn no_flatscreen_fallback( &mut self, no_flatscreen_fallback: bool, ) -> &mut Self

If the preferred display fails, should we avoid falling back to flatscreen and just crash out? Default is false. https://stereokit.net/Pages/StereoKit/SKSettings/noFlatscreenFallback.html

Source

pub fn blend_preference(&mut self, blend_preference: DisplayBlend) -> &mut Self

What kind of depth buffer should StereoKit use? A fast one, a detailed one, one that uses stencils? By default StereoKit will let the XR runtime choose, which typically results in fast, 16bit depth buffers for battery powered devices, and detailed 32bit depth buffers on PCs. If the requested mode is not available, StereoKit will fall back to the XR runtime’s preference. https://stereokit.net/Pages/StereoKit/SKSettings/blendPreference.html

Source

pub fn depth_mode(&mut self, depth_mode: DepthMode) -> &mut Self

What kind of depth buffer should StereoKit use? A fast one, a detailed one, one that uses stencils? By default, StereoKit uses a balanced mix depending on platform, prioritizing speed but opening up when there’s headroom. https://stereokit.net/Pages/StereoKit/SKSettings/depthMode.html

Source

pub fn color_format(&mut self, color_format: TexFormat) -> &mut Self

What kind of color buffer should StereoKit use for the primary display surface? By default StereoKit will let the XR runtime choose from a list that StereoKit likes. This is generally the best choice, as the runtime can pick surface formats that can improve performance. If a requested format is not available, StereoKit will fall back to the XR runtime’s preference. https://stereokit.net/Pages/StereoKit/SKSettings/colorFormat.html

Source

pub fn log_filter(&mut self, log_filter: LogLevel) -> &mut Self

before Initialization occurs, so you can choose to get information from that. Default is LogLevel.Diagnostic. https://stereokit.net/Pages/StereoKit/SKSettings/logFilter.html

Source

pub fn overlay_app(&mut self, overlay_app: bool) -> &mut Self

If the runtime supports it, should this application run as an overlay above existing applications? Check SK.System.overlayApp after initialization to see if the runtime could comply with this flag. This will always force StereoKit to work in a blend compositing mode. https://stereokit.net/Pages/StereoKit/SKSettings/overlayApp.html

Source

pub fn overlay_priority(&mut self, overlay_priority: u32) -> &mut Self

For overlay applications, this is the order in which apps should be composited together. 0 means first, bottom of the stack, and uint.MaxValue is last, on top of the stack. https://stereokit.net/Pages/StereoKit/SKSettings/overlayPriority.html

Source

pub fn flatscreen_pos_x(&mut self, flatscreen_pos_x: i32) -> &mut Self

If using DisplayMode::Flatscreen, the pixel position of the window on the screen. https://stereokit.net/Pages/StereoKit/SKSettings/flatscreenPosX.html

Source

pub fn flatscreen_pos_y(&mut self, flatscreen_pos_y: i32) -> &mut Self

If using DisplayMode::Flatscreen, the pixel position of the window on the screen. https://stereokit.net/Pages/StereoKit/SKSettings/flatscreenPosY.html

Source

pub fn flatscreen_pos( &mut self, flatscreen_pos_x: i32, flatscreen_pos_y: i32, ) -> &mut Self

If using DisplayMode::Flatscreen, the pixel position of the window on the screen. https://stereokit.net/Pages/StereoKit/SKSettings.html

Source

pub fn flatscreen_width(&mut self, flatscreen_width: i32) -> &mut Self

If using DisplayMode::Flatscreen, the pixel size of the window on the screen. https://stereokit.net/Pages/StereoKit/SKSettings/flatscreenWidth.html

Source

pub fn flatscreen_height(&mut self, flatscreen_height: i32) -> &mut Self

If using DisplayMode::Flatscreen, the pixel size of the window on the screen. https://stereokit.net/Pages/StereoKit/SKSettings/flatscreenHeight.html

Source

pub fn flatscreen_size( &mut self, flatscreen_width: i32, flatscreen_height: i32, ) -> &mut Self

If using DisplayMode::Flatscreen, the pixel size of the window on the screen. https://stereokit.net/Pages/StereoKit/SKSettings.html

Source

pub fn disable_desktop_input_window( &mut self, disabled_desktop_input_window: bool, ) -> &mut Self

By default, StereoKit will open a desktop window for keyboard input due to lack of XR-native keyboard APIs on many platforms. If you don’t want this, you can disable it with this setting! https://stereokit.net/Pages/StereoKit/SKSettings/disableDesktopInputWindow.html

Source

pub fn disable_unfocused_sleep( &mut self, disable_unfocused_sleep: bool, ) -> &mut Self

👎Deprecated since 0.40.0: please use standby_mode = StandbyMode::None instead

By default, StereoKit will slow down when the application is out of focus. This is useful for saving processing power while the app is out-of-focus, but may not always be desired. In particular, running multiple copies of a SK app for testing networking code may benefit from this setting. https://stereokit.net/Pages/StereoKit/SKSettings/disableUnfocusedSleep.html

Source

pub fn render_scaling(&mut self, render_scaling: f32) -> &mut Self

If you know in advance that you need this feature, this setting allows you to set Renderer::scaling before initialization. This avoids creating and discarding a large and unnecessary swapchain object. Default value is 1. https://stereokit.net/Pages/StereoKit/SKSettings/renderScaling.html

Source

pub fn render_multisample(&mut self, render_multisample: i32) -> &mut Self

If you know in advance that you need this feature, this setting allows you to set Renderer::multisample before initialization. This avoids creating and discarding a large and unnecessary swapchain object. Default value is 1. https://stereokit.net/Pages/StereoKit/SKSettings/renderMultisample.html

Source

pub fn origin(&mut self, origin_mode: OriginMode) -> &mut Self

Set the behavior of StereoKit’s initial origin. Default behavior is OriginMode.Local, which is the most universally supported origin mode. Different origin modes have varying levels of support on different XR runtimes, and StereoKit will provide reasonable fallbacks for each. NOTE that when falling back, StereoKit will use a different root origin mode plus an offset. You can check World.OriginMode and World.OriginOffset to inspect what StereoKit actually landed on. https://stereokit.net/Pages/StereoKit/SKSettings/origin.html

Source

pub fn omit_empty_frames(&mut self, origin_mode: bool) -> &mut Self

If StereoKit has nothing to render for this frame, it skips submitting a projection layer to OpenXR entirely. https://stereokit.net/Pages/StereoKit/SKSettings/omitEmptyFrames.html

Source

pub fn standby_mode(&mut self, mode: StandbyMode) -> &mut Self

Configures StereoKit’s behavior during device standby. By default in v0.4, SK will completely pause the main thread and disable audio. In v0.3, SK will continue to execute at a throttled pace, and audio will remain on. https://stereokit.net/Pages/StereoKit/SKSettings/omitEmptyFrames.html

Source§

impl SkSettings

Source

pub fn init_with_event_loop( &mut self, ) -> Result<(Sk, EventLoop<StepperAction>), StereoKitError>

Initialise Sk with the given settings parameter (here for non Android platform) https://stereokit.net/Pages/StereoKit/SK/Initialize.html

see also Sk::init_with_event_loop

§Examples
use stereokit_rust::{prelude::*, system::{LogLevel,Renderer}, framework::SkClosures,
                     maths::{Vec3, Matrix, Pose} ,tools::title::Title, util::named_colors};
use stereokit_rust::sk::{Sk, SkSettings, AppMode, DisplayBlend, DepthMode,
                         OriginMode, StandbyMode, QuitReason};

let mut settings = SkSettings::default();
settings
    .app_name("Test")
    .mode(AppMode::Offscreen)
    .origin(OriginMode::Floor)
    .render_multisample(4)
    .render_scaling(0.8)
    .depth_mode(DepthMode::D32)
    .omit_empty_frames(true)
    .log_filter(LogLevel::Diagnostic)
    .no_flatscreen_fallback(true);

let (mut sk, event_loop) = settings.init_with_event_loop()
                               .expect("StereoKit should initialize");

let mut title = Title::new("Sk basic example", Some(named_colors::BLUE), None, None);
title.transform = Matrix::t_r([0.5, 0.5, -1.9], [0.0, 200.0, 0.0]);
sk.send_event(StepperAction::add("Title_blue_ID1", title));

let mut iter = 0;
let number_of_steps = 3;
let filename_scr = "screenshots/sk_basic_example.jpeg";
SkClosures::new(sk, |sk, token|  {
    // Main loop where we draw stuff and do things!!
    if iter > number_of_steps {sk.quit(None)}

    if iter == number_of_steps {
        // render screenshot
        Renderer::screenshot(token, filename_scr, 90, Pose::look_at(Vec3::Z, Vec3::ZERO),
            200, 200, Some(99.0) );
    }

    iter+=1;
})
.shutdown(|sk| {
   // This is called when the app is shutting down
    assert_eq!(sk.get_quit_reason(), QuitReason::User);
    Log::info(format!("QuitReason is {:?}", sk.get_quit_reason()));
})
.run(event_loop);

Sk::shutdown();
screenshot

Trait Implementations§

Source§

impl Clone for SkSettings

Source§

fn clone(&self) -> SkSettings

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SkSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SkSettings

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for SkSettings

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more