pub struct Graphics {
pub canvas: Canvas<Window>,
pub sdl_context: Sdl,
pub texture_creator: TextureCreator<WindowContext>,
/* private fields */
}Expand description
Owned SDL variables used for rendering
canvas: the drawing surface for the windowsdl_context: the SDL context
Fields§
§canvas: Canvas<Window>§sdl_context: Sdl§texture_creator: TextureCreator<WindowContext>Implementations§
Source§impl Graphics
impl Graphics
Sourcepub fn new(
name: String,
dimensions: (u32, u32),
) -> Result<Graphics, Box<dyn Error>>
pub fn new( name: String, dimensions: (u32, u32), ) -> Result<Graphics, Box<dyn Error>>
Initialize SDL3, create a centered, resizable window and return a Graphics
container with the canvas and SDL context.
§Parameters
name: Window title.dimensions: (width, height) in pixels (u32).
§Returns
Ok(Graphics)on success.Err(Box<dyn std::error::Error>)on failure (window/canvas build error).
§Example
let graphics = graphics::init(String::from("my cool game"), (500, 500));Auto Trait Implementations§
impl Freeze for Graphics
impl RefUnwindSafe for Graphics
impl !Send for Graphics
impl !Sync for Graphics
impl Unpin for Graphics
impl UnwindSafe for Graphics
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> 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