diff options
| author | 2020-05-28 21:52:34 +0200 | |
|---|---|---|
| committer | 2020-05-28 21:52:34 +0200 | |
| commit | d3db055583f4cbef1441fd66d07da70424bd1200 (patch) | |
| tree | 9f695bd26f688a5aaf3b8fa687a0e3ff096ffe11 /graphics/src/triangle.rs | |
| parent | ead4186870d1b46015986f702dd63382498060fc (diff) | |
| parent | 709ed1f3f7ad8cf67a176763e394aaae4e808e93 (diff) | |
| download | iced-d3db055583f4cbef1441fd66d07da70424bd1200.tar.gz iced-d3db055583f4cbef1441fd66d07da70424bd1200.tar.bz2 iced-d3db055583f4cbef1441fd66d07da70424bd1200.zip  | |
Merge pull request #354 from hecrj/feature/glow-renderer
OpenGL renderer and backend-agnostic graphics subcrate
Diffstat (limited to 'graphics/src/triangle.rs')
| -rw-r--r-- | graphics/src/triangle.rs | 32 | 
1 files changed, 32 insertions, 0 deletions
diff --git a/graphics/src/triangle.rs b/graphics/src/triangle.rs new file mode 100644 index 00000000..ce879ffc --- /dev/null +++ b/graphics/src/triangle.rs @@ -0,0 +1,32 @@ +//! Draw geometry using meshes of triangles. + +/// 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>, +} + +/// A two-dimensional vertex with some color in __linear__ RGBA. +#[derive(Copy, Clone, Debug)] +#[repr(C)] +pub struct Vertex2D { +    /// The vertex position +    pub position: [f32; 2], +    /// The vertex color in __linear__ RGBA. +    pub color: [f32; 4], +} + +#[allow(unsafe_code)] +unsafe impl bytemuck::Zeroable for Vertex2D {} + +#[allow(unsafe_code)] +unsafe impl bytemuck::Pod for Vertex2D {}  | 
