Skip to content

Commit

Permalink
feat: embed editor into engine
Browse files Browse the repository at this point in the history
  • Loading branch information
SkillerRaptor committed Jul 16, 2024
1 parent 62a92bc commit 62f6c6d
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 274 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions bin/hyper_editor/Cargo.toml

This file was deleted.

45 changes: 0 additions & 45 deletions bin/hyper_editor/build.rs

This file was deleted.

18 changes: 0 additions & 18 deletions bin/hyper_editor/src/editor.rs

This file was deleted.

93 changes: 0 additions & 93 deletions bin/hyper_editor/src/logger.rs

This file was deleted.

40 changes: 0 additions & 40 deletions bin/hyper_editor/src/main.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/hyper_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ hyper_platform = { path = "../hyper_platform" }
hyper_rhi = { path = "../hyper_rhi" }

log = { workspace = true }
thiserror = { workspace = true }
32 changes: 8 additions & 24 deletions crates/hyper_engine/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,17 @@

use std::{borrow::Cow, num::NonZeroU32, time::Instant};

use thiserror::Error;
use anyhow::Result;

use hyper_platform::window::{self, Window, WindowDescriptor};
use hyper_platform::window::{Window, WindowDescriptor};
use hyper_rhi::{
graphics_device::{GraphicsApi, GraphicsDevice, GraphicsDeviceDescriptor},
graphics_pipeline::{GraphicsPipeline, GraphicsPipelineDescriptor},
render_pass::RenderPassDescriptor,
shader_module::{ShaderModuleDescriptor, ShaderModuleError, ShaderStage},
shader_module::{ShaderModuleDescriptor, ShaderStage},
surface::{Surface, SurfaceDescriptor},
};

use crate::game::Game;

#[derive(Debug, Error)]
pub enum ApplicationError {
#[error(transparent)]
Window(#[from] window::Error),

#[error("failed to create shader module")]
ShaderModuleCreation(#[from] ShaderModuleError),
}

pub struct ApplicationDescriptor<'a> {
pub title: &'a str,
pub width: NonZeroU32,
Expand All @@ -42,14 +31,10 @@ pub struct Application {
graphics_device: GraphicsDevice,

window: Window,
game: Box<dyn Game>,
}

impl Application {
pub fn new(
game: Box<dyn Game>,
descriptor: ApplicationDescriptor,
) -> Result<Self, ApplicationError> {
pub fn new(descriptor: ApplicationDescriptor) -> Result<Self> {
let start_time = Instant::now();

let title = if cfg!(debug_assertions) {
Expand Down Expand Up @@ -103,13 +88,12 @@ impl Application {
graphics_device,

window,
game,
})
}

pub fn run(&mut self) {
// Fixed at 60 frames per second
let mut time = 0.0;
let mut _time = 0.0;
let delta_time = 1.0 / 60.0;

let mut current_time = Instant::now();
Expand All @@ -133,12 +117,12 @@ impl Application {

// Update
while accumulator >= delta_time {
self.game.update_fixed(delta_time, time);
// Update Fixed
accumulator -= delta_time;
time += delta_time;
_time += delta_time;
}

self.game.update();
// Normal Update

// Render
let swapchain_texture = self.surface.current_texture();
Expand Down
13 changes: 0 additions & 13 deletions crates/hyper_engine/src/game.rs

This file was deleted.

17 changes: 0 additions & 17 deletions crates/hyper_engine/src/lib.rs

This file was deleted.

25 changes: 25 additions & 0 deletions crates/hyper_engine/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2022-2024, SkillerRaptor
*
* SPDX-License-Identifier: MIT
*/

use std::num::NonZeroU32;

use crate::application::{Application, ApplicationDescriptor};

mod application;

fn main() {
let mut application = Application::new(ApplicationDescriptor {
title: "Hyper Engine",
width: NonZeroU32::new(1280).unwrap(),
height: NonZeroU32::new(720).unwrap(),
resizable: false,
})
.unwrap();

application.run();

Ok(())
}

0 comments on commit 62f6c6d

Please sign in to comment.