pub struct Vertex {
pub pos: Vector2<f32>,
pub tex: Vector2<f32>,
pub color: Color,
}Expand description
Vertex structure defined by texture coord, space coors and color
Fields§
§pos: Vector2<f32>§tex: Vector2<f32>§color: ColorImplementations§
Source§impl Vertex
impl Vertex
Sourcepub fn new(pos: Vector2<f32>, tex: Vector2<f32>, color: Color) -> Vertex
pub fn new(pos: Vector2<f32>, tex: Vector2<f32>, color: Color) -> Vertex
Create a vertex containing position, texCoord and Color
Examples found in repository?
examples/shape.rs (lines 12-16)
8fn main() {
9 let mut window = Window::new(gust::WIDTH, gust::HEIGHT, "Hello");
10 let vert_arr = VertexArray::from(
11 vec![
12 Vertex::new(
13 Vector::new(800.0, 400.0),
14 Vector::new(200.0, 0.0),
15 Color::new(0.0, 1.0, 0.0),
16 ),
17 Vertex::new(
18 Vector::new(1200.0, 700.0),
19 Vector::new(20.0, 10.0),
20 Color::new(0.0, 1.0, 1.0),
21 ),
22 Vertex::new(
23 Vector::new(1000.0, 300.0),
24 Vector::new(0.0, 0.0),
25 Color::new(0.0, 0.2, 1.0),
26 ),
27 Vertex::new(
28 Vector::new(800.0, 100.0),
29 Vector::new(0.0, 0.0),
30 Color::new(1.0, 1.0, 0.5),
31 ),
32 Vertex::new(
33 Vector::new(600.0, 300.0),
34 Vector::new(0.0, 0.0),
35 Color::new(0.5, 0.2, 0.1),
36 ),
37 Vertex::new(
38 Vector::new(400.0, 700.0),
39 Vector::new(0.0, 0.0),
40 Color::new(1.0, 0.0, 0.0),
41 ),
42 ]
43 .as_slice(),
44 );
45
46 let vert_arr_2 = VertexArray::from(
47 vec![
48 Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::blue()),
49 Vertex::new(
50 Vector::new(0.0, 100.0),
51 Vector::new(0.0, 0.0),
52 Color::blue(),
53 ),
54 Vertex::new(
55 Vector::new(100.0, 100.0),
56 Vector::new(0.0, 0.0),
57 Color::blue(),
58 ),
59 Vertex::new(Vector::new(0.0, 0.0), Vector::new(0.0, 0.0), Color::green()),
60 Vertex::new(
61 Vector::new(100.0, 100.0),
62 Vector::new(0.0, 0.0),
63 Color::green(),
64 ),
65 Vertex::new(
66 Vector::new(100.0, 0.0),
67 Vector::new(0.0, 0.0),
68 Color::green(),
69 ),
70 ]
71 .as_slice(),
72 );
73
74 let vert_buf = VertexBuffer::new(Primitive::TriangleFan, vert_arr);
75 let vert_buf2 = VertexBuffer::new(Primitive::Triangles, vert_arr_2);
76
77 let event_handler = EventHandler::new(&window);
78
79 window.set_clear_color(Color::red());
80 window.poll(EventType::Key);
81 while window.is_open() {
82 window.poll_events();
83
84 for event in event_handler.fetch() {
85 match event.1 {
86 Events::Key(Key::Escape, _, Action::Press, _) => {
87 window.close();
88 }
89 _ => {}
90 }
91 }
92
93 window.clear();
94 window.draw(&vert_buf);
95 window.draw(&vert_buf2);
96 window.display();
97 }
98}Trait Implementations§
Source§impl From<(Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2>>::Buffer>, Color)> for Vertex
impl From<(Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2>>::Buffer>, Color)> for Vertex
Source§impl From<(Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2>>::Buffer>, Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2>>::Buffer>)> for Vertex
impl From<(Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2>>::Buffer>, Matrix<f32, U2, U1, <DefaultAllocator as Allocator<f32, U2>>::Buffer>)> for Vertex
impl Copy for Vertex
impl StructuralPartialEq for Vertex
Auto Trait Implementations§
impl Freeze for Vertex
impl RefUnwindSafe for Vertex
impl Send for Vertex
impl Sync for Vertex
impl Unpin for Vertex
impl UnsafeUnpin for Vertex
impl UnwindSafe for Vertex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SetParameter for T
impl<T> SetParameter for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.