1mod instance;
8mod sprite;
9mod vectors;
10
11pub use instance::Instance;
12pub use sdl3;
13pub use sdl3::event::Event;
14pub use sdl3::event::EventPollIterator;
15pub use sdl3::image::LoadTexture;
16pub use sdl3::keyboard::Keycode;
17pub use sdl3::pixels::Color;
18pub use sdl3::rect::Rect;
19pub use sdl3::render;
20pub use sdl3::render::ScaleMode;
21pub use sdl3::render::TextureQuery;
22pub use sdl3::ttf;
23pub use sdl3::video;
24pub use sprite::Sprite;
25pub use vectors::Vec2d;
26
27pub fn create_text_texture<'a>(
33 font: &ttf::Font,
34 text: &str,
35 color: &Color,
36 texture_creator: &'a render::TextureCreator<video::WindowContext>,
37) -> Result<render::Texture<'a>, String> {
38 let surface = match font.render(text).blended(*color) {
39 Ok(surface) => surface,
40 Err(e) => return Err(format!("Failed to create surface for text texture: {}", e)),
41 };
42
43 let texture = texture_creator
44 .create_texture_from_surface(&surface)
45 .map_err(|e| format!("Failed to create text texture from surface: {}", e))?;
46
47 Ok(texture)
48}