Finished implementing refresh in a separate thread.
This commit is contained in:
+5
-9
@@ -1,22 +1,18 @@
|
||||
|
||||
pub mod structs;
|
||||
|
||||
use sdl3::{Sdl, pixels::Color, rect::Rect, render::Canvas, ttf::Font, video::Window};
|
||||
use sdl3::{Sdl, pixels::Color, rect::Rect};
|
||||
use structs::{Prefs};
|
||||
|
||||
pub struct Screen<'a> {
|
||||
canvas: Box<Canvas<Window>>,
|
||||
font: Box<Font<'a>>,
|
||||
context: Box<Sdl>
|
||||
}
|
||||
use crate::renderer::structs::Screen;
|
||||
|
||||
impl Screen<'_> {
|
||||
|
||||
pub fn get_context(&self) -> &Sdl {
|
||||
pub fn _get_context(&self) -> &Sdl {
|
||||
return &self.context;
|
||||
}
|
||||
|
||||
pub fn print(&mut self, line: u32, text: &str) {
|
||||
pub fn _print(&mut self, line: u32, text: &str) {
|
||||
let rendered_text = self.font.render(text).solid(Color::RED).unwrap();
|
||||
let texture_creator = self.canvas.texture_creator();
|
||||
let texture = rendered_text.as_texture(&texture_creator).unwrap();
|
||||
@@ -35,7 +31,7 @@ impl Screen<'_> {
|
||||
|
||||
/// Initialize video, allocate buffers and load fonts
|
||||
/// Based on https://github.com/vhspace/sdl3-rs/blob/master/examples/ttf-demo.rs
|
||||
pub fn init(prefs: &Prefs) -> Screen<'_> {
|
||||
pub fn _init(prefs: &Prefs) -> Screen<'_> {
|
||||
// Initialize the screen
|
||||
let sdl_context = sdl3::init().unwrap();
|
||||
let video_subsys = sdl_context.video().unwrap();
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
use sdl3::{Sdl, render::Canvas, ttf::Font, video::Window};
|
||||
|
||||
|
||||
pub struct Screen<'a> {
|
||||
pub(crate) canvas: Box<Canvas<Window>>,
|
||||
pub(crate) font: Box<Font<'a>>,
|
||||
pub(crate) context: Box<Sdl>
|
||||
}
|
||||
|
||||
pub struct Prefs {
|
||||
pub font_path: String,
|
||||
|
||||
Reference in New Issue
Block a user