Begin work on Raylib impl of agnostic_interface
This commit is contained in:
parent
98bbc98b6b
commit
c9bd639732
6 changed files with 1937 additions and 5 deletions
196
Cargo.lock
generated
196
Cargo.lock
generated
|
@ -2,12 +2,66 @@
|
|||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.64.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"peeking_take_while",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.16"
|
||||
|
@ -19,10 +73,29 @@ dependencies = [
|
|||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "ld45_one_and_all"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"rand",
|
||||
"serde",
|
||||
]
|
||||
|
@ -33,6 +106,59 @@ version = "0.2.126"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "7.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.16"
|
||||
|
@ -41,9 +167,9 @@ checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.39"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f"
|
||||
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
@ -98,6 +224,27 @@ dependencies = [
|
|||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733"
|
||||
dependencies = [
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.137"
|
||||
|
@ -119,10 +266,16 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.96"
|
||||
name = "shlex"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0748dd251e24453cb8717f0354206b91557e4ec8703673a4b30208f2abaf1ebf"
|
||||
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -140,3 +293,36 @@ name = "wasi"
|
|||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
|
|
@ -10,3 +10,10 @@ edition = "2018"
|
|||
#quicksilver = { version = "0.3.19", default-features = false, features = [ "fonts", "saving", "sounds" ] }
|
||||
rand = "0.7.2"
|
||||
serde = { version = "1.0.101", features = ["derive"] }
|
||||
|
||||
[build-dependencies]
|
||||
bindgen = "0.64"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
no_link_raylib = []
|
||||
|
|
29
build.rs
Normal file
29
build.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
extern crate bindgen;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(not(feature = "no_link_raylib"))]
|
||||
fn linking_raylib() {
|
||||
println!("cargo:rustc-link-lib=raylib");
|
||||
}
|
||||
|
||||
#[cfg(feature = "no_link_raylib")]
|
||||
fn linking_raylib() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
linking_raylib();
|
||||
println!("cargo:rerun-if-changed=raylib/raylib.h");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header("raylib/raylib.h")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("raylib_bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
1568
raylib/raylib.h
Normal file
1568
raylib/raylib.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,5 @@
|
|||
pub mod raylib_impl;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use crate::faux_quicksilver::{Circle, Color, Rectangle, Transform, Vector};
|
||||
|
|
140
src/agnostic_interface/raylib_impl.rs
Normal file
140
src/agnostic_interface/raylib_impl.rs
Normal file
|
@ -0,0 +1,140 @@
|
|||
mod ffi {
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/raylib_bindings.rs"));
|
||||
}
|
||||
|
||||
use super::GameInterface;
|
||||
|
||||
struct RaylibGame {
|
||||
width: f32,
|
||||
height: f32,
|
||||
}
|
||||
|
||||
impl RaylibGame {
|
||||
pub fn new_boxed(width: f32, height: f32) -> Box<dyn GameInterface> {
|
||||
Box::new(Self {
|
||||
width,
|
||||
height,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl GameInterface for RaylibGame {
|
||||
fn get_dimensions(&self) -> Result<(f32, f32), String> {
|
||||
Ok((self.width, self.height))
|
||||
}
|
||||
|
||||
fn get_key_pressed(&mut self, key: char) -> Result<bool, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_mouse_pressed(&mut self) -> Result<Option<(f32, f32)>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_mouse_down(&mut self) -> Result<Option<(f32, f32)>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_mouse_xy(&self) -> Result<(f32, f32), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_mouse_xy_vec(&self) -> Result<crate::faux_quicksilver::Vector, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_delta_time(&self) -> f32 {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn clear_window(&mut self, color: crate::faux_quicksilver::Color) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn begin_drawing(&mut self) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn end_drawing(&mut self) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn draw_circle(&mut self, circle: crate::faux_quicksilver::Circle, color: crate::faux_quicksilver::Color) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn draw_circle_ex(
|
||||
&mut self,
|
||||
circle: crate::faux_quicksilver::Circle,
|
||||
color: crate::faux_quicksilver::Color,
|
||||
origin: crate::faux_quicksilver::Vector,
|
||||
rot: f32,
|
||||
) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn draw_circle_transform(
|
||||
&mut self,
|
||||
circle: crate::faux_quicksilver::Circle,
|
||||
color: crate::faux_quicksilver::Color,
|
||||
transform: crate::faux_quicksilver::Transform,
|
||||
) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn draw_rect(&mut self, rect: crate::faux_quicksilver::Rectangle, color: crate::faux_quicksilver::Color) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn draw_rect_ex(
|
||||
&mut self,
|
||||
rect: crate::faux_quicksilver::Rectangle,
|
||||
color: crate::faux_quicksilver::Color,
|
||||
origin: crate::faux_quicksilver::Vector,
|
||||
rot: f32,
|
||||
) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn draw_rect_transform(
|
||||
&mut self,
|
||||
rect: crate::faux_quicksilver::Rectangle,
|
||||
color: crate::faux_quicksilver::Color,
|
||||
transform: crate::faux_quicksilver::Transform,
|
||||
) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn load_image(&mut self, path: &std::path::Path) -> Result<Box<dyn super::ImageInterface>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn load_font(&mut self, path: &std::path::Path) -> Result<Box<dyn super::FontInterface>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn load_sound(&mut self, path: &std::path::Path) -> Result<Box<dyn super::SoundInterface>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn load_music(&mut self, path: &std::path::Path) -> Result<Box<dyn super::MusicInterface>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_camera(&mut self) -> Result<Box<dyn super::CameraInterface>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_default_camera(&mut self) -> Result<Box<dyn super::CameraInterface>, String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn set_camera(&mut self, camera: &Box<dyn super::CameraInterface>) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue