#[repr(C)]pub struct Vector4<T> {
pub x: T,
pub y: T,
pub z: T,
pub w: T,
}Fields§
§x: T§y: T§z: T§w: TImplementations§
Source§impl<T> Vector4<T>where
T: Scalar,
impl<T> Vector4<T>where
T: Scalar,
Sourcepub fn new(x: T, y: T, z: T, w: T) -> Vector4<T>
pub fn new(x: T, y: T, z: T, w: T) -> Vector4<T>
Examples found in repository?
examples/triangle.rs (line 141)
111fn main() {
112 // initialize GLFW3 with OpenGL ES 3.0
113 let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
114 glfw.window_hint(glfw::WindowHint::ContextCreationApi(
115 glfw::ContextCreationApi::Egl,
116 ));
117 glfw.window_hint(glfw::WindowHint::ClientApi(glfw::ClientApiHint::OpenGlEs));
118 glfw.window_hint(glfw::WindowHint::ContextVersion(3, 0));
119 glfw.window_hint(glfw::WindowHint::OpenGlProfile(
120 glfw::OpenGlProfileHint::Core,
121 ));
122 glfw.window_hint(glfw::WindowHint::DoubleBuffer(true));
123 glfw.window_hint(glfw::WindowHint::Resizable(true));
124 glfw.window_hint(glfw::WindowHint::Floating(true));
125
126 let (mut window, events) = glfw
127 .create_window(1024, 900, "Triangle", glfw::WindowMode::Windowed)
128 .expect("Failed to create GLFW window.");
129
130 window.set_char_polling(true);
131 window.set_cursor_pos_polling(true);
132 window.set_key_polling(true);
133 window.set_mouse_button_polling(true);
134 window.make_current();
135 glfw.set_swap_interval(glfw::SwapInterval::Sync(1));
136
137 let mut driver = renderer::get_driver();
138
139 let vertices = vec![
140 Vertex {
141 position: Vec4f::new(-0.5, -0.5, 0.0, 1.0),
142 color: Vec4f::new(1.0, 0.0, 0.0, 1.0),
143 },
144 Vertex {
145 position: Vec4f::new(0.5, -0.5, 0.0, 1.0),
146 color: Vec4f::new(0.0, 0.0, 1.0, 1.0),
147 },
148 Vertex {
149 position: Vec4f::new(0.0, 0.5, 0.0, 1.0),
150 color: Vec4f::new(0.0, 1.0, 0.0, 1.0),
151 },
152 ];
153
154 let mut vertex_buffer = driver
155 .create_device_buffer(DeviceBufferDesc::Vertex(Usage::Dynamic(
156 3 * std::mem::size_of::<Vertex>(),
157 )))
158 .unwrap();
159 let pipeline = init_render_objects(&mut driver);
160
161 let mut quit = false;
162 while !window.should_close() {
163 let (width, height) = window.get_framebuffer_size();
164
165 let mut pass = Pass::new(
166 width as usize,
167 height as usize,
168 None,
169 [
170 ColorPassAction::Clear(color4b(0x00, 0x00, 0x00, 0x00)),
171 ColorPassAction::Previous,
172 ColorPassAction::Previous,
173 ColorPassAction::Previous,
174 ],
175 DepthPassAction::Clear(1.0),
176 );
177
178 let bindings = Bindings {
179 vertex_buffers: vec![vertex_buffer.clone()],
180 index_buffer: None,
181
182 vertex_images: Vec::new(),
183 pixel_images: Vec::new(),
184 };
185
186 pass.update_device_buffer(&mut vertex_buffer, 0, Arc::new(vertices.to_vec()));
187 pass.draw(&pipeline, &bindings, Arc::new(Vec::<Vec3f>::new()), 1, 1);
188 driver.render_pass(&mut pass);
189 window.swap_buffers();
190
191 glfw.poll_events();
192 for (_, event) in glfw::flush_messages(&events) {
193 match event {
194 glfw::WindowEvent::Key(glfw::Key::Escape, _, _, _) | glfw::WindowEvent::Close => {
195 quit = true
196 }
197 _ => (),
198 }
199 }
200
201 if quit {
202 window.set_should_close(true)
203 }
204 }
205}Trait Implementations§
Source§impl AttributeDataTypeGetter for Vector4<f32>
impl AttributeDataTypeGetter for Vector4<f32>
Source§impl AttributeDataTypeGetter for Vector4<i16>
impl AttributeDataTypeGetter for Vector4<i16>
Source§impl AttributeDataTypeGetter for Vector4<i32>
impl AttributeDataTypeGetter for Vector4<i32>
Source§impl AttributeDataTypeGetter for Vector4<i8>
impl AttributeDataTypeGetter for Vector4<i8>
Source§impl AttributeDataTypeGetter for Vector4<u32>
impl AttributeDataTypeGetter for Vector4<u32>
Source§impl AttributeDataTypeGetter for Vector4<u8>
impl AttributeDataTypeGetter for Vector4<u8>
Source§impl<T> FloatVector<T> for Vector4<T>where
T: FloatScalar,
impl<T> FloatVector<T> for Vector4<T>where
T: FloatScalar,
Source§impl<T> Swizzle3<T> for Vector4<T>where
T: Scalar,
impl<T> Swizzle3<T> for Vector4<T>where
T: Scalar,
fn xxx(&self) -> Vector3<T>
fn xxy(&self) -> Vector3<T>
fn xxz(&self) -> Vector3<T>
fn xyx(&self) -> Vector3<T>
fn xyy(&self) -> Vector3<T>
fn xyz(&self) -> Vector3<T>
fn xzx(&self) -> Vector3<T>
fn xzy(&self) -> Vector3<T>
fn xzz(&self) -> Vector3<T>
fn yxx(&self) -> Vector3<T>
fn yxy(&self) -> Vector3<T>
fn yxz(&self) -> Vector3<T>
fn yyx(&self) -> Vector3<T>
fn yyy(&self) -> Vector3<T>
fn yyz(&self) -> Vector3<T>
fn yzx(&self) -> Vector3<T>
fn yzy(&self) -> Vector3<T>
fn yzz(&self) -> Vector3<T>
fn zxx(&self) -> Vector3<T>
fn zxy(&self) -> Vector3<T>
fn zxz(&self) -> Vector3<T>
fn zyx(&self) -> Vector3<T>
fn zyy(&self) -> Vector3<T>
fn zyz(&self) -> Vector3<T>
fn zzx(&self) -> Vector3<T>
fn zzy(&self) -> Vector3<T>
fn zzz(&self) -> Vector3<T>
Source§impl UniformDataTypeGetter for Vector4<f32>
impl UniformDataTypeGetter for Vector4<f32>
Source§impl UniformDataTypeGetter for Vector4<i32>
impl UniformDataTypeGetter for Vector4<i32>
Source§impl UniformDataTypeGetter for Vector4<u32>
impl UniformDataTypeGetter for Vector4<u32>
Source§impl<T> Vector<T> for Vector4<T>where
T: Scalar,
impl<T> Vector<T> for Vector4<T>where
T: Scalar,
Source§fn dot(l: &Vector4<T>, r: &Vector4<T>) -> T
fn dot(l: &Vector4<T>, r: &Vector4<T>) -> T
Computes the dot product of two vectors. Read more
Source§fn mul_vv(l: &Vector4<T>, r: &Vector4<T>) -> Vector4<T>
fn mul_vv(l: &Vector4<T>, r: &Vector4<T>) -> Vector4<T>
Multiplies two vectors component-wise (Hadamard product).
Source§fn rem_vv(l: &Vector4<T>, r: &Vector4<T>) -> Vector4<T>
fn rem_vv(l: &Vector4<T>, r: &Vector4<T>) -> Vector4<T>
Computes the remainder of component-wise division.
impl<T> Copy for Vector4<T>where
T: Copy,
Auto Trait Implementations§
impl<T> Freeze for Vector4<T>where
T: Freeze,
impl<T> RefUnwindSafe for Vector4<T>where
T: RefUnwindSafe,
impl<T> Send for Vector4<T>where
T: Send,
impl<T> Sync for Vector4<T>where
T: Sync,
impl<T> Unpin for Vector4<T>where
T: Unpin,
impl<T> UnwindSafe for Vector4<T>where
T: UnwindSafe,
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