Move PlatformContext to the raidillon_platform crate
This commit is contained in:
parent
9905ffd26b
commit
369bbd19c7
8 changed files with 15 additions and 16 deletions
|
|
@ -1,14 +1,14 @@
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use crate::context::PlatformContext;
|
||||
use crate::DebugUIBuffer;
|
||||
use crate::scene::Scene;
|
||||
|
||||
pub trait EngineTrait {
|
||||
type PlatformCtx: Clone;
|
||||
fn new() -> Self;
|
||||
fn initialize(&mut self, platform_context: PlatformContext);
|
||||
fn update(&mut self, platform_context: PlatformContext);
|
||||
fn handle_event(&mut self, platform_context: PlatformContext);
|
||||
fn initialize(&mut self, platform_context: Self::PlatformCtx);
|
||||
fn update(&mut self, platform_context: Self::PlatformCtx);
|
||||
fn handle_event(&mut self, platform_context: Self::PlatformCtx);
|
||||
fn current_scene_mut(&mut self) -> &mut Scene;
|
||||
fn get_debug_ui_buffer(&self) -> Rc<RefCell<DebugUIBuffer>>;
|
||||
fn reset_debug_ui_buffer(&mut self);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
pub mod engine;
|
||||
pub mod scene;
|
||||
pub mod context;
|
||||
pub mod debug_ui;
|
||||
pub use debug_ui::*;
|
||||
|
|
@ -2,7 +2,7 @@ use std::cell::RefCell;
|
|||
use std::rc::Rc;
|
||||
use raidillon_core::scene::{Scene, SceneManager};
|
||||
use crate::system::{SystemContext, SystemManager};
|
||||
use raidillon_core::context::PlatformContext;
|
||||
use raidillon_platform::PlatformContext;
|
||||
use raidillon_core::DebugUIBuffer;
|
||||
use raidillon_core::engine::EngineTrait;
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ pub struct Engine {
|
|||
}
|
||||
|
||||
impl EngineTrait for Engine {
|
||||
type PlatformCtx = PlatformContext;
|
||||
fn new() -> Self {
|
||||
let scene_manager = SceneManager::new();
|
||||
let system_manager = SystemManager::new();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::any::TypeId;
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use indexmap::IndexMap;
|
||||
use raidillon_core::context::PlatformContext;
|
||||
use raidillon_platform::PlatformContext;
|
||||
use raidillon_core::scene::Scene;
|
||||
use raidillon_core::DebugUIBuffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::render::debug_ui::ImguiBridge;
|
|||
use crate::render::BasicMeshRenderingSystem;
|
||||
use crate::GliumAssetManager;
|
||||
|
||||
pub struct GliumPlatform<E: EngineTrait> {
|
||||
pub struct GliumPlatform<E: EngineTrait<PlatformCtx = PlatformContext>> {
|
||||
event_loop: EventLoop<()>,
|
||||
window: Window,
|
||||
display: Display<WindowSurface>,
|
||||
|
|
@ -24,7 +24,7 @@ pub struct GliumPlatform<E: EngineTrait> {
|
|||
engine: E,
|
||||
}
|
||||
|
||||
impl<E: EngineTrait> Platform<E> for GliumPlatform<E> {
|
||||
impl<E: EngineTrait<PlatformCtx = PlatformContext>> Platform<E> for GliumPlatform<E> {
|
||||
fn initialize(mut engine: E, title: String, width: u32, height: u32) -> Self {
|
||||
let event_loop = glium::winit::event_loop::EventLoop::builder()
|
||||
.build()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use winit::event::Event;
|
||||
use raidillon_assets::{ModelManagerRef, ModelManager};
|
||||
use raidillon_assets::ModelManagerRef;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PlatformContext {
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
pub mod platform;
|
||||
mod camera;
|
||||
mod event;
|
||||
pub mod context;
|
||||
|
||||
pub use platform::Platform;
|
||||
pub use camera::Camera;
|
||||
pub use raidillon_core::context::PlatformContext;
|
||||
pub use context::PlatformContext;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use raidillon_assets::ModelManager;
|
|||
use raidillon_core::engine::EngineTrait;
|
||||
use crate::PlatformContext;
|
||||
|
||||
pub trait Platform<E: EngineTrait> {
|
||||
pub trait Platform<E: EngineTrait<PlatformCtx = PlatformContext>> {
|
||||
/// Initialize platform.
|
||||
fn initialize(engine: E, title: String, width: u32, height: u32) -> Self;
|
||||
fn run(self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue