Draft new iced_graphics crate 🎉
This commit is contained in:
parent
d4743183d4
commit
05af8d00d4
100 changed files with 861 additions and 1755 deletions
|
|
@ -4,6 +4,8 @@ use iced_native::{Rectangle, Vector};
|
|||
use std::mem;
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
pub use iced_graphics::triangle::{Mesh2D, Vertex2D};
|
||||
|
||||
mod msaa;
|
||||
|
||||
const UNIFORM_BUFFER_SIZE: usize = 100;
|
||||
|
|
@ -236,7 +238,7 @@ impl Pipeline {
|
|||
.into();
|
||||
|
||||
let vertex_buffer = device.create_buffer_with_data(
|
||||
mesh.vertices.as_bytes(),
|
||||
bytemuck::cast_slice(&mesh.vertices),
|
||||
wgpu::BufferUsage::COPY_SRC,
|
||||
);
|
||||
|
||||
|
|
@ -387,26 +389,3 @@ impl From<Transformation> for Uniforms {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A two-dimensional vertex with some color in __linear__ RGBA.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, AsBytes)]
|
||||
pub struct Vertex2D {
|
||||
/// The vertex position
|
||||
pub position: [f32; 2],
|
||||
/// The vertex color in __linear__ RGBA.
|
||||
pub color: [f32; 4],
|
||||
}
|
||||
|
||||
/// A set of [`Vertex2D`] and indices representing a list of triangles.
|
||||
///
|
||||
/// [`Vertex2D`]: struct.Vertex2D.html
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Mesh2D {
|
||||
/// The vertices of the mesh
|
||||
pub vertices: Vec<Vertex2D>,
|
||||
/// The list of vertex indices that defines the triangles of the mesh.
|
||||
///
|
||||
/// Therefore, this list should always have a length that is a multiple of 3.
|
||||
pub indices: Vec<u32>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue