Skip to content

Commit

Permalink
GameRuntime & Game cleanup
Browse files Browse the repository at this point in the history
Fixes #390
  • Loading branch information
SakulFlee committed Dec 2, 2024
1 parent b152d9a commit 87afba8
Show file tree
Hide file tree
Showing 39 changed files with 61 additions and 386 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
use std::time::Duration;

use crate::app::AppSettings;

#[derive(Default, Debug, Clone)]
pub struct GameSettings {// TODO: Cleanup
pub app_settings: AppSettings,
pub pipeline_cache: CacheSettings,
pub material_cache: CacheSettings,
}

#[derive(Debug, Clone)]
pub struct CacheSettings {
pub cleanup_interval: Duration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use orbital::{
app::AppChange,
async_trait::{async_trait},
cgmath::{Point3, Vector3},
game::{CameraChange, Element, ElementRegistration, Message, Mode, WorldChange},
world::{CameraChange, Element, ElementRegistration, Message, Mode, WorldChange},
gilrs::Button,
input::{InputAxis, InputButton, InputState},
resources::descriptors::CameraDescriptor,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use orbital::{
async_trait::async_trait,
cgmath::Vector3,
game::{Element, ElementRegistration, Message, WorldChange},
world::{Element, ElementRegistration, Message, WorldChange},
input::InputState,
loader::{GLTFLoader, GLTFWorkerMode},
transform::Transform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Instant;

use orbital::{
async_trait::async_trait,
game::{Element, ElementRegistration, Message, WorldChange},
world::{Element, ElementRegistration, Message, WorldChange},
input::InputState,
log::debug,
resources::descriptors::SkyboxType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use orbital::{
cgmath::Vector3,
game::{Element, ElementRegistration, WorldChange},
resources::{descriptors::LightDescriptor, realizations::PointLight},
world::{Element, ElementRegistration, WorldChange},
};

#[derive(Debug)]
Expand Down
17 changes: 17 additions & 0 deletions Example/src/app/elements/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mod camera;
pub use camera::*;

mod damaged_helmet;
pub use damaged_helmet::*;

mod debug_world_environment;
pub use debug_world_environment::*;

mod lights;
pub use lights::*;

mod pbr_spheres;
pub use pbr_spheres::*;

mod ping_pong;
pub use ping_pong::*;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use orbital::{
game::{Element, ElementRegistration, WorldChange},
world::{Element, ElementRegistration, WorldChange},
loader::{GLTFLoader, GLTFWorkerMode},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use orbital::{
async_trait::async_trait,
game::{Element, ElementRegistration, Message, WorldChange},
world::{Element, ElementRegistration, Message, WorldChange},
hashbrown::HashMap,
input::InputState,
variant::Variant,
Expand Down
11 changes: 6 additions & 5 deletions Example/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ use std::time::Instant;
use orbital::{
app::{App, AppChange},
cgmath::Vector2,
game::{CacheSettings, World, WorldChange},
input::InputState,
log::{debug, info, warn},
renderer::Renderer,
resources::realizations::{Material, Pipeline},
timer::Timer,
wgpu::{Device, Queue, SurfaceConfiguration, TextureView},
world::{World, WorldChange},
};

use crate::game::elements::{
camera::Camera, damaged_helmet::DamagedHelmet, debug_world_environment::DebugWorldEnvironment,
lights::Lights, pbr_spheres::PBRSpheres, ping_pong::PingPongElement,
};
mod cache_settings;
pub use cache_settings::*;

mod elements;
use elements::*;

pub struct MyApp<RendererImpl: Renderer + Send> {
renderer: Option<RendererImpl>,
Expand Down
7 changes: 5 additions & 2 deletions Example/src/entrypoint.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use orbital::{
app::{AppRuntime, AppSettings}, game::CacheSettings, logging, renderer::StandardRenderer, winit::{error::EventLoopError, event_loop::EventLoop}
app::{AppRuntime, AppSettings},
logging,
renderer::StandardRenderer,
winit::{error::EventLoopError, event_loop::EventLoop},
};

use crate::app::MyApp;
use crate::app::{CacheSettings, MyApp};

pub fn entrypoint(event_loop_result: Result<EventLoop<()>, EventLoopError>) {
logging::init();
Expand Down
6 changes: 0 additions & 6 deletions Example/src/game/elements/mod.rs

This file was deleted.

44 changes: 0 additions & 44 deletions Example/src/game/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion Example/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod app;
pub mod game;

pub mod entrypoint;

Expand Down
13 changes: 1 addition & 12 deletions Orbital/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@ edition = "2021"
crate-type = ["lib", "cdylib"]

[features]
default = [
"gltf",
"game_runtime",
"gamepad_input",
"gamepad_input_poll",
"auto_request_redraw",
]
default = ["gltf", "gamepad_input", "gamepad_input_poll", "auto_request_redraw"]
# Enables glTF support.
gltf = ["dep:easy-gltf", "easy-gltf/names"]
# Enables the game runtime and integrates it into the app runtime.
# This will make many things easier to implement as many things will be handled by the game runtime automatically, while the game-dev can focus on the game.
# However, this can be too restrictive for a few games.
# Disabling this feature will give you full control over everything, or, just to implement a simple app, rather than a full game.
game_runtime = []
# Enables gamepad inputs from being polled and processed.
# Note: Winit _does_ have _some_ gamepad input support, but it's not very good at the moment, gilrs takes a much better approach (for now?).
gamepad_input = ["dep:gilrs"]
Expand Down
6 changes: 3 additions & 3 deletions Orbital/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ use crate::input::InputState;
/// [EventLoop]: crate::winit::event_loop::EventLoop
/// [EventLoops]: crate::winit::event_loop::EventLoop
/// [Apps]: crate::app::App
/// [Game]: crate::game::Game
/// [Games]: crate::game::Game
/// [GameRuntime]: crate::game::GameRuntime
/// [Game]: crate::world::Game
/// [Games]: crate::world::Game
/// [GameRuntime]: crate::world::GameRuntime
/// [winit]: crate::winit
pub trait App {
/// Gets called upon the [App] getting resumed _OR_ when the [App] got initiated first time and we know have access to the GPU via [Device] & [Queue].
Expand Down
Loading

0 comments on commit 87afba8

Please sign in to comment.