mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-26 05:38:20 -06:00
add pre_startup stage, use msaa settings in window init
This commit is contained in:
parent
46a5da3b26
commit
41a97cbcef
|
@ -51,7 +51,7 @@ use world::{
|
|||
};
|
||||
use player::{spawn_player, MainPlayer};
|
||||
use prefabs::load_prefabs;
|
||||
use settings::load_settings;
|
||||
use settings::{load_settings, GameSettings};
|
||||
use camera::compute_cameras;
|
||||
use events::{
|
||||
clear_events,
|
||||
|
@ -84,11 +84,17 @@ use gui::{render_gui, init_gui, update_gui};
|
|||
use loading_screen::update_loading_screen;
|
||||
use connecting_screen::switch_to_loading_if_connected;
|
||||
|
||||
/// stuff required to init the renderer and other basic systems
|
||||
fn pre_startup() -> Workload {
|
||||
(
|
||||
load_settings,
|
||||
).into_sequential_workload()
|
||||
}
|
||||
|
||||
fn startup() -> Workload {
|
||||
(
|
||||
initial_resize_event,
|
||||
init_window_size,
|
||||
load_settings,
|
||||
load_prefabs,
|
||||
init_primitives,
|
||||
insert_lock_state,
|
||||
|
@ -170,19 +176,26 @@ fn main() {
|
|||
|
||||
//Create a shipyard world
|
||||
let mut world = World::new();
|
||||
|
||||
//Create event loop
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
//Add systems and uniques, Init and load things
|
||||
world.add_unique_non_send_sync(Renderer::init(&event_loop));
|
||||
world.add_unique(BackgroundColor(vec3(0.5, 0.5, 1.)));
|
||||
|
||||
|
||||
//Register workloads
|
||||
world.add_workload(pre_startup);
|
||||
world.add_workload(startup);
|
||||
world.add_workload(update);
|
||||
world.add_workload(render);
|
||||
world.add_workload(after_frame_end);
|
||||
|
||||
//Run pre-startup procedure
|
||||
world.run_workload(pre_startup).unwrap();
|
||||
|
||||
//Create event loop
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
//Initialize renderer
|
||||
{
|
||||
let settings = world.borrow::<UniqueView<GameSettings>>().unwrap();
|
||||
world.add_unique_non_send_sync(Renderer::init(&event_loop, &settings));
|
||||
}
|
||||
world.add_unique(BackgroundColor(vec3(0.5, 0.5, 1.)));
|
||||
|
||||
//Save _visualizer.json
|
||||
#[cfg(feature = "generate_visualizer_data")]
|
||||
|
|
|
@ -9,7 +9,7 @@ use glium::{
|
|||
},
|
||||
};
|
||||
use glam::{Vec3, UVec2};
|
||||
use crate::events::WindowResizedEvent;
|
||||
use crate::{events::WindowResizedEvent, settings::GameSettings};
|
||||
|
||||
pub mod primitives;
|
||||
pub mod world;
|
||||
|
@ -29,13 +29,14 @@ pub struct Renderer {
|
|||
pub display: Display
|
||||
}
|
||||
impl Renderer {
|
||||
pub fn init(event_loop: &EventLoop<()>) -> Self {
|
||||
pub fn init(event_loop: &EventLoop<()>, settings: &GameSettings) -> Self {
|
||||
log::info!("initializing display");
|
||||
let wb = WindowBuilder::new()
|
||||
.with_title("uwu")
|
||||
.with_maximized(true);
|
||||
let cb = ContextBuilder::new()
|
||||
.with_depth_buffer(24)
|
||||
.with_multisampling(settings.msaa.unwrap_or_default())
|
||||
.with_gl_profile(GlProfile::Core);
|
||||
let display = Display::new(wb, cb, event_loop)
|
||||
.expect("Failed to create a glium Display");
|
||||
|
|
|
@ -2,7 +2,7 @@ use shipyard::{Unique, AllStoragesView};
|
|||
|
||||
#[derive(Unique)]
|
||||
pub struct GameSettings {
|
||||
pub msaa: Option<u8>,
|
||||
pub msaa: Option<u16>,
|
||||
pub max_anisotropy: Option<u16>,
|
||||
/// there's a 1 chunk border of loaded but invisible around this
|
||||
pub render_distance: u8,
|
||||
|
@ -24,6 +24,7 @@ impl Default for GameSettings {
|
|||
pub fn load_settings(
|
||||
storages: AllStoragesView
|
||||
) {
|
||||
log::info!("loading game settings");
|
||||
//todo
|
||||
storages.add_unique(GameSettings::default());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue