pub struct PixelBuffer { /* private fields */ }Expand description
A wrapper around softbuffer to provide a soft buffer for pixel manipulation
Implementations§
Source§impl PixelBuffer
impl PixelBuffer
Sourcepub fn size(&self) -> Point2
pub fn size(&self) -> Point2
Get the size of the soft buffer surface Returns the size of the soft buffer surface in pixels
Sourcepub fn write_buffers(
&mut self,
pixels: &[u32],
size: Point2,
) -> Result<(), PixelBufferError>
pub fn write_buffers( &mut self, pixels: &[u32], size: Point2, ) -> Result<(), PixelBufferError>
Write pixels to the soft buffer surface
Examples found in repository?
examples/software.rs (line 34)
6fn main() {
7 let mut runner = est_render::runner::new().expect("Failed to create runner");
8 let mut window = runner
9 .create_window("Engine Example", Point2::new(800, 600))
10 .build()
11 .expect("Failed to create window");
12
13 let mut sw = est_render::software::new(Some(&mut window))
14 .build()
15 .expect("Failed to create pixel buffer");
16
17 let mut pixels = vec![128u32; (800 * 600) as usize];
18 let mut size_px = Point2::new(800.0, 600.0);
19
20 while runner.pool_events(None) {
21 for event in runner.get_events() {
22 match event {
23 Event::WindowClosed { .. } => {
24 return;
25 }
26 Event::WindowResized { size, .. } => {
27 pixels.resize((size.x * size.y) as usize, 128);
28 size_px = Point2::new(size.x as f32, size.y as f32);
29 }
30 _ => {}
31 }
32 }
33
34 if let Err(e) = sw.write_buffers(&pixels, size_px) {
35 eprintln!("Error writing buffers: {}", e);
36 }
37 }
38}Trait Implementations§
Source§impl Clone for PixelBuffer
impl Clone for PixelBuffer
Source§fn clone(&self) -> PixelBuffer
fn clone(&self) -> PixelBuffer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PixelBuffer
impl !RefUnwindSafe for PixelBuffer
impl !Send for PixelBuffer
impl !Sync for PixelBuffer
impl Unpin for PixelBuffer
impl !UnwindSafe for PixelBuffer
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more