]> git.seodisparate.com - LudumDare45_StartWithNothing/commitdiff
Fix native build
authorStephen Seo <seo.disparate@gmail.com>
Wed, 22 Feb 2023 05:21:50 +0000 (14:21 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Wed, 22 Feb 2023 05:21:50 +0000 (14:21 +0900)
Cargo.lock
Cargo.toml
build.rs
src/bin.rs [new file with mode: 0644]
src/lib.rs
src/main.rs [deleted file]

index 91bff41cda6da8b4db89c41ba76ea3e7ef7b1c70..712ae333dd150809430b52d48fbd8874ea2eb150 100644 (file)
@@ -247,18 +247,18 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
 
 [[package]]
 name = "serde"
-version = "1.0.137"
+version = "1.0.152"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
+checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
 dependencies = [
  "serde_derive",
 ]
 
 [[package]]
 name = "serde_derive"
-version = "1.0.137"
+version = "1.0.152"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
+checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
 dependencies = [
  "proc-macro2",
  "quote",
index 920779b1126cd8a6a92588a2820d085a7e3ea9cf..aeb771bc256f018de9526e05c6917296fdce0e69 100644 (file)
@@ -14,15 +14,11 @@ serde = { version = "1.0.101", features = ["derive"] }
 [build-dependencies]
 bindgen = "0.64"
 
-[features]
-default = []
-no_link_libs = []
-
 [lib]
 name = "ld45_lib"
-crate-type = ["staticlib"]
-required-features = ["no_link_libs"]
+path = "src/lib.rs"
+crate-type = ["rlib", "staticlib"]
 
 [[bin]]
 name = "ld45_bin"
-path = "src/main.rs"
+path = "src/bin.rs"
index e16c200922e8296dac199a62a5661093f3e7358c..1bb9aed5ac2b851e4d321399c9f8e9463a65eabb 100644 (file)
--- a/build.rs
+++ b/build.rs
@@ -3,17 +3,9 @@ extern crate bindgen;
 use std::env;
 use std::path::PathBuf;
 
-#[cfg(not(feature = "no_link_libs"))]
-fn linking_libs() {
+fn main() {
     println!("cargo:rustc-link-lib=raylib");
     println!("cargo:rustc-link-lib=OpenGL");
-}
-
-#[cfg(feature = "no_link_libs")]
-fn linking_libs() {}
-
-fn main() {
-    linking_libs();
     println!("cargo:rerun-if-changed=raylib/raylib.h");
 
     let bindings = bindgen::Builder::default()
diff --git a/src/bin.rs b/src/bin.rs
new file mode 100644 (file)
index 0000000..cdbbb6f
--- /dev/null
@@ -0,0 +1,17 @@
+use ld45_lib::agnostic_interface;
+
+fn will_close() -> bool {
+    unsafe { agnostic_interface::raylib_impl::ffi::WindowShouldClose() }
+}
+
+fn main() {
+    let state_ptr = ld45_lib::ld45_initialize();
+
+    while !will_close() {
+        ld45_lib::ld45_iterate(state_ptr);
+    }
+
+    unsafe {
+        drop(Box::from_raw(state_ptr as *mut ld45_lib::WasmState));
+    }
+}
index 0331a45247489aa0275a04722e5d1dd3c875894b..7e6484f8d41571a8aba4422b2292dc2bc79b7f67 100644 (file)
@@ -1,4 +1,4 @@
-mod agnostic_interface;
+pub mod agnostic_interface;
 mod faux_quicksilver;
 mod original_impl;
 mod shaders;
@@ -7,7 +7,7 @@ use agnostic_interface::raylib_impl::RaylibGame;
 use faux_quicksilver::Window;
 use original_impl::GameState;
 
-struct WasmState {
+pub struct WasmState {
     pub window: Window,
     pub game_state: GameState,
 }
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644 (file)
index 6241b62..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-use agnostic_interface::raylib_impl::RaylibGame;
-use faux_quicksilver::Window;
-use original_impl::GameState;
-
-mod agnostic_interface;
-mod faux_quicksilver;
-mod original_impl;
-mod shaders;
-
-fn will_close() -> bool {
-    unsafe { agnostic_interface::raylib_impl::ffi::WindowShouldClose() }
-}
-
-fn main() {
-    // TODO
-    //run::<GameState>(
-    //    "One And All - a Ludum Dare 45 compo entry",
-    //    Vector::new(800, 600),
-    //    Settings::default(),
-    //);
-
-    let game_interface = RaylibGame::new_boxed(800, 600);
-    let mut window = Window::new(game_interface);
-    let mut game_state = GameState::new(&mut window).unwrap();
-
-    while !will_close() {
-        window.update_music().unwrap();
-        game_state.update(&mut window).unwrap();
-        game_state.draw(&mut window).unwrap();
-    }
-}