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