Remove ECS pattern: Split into new repo

This commit is contained in:
Florian RICHER 2025-05-25 18:55:58 +02:00
parent d232706f68
commit f486486be3
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
32 changed files with 23 additions and 1823 deletions

View file

@ -1,19 +0,0 @@
use bevy_ecs::component::Component;
use glam::{Mat4, Quat, Vec3};
pub trait Camera: Into<Mat4> + Component {}
#[derive(Component)]
pub struct Camera3D {
pub projection: Mat4,
pub position: Vec3,
pub rotation: Quat,
}
impl Into<Mat4> for Camera3D {
fn into(self) -> Mat4 {
Mat4::from_rotation_translation(self.rotation, self.position) * self.projection
}
}
impl Camera for Camera3D {}

View file

@ -1,2 +0,0 @@
pub mod camera;
pub mod render;

View file

@ -1,7 +0,0 @@
use std::sync::Arc;
use bevy_ecs::component::Component;
use vulkano::pipeline::GraphicsPipeline;
#[derive(Component)]
pub struct Material(pub Arc<GraphicsPipeline>);

View file

@ -1,14 +0,0 @@
use bevy_ecs::component::Component;
use super::vertex::Vertex2D;
#[derive(Component)]
pub struct Mesh2D {
pub vertices: Vec<Vertex2D>,
}
impl Mesh2D {
pub fn new(vertices: Vec<Vertex2D>) -> Self {
Self { vertices }
}
}

View file

@ -1,3 +0,0 @@
pub mod material;
pub mod mesh;
pub mod vertex;

View file

@ -1,36 +0,0 @@
use bevy_app::App;
use engine_render::RenderPlugin;
use engine_vulkan::{VulkanConfig, VulkanPlugin};
use engine_window::{WindowPlugin, config::WindowConfig};
use vulkano::device::{DeviceExtensions, DeviceFeatures};
pub fn init(app: &mut App) {
let window_config = WindowConfig {
title: "Rust ASH Test".to_string(),
width: 800,
height: 600,
};
let device_extensions = DeviceExtensions {
khr_dynamic_rendering: true,
..Default::default()
};
let device_features = DeviceFeatures {
dynamic_rendering: true,
..Default::default()
};
let vulkan_config = VulkanConfig {
instance_layers: vec![String::from("VK_LAYER_KHRONOS_validation")],
device_extensions,
device_features,
..Default::default()
};
app.add_plugins((
WindowPlugin { window_config },
VulkanPlugin { vulkan_config },
RenderPlugin,
));
}

View file

@ -1,35 +1,14 @@
use winit::event_loop::{ControlFlow, EventLoop};
use bevy_app::{App, AppExit};
pub mod core;
pub mod game;
pub mod old_app;
mod render;
fn main() {
env_logger::init();
run_new_app();
// run_old_app();
}
fn run_new_app() {
let mut app = App::default();
game::init(&mut app);
match app.run() {
AppExit::Success => {}
AppExit::Error(e) => {
log::error!("Error running new app: {e}");
}
}
}
fn run_old_app() {
let event_loop = EventLoop::new().unwrap();
event_loop.set_control_flow(ControlFlow::Poll);
let vulkan_context = old_app::vulkan_context::VulkanContext::from(&event_loop);
let mut app = old_app::app::App::from(vulkan_context);
let vulkan_context = render::vulkan_context::VulkanContext::from(&event_loop);
let mut app = render::app::App::from(vulkan_context);
match event_loop.run_app(&mut app) {
Ok(_) => {}

View file

@ -1,6 +1,6 @@
use crate::old_app::scene::Scene;
use crate::old_app::vulkan_context::VulkanContext;
use crate::old_app::window_render_context::WindowRenderContext;
use crate::render::scene::Scene;
use crate::render::vulkan_context::VulkanContext;
use crate::render::window_render_context::WindowRenderContext;
use std::sync::Arc;
use vulkano::command_buffer::{RenderingAttachmentInfo, RenderingInfo};
use vulkano::render_pass::{AttachmentLoadOp, AttachmentStoreOp};

View file

@ -3,3 +3,4 @@ pub mod pipelines;
pub mod scene;
pub mod vulkan_context;
pub mod window_render_context;
pub mod vertex;

View file

@ -20,7 +20,7 @@ use vulkano::pipeline::{
use vulkano::shader::{EntryPoint, ShaderStages};
use vulkano::swapchain::Swapchain;
use crate::core::render::vertex::Vertex2D;
use crate::render::vertex::Vertex2D;
pub mod shaders {
pub mod vs {

View file

@ -1,4 +1,4 @@
use crate::old_app::pipelines::triangle_pipeline::shaders::vs;
use crate::render::pipelines::triangle_pipeline::shaders::vs;
use glam::{Mat3, Mat4, Vec3};
use std::error::Error;
use std::sync::Arc;
@ -9,8 +9,8 @@ use vulkano::descriptor_set::{DescriptorSet, WriteDescriptorSet};
use vulkano::memory::allocator::{AllocationCreateInfo, MemoryTypeFilter};
use vulkano::pipeline::{GraphicsPipeline, Pipeline, PipelineBindPoint};
use crate::core::render::vertex::Vertex2D;
use crate::old_app::pipelines::triangle_pipeline::create_triangle_pipeline;
use crate::render::vertex::Vertex2D;
use crate::render::pipelines::triangle_pipeline::create_triangle_pipeline;
use super::vulkan_context::VulkanContext;
use super::window_render_context::WindowRenderContext;