feat: render and manage textures :3
This commit is contained in:
parent
2501390225
commit
74a1be796f
21 changed files with 2908 additions and 320 deletions
|
|
@ -4,11 +4,14 @@ use glam::{Mat4, Vec3};
|
|||
use core::f32;
|
||||
use std::mem::size_of;
|
||||
|
||||
mod material;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Copy)]
|
||||
pub struct Vertex {
|
||||
pub pos: [f32; 3],
|
||||
pub color: [f32; 3],
|
||||
pub normal: [f32; 3],
|
||||
pub tex_coord: [f32; 2],
|
||||
}
|
||||
|
||||
impl Vertex {
|
||||
|
|
@ -19,7 +22,7 @@ impl Vertex {
|
|||
.input_rate(vk::VertexInputRate::VERTEX)
|
||||
}
|
||||
|
||||
pub fn get_attribute_descriptions() -> [vk::VertexInputAttributeDescription; 2] {
|
||||
pub fn get_attribute_descriptions() -> [vk::VertexInputAttributeDescription; 3] {
|
||||
[
|
||||
vk::VertexInputAttributeDescription::default()
|
||||
.location(0)
|
||||
|
|
@ -30,7 +33,12 @@ impl Vertex {
|
|||
.location(1)
|
||||
.binding(0)
|
||||
.format(vk::Format::R32G32B32_SFLOAT)
|
||||
.offset(memoffset::offset_of!(Vertex, color) as u32),
|
||||
.offset(memoffset::offset_of!(Vertex, normal) as u32),
|
||||
vk::VertexInputAttributeDescription::default()
|
||||
.location(2)
|
||||
.binding(0)
|
||||
.format(vk::Format::R32G32_SFLOAT)
|
||||
.offset(memoffset::offset_of!(Vertex, tex_coord) as u32),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +46,6 @@ impl Vertex {
|
|||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Copy, PartialEq)]
|
||||
pub struct UniformBufferObject {
|
||||
pub model: Mat4,
|
||||
pub view: Mat4,
|
||||
pub proj: Mat4,
|
||||
}
|
||||
|
|
@ -47,6 +54,7 @@ pub struct UniformBufferObject {
|
|||
pub struct CameraInfo {
|
||||
pub camera_pos: Vec3,
|
||||
pub camera_target: Vec3,
|
||||
pub camera_up: Vec3,
|
||||
pub camera_fov: f32,
|
||||
}
|
||||
|
||||
|
|
@ -55,6 +63,7 @@ impl Default for CameraInfo {
|
|||
Self {
|
||||
camera_pos: Vec3::new(10.0, 10.0, 10.0),
|
||||
camera_target: Vec3::new(0.0, 0.0, 0.0),
|
||||
camera_up: Vec3::Y,
|
||||
camera_fov: 45.0,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
0
crates/shared/src/material.rs
Normal file
0
crates/shared/src/material.rs
Normal file
Loading…
Add table
Add a link
Reference in a new issue