[−][src]Struct golem::Surface
A framebuffer that allows render-to-texture
Implementations
impl Surface
[src]
pub fn new(ctx: &Context, texture: Texture) -> Result<Surface, GolemError>
[src]
Create a new Surface to render to, backed by the given texture
pub fn has_texture(&self) -> bool
[src]
Check if a texture is attached to this Surface
Textures can be attached via Surface::put_texture
and removed via
Surface::take_texture
.
pub fn is_bound(&self) -> bool
[src]
Check if this surface is bound to be operated on
Call Surface::bind
to bind the surface, which is required to render to it or to call
Surface::get_pixel_data
pub fn take_texture(&mut self) -> Option<Texture>
[src]
Remove the texture from the Surface to operate on it
Until another texture is added via Surface::put_texture
, operations on the Surface will
panic.
pub fn put_texture(&mut self, texture: Texture)
[src]
Put a texture into the Surface to operate on
pub fn bind(&self)
[src]
Set the current render target to this surface
Also necessary for operations like Surface::get_pixel_data
pub fn unbind(ctx: &Context)
[src]
Unbind the surface and set the render target to the screen
pub fn get_pixel_data(
&self,
x: u32,
y: u32,
width: u32,
height: u32,
format: ColorFormat,
data: &mut [u8]
)
[src]
&self,
x: u32,
y: u32,
width: u32,
height: u32,
format: ColorFormat,
data: &mut [u8]
)
Get the pixel data and write it to a buffer
The surface must be bound first, see Surface::bind
.
The ColorFormat determines how many bytes each pixel is: 3 bytes for RGB and 4 for RGBA. The
slice needs have a length of (width - x) * (height - y) * ColorFormat size
.
pub fn width(&self) -> Option<u32>
[src]
Get the width of the inner texture, or None if there is no texture
pub fn height(&self) -> Option<u32>
[src]
Get the height of the inner texture, or None if there is no texture
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Surface
impl !Send for Surface
impl !Sync for Surface
impl Unpin for Surface
impl !UnwindSafe for Surface
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,