mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 06:48:43 -06:00
Compare commits
No commits in common. "fe1427249b6c75cb79734bb85c274c78e7af92c9" and "927337c86d8a6761a138a811772e83ff4bd3ca4d" have entirely different histories.
fe1427249b
...
927337c86d
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,6 +15,3 @@ _src
|
|||
_visualizer.json
|
||||
|
||||
*.kubi
|
||||
|
||||
/*_log*.txt
|
||||
/*.log
|
||||
|
|
1683
Cargo.lock
generated
1683
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,7 @@ publish = false
|
|||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-logging = { path = "../kubi-logging" }
|
||||
log = "0.4"
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "0934b426eb9a8", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
|
||||
toml = "0.8"
|
||||
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
|
||||
|
|
|
@ -6,7 +6,7 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math", "serde"] }
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std"] }
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "0934b426eb9a8", default-features = false, features = ["std"] }
|
||||
strum = { version = "0.25", features = ["derive"] }
|
||||
num_enum = "0.7"
|
||||
postcard = { version = "1.0", features = ["alloc"] }
|
||||
|
|
|
@ -8,7 +8,7 @@ publish = false
|
|||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
glam = { version = "0.24", features = ["approx"] }
|
||||
glium = { git = "https://github.com/glium/glium", rev = "968fc92378caf", optional = true }
|
||||
glium = { git = "https://github.com/glium/glium", rev = "5d50e7", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["backend_glium", "builtin_elements"]
|
||||
|
|
|
@ -2,13 +2,12 @@ use std::any::Any;
|
|||
use crate::{
|
||||
LayoutInfo,
|
||||
draw::UiDrawCall,
|
||||
measure::Response,
|
||||
measure::{IsMeasurable, Response},
|
||||
state::StateRepo
|
||||
};
|
||||
|
||||
#[cfg(feature = "builtin_elements")] pub mod container;
|
||||
#[cfg(feature = "builtin_elements")] pub mod spacer;
|
||||
#[cfg(feature = "builtin_elements")] pub mod progress_bar;
|
||||
#[cfg(feature = "builtin_elements")] pub mod layout_box;
|
||||
|
||||
pub trait UiElement {
|
||||
fn name(&self) -> &'static str { "UiElement" }
|
||||
|
@ -16,6 +15,7 @@ pub trait UiElement {
|
|||
fn is_stateful(&self) -> bool { self.state_id().is_some() }
|
||||
fn is_stateless(&self) -> bool { self.state_id().is_none() }
|
||||
fn init_state(&self) -> Option<Box<dyn Any>> { None }
|
||||
fn measure(&self, state: &StateRepo, layout: &LayoutInfo) -> Response;
|
||||
fn draw(&self, measure: &Response, state: &mut StateRepo, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>);
|
||||
fn is_measurable(&self) -> IsMeasurable { IsMeasurable::No }
|
||||
fn measure(&self, state: &StateRepo, layout: &LayoutInfo) -> Option<Response> { None }
|
||||
fn process(&self, state: &mut StateRepo, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) -> Response;
|
||||
}
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
use glam::{Vec2, Vec4};
|
||||
use crate::{UiDirection, LayoutInfo, draw::UiDrawCall, measure::{IsMeasurable, Response}, state::StateRepo, UiSize};
|
||||
use super::UiElement;
|
||||
|
||||
#[derive(Default, Clone, Copy, Debug)]
|
||||
pub struct ContainerBorders {
|
||||
pub top: Option<(Vec4, f32)>,
|
||||
pub bottom: Option<(Vec4, f32)>,
|
||||
pub left: Option<(Vec4, f32)>,
|
||||
pub right: Option<(Vec4, f32)>,
|
||||
}
|
||||
|
||||
pub enum ContainerAlign {
|
||||
Begin,
|
||||
Center,
|
||||
End,
|
||||
}
|
||||
|
||||
pub struct Container {
|
||||
pub min_size: (UiSize, UiSize),
|
||||
pub max_size: (UiSize, UiSize),
|
||||
pub direction: UiDirection,
|
||||
pub gap: f32,
|
||||
pub padding: f32,
|
||||
pub align: (ContainerAlign, ContainerAlign),
|
||||
pub background: Option<Vec4>,
|
||||
pub borders: ContainerBorders,
|
||||
pub clip: bool,
|
||||
pub elements: Vec<Box<dyn UiElement>>,
|
||||
}
|
||||
|
||||
impl Default for Container {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
min_size: (UiSize::Auto, UiSize::Auto),
|
||||
max_size: (UiSize::Auto, UiSize::Auto),
|
||||
direction: UiDirection::Vertical,
|
||||
gap: 0.,
|
||||
padding: 0.,
|
||||
align: (ContainerAlign::Center, ContainerAlign::Begin),
|
||||
background: Default::default(),
|
||||
borders: Default::default(),
|
||||
clip: Default::default(),
|
||||
elements: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl UiElement for Container {
|
||||
fn measure(&self, state: &StateRepo, layout: &LayoutInfo) -> Response {
|
||||
let mut size = Vec2::ZERO;
|
||||
let mut leftover_gap = Vec2::ZERO;
|
||||
for element in &self.elements {
|
||||
let measure = element.measure(state, &LayoutInfo {
|
||||
position: layout.position + size,
|
||||
max_size: layout.max_size - size,
|
||||
direction: self.direction,
|
||||
});
|
||||
match self.direction {
|
||||
UiDirection::Horizontal => {
|
||||
size.x += measure.desired_size.x + self.gap;
|
||||
size.y = size.y.max(measure.desired_size.y);
|
||||
leftover_gap.x = self.gap;
|
||||
},
|
||||
UiDirection::Vertical => {
|
||||
size.x = size.x.max(measure.desired_size.x);
|
||||
size.y += measure.desired_size.y + self.gap;
|
||||
leftover_gap.y = self.gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
size -= leftover_gap;
|
||||
Response { desired_size: size }
|
||||
}
|
||||
|
||||
fn draw(&self, measure: &Response, state: &mut StateRepo, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) {
|
||||
if let Some(color) = self.background {
|
||||
draw.push(UiDrawCall::Rectangle {
|
||||
position: layout.position,
|
||||
size: measure.desired_size,
|
||||
color
|
||||
});
|
||||
|
||||
//TODO draw borders
|
||||
}
|
||||
}
|
||||
}
|
29
kubi-ui/src/element/layout_box.rs
Normal file
29
kubi-ui/src/element/layout_box.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use std::any::Any;
|
||||
use crate::{UiDirection, LayoutInfo, draw::UiDrawCall, measure::{IsMeasurable, Response}, state::StateRepo};
|
||||
use super::UiElement;
|
||||
|
||||
pub struct LayoutBox {
|
||||
pub direction: UiDirection,
|
||||
pub gap: f32,
|
||||
pub elements: Vec<Box<dyn UiElement>>,
|
||||
}
|
||||
|
||||
impl UiElement for LayoutBox {
|
||||
fn is_measurable(&self) -> IsMeasurable {
|
||||
IsMeasurable::Maybe
|
||||
}
|
||||
|
||||
fn measure(&self, state: StateRepo, layout: &LayoutInfo) -> Option<Response> {
|
||||
for element in &self.elements {
|
||||
if element.is_measurable() == IsMeasurable::No {
|
||||
return None
|
||||
}
|
||||
element.measure(None, layout);
|
||||
}
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn process(&self, _state: Option<&mut Box<dyn Any>>, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) -> Response {
|
||||
todo!()
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
use glam::{vec2, Vec4};
|
||||
use glam::{vec2, Vec2, Vec4};
|
||||
use crate::{
|
||||
UiSize, LayoutInfo,
|
||||
draw::UiDrawCall,
|
||||
measure::Response,
|
||||
measure::{Response, IsMeasurable},
|
||||
state::StateRepo
|
||||
};
|
||||
use super::UiElement;
|
||||
|
@ -19,11 +19,13 @@ const BAR_HEIGHT: f32 = 20.0;
|
|||
impl UiElement for ProgressBar {
|
||||
fn name(&self) -> &'static str { "Progress bar" }
|
||||
|
||||
fn measure(&self, _: &StateRepo, layout: &LayoutInfo) -> Response {
|
||||
Response {
|
||||
desired_size: vec2(
|
||||
fn is_measurable(&self) -> IsMeasurable { IsMeasurable::Yes }
|
||||
|
||||
fn measure(&self, _: &StateRepo, layout: &LayoutInfo) -> Option<Response> {
|
||||
Some(Response {
|
||||
size: Vec2::new(
|
||||
match self.size.0 {
|
||||
UiSize::Auto => layout.max_size.x.max(300.),
|
||||
UiSize::Auto => layout.max_size.x,
|
||||
UiSize::Percentage(p) => layout.max_size.x * p,
|
||||
UiSize::Pixels(p) => p,
|
||||
},
|
||||
|
@ -33,20 +35,24 @@ impl UiElement for ProgressBar {
|
|||
UiSize::Pixels(p) => p,
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn draw(&self, measure: &Response, state: &mut StateRepo, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) {
|
||||
fn process(&self, state: &mut StateRepo, layout: &LayoutInfo, draw: &mut Vec<UiDrawCall>) -> Response {
|
||||
let measure = self.measure(&state, layout).unwrap();
|
||||
|
||||
draw.push(UiDrawCall::Rectangle {
|
||||
position: layout.position,
|
||||
size: measure.desired_size,
|
||||
size: measure.size,
|
||||
color: self.color_background
|
||||
});
|
||||
|
||||
draw.push(UiDrawCall::Rectangle {
|
||||
position: layout.position,
|
||||
size: measure.desired_size * vec2(self.value, 1.0),
|
||||
size: measure.size * vec2(self.value, 1.0),
|
||||
color: self.color_foreground
|
||||
});
|
||||
|
||||
measure
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
use glam::vec2;
|
||||
use crate::{state::StateRepo, LayoutInfo, measure::Response, draw::UiDrawCall, UiDirection};
|
||||
use super::UiElement;
|
||||
|
||||
pub struct Spacer(f32);
|
||||
|
||||
impl UiElement for Spacer {
|
||||
fn measure(&self, state: &StateRepo, layout: &LayoutInfo) -> Response {
|
||||
Response {
|
||||
desired_size: match layout.direction {
|
||||
UiDirection::Horizontal => vec2(self.0, 0.),
|
||||
UiDirection::Vertical => vec2(0., self.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(&self, _measure: &Response, _state: &mut StateRepo, _layout: &LayoutInfo, _draw: &mut Vec<UiDrawCall>) {}
|
||||
}
|
|
@ -32,15 +32,13 @@ impl Default for KubiUi {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum UiSize {
|
||||
#[default]
|
||||
Auto,
|
||||
Percentage(f32),
|
||||
Pixels(f32),
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Default)]
|
||||
pub enum UiDirection {
|
||||
#[default]
|
||||
Vertical,
|
||||
|
@ -48,7 +46,6 @@ pub enum UiDirection {
|
|||
}
|
||||
|
||||
struct LayoutInfo {
|
||||
///Not availabe during measuring step
|
||||
position: Vec2,
|
||||
max_size: Vec2,
|
||||
direction: UiDirection,
|
||||
|
|
|
@ -9,5 +9,5 @@ pub enum IsMeasurable {
|
|||
}
|
||||
|
||||
pub struct Response {
|
||||
pub desired_size: Vec2
|
||||
pub size: Vec2
|
||||
}
|
||||
|
|
|
@ -13,18 +13,14 @@ kubi-shared = { path = "../kubi-shared" }
|
|||
kubi-logging = { path = "../kubi-logging" }
|
||||
kubi-ui = { path = "../kubi-ui" }
|
||||
log = "0.4"
|
||||
glium = { git = "https://github.com/glium/glium", rev = "968fc92378caf" }
|
||||
glutin = "0.31"
|
||||
winit = { version = "0.29", features = ["android-native-activity"] }
|
||||
glutin-winit = "0.4"
|
||||
raw-window-handle = "0.5"
|
||||
glium = { git = "https://github.com/glium/glium", rev = "5d50e7" }
|
||||
glam = { version = "0.24", features = ["debug-glam-assert", "fast-math"] }
|
||||
image = { version = "0.24", default_features = false, features = ["png"] }
|
||||
strum = { version = "0.25", features = ["derive"] }
|
||||
hashbrown = "0.14"
|
||||
nohash-hasher = "0.2"
|
||||
rayon = "1.7"
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "8ef90ea6c4d1eb6c9cb0988f0d2f873f75044d49", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
shipyard = { git = "https://github.com/leudz/shipyard", rev = "0934b426eb9a8", default-features = false, features = ["std", "proc", "thread_local"] }
|
||||
anyhow = "1.0"
|
||||
flume = "0.11"
|
||||
gilrs = { version = "0.10", default_features = false, features = ["xinput"] }
|
||||
|
@ -36,8 +32,8 @@ tinyset = "0.4"
|
|||
serde_json = { version = "1.0", optional = true } #only used for `generate_visualizer_data`
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
android-activity = "0.5"
|
||||
ndk = "0.8"
|
||||
ndk = "0.7"
|
||||
ndk-glue = "0.7"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = "0.3"
|
||||
|
@ -68,14 +64,6 @@ target_sdk_version = 30
|
|||
required = true
|
||||
glEsVersion = 0x00030000
|
||||
|
||||
[[package.metadata.android.uses_feature]]
|
||||
name = "android.hardware.touchscreen.multitouch"
|
||||
required = true
|
||||
|
||||
[[package.metadata.android.uses_feature]]
|
||||
name = "android.hardware.touchscreen.multitouch.distinct"
|
||||
required = true
|
||||
|
||||
[package.metadata.android.application.activity]
|
||||
config_changes = "orientation|keyboardHidden|screenLayout|screenSize"
|
||||
exported = true
|
||||
|
|
|
@ -1,32 +1,26 @@
|
|||
use shipyard::{UniqueViewMut, UniqueView, View, IntoIter, ViewMut, EntitiesViewMut, Workload, IntoWorkload};
|
||||
use winit::keyboard::KeyCode;
|
||||
use glium::glutin::event::VirtualKeyCode;
|
||||
use kubi_shared::{
|
||||
block::Block,
|
||||
queue::QueuedBlock,
|
||||
queue::QueuedBlock,
|
||||
player::PlayerHolding,
|
||||
};
|
||||
use crate::{
|
||||
player::MainPlayer,
|
||||
world::{
|
||||
raycast::{LookingAtBlock, RAYCAST_STEP},
|
||||
queue::BlockUpdateQueue
|
||||
},
|
||||
input::{Inputs, PrevInputs, RawKbmInputState},
|
||||
events::{
|
||||
EventComponent,
|
||||
player_actions::PlayerActionEvent
|
||||
},
|
||||
world::{raycast::{LookingAtBlock, RAYCAST_STEP}, queue::BlockUpdateQueue},
|
||||
input::{Inputs, PrevInputs, RawKbmInputState},
|
||||
events::{EventComponent, player_actions::PlayerActionEvent},
|
||||
};
|
||||
|
||||
const BLOCK_KEY_MAP: &[(KeyCode, Block)] = &[
|
||||
(KeyCode::Digit1, Block::Cobblestone),
|
||||
(KeyCode::Digit2, Block::Planks),
|
||||
(KeyCode::Digit3, Block::Dirt),
|
||||
(KeyCode::Digit4, Block::Grass),
|
||||
(KeyCode::Digit5, Block::Sand),
|
||||
(KeyCode::Digit6, Block::Stone),
|
||||
(KeyCode::Digit7, Block::Torch),
|
||||
(KeyCode::Digit8, Block::Leaf),
|
||||
const BLOCK_KEY_MAP: &[(VirtualKeyCode, Block)] = &[
|
||||
(VirtualKeyCode::Key1, Block::Cobblestone),
|
||||
(VirtualKeyCode::Key2, Block::Planks),
|
||||
(VirtualKeyCode::Key3, Block::Dirt),
|
||||
(VirtualKeyCode::Key4, Block::Grass),
|
||||
(VirtualKeyCode::Key5, Block::Sand),
|
||||
(VirtualKeyCode::Key6, Block::Stone),
|
||||
(VirtualKeyCode::Key7, Block::Torch),
|
||||
(VirtualKeyCode::Key8, Block::Leaf),
|
||||
];
|
||||
|
||||
fn pick_block_with_number_keys(
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use shipyard::{UniqueView, UniqueViewMut, Unique, AllStoragesView};
|
||||
use winit::{keyboard::KeyCode, event_loop::ControlFlow};
|
||||
use glium::glutin::{event::VirtualKeyCode, event_loop::ControlFlow};
|
||||
use crate::input::RawKbmInputState;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct RequestExit(pub bool);
|
||||
pub struct SetControlFlow(pub Option<ControlFlow>);
|
||||
|
||||
pub fn exit_on_esc(
|
||||
raw_inputs: UniqueView<RawKbmInputState>,
|
||||
mut exit: UniqueViewMut<RequestExit>
|
||||
mut control_flow: UniqueViewMut<SetControlFlow>
|
||||
) {
|
||||
if raw_inputs.keyboard_state.contains(KeyCode::Escape as u32) {
|
||||
exit.0 = true;
|
||||
if raw_inputs.keyboard_state.contains(VirtualKeyCode::Escape as u32) {
|
||||
control_flow.0 = Some(ControlFlow::Exit);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert_control_flow_unique(
|
||||
storages: AllStoragesView
|
||||
) {
|
||||
storages.add_unique(RequestExit(false))
|
||||
storages.add_unique(SetControlFlow(None))
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use shipyard::{AllStoragesView, Unique, NonSendSync, UniqueView, UniqueViewMut};
|
||||
use crate::rendering::Renderer;
|
||||
use winit::window::CursorGrabMode;
|
||||
use glium::glutin::window::CursorGrabMode;
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct CursorLock(pub bool);
|
||||
|
@ -13,8 +13,8 @@ pub fn update_cursor_lock_state(
|
|||
return
|
||||
}
|
||||
if lock.is_inserted_or_modified() {
|
||||
//TODO MIGRATION
|
||||
let window = &display.window;
|
||||
let gl_window = display.display.gl_window();
|
||||
let window = gl_window.window();
|
||||
window.set_cursor_grab(match lock.0 {
|
||||
true => CursorGrabMode::Confined,
|
||||
false => CursorGrabMode::None,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use glam::UVec2;
|
||||
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
|
||||
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch, RawKeyEvent, TouchPhase};
|
||||
use glium::glutin::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch};
|
||||
use crate::rendering::Renderer;
|
||||
|
||||
pub mod player_actions;
|
||||
|
@ -24,7 +24,7 @@ pub struct TouchEvent(pub Touch);
|
|||
#[derive(Component, Clone, Copy, Debug, Default)]
|
||||
pub struct WindowResizedEvent(pub UVec2);
|
||||
|
||||
pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
|
||||
pub fn process_glutin_events(world: &mut World, event: &Event<'_, ()>) {
|
||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||
match event {
|
||||
Event::WindowEvent { window_id: _, event } => match event {
|
||||
|
@ -36,25 +36,17 @@ pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
|
|||
},
|
||||
|
||||
#[cfg(not(feature = "raw-evt"))]
|
||||
WindowEvent::KeyboardInput { device_id, event, .. } => {
|
||||
WindowEvent::KeyboardInput { device_id, input, is_synthetic } => {
|
||||
world.add_entity((
|
||||
EventComponent,
|
||||
InputDeviceEvent {
|
||||
device_id: *device_id,
|
||||
event: DeviceEvent::Key(RawKeyEvent {
|
||||
physical_key: event.physical_key,
|
||||
state: event.state,
|
||||
})
|
||||
event: DeviceEvent::Key(*input)
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
WindowEvent::Touch(touch) => {
|
||||
// if matches!(touch.phase, TouchPhase::Started | TouchPhase::Cancelled | TouchPhase::Ended) {
|
||||
// println!("TOUCH ==================== {:#?}", touch);
|
||||
// } else {
|
||||
// println!("TOUCH MOVED {:?} {}", touch.phase, touch.id);
|
||||
// }
|
||||
world.add_entity((
|
||||
EventComponent,
|
||||
TouchEvent(*touch)
|
||||
|
@ -75,13 +67,13 @@ pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
|
|||
));
|
||||
},
|
||||
|
||||
Event::LoopExiting => {
|
||||
Event::LoopDestroyed => {
|
||||
world.add_entity((
|
||||
EventComponent,
|
||||
OnBeforeExitEvent
|
||||
));
|
||||
},
|
||||
|
||||
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,21 @@
|
|||
use std::{fs::File, path::Path, io::{Read, Seek}};
|
||||
use anyhow::Result;
|
||||
use shipyard::{Unique, AllStoragesView};
|
||||
|
||||
pub trait ReadOnly: Read + Seek {}
|
||||
impl<T: Read + Seek> ReadOnly for T {}
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct AssetManager {
|
||||
#[cfg(target_os = "android")]
|
||||
pub(crate) app: android_activity::AndroidApp,
|
||||
}
|
||||
|
||||
impl AssetManager {
|
||||
pub fn open_asset(&self, path: &Path) -> Result<Box<dyn ReadOnly>> {
|
||||
#[cfg(target_os = "android")] {
|
||||
use anyhow::Context;
|
||||
use std::ffi::CString;
|
||||
let asset_manager = self.app.asset_manager();
|
||||
let path_cstr = CString::new(path.to_string_lossy().as_bytes())?;
|
||||
let handle = asset_manager.open(&path_cstr).context("Asset doesn't exist")?;
|
||||
Ok(Box::new(handle))
|
||||
}
|
||||
#[cfg(not(target_os = "android"))] {
|
||||
let asset_path = Path::new("./assets/").join(path);
|
||||
Ok(Box::new(File::open(asset_path)?))
|
||||
}
|
||||
pub fn open_asset(path: &Path) -> Result<Box<dyn ReadOnly>> {
|
||||
#[cfg(target_os = "android")] {
|
||||
use anyhow::Context;
|
||||
use std::ffi::CString;
|
||||
|
||||
let asset_manager = ndk_glue::native_activity().asset_manager();
|
||||
let path_cstr = CString::new(path.to_string_lossy().as_bytes())?;
|
||||
let handle = asset_manager.open(&path_cstr).context("Asset doesn't exist")?;
|
||||
Ok(Box::new(handle))
|
||||
}
|
||||
#[cfg(not(target_os = "android"))] {
|
||||
let asset_path = Path::new("./assets/").join(path);
|
||||
Ok(Box::new(File::open(asset_path)?))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
use gilrs::{Gilrs, GamepadId, Button, Event, Axis};
|
||||
use glam::{Vec2, DVec2, vec2, dvec2};
|
||||
use winit::{
|
||||
keyboard::{KeyCode, PhysicalKey},
|
||||
event::{DeviceEvent, DeviceId, ElementState, TouchPhase}
|
||||
};
|
||||
use glium::glutin::event::{DeviceEvent, DeviceId, VirtualKeyCode, ElementState, TouchPhase};
|
||||
use hashbrown::HashMap;
|
||||
use tinyset::{SetU32, SetU64};
|
||||
use nohash_hasher::BuildNoHashHasher;
|
||||
|
@ -97,21 +94,21 @@ fn process_events(
|
|||
) {
|
||||
input_state.mouse_delta = DVec2::ZERO;
|
||||
for event in device_events.iter() {
|
||||
match &event.event {
|
||||
match event.event {
|
||||
DeviceEvent::MouseMotion { delta } => {
|
||||
input_state.mouse_delta = DVec2::from(*delta);
|
||||
input_state.mouse_delta = DVec2::from(delta);
|
||||
},
|
||||
DeviceEvent::Key(input) => {
|
||||
if let PhysicalKey::Code(code) = input.physical_key {
|
||||
if let Some(keycode) = input.virtual_keycode {
|
||||
match input.state {
|
||||
ElementState::Pressed => input_state.keyboard_state.insert(code as u32),
|
||||
ElementState::Released => input_state.keyboard_state.remove(code as u32),
|
||||
ElementState::Pressed => input_state.keyboard_state.insert(keycode as u32),
|
||||
ElementState::Released => input_state.keyboard_state.remove(keycode as u32),
|
||||
};
|
||||
}
|
||||
},
|
||||
DeviceEvent::Button { button, state } => {
|
||||
if *button < 32 {
|
||||
input_state.button_state[*button as usize] = matches!(*state, ElementState::Pressed);
|
||||
if button < 32 {
|
||||
input_state.button_state[button as usize] = matches!(state, ElementState::Pressed);
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
|
@ -130,7 +127,6 @@ fn process_touch_events(
|
|||
let position = dvec2(event.0.location.x, event.0.location.y);
|
||||
match event.0.phase {
|
||||
TouchPhase::Started => {
|
||||
//println!("touch started: finger {}", event.0.id);
|
||||
touch_state.fingers.insert(event.0.id, Finger {
|
||||
id: event.0.id,
|
||||
device_id: event.0.device_id,
|
||||
|
@ -147,7 +143,6 @@ fn process_touch_events(
|
|||
}
|
||||
},
|
||||
TouchPhase::Ended | TouchPhase::Cancelled => {
|
||||
//println!("touch ended: finger {}", event.0.id);
|
||||
touch_state.fingers.remove(&event.0.id);
|
||||
},
|
||||
}
|
||||
|
@ -178,14 +173,14 @@ fn update_input_state (
|
|||
mut inputs: UniqueViewMut<Inputs>,
|
||||
) {
|
||||
inputs.movement += Vec2::new(
|
||||
raw_inputs.keyboard_state.contains(KeyCode::KeyD as u32) as u32 as f32 -
|
||||
raw_inputs.keyboard_state.contains(KeyCode::KeyA as u32) as u32 as f32,
|
||||
raw_inputs.keyboard_state.contains(KeyCode::KeyW as u32) as u32 as f32 -
|
||||
raw_inputs.keyboard_state.contains(KeyCode::KeyS as u32) as u32 as f32
|
||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::D as u32) as u32 as f32 -
|
||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::A as u32) as u32 as f32,
|
||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::W as u32) as u32 as f32 -
|
||||
raw_inputs.keyboard_state.contains(VirtualKeyCode::S as u32) as u32 as f32
|
||||
);
|
||||
inputs.look += raw_inputs.mouse_delta.as_vec2();
|
||||
inputs.action_a |= raw_inputs.button_state[0];
|
||||
inputs.action_b |= raw_inputs.button_state[1];
|
||||
inputs.action_a |= raw_inputs.button_state[1];
|
||||
inputs.action_b |= raw_inputs.button_state[3];
|
||||
}
|
||||
|
||||
fn update_input_state_gamepad (
|
||||
|
|
100
kubi/src/lib.rs
100
kubi/src/lib.rs
|
@ -6,7 +6,7 @@ use shipyard::{
|
|||
NonSendSync, WorkloadModificator,
|
||||
SystemModificator
|
||||
};
|
||||
use winit::{
|
||||
use glium::glutin::{
|
||||
event_loop::{EventLoop, ControlFlow},
|
||||
event::{Event, WindowEvent}
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ use rendering::{
|
|||
use block_placement::update_block_placement;
|
||||
use delta_time::{DeltaTime, init_delta_time};
|
||||
use cursor_lock::{insert_lock_state, update_cursor_lock_state, lock_cursor_now};
|
||||
use control_flow::{exit_on_esc, insert_control_flow_unique, RequestExit};
|
||||
use control_flow::{exit_on_esc, insert_control_flow_unique, SetControlFlow};
|
||||
use state::{is_ingame, is_ingame_or_loading, is_loading, init_state, update_state, is_connecting};
|
||||
use networking::{update_networking, update_networking_late, is_multiplayer, disconnect_on_exit, is_singleplayer};
|
||||
use init::initialize_from_args;
|
||||
|
@ -80,7 +80,6 @@ use legacy_gui::{render_gui, init_gui, update_gui};
|
|||
use loading_screen::update_loading_screen;
|
||||
use connecting_screen::switch_to_loading_if_connected;
|
||||
use fixed_timestamp::init_fixed_timestamp_storage;
|
||||
use filesystem::AssetManager;
|
||||
|
||||
/// stuff required to init the renderer and other basic systems
|
||||
fn pre_startup() -> Workload {
|
||||
|
@ -170,15 +169,8 @@ fn attach_console() {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[cfg(target_os = "android")]
|
||||
pub fn android_main(app: android_activity::AndroidApp) {
|
||||
use android_activity::WindowManagerFlags;
|
||||
app.set_window_flags(WindowManagerFlags::FULLSCREEN, WindowManagerFlags::empty());
|
||||
kubi_main(app)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp) {
|
||||
#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
|
||||
pub fn kubi_main() {
|
||||
//Attach console on release builds on windows
|
||||
#[cfg(all(windows, not(debug_assertions)))] attach_console();
|
||||
|
||||
|
@ -190,19 +182,26 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
|||
|
||||
//Create a shipyard world
|
||||
let mut world = World::new();
|
||||
|
||||
//Init assman
|
||||
world.add_unique(AssetManager {
|
||||
#[cfg(target_os = "android")]
|
||||
app: app.clone()
|
||||
});
|
||||
|
||||
|
||||
//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")]
|
||||
|
@ -211,65 +210,24 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
|||
serde_json::to_string(&world.workloads_info()).unwrap(),
|
||||
).unwrap();
|
||||
|
||||
//Run pre-startup procedure
|
||||
world.run_workload(pre_startup).unwrap();
|
||||
|
||||
//Create event loop
|
||||
let event_loop ={
|
||||
#[cfg(not(target_os = "android"))] { EventLoop::new().unwrap() }
|
||||
#[cfg(target_os = "android")] {
|
||||
use winit::{
|
||||
platform::android::EventLoopBuilderExtAndroid,
|
||||
event_loop::EventLoopBuilder
|
||||
};
|
||||
EventLoopBuilder::new().with_android_app(app).build().unwrap()
|
||||
}
|
||||
};
|
||||
//Run startup systems
|
||||
world.run_workload(startup).unwrap();
|
||||
|
||||
//Run the event loop
|
||||
let mut last_update = Instant::now();
|
||||
let mut ready = false;
|
||||
event_loop.run(move |event, window_target| {
|
||||
//Wait for the window to become active (required for android)
|
||||
if !ready {
|
||||
if Event::Resumed != event {
|
||||
window_target.set_control_flow(ControlFlow::Wait);
|
||||
return
|
||||
}
|
||||
|
||||
//Initialize renderer
|
||||
{
|
||||
let settings = world.borrow::<UniqueView<GameSettings>>().unwrap();
|
||||
world.add_unique_non_send_sync(Renderer::init(window_target, &settings));
|
||||
}
|
||||
world.add_unique(BackgroundColor(vec3(0.5, 0.5, 1.)));
|
||||
|
||||
//Run startup systems
|
||||
world.run_workload(startup).unwrap();
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
window_target.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
*control_flow = ControlFlow::Poll;
|
||||
process_glutin_events(&mut world, &event);
|
||||
|
||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||
match event {
|
||||
#[cfg(target_os = "android")]
|
||||
Event::Suspended => {
|
||||
window_target.exit();
|
||||
}
|
||||
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::CloseRequested => {
|
||||
log::info!("exit requested");
|
||||
window_target.exit();
|
||||
*control_flow = ControlFlow::Exit;
|
||||
},
|
||||
_ => (),
|
||||
},
|
||||
|
||||
Event::AboutToWait => {
|
||||
Event::MainEventsCleared => {
|
||||
//Update delta time (maybe move this into a system?)
|
||||
{
|
||||
let mut dt_view = world.borrow::<UniqueViewMut<DeltaTime>>().unwrap();
|
||||
|
@ -277,10 +235,10 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
|||
dt_view.0 = now - last_update;
|
||||
last_update = now;
|
||||
}
|
||||
|
||||
|
||||
//Run update workflows
|
||||
world.run_workload(update).unwrap();
|
||||
|
||||
|
||||
//Start rendering (maybe use custom views for this?)
|
||||
let target = {
|
||||
let renderer = world.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
|
@ -299,11 +257,11 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
|||
world.run_workload(after_frame_end).unwrap();
|
||||
|
||||
//Process control flow changes
|
||||
if world.borrow::<UniqueView<RequestExit>>().unwrap().0 {
|
||||
window_target.exit();
|
||||
if let Some(flow) = world.borrow::<UniqueView<SetControlFlow>>().unwrap().0 {
|
||||
*control_flow = flow;
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
};
|
||||
}).unwrap();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use shipyard::{UniqueView, UniqueViewMut, Workload, IntoWorkload, EntityId, Unique, AllStoragesViewMut, ViewMut, Get, SystemModificator, track};
|
||||
use winit::keyboard::KeyCode;
|
||||
use glium::glutin::event::VirtualKeyCode;
|
||||
use glam::{Mat3, vec2};
|
||||
use crate::{
|
||||
world::ChunkStorage,
|
||||
state::{GameState, NextState, is_changing_state},
|
||||
transform::Transform2d,
|
||||
legacy_gui::{
|
||||
GuiComponent,
|
||||
GuiComponent,
|
||||
progressbar::ProgressbarComponent
|
||||
},
|
||||
rendering::{WindowSize, if_resized},
|
||||
|
@ -76,7 +76,7 @@ fn override_loading(
|
|||
kbm_state: UniqueView<RawKbmInputState>,
|
||||
mut state: UniqueViewMut<NextState>
|
||||
) {
|
||||
if kbm_state.keyboard_state.contains(KeyCode::KeyF as u32) {
|
||||
if kbm_state.keyboard_state.contains(VirtualKeyCode::F as u32) {
|
||||
state.0 = Some(GameState::InGame);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use shipyard::{Unique, AllStoragesView, UniqueView, UniqueViewMut, Workload, IntoWorkload, EntitiesViewMut, Component, ViewMut, SystemModificator, View, IntoIter, WorkloadModificator};
|
||||
use winit::event_loop::ControlFlow;
|
||||
use glium::glutin::event_loop::ControlFlow;
|
||||
use std::net::SocketAddr;
|
||||
use uflow::{
|
||||
client::{Client, Config as ClientConfig, Event as ClientEvent},
|
||||
|
@ -12,7 +12,7 @@ use kubi_shared::networking::{
|
|||
};
|
||||
use crate::{
|
||||
events::EventComponent,
|
||||
control_flow::RequestExit,
|
||||
control_flow::SetControlFlow,
|
||||
world::tasks::ChunkTaskManager,
|
||||
state::is_ingame_or_loading,
|
||||
fixed_timestamp::FixedTimestamp
|
||||
|
@ -155,11 +155,10 @@ pub fn update_networking_late() -> Workload {
|
|||
}
|
||||
|
||||
pub fn disconnect_on_exit(
|
||||
exit: UniqueView<RequestExit>,
|
||||
control_flow: UniqueView<SetControlFlow>,
|
||||
mut client: UniqueViewMut<UdpClient>,
|
||||
) {
|
||||
//TODO check if this works
|
||||
if exit.0 {
|
||||
if let Some(ControlFlow::ExitWithCode(_)) = control_flow.0 {
|
||||
if client.0.is_active() {
|
||||
client.0.flush();
|
||||
client.0.disconnect();
|
||||
|
@ -168,6 +167,11 @@ pub fn disconnect_on_exit(
|
|||
} else {
|
||||
log::info!("Client inactive")
|
||||
}
|
||||
// if let Err(error) = client.0. {
|
||||
// log::error!("failed to disconnect: {}", error);
|
||||
// } else {
|
||||
// log::info!("Client disconnected");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use shipyard::{NonSendSync, UniqueView, Unique, AllStoragesView};
|
||||
use glium::{texture::{SrgbTexture2dArray, MipmapsOption}, Program};
|
||||
use kubi_shared::block::BlockTexture;
|
||||
use crate::{rendering::Renderer, filesystem::AssetManager};
|
||||
use crate::rendering::Renderer;
|
||||
|
||||
mod texture;
|
||||
mod shaders;
|
||||
|
@ -54,14 +54,12 @@ pub struct ProgressbarShaderPrefab(pub Program);
|
|||
|
||||
pub fn load_prefabs(
|
||||
storages: AllStoragesView,
|
||||
renderer: NonSendSync<UniqueView<Renderer>>,
|
||||
assman: UniqueView<AssetManager>
|
||||
renderer: NonSendSync<UniqueView<Renderer>>
|
||||
) {
|
||||
log::info!("Loading textures...");
|
||||
storages.add_unique_non_send_sync(BlockTexturesPrefab(
|
||||
load_texture2darray_prefab::<BlockTexture, _>(
|
||||
&assman,
|
||||
"blocks".into(),
|
||||
"blocks".into(),
|
||||
&renderer.display,
|
||||
MipmapsOption::AutoGeneratedMipmaps
|
||||
)
|
||||
|
|
|
@ -2,14 +2,13 @@ use strum::IntoEnumIterator;
|
|||
use rayon::prelude::*;
|
||||
use std::{path::PathBuf, io::BufReader};
|
||||
use glium::{texture::{SrgbTexture2dArray, RawImage2d, MipmapsOption}, backend::Facade};
|
||||
use crate::filesystem::AssetManager;
|
||||
use crate::filesystem::open_asset;
|
||||
use super::AssetPaths;
|
||||
|
||||
pub fn load_texture2darray_prefab<
|
||||
T: AssetPaths + IntoEnumIterator,
|
||||
E: Facade
|
||||
>(
|
||||
assman: &AssetManager,
|
||||
directory: PathBuf,
|
||||
facade: &E,
|
||||
mipmaps: MipmapsOption,
|
||||
|
@ -22,7 +21,7 @@ pub fn load_texture2darray_prefab<
|
|||
//Get path to the image and open the file
|
||||
let reader = {
|
||||
let path = directory.join(file_name);
|
||||
BufReader::new(assman.open_asset(&path).expect("Failed to open texture file"))
|
||||
BufReader::new(open_asset(&path).expect("Failed to open texture file"))
|
||||
};
|
||||
//Parse image data
|
||||
let (image_data, dimensions) = {
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
use std::num::NonZeroU32;
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
||||
use winit::{
|
||||
event_loop::EventLoopWindowTarget,
|
||||
window::{WindowBuilder, Fullscreen, Window},
|
||||
dpi::PhysicalSize
|
||||
};
|
||||
use glium::{Display, Surface, Version, Api};
|
||||
use glutin::{
|
||||
prelude::*,
|
||||
context::ContextAttributesBuilder,
|
||||
surface::{WindowSurface, SurfaceAttributesBuilder},
|
||||
display::GetGlDisplay,
|
||||
use glium::{
|
||||
Display, Surface,
|
||||
Version, Api,
|
||||
glutin::{
|
||||
event_loop::EventLoop,
|
||||
window::{WindowBuilder, Fullscreen},
|
||||
ContextBuilder, GlProfile, GlRequest, dpi::PhysicalSize
|
||||
},
|
||||
};
|
||||
use glam::{Vec3, UVec2};
|
||||
use crate::{events::WindowResizedEvent, settings::{GameSettings, FullscreenMode}};
|
||||
|
@ -35,14 +30,12 @@ pub struct WindowSize(pub UVec2);
|
|||
|
||||
#[derive(Unique)]
|
||||
pub struct Renderer {
|
||||
pub window: Window,
|
||||
pub display: Display<WindowSurface>,
|
||||
pub display: Display
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn init(event_loop: &EventLoopWindowTarget<()>, settings: &GameSettings) -> Self {
|
||||
pub fn init(event_loop: &EventLoop<()>, settings: &GameSettings) -> Self {
|
||||
log::info!("initializing display");
|
||||
|
||||
|
||||
let wb = WindowBuilder::new()
|
||||
.with_title("kubi")
|
||||
.with_maximized(true)
|
||||
|
@ -89,43 +82,16 @@ impl Renderer {
|
|||
}
|
||||
});
|
||||
|
||||
// First we start by opening a new Window
|
||||
let display_builder = glutin_winit::DisplayBuilder::new().with_window_builder(Some(wb));
|
||||
let config_template_builder = glutin::config::ConfigTemplateBuilder::new();
|
||||
let (window, gl_config) = display_builder
|
||||
.build(event_loop, config_template_builder, |mut configs| {
|
||||
configs.next().unwrap()
|
||||
})
|
||||
.unwrap();
|
||||
let window = window.unwrap();
|
||||
let cb = ContextBuilder::new()
|
||||
//.with_srgb(false)
|
||||
.with_depth_buffer(24)
|
||||
.with_multisampling(settings.msaa.unwrap_or_default())
|
||||
.with_vsync(settings.vsync)
|
||||
.with_gl_profile(GlProfile::Core)
|
||||
.with_gl(GlRequest::Latest);
|
||||
|
||||
// Now we get the window size to use as the initial size of the Surface
|
||||
let (width, height): (u32, u32) = window.inner_size().into();
|
||||
let attrs = SurfaceAttributesBuilder::<WindowSurface>::new().build(
|
||||
window.raw_window_handle(),
|
||||
NonZeroU32::new(width).unwrap(),
|
||||
NonZeroU32::new(height).unwrap(),
|
||||
);
|
||||
|
||||
// Finally we can create a Surface, use it to make a PossiblyCurrentContext and create the glium Display
|
||||
let surface = unsafe { gl_config.display().create_window_surface(&gl_config, &attrs).unwrap() };
|
||||
let context_attributes = ContextAttributesBuilder::new().build(Some(window.raw_window_handle()));
|
||||
let current_context = unsafe {
|
||||
gl_config.display().create_context(&gl_config, &context_attributes).expect("failed to create context")
|
||||
}.make_current(&surface).unwrap();
|
||||
let display = Display::from_context_surface(current_context, surface).unwrap();
|
||||
|
||||
//TODO MIGRATION
|
||||
// let cb = ContextBuilder::new()
|
||||
// //.with_srgb(false)
|
||||
// .with_depth_buffer(24)
|
||||
// .with_multisampling(settings.msaa.unwrap_or_default())
|
||||
// .with_vsync(settings.vsync)
|
||||
// .with_gl_profile(GlProfile::Core)
|
||||
// .with_gl(GlRequest::Latest);
|
||||
|
||||
// let display = Display::new(wb, cb)
|
||||
// .expect("Failed to create a glium Display");
|
||||
let display = Display::new(wb, cb, event_loop)
|
||||
.expect("Failed to create a glium Display");
|
||||
|
||||
log::info!("Vendor: {}", display.get_opengl_vendor_string());
|
||||
log::info!("Renderer: {}", display.get_opengl_renderer_string());
|
||||
|
@ -135,10 +101,10 @@ impl Renderer {
|
|||
if display.is_context_loss_possible() { log::warn!("OpenGL context loss possible") }
|
||||
if display.is_robust() { log::warn!("OpenGL implementation is not robust") }
|
||||
if display.is_debug() { log::info!("OpenGL context is in debug mode") }
|
||||
|
||||
|
||||
assert!(display.is_glsl_version_supported(&Version(Api::GlEs, 3, 0)), "GLSL ES 3.0 is not supported");
|
||||
|
||||
Self { window, display }
|
||||
Self { display }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,13 +27,9 @@ impl Default for GameSettings {
|
|||
fullscreen: None,
|
||||
msaa: Some(4),
|
||||
max_anisotropy: Some(16),
|
||||
render_distance: match true {
|
||||
cfg!(debug_assertions) => 5,
|
||||
cfg!(target_os = "android") => 6,
|
||||
#[allow(unreachable_patterns)] _ => 8,
|
||||
},
|
||||
render_distance: 6,
|
||||
mouse_sensitivity: 1.,
|
||||
debug_draw_current_chunk_border: false, //cfg!(not(target_os = "android")) && cfg!(debug_assertions),
|
||||
debug_draw_current_chunk_border: cfg!(not(target_os = "android")) && cfg!(debug_assertions),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue