Skip to content

Commit

Permalink
Made multisampling a command-line argument since it can't be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
superlou committed Jun 11, 2023
1 parent 42cf12e commit 16ecac4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/js_env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl JsEnv {
Ok(())
}

pub fn get_value<T, K>(&mut self, key: K) -> Result<T, JsError>
pub fn _get_value<T, K>(&mut self, key: K) -> Result<T, JsError>
where K: Into<PropertyKey>,
T: TryFromJs
{
Expand All @@ -171,7 +171,7 @@ impl JsEnv {
Ok(value)
}

pub fn get_array<T, K>(&mut self, key: K) -> Result<Vec<T>, JsError>
pub fn _get_array<T, K>(&mut self, key: K) -> Result<Vec<T>, JsError>
where K: Into<PropertyKey>,
T: TryFromJs
{
Expand Down
15 changes: 7 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ FLAGS:
#[derive(Debug)]
struct SignArgs {
app_path: String,
multisampling: u16,
}

fn parse_args() -> Result<SignArgs, pico_args::Error> {
Expand All @@ -32,6 +33,7 @@ fn parse_args() -> Result<SignArgs, pico_args::Error> {

let args = SignArgs {
app_path: pargs.free_from_str()?,
multisampling: pargs.opt_value_from_str("--multisampling")?.unwrap_or(1),
};

Ok(args)
Expand All @@ -47,20 +49,17 @@ fn main() {
};

let app_path = args.app_path;
println!("Starting {}...", &app_path);
let mut handler = SignWindowHandler::new(app_path);
// let resolution = handler.get_resolution().expect("Script didn't set resolution!");
let multisampling = handler.get_multisampling().unwrap_or(1_u16);

// println!("Resolution: {}x{}", resolution.0, resolution.1);
println!("Multisampling: {}", multisampling);
let handler = SignWindowHandler::new(&app_path);

let options = WindowCreationOptions::new_windowed(WindowSize::PhysicalPixels((640, 480).into()), None)
.with_multisampling(multisampling).with_fixed_resolution(true);
.with_multisampling(args.multisampling)
.with_fixed_resolution(true);

let window: Window<String> = Window::new_with_user_events("Title", options)
.expect("Failed to create window!");

println!("Starting {}...", &app_path);
println!("Multisampling: {}", args.multisampling);
window.run_loop(handler);

}
7 changes: 0 additions & 7 deletions src/window_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,6 @@ impl SignWindowHandler {
file_change_rx: rx,
}
}

pub fn get_multisampling(&mut self) -> Option<u16> {
match self.script_env.get_value::<i32, _>("multisampling") {
Ok(value) => Some(value as u16),
Err(_) => None,
}
}

fn get_image_handle(&mut self, path_string: &str, graphics: &mut Graphics2D) -> ImageHandle {
let mut created = false;
Expand Down

0 comments on commit 16ecac4

Please sign in to comment.