move assert_renderer to

This commit is contained in:
griffi-gh 2023-02-10 00:49:05 +01:00
parent 39b97eb990
commit 7edf3529db
3 changed files with 14 additions and 11 deletions

View file

@ -1,17 +1,10 @@
use shipyard::{AllStoragesView, NonSendSync, UniqueView}; use shipyard::AllStoragesView;
use glium::{Version, Api};
use std::{env, net::SocketAddr}; use std::{env, net::SocketAddr};
use crate::{ use crate::{
networking::{GameType, ServerAddress}, networking::{GameType, ServerAddress},
state::GameState, rendering::Renderer state::GameState
}; };
pub fn assert_renderer(
renderer: NonSendSync<UniqueView<Renderer>>
) {
assert!(renderer.display.is_glsl_version_supported(&Version(Api::GlEs, 3, 0)), "GLES 3.0 is not supported");
}
pub fn initialize_from_args( pub fn initialize_from_args(
all_storages: AllStoragesView, all_storages: AllStoragesView,
) { ) {

View file

@ -57,6 +57,7 @@ use rendering::{
RenderTarget, RenderTarget,
BackgroundColor, BackgroundColor,
clear_background, clear_background,
assert_renderer,
primitives::init_primitives, primitives::init_primitives,
selection_box::render_selection_box, selection_box::render_selection_box,
world::draw_world, world::draw_world,
@ -67,7 +68,7 @@ use delta_time::{DeltaTime, init_delta_time};
use cursor_lock::{insert_lock_state, update_cursor_lock_state, lock_cursor_now}; use cursor_lock::{insert_lock_state, update_cursor_lock_state, lock_cursor_now};
use control_flow::{exit_on_esc, insert_control_flow_unique, SetControlFlow}; use control_flow::{exit_on_esc, insert_control_flow_unique, SetControlFlow};
use state::{is_ingame, is_ingame_or_loading, is_loading}; use state::{is_ingame, is_ingame_or_loading, is_loading};
use init::{initialize_from_args, assert_renderer}; use init::initialize_from_args;
use gui::{render_gui, init_gui, gui_testing, update_gui}; use gui::{render_gui, init_gui, gui_testing, update_gui};
fn startup() -> Workload { fn startup() -> Workload {

View file

@ -1,6 +1,7 @@
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut}; use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut};
use glium::{ use glium::{
Display, Surface, Display, Surface,
Version, Api,
glutin::{ glutin::{
event_loop::EventLoop, event_loop::EventLoop,
window::WindowBuilder, window::WindowBuilder,
@ -34,10 +35,18 @@ impl Renderer {
.with_gl_profile(GlProfile::Core); .with_gl_profile(GlProfile::Core);
let display = Display::new(wb, cb, event_loop) let display = Display::new(wb, cb, event_loop)
.expect("Failed to create a glium Display"); .expect("Failed to create a glium Display");
log::info!("renderer: {}", display.get_opengl_renderer_string());
log::info!("oepngl {}", display.get_opengl_version_string());
Self { display } Self { display }
} }
} }
pub fn assert_renderer(
renderer: NonSendSync<UniqueView<Renderer>>
) {
assert!(renderer.display.is_glsl_version_supported(&Version(Api::GlEs, 3, 0)), "GLES 3.0 is not supported");
}
pub fn clear_background( pub fn clear_background(
mut target: NonSendSync<UniqueViewMut<RenderTarget>>, mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
color: UniqueView<BackgroundColor>, color: UniqueView<BackgroundColor>,