got stuff on the screen, but imgui aint happy
This commit is contained in:
55
src/main.rs
55
src/main.rs
@@ -6,7 +6,7 @@ extern crate winit;
|
||||
|
||||
use std::f32::consts::PI;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@@ -44,6 +44,10 @@ use crate::components::{Collider, Color, LoopState, Physics, Position};
|
||||
use crate::owned_event::{OwnedEvent, OwnedEventExtension};
|
||||
use crate::physics::PhysicsState;
|
||||
use crate::render::Renderer;
|
||||
use legion::systems::{UnsafeResources, SyncResources};
|
||||
use std::borrow::Borrow;
|
||||
use imgui::__core::convert::TryInto;
|
||||
use imgui_winit_support::WinitPlatform;
|
||||
|
||||
mod camera;
|
||||
mod components;
|
||||
@@ -84,20 +88,26 @@ ECS
|
||||
|
||||
//log::info!("");
|
||||
|
||||
|
||||
pub struct ImguiContext {
|
||||
pub context: imgui::Context,
|
||||
}
|
||||
unsafe impl Send for ImguiContext {}
|
||||
|
||||
pub struct ImguiPlatform {
|
||||
pub platform: WinitPlatform,
|
||||
}
|
||||
unsafe impl Send for ImguiPlatform {}
|
||||
|
||||
fn main() {
|
||||
let mut world = World::default();
|
||||
|
||||
let (mut pool, spawner) = {
|
||||
let local_pool = futures::executor::LocalPool::new();
|
||||
let spawner = local_pool.spawner();
|
||||
(local_pool, spawner)
|
||||
};
|
||||
|
||||
let mut render_schedule = Schedule::builder()
|
||||
.add_system(render::render_test_system())
|
||||
.build();
|
||||
|
||||
let mut update_schedule = Schedule::builder()
|
||||
.add_system(physics::test_unsafe_system())
|
||||
.add_system(physics::update_camera_system())
|
||||
.add_system(physics::run_physics_system())
|
||||
.add_system(physics::update_models_system())
|
||||
@@ -118,11 +128,41 @@ fn main() {
|
||||
|
||||
// Load up all the resources
|
||||
{
|
||||
let mut imgui_context = imgui::Context::create();
|
||||
let mut platform = imgui_winit_support::WinitPlatform::init(&mut imgui_context);
|
||||
platform.attach_window(
|
||||
imgui_context.io_mut(),
|
||||
&window,
|
||||
imgui_winit_support::HiDpiMode::Default,
|
||||
);
|
||||
|
||||
// imgui rendering context
|
||||
let mut imgui_context = ImguiContext {
|
||||
context: imgui_context,
|
||||
};
|
||||
let mut imgui_platform = ImguiPlatform {
|
||||
platform: platform,
|
||||
};
|
||||
let font_size = 10.0 as f32;
|
||||
imgui_context.context.io_mut().font_global_scale = 10.0 as f32;
|
||||
|
||||
imgui_context.context.fonts().add_font(&[FontSource::DefaultFontData {
|
||||
config: Some(imgui::FontConfig {
|
||||
oversample_h: 1,
|
||||
pixel_snap_h: true,
|
||||
size_pixels: font_size,
|
||||
..Default::default()
|
||||
}),
|
||||
}]);
|
||||
imgui_context.context.set_ini_filename(None);
|
||||
|
||||
// The renderer
|
||||
let mut renderer = render::Renderer::init(&window, &mut imgui_context);
|
||||
entity_loading(&mut world, &mut renderer);
|
||||
|
||||
resources.insert(renderer);
|
||||
resources.insert(Arc::new(Mutex::new(imgui_context)));
|
||||
resources.insert(Arc::new(Mutex::new(imgui_platform)));
|
||||
resources.insert(window);
|
||||
|
||||
// Physics
|
||||
@@ -140,7 +180,6 @@ fn main() {
|
||||
|
||||
// And our event stack
|
||||
resources.insert(Vec::<OwnedEvent<OwnedEventExtension>>::new());
|
||||
|
||||
};
|
||||
|
||||
let event_loop_proxy = event_loop.create_proxy();
|
||||
|
||||
Reference in New Issue
Block a user