Added ash and thiserror dependencies to the renderer crate. Defined RendererError for typed Vulkan failure handling. Implemented the Renderer struct with basic Vulkan Entry and Instance creation.
33 lines
882 B
Rust
33 lines
882 B
Rust
pub mod error;
|
|
|
|
use std::ffi::c_char;
|
|
use ash::{Entry, Instance, vk};
|
|
|
|
pub use error::RendererError;
|
|
|
|
pub struct Renderer {
|
|
_entry: Entry,
|
|
instance: Instance,
|
|
}
|
|
|
|
impl Renderer {
|
|
/// Initializes the Vulkan renderer.
|
|
/// `required_extensions` are raw C-strings (pointers) provided by the windowing system.
|
|
pub fn new(required_extensions: &[*const c_char]) -> Result<Self, RendererError> {
|
|
let entry = unsafe { Entry::load() }?;
|
|
|
|
let app_info = vk::ApplicationInfo::default()
|
|
.api_version(vk::API_VERSION_1_3);
|
|
|
|
let create_info = vk::InstanceCreateInfo::default()
|
|
.application_info(&app_info)
|
|
.enabled_extension_names(required_extensions);
|
|
|
|
let instance = unsafe { entry.create_instance(&create_info, None)? };
|
|
|
|
Ok(Self {
|
|
_entry: entry,
|
|
instance,
|
|
})
|
|
}
|
|
} |