Skip to content

Commit

Permalink
fixed some bad code (#126)
Browse files Browse the repository at this point in the history
* fixed bad code
	modified:   crates/vent-runtime/src/lib.rs
	modified:   crates/vent-runtime/src/main.rs
	modified:   crates/vent-runtime/src/project/mod.rs

* fixed some errors and `cargo clippy`d
	modified:   crates/vent-assets/src/model/loader.rs
	modified:   crates/vent-rendering/src/debug.rs
	modified:   crates/vent-rendering/src/instance.rs
	modified:   crates/vent-rendering/src/pipeline.rs
	modified:   crates/vent-runtime/src/lib.rs
	modified:   crates/vent-runtime/src/main.rs

---------

Co-authored-by: user <user@CND0274327>
  • Loading branch information
Polygons1 and user authored Dec 16, 2024
1 parent 15ff22c commit 2da0248
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 32 deletions.
4 changes: 2 additions & 2 deletions crates/vent-assets/src/model/loader.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, ffi::CStr, fs::File, path::Path};
use std::{collections::HashMap, fs::File, path::Path};

use ash::{
util::read_spv,
Expand Down Expand Up @@ -45,7 +45,7 @@ impl ModelLoader {
}
.unwrap();

let shader_entry_name = unsafe { CStr::from_bytes_with_nul_unchecked(b"main\0") };
let shader_entry_name = unsafe { c"main" };
let shader_stage_create_info = [
vk::PipelineShaderStageCreateInfo {
module: vertex_module,
Expand Down
4 changes: 2 additions & 2 deletions crates/vent-rendering/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ pub fn set_object_name<H: Handle>(
}

pub fn get_validation_features() -> vk::ValidationFeaturesEXT<'static> {
return vk::ValidationFeaturesEXT::default()
vk::ValidationFeaturesEXT::default()
.enabled_validation_features(&[
vk::ValidationFeatureEnableEXT::GPU_ASSISTED,
// vk::ValidationFeatureEnableEXT::BEST_PRACTICES, Does hide real errors, so lets disable it for now
vk::ValidationFeatureEnableEXT::SYNCHRONIZATION_VALIDATION,
])
.disabled_validation_features(&[]); // We need to give it an empty Array, If not we get an validation error
.disabled_validation_features(&[])// We need to give it an empty Array, If not we get an validation error
}

/// Setup the debug message if validation layers are enabled.
Expand Down
2 changes: 1 addition & 1 deletion crates/vent-rendering/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl VulkanInstance {
application_name.as_bytes(),
))
.application_version(application_version)
.engine_name(CStr::from_bytes_with_nul_unchecked(b"Vent-Engine\0"))
.engine_name(c"Vent-Engine")
.engine_version(engine_version)
.api_version(vk::API_VERSION_1_3)
};
Expand Down
4 changes: 2 additions & 2 deletions crates/vent-rendering/src/pipeline.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{ffi::CStr, fs::File, path::Path};
use std::{fs::File, path::Path};

use ash::{
util::read_spv,
Expand Down Expand Up @@ -65,7 +65,7 @@ impl VulkanPipeline {
}
.unwrap();

let shader_entry_name = unsafe { CStr::from_bytes_with_nul_unchecked(b"main\0") };
let shader_entry_name = unsafe { c"main" };

Check failure on line 68 in crates/vent-rendering/src/pipeline.rs

View workflow job for this annotation

GitHub Actions / Linux Build

unnecessary `unsafe` block

Check failure on line 68 in crates/vent-rendering/src/pipeline.rs

View workflow job for this annotation

GitHub Actions / Windows Build

unnecessary `unsafe` block
let shader_stage_create_info = [
vk::PipelineShaderStageCreateInfo {
module: vertex_module,
Expand Down
27 changes: 4 additions & 23 deletions crates/vent-runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
use crate::render::Dimension;

use project::{RenderSettings, VentApplicationProject};
use project::VentApplicationProject;
use render::{camera::camera_controller3d::CameraController3D, DefaultRuntimeRenderer};

use util::{crash::init_panic_hook, input_handler::InputHandler, version::Version};
use vent_logging::Logger;
use vent_window::{Window, WindowAttribs, WindowEvent};
use util::input_handler::InputHandler;
use vent_window::{Window, WindowEvent};

pub mod project;
pub mod render;
pub mod util;

#[derive(Default)]
pub struct VentApplication {
project: VentApplicationProject,
}

impl VentApplication {
pub fn default() {
init_panic_hook();
Logger::init();

let project = VentApplicationProject {
name: "Placeholder".to_string(),
version: Version::new(1, 0, 0),
window_settings: WindowAttribs::default().with_title("Placeholder".to_string()),
render_settings: RenderSettings {
dimension: Dimension::D3,
vsync: false,
},
};
let app = VentApplication::new(project);
app.start();
}

pub fn new(project: VentApplicationProject) -> Self {
Self { project }
}
Expand Down
8 changes: 6 additions & 2 deletions crates/vent-runtime/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // This disables the Windows Console in release mode

use vent_runtime::VentApplication;
use vent_logging::Logger;
use vent_runtime::{util::crash::init_panic_hook, VentApplication};

fn main() {
VentApplication::default();
init_panic_hook();
Logger::init();
let app = VentApplication::default();
app.start();
}

#[cfg(target_os = "android")]
Expand Down
14 changes: 14 additions & 0 deletions crates/vent-runtime/src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ pub struct VentApplicationProject {
pub render_settings: RenderSettings,
}

impl Default for VentApplicationProject {
fn default() -> Self {
VentApplicationProject {
name: "Placeholder".to_string(),
version: Version::new(1, 0, 0),
window_settings: WindowAttribs::default().with_title("Placeholder".to_string()),
render_settings: RenderSettings {
dimension: Dimension::D3,
vsync: false,
},
}
}
}

#[derive(Serialize, Deserialize)]
pub struct RenderSettings {
// Inital vsync setting, can be changed later
Expand Down

0 comments on commit 2da0248

Please sign in to comment.