Last active
June 11, 2022 01:44
-
-
Save chasepeck/2ff217dd2ea579fb951f35a54e43610b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use sdl2::render::Canvas; | |
pub fn new_sdl(name: &str, width: u32, height: u32) | |
-> (sdl2::Sdl, Canvas<sdl2::video::Window>, sdl2::VideoSubsystem) | |
{ | |
let context = sdl2::init().unwrap(); | |
let video_subsystem = context.video().unwrap(); | |
let window = new_window(name, width, height, &video_subsystem); | |
let canvas = new_canvas(window); | |
(context, canvas, video_subsystem) | |
} | |
pub fn new_window(name: &str, width: u32, height: u32, video: &sdl2::VideoSubsystem) | |
-> sdl2::video::Window | |
{ | |
let window = video.window(&name, width, height) | |
.position_centered() | |
.build() | |
.unwrap(); | |
window | |
} | |
pub fn new_canvas(window: sdl2::video::Window) | |
-> Canvas<sdl2::video::Window> | |
{ | |
let canvas = window.into_canvas().build().unwrap(); | |
canvas | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment