Begin move mesh + Vertex and Camera into core
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 20m30s
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Failing after 20m30s
This commit is contained in:
parent
2fbf4e6ce2
commit
852d72d716
11 changed files with 64 additions and 3 deletions
|
@ -1,5 +1,4 @@
|
|||
pub mod pipelines;
|
||||
pub mod vertex;
|
||||
pub mod vulkan_context;
|
||||
pub mod window_render_context;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use vulkano::pipeline::{
|
|||
use vulkano::shader::{EntryPoint, ShaderStages};
|
||||
use vulkano::swapchain::Swapchain;
|
||||
|
||||
use crate::vulkan::vertex::Vertex2D;
|
||||
use crate::core::render::vertex::Vertex2D;
|
||||
|
||||
pub mod shaders {
|
||||
pub mod vs {
|
||||
|
|
|
@ -8,7 +8,8 @@ use vulkano::command_buffer::{AutoCommandBufferBuilder, PrimaryAutoCommandBuffer
|
|||
use vulkano::descriptor_set::{DescriptorSet, WriteDescriptorSet};
|
||||
use vulkano::pipeline::{GraphicsPipeline, Pipeline, PipelineBindPoint};
|
||||
|
||||
use crate::vulkan::{pipelines::triangle_pipeline::create_triangle_pipeline, vertex::Vertex2D};
|
||||
use crate::core::render::vertex::Vertex2D;
|
||||
use crate::vulkan::pipelines::triangle_pipeline::create_triangle_pipeline;
|
||||
|
||||
use super::vulkan_context::VulkanContext;
|
||||
use super::window_render_context::WindowRenderContext;
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
use std::sync::Arc;
|
||||
use vulkano::buffer::{
|
||||
AllocateBufferError, Buffer, BufferContents, BufferCreateInfo, BufferUsage, Subbuffer,
|
||||
};
|
||||
use vulkano::memory::allocator::{AllocationCreateInfo, MemoryTypeFilter, StandardMemoryAllocator};
|
||||
use vulkano::pipeline::graphics::vertex_input::Vertex;
|
||||
use vulkano::Validated;
|
||||
|
||||
#[derive(BufferContents, Vertex)]
|
||||
#[repr(C)]
|
||||
pub struct Vertex2D {
|
||||
#[format(R32G32_SFLOAT)]
|
||||
pub position: [f32; 2],
|
||||
|
||||
#[format(R32G32B32_SFLOAT)]
|
||||
pub color: [f32; 3],
|
||||
}
|
||||
|
||||
impl Vertex2D {
|
||||
pub fn create_buffer(
|
||||
vertices: Vec<Vertex2D>,
|
||||
memory_allocator: &Arc<StandardMemoryAllocator>,
|
||||
) -> Result<Subbuffer<[Vertex2D]>, Validated<AllocateBufferError>> {
|
||||
Buffer::from_iter(
|
||||
memory_allocator.clone(),
|
||||
BufferCreateInfo {
|
||||
usage: BufferUsage::VERTEX_BUFFER,
|
||||
..Default::default()
|
||||
},
|
||||
AllocationCreateInfo {
|
||||
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE
|
||||
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||
..Default::default()
|
||||
},
|
||||
vertices,
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue