Skip to content

Commit

Permalink
unjank almost all dependencies (glam25 needs a temporary hack)
Browse files Browse the repository at this point in the history
  • Loading branch information
pillowtrucker committed Feb 16, 2024
1 parent d898328 commit 9bcf0bd
Show file tree
Hide file tree
Showing 10 changed files with 219 additions and 113 deletions.
271 changes: 184 additions & 87 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions brainworms_arson/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
egui = { version = "0.25", git = "https://github.com/emilk/egui.git", branch="master"}
egui-wgpu = {version = "0.25", git = "https://github.com/emilk/egui.git", branch="master", features = ["winit"] }
egui-winit = {version = "0.25", git = "https://github.com/emilk/egui.git", branch="master", default-features = false, features = ["clipboard", "links", "wayland"] }
#egui = { version = "0.26", git = "https://github.com/emilk/egui.git", branch="master"}
#egui-wgpu = {version = "0.26", git = "https://github.com/emilk/egui.git", branch="master", features = ["winit"] }
#egui-winit = {version = "0.26", git = "https://github.com/emilk/egui.git", branch="master", default-features = false, features = ["clipboard", "links", "wayland"] }
egui = { version = "0.26"}
egui-wgpu = {version = "0.26"}
egui-winit = {version = "0.26"}
nanorand = { version = "0.7", default-features = false, features = ["wyrand"] }
nom = "7"
anyhow = "1"
4 changes: 3 additions & 1 deletion brainworms_arson/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ impl Widget for KineticLabel {
angle: 0.0,
fallback_color: response_color,
override_text_color: Some(response_color),
opacity_factor: 1.,
});
};
if self.kinesis.is_none() {
Expand All @@ -359,7 +360,8 @@ impl Widget for KineticLabel {
underline,
angle: 0.0,
fallback_color: response_color,
override_text_color: None, // override_text_color: Some(response_color),
override_text_color: None,
opacity_factor: 1., // override_text_color: Some(response_color),
};
let clipped_shape: ClippedShape = ClippedShape {
clip_rect: Rect::EVERYTHING,
Expand Down
5 changes: 3 additions & 2 deletions brainworms_lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["wgpu", "rend3", "not-bevy", "no-ecs", "game", "program"]
[dependencies]
brainworms_arson = {path = "../brainworms_arson"}
brainworms_farting_noises = {path = "../brainworms_farting_noises"}
wgpu = { version = "0.18", default-features = false }
wgpu = { version = "0.19", default-features = false }

pollster = "0.3.0"
log = "0.4.20"
Expand All @@ -26,6 +26,7 @@ env_logger = "0.10.2"

# Linear algebra library
glam = "0.24"
glam25compat = {package = "glam", version = "0.25"}
# Importing png's
image = { version = "0.24.3", default-features = false, features = ["png","jpeg","tiff"] }
# Renderer core
Expand All @@ -45,7 +46,7 @@ inox2d-wgpu = {path = "../inox2d/inox2d-wgpu"}
bytemuck = { version = "1.14.1", features = ["derive"] }

pico-args = "0.5"
wgpu-profiler = "0.15.0"
#wgpu-profiler = "0.15.0"
#gluon = {git = "https://github.com/gluon-lang/gluon", branch = "master"}

cfg-if = "1"
Expand Down
17 changes: 11 additions & 6 deletions brainworms_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ pub use parry3d;
use rend3::types::DirectionalLight;
pub use rend3_routine;
use rend3_routine::base::BaseRenderGraph;
use std::{sync::Arc, time};
use std::{
sync::Arc,
time::{self, Duration},
};
pub use the_great_mind_palace_of_theatrical_arts as theater;
use theater::{
basement::{
Expand Down Expand Up @@ -120,6 +123,7 @@ impl<
.unwrap();

let window_size = window.inner_size();
let window = Arc::new(window);
// The one line of unsafe needed. We just need to guarentee that the window
// outlives the use of the surface.
//
Expand All @@ -129,7 +133,7 @@ impl<
None
} else {
Some(Arc::new(
unsafe { iad.instance.create_surface(&window) }.unwrap(),
iad.instance.create_surface(window.clone()).unwrap(),
))
};
let renderer = rend3::Renderer::new(
Expand All @@ -138,7 +142,7 @@ impl<
Some(window_size.width as f32 / window_size.height as f32),
)
.unwrap();
self.state.window = Some(Arc::new(window));
self.state.window = Some(window.clone());
self.state.renderer = Some(renderer.clone());
let window = self.state.window.clone().unwrap();
// Get the preferred format for the surface.
Expand Down Expand Up @@ -209,7 +213,7 @@ impl<
let mut control_flow = event_loop_window_target.control_flow();
if let Some(suspend) = Self::handle_surface(
&mut self,
&window,
window.clone(),
&event,
&iad.instance,
&mut surface,
Expand Down Expand Up @@ -386,14 +390,15 @@ impl<
.unwrap()
{
let t = game_data.timestamp_start.elapsed().as_secs_f32();
let dt = game_state.last_update.unwrap().elapsed().as_secs_f32();
let actresses = cs_implementation.actresses.values();
for a in actresses {
let renderer = Arc::clone(&renderer);
let a = Arc::clone(a);
// this kind of makes self.spawn at best useless and probably counter-productive
self.rts.as_ref().map(|rts| {
rts.spawn(async move {
draw_actor(a, renderer, t);
draw_actor(a, renderer, t, dt);
})
});
}
Expand Down Expand Up @@ -427,7 +432,7 @@ impl<
match event {
WindowEvent::CloseRequested => {
let the_rt = self.rts.take();
the_rt.unwrap().shutdown_background();
the_rt.unwrap().shutdown_timeout(Duration::from_secs(10));
event_loop_window_target.exit();
}
winit::event::WindowEvent::Resized(size) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pub(crate) fn extract_backend(value: &str) -> Result<Backend, &'static str> {
Ok(match value.to_lowercase().as_str() {
"vulkan" | "vk" => Backend::Vulkan,
"dx12" | "12" => Backend::Dx12,
"dx11" | "11" => Backend::Dx11,
"metal" | "mtl" => Backend::Metal,
"opengl" | "gl" => Backend::Gl,
_ => return Err("unknown backend"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<PlayablesEnum: Playable<InputContextEnum> + 'static, InputContextEnum: Inpu
#[allow(clippy::too_many_arguments)]
pub(crate) fn handle_surface(
&mut self,
window: &Window,
window: Arc<Window>,
event: &Event,
instance: &Instance,
surface: &mut Option<Arc<Surface>>,
Expand All @@ -109,9 +109,7 @@ impl<PlayablesEnum: Playable<InputContextEnum> + 'static, InputContextEnum: Inpu
Event::Resumed => {
if surface.is_none() {
// uhh this is still the same one line of unsafe I guess but for android
*surface = Some(Arc::new(
unsafe { instance.create_surface(window) }.unwrap(),
));
*surface = Some(Arc::new(instance.create_surface(window.clone()).unwrap()));
}
Some(false)
}
Expand Down Expand Up @@ -154,6 +152,7 @@ impl<PlayablesEnum: Playable<InputContextEnum> + 'static, InputContextEnum: Inpu
present_mode: wgpu::PresentMode::Immediate,
alpha_mode,
view_formats: Vec::new(),
desired_maximum_frame_latency: 2,
};

surface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{num::NonZeroU32, sync::Arc};

use glam::{uvec2, vec2, Vec2};
use glam::uvec2;
use inox2d::formats::inp::parse_inp;
use parking_lot::Mutex;
use rend3::{types::MipmapCount, Renderer};
Expand Down Expand Up @@ -35,7 +35,7 @@ pub enum AstinkSprite {
Loaded((String, uuid::Uuid, Actress)),
}

pub(crate) fn draw_actor(a: Arc<Mutex<AstinkSprite>>, renderer: Arc<Renderer>, t: f32) {
pub(crate) fn draw_actor(a: Arc<Mutex<AstinkSprite>>, renderer: Arc<Renderer>, t: f32, dt: f32) {
let mut a = a.lock();
let AstinkSprite::Loaded((_, _, ref mut actress)) = *a else {
return;
Expand All @@ -46,9 +46,9 @@ pub(crate) fn draw_actor(a: Arc<Mutex<AstinkSprite>>, renderer: Arc<Renderer>, t

puppet.begin_set_params();

puppet.set_param("Head:: Yaw-Pitch", vec2(t.cos(), t.sin()));
puppet.set_named_param("Head:: Yaw-Pitch", glam25compat::vec2(t.cos(), t.sin()));

puppet.end_set_params();
puppet.end_set_params(dt);
}

let inox_texture_rend3_handle = actress.texture_rend3_handle.clone();
Expand Down Expand Up @@ -93,7 +93,7 @@ pub async fn create_actor(
) {
let path = format!("{}/{}.inp", &directory, name);
let format = TextureFormat::Bgra8Unorm;
let texture_size_uvec2 = uvec2(8192, 8192); // we no longer care about the surface size for the sprite texture
let texture_size_uvec2 = glam25compat::uvec2(8192, 8192); // we no longer care about the surface size for the sprite texture

let texture_size = wgpu::Extent3d {
width: texture_size_uvec2.x,
Expand All @@ -112,7 +112,7 @@ pub async fn create_actor(
texture_size_uvec2,
);

inox_renderer.camera.scale = Vec2::splat(1.0);
inox_renderer.camera.scale = glam25compat::Vec2::splat(1.0);

let inox_texture_descriptor = wgpu::TextureDescriptor {
size: texture_size,
Expand All @@ -132,7 +132,7 @@ pub async fn create_actor(
base_mip_level: 0,
..Default::default()
});

let texture_size_uvec2 = uvec2(8192, 8192); // we no longer care about the surface size for the sprite texture
let inox_texture_rend3 = rend3::types::Texture {
label: Some("inox texture but rend3".to_owned()),
format,
Expand Down

0 comments on commit 9bcf0bd

Please sign in to comment.