mirror of
https://github.com/Zenithsiz/zsw.git
synced 2026-02-04 02:08:37 +00:00
Moved renderer to it's own crate.
This commit is contained in:
parent
71728709eb
commit
eb8a04b4bd
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -2431,6 +2431,7 @@ dependencies = [
|
||||
"zsw-panels",
|
||||
"zsw-playlist",
|
||||
"zsw-profiles",
|
||||
"zsw-renderer",
|
||||
"zsw-settings-window",
|
||||
"zsw-side-effect-macros",
|
||||
"zsw-util",
|
||||
@ -2516,6 +2517,25 @@ dependencies = [
|
||||
"zsw-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zsw-renderer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-lock",
|
||||
"egui_wgpu_backend",
|
||||
"log",
|
||||
"pollster",
|
||||
"winit",
|
||||
"zsw-egui",
|
||||
"zsw-img",
|
||||
"zsw-panels",
|
||||
"zsw-settings-window",
|
||||
"zsw-side-effect-macros",
|
||||
"zsw-util",
|
||||
"zsw-wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zsw-settings-window"
|
||||
version = "0.1.0"
|
||||
|
||||
@ -10,6 +10,7 @@ members = [
|
||||
"zsw-profiles",
|
||||
"zsw-util",
|
||||
"zsw-settings-window",
|
||||
"zsw-renderer",
|
||||
"zsw-side-effect-macros",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
33
zsw-renderer/Cargo.toml
Normal file
33
zsw-renderer/Cargo.toml
Normal file
@ -0,0 +1,33 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "zsw-renderer"
|
||||
version = "0.1.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
# Zsw
|
||||
zsw-egui = {path = "../zsw-egui"}
|
||||
zsw-img = {path = "../zsw-img"}
|
||||
zsw-panels = {path = "../zsw-panels"}
|
||||
zsw-settings-window = {path = "../zsw-settings-window"}
|
||||
zsw-side-effect-macros = {path = "../zsw-side-effect-macros"}
|
||||
zsw-util = {path = "../zsw-util"}
|
||||
zsw-wgpu = {path = "../zsw-wgpu"}
|
||||
|
||||
# Windowing
|
||||
winit = "0.26.1"
|
||||
|
||||
# Gui
|
||||
egui_wgpu_backend = "0.16.0"
|
||||
|
||||
# Async
|
||||
async-lock = "2.4.0"
|
||||
pollster = "0.2.4"
|
||||
|
||||
# Error handling
|
||||
anyhow = "1.0.52"
|
||||
|
||||
# Logging
|
||||
log = "0.4.14"
|
||||
@ -1,5 +1,54 @@
|
||||
//! Renderer
|
||||
|
||||
// Features
|
||||
#![feature(never_type)]
|
||||
// Lints
|
||||
#![warn(
|
||||
clippy::pedantic,
|
||||
clippy::nursery,
|
||||
missing_copy_implementations,
|
||||
missing_debug_implementations,
|
||||
noop_method_call,
|
||||
unused_results
|
||||
)]
|
||||
#![deny(
|
||||
// We want to annotate unsafe inside unsafe fns
|
||||
unsafe_op_in_unsafe_fn,
|
||||
// We muse use `expect` instead
|
||||
clippy::unwrap_used
|
||||
)]
|
||||
#![allow(
|
||||
// Style
|
||||
clippy::implicit_return,
|
||||
clippy::multiple_inherent_impl,
|
||||
clippy::pattern_type_mismatch,
|
||||
// `match` reads easier than `if / else`
|
||||
clippy::match_bool,
|
||||
clippy::single_match_else,
|
||||
//clippy::single_match,
|
||||
clippy::self_named_module_files,
|
||||
clippy::items_after_statements,
|
||||
clippy::module_name_repetitions,
|
||||
// Performance
|
||||
clippy::suboptimal_flops, // We prefer readability
|
||||
// Some functions might return an error in the future
|
||||
clippy::unnecessary_wraps,
|
||||
// Due to working with windows and rendering, which use `u32` / `f32` liberally
|
||||
// and interchangeably, we can't do much aside from casting and accepting possible
|
||||
// losses, although most will be lossless, since we deal with window sizes and the
|
||||
// such, which will fit within a `f32` losslessly.
|
||||
clippy::cast_precision_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
// We use proper error types when it matters what errors can be returned, else,
|
||||
// such as when using `anyhow`, we just assume the caller won't check *what* error
|
||||
// happened and instead just bubbles it up
|
||||
clippy::missing_errors_doc,
|
||||
// Too many false positives and not too important
|
||||
clippy::missing_const_for_fn,
|
||||
// This is a binary crate, so we don't expose any API
|
||||
rustdoc::private_intra_doc_links,
|
||||
)]
|
||||
|
||||
// Imports
|
||||
use {
|
||||
anyhow::Context,
|
||||
@ -17,6 +66,7 @@ use {
|
||||
};
|
||||
|
||||
/// Renderer
|
||||
#[derive(Debug)]
|
||||
pub struct Renderer {
|
||||
/// Frame timings
|
||||
frame_timings: Mutex<FrameTimings>,
|
||||
@ -24,7 +74,7 @@ pub struct Renderer {
|
||||
|
||||
impl Renderer {
|
||||
/// Creates a new renderer
|
||||
pub fn new() -> Self {
|
||||
#[must_use] pub fn new() -> Self {
|
||||
Self {
|
||||
frame_timings: Mutex::new(FrameTimings::new()),
|
||||
}
|
||||
@ -201,7 +251,14 @@ impl Renderer {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Renderer {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
/// Frame timings
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct FrameTimings {
|
||||
/// Timings
|
||||
timings: [FrameTiming; 60],
|
||||
@ -12,6 +12,7 @@ zsw-img = {path = "../zsw-img"}
|
||||
zsw-panels = {path = "../zsw-panels"}
|
||||
zsw-playlist = {path = "../zsw-playlist"}
|
||||
zsw-profiles = {path = "../zsw-profiles"}
|
||||
zsw-renderer = {path = "../zsw-renderer"}
|
||||
zsw-settings-window = {path = "../zsw-settings-window"}
|
||||
zsw-side-effect-macros = {path = "../zsw-side-effect-macros"}
|
||||
zsw-util = {path = "../zsw-util"}
|
||||
|
||||
@ -6,11 +6,10 @@
|
||||
|
||||
// Modules
|
||||
mod event_handler;
|
||||
mod renderer;
|
||||
|
||||
// Imports
|
||||
use {
|
||||
self::{event_handler::EventHandler, renderer::Renderer},
|
||||
self::event_handler::EventHandler,
|
||||
crate::Args,
|
||||
anyhow::Context,
|
||||
cgmath::{Point2, Vector2},
|
||||
@ -31,6 +30,7 @@ use {
|
||||
zsw_panels::Panels,
|
||||
zsw_playlist::Playlist,
|
||||
zsw_profiles::Profiles,
|
||||
zsw_renderer::Renderer,
|
||||
zsw_settings_window::SettingsWindow,
|
||||
zsw_util::{FutureRunner, MightLock, Rect, WithSideEffect},
|
||||
zsw_wgpu::Wgpu,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user