mirror of
https://github.com/lisk77/comet.git
synced 2025-12-16 02:28:49 +00:00
feat: added Font to get glyphs out of ttf files and make a TextureAtlas with them (right now only latin range of Unicode to not explode the atlas) and started trying to incorporate text rendering in ECS and Renderer2D
This commit is contained in:
parent
5430ee0d7e
commit
9e16179df3
12 changed files with 191 additions and 317 deletions
|
|
@ -4,19 +4,21 @@ use std::{
|
|||
|
||||
use wgpu::{naga, Device, FilterMode, Queue, ShaderModule, TextureFormat, TextureUsages};
|
||||
use wgpu::naga::ShaderStage;
|
||||
use crate::{texture, Texture};
|
||||
use crate::{font, texture, Texture};
|
||||
use crate::texture_atlas::{TextureAtlas, TextureRegion};
|
||||
|
||||
pub struct GraphicResorceManager {
|
||||
pub struct GraphicResourceManager {
|
||||
texture_atlas: TextureAtlas,
|
||||
fonts: HashMap<String, TextureAtlas>,
|
||||
data_files: HashMap<String, String>,
|
||||
shaders: HashMap<String, ShaderModule>
|
||||
}
|
||||
|
||||
impl GraphicResorceManager {
|
||||
impl GraphicResourceManager {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
texture_atlas: TextureAtlas::empty(),
|
||||
fonts: HashMap::new(),
|
||||
data_files: HashMap::new(),
|
||||
shaders: HashMap::new()
|
||||
}
|
||||
|
|
@ -119,6 +121,12 @@ impl GraphicResorceManager {
|
|||
self.shaders.get(shader)
|
||||
}
|
||||
|
||||
pub fn load_font(&mut self, path: &str, size: f32) {
|
||||
let font = font::Font::new(path, size);
|
||||
let atlas = TextureAtlas::from_textures(font.glyphs(), font.names());
|
||||
self.fonts.insert(font.name().to_string(), atlas);
|
||||
}
|
||||
|
||||
/*pub async fn load_model(
|
||||
&self,
|
||||
file_name: &str,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue