mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 22:38:41 -06:00
Compare commits
2 commits
5bac932108
...
0f93d0ca71
Author | SHA1 | Date | |
---|---|---|---|
griffi-gh | 0f93d0ca71 | ||
griffi-gh | ee1f3ced47 |
|
@ -1,4 +1,4 @@
|
||||||
use crate::IfModified;
|
use crate::{IfModified, text::TextRenderer};
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use glam::{Vec2, Vec4, vec2};
|
use glam::{Vec2, Vec4, vec2};
|
||||||
|
@ -49,13 +49,13 @@ pub struct UiVertex {
|
||||||
pub position: Vec2,
|
pub position: Vec2,
|
||||||
pub color: Vec4,
|
pub color: Vec4,
|
||||||
pub uv: Vec2,
|
pub uv: Vec2,
|
||||||
pub bind_texture: Option<BindTexture>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct UiDrawCall {
|
pub struct UiDrawCall {
|
||||||
pub vertices: Vec<UiVertex>,
|
pub vertices: Vec<UiVertex>,
|
||||||
pub indices: Vec<u32>,
|
pub indices: Vec<u32>,
|
||||||
|
pub bind_texture: Option<BindTexture>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -64,7 +64,7 @@ pub struct UiDrawPlan {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UiDrawPlan {
|
impl UiDrawPlan {
|
||||||
pub fn build(calls: &UiDrawCommands) -> Self {
|
pub fn build(calls: &UiDrawCommands, tr: &mut TextRenderer) -> Self {
|
||||||
let mut call = UiDrawCall::default();
|
let mut call = UiDrawCall::default();
|
||||||
for command in &calls.commands {
|
for command in &calls.commands {
|
||||||
match command {
|
match command {
|
||||||
|
@ -76,25 +76,21 @@ impl UiDrawPlan {
|
||||||
position: *position,
|
position: *position,
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(0.0, 0.0),
|
uv: vec2(0.0, 0.0),
|
||||||
bind_texture: None,
|
|
||||||
},
|
},
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position + Vec2::new(size.x, 0.0),
|
position: *position + Vec2::new(size.x, 0.0),
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(1.0, 0.0),
|
uv: vec2(1.0, 0.0),
|
||||||
bind_texture: None,
|
|
||||||
},
|
},
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position + *size,
|
position: *position + *size,
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(1.0, 1.0),
|
uv: vec2(1.0, 1.0),
|
||||||
bind_texture: None,
|
|
||||||
},
|
},
|
||||||
UiVertex {
|
UiVertex {
|
||||||
position: *position + Vec2::new(0.0, size.y),
|
position: *position + Vec2::new(0.0, size.y),
|
||||||
color: *color,
|
color: *color,
|
||||||
uv: vec2(0.0, 1.0),
|
uv: vec2(0.0, 1.0),
|
||||||
bind_texture: None,
|
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl KubiUi {
|
||||||
if self.draw_commands.commands == self.prev_draw_commands.commands {
|
if self.draw_commands.commands == self.prev_draw_commands.commands {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.draw_plan = UiDrawPlan::build(&self.draw_commands);
|
self.draw_plan = UiDrawPlan::build(&self.draw_commands, &mut self.text_renderer);
|
||||||
self.draw_plan_modified = true;
|
self.draw_plan_modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
mod font;
|
mod font;
|
||||||
mod ftm;
|
mod texman;
|
||||||
|
|
||||||
use font::FontManager;
|
use font::FontManager;
|
||||||
pub use font::FontHandle;
|
pub use font::FontHandle;
|
||||||
use ftm::FontTextureManager;
|
use texman::FontTextureManager;
|
||||||
pub use ftm::{FontTextureInfo, GlyphCacheEntry};
|
pub use texman::{FontTextureInfo, GlyphCacheEntry};
|
||||||
|
|
||||||
pub struct TextRenderer {
|
pub struct TextRenderer {
|
||||||
fm: FontManager,
|
fm: FontManager,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use fontdue::{Font, Metrics};
|
use fontdue::Metrics;
|
||||||
use glam::{IVec2, UVec2, uvec2, ivec2};
|
use glam::{IVec2, UVec2, uvec2, ivec2};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use rect_packer::DensePacker;
|
use rect_packer::DensePacker;
|
||||||
|
@ -8,8 +8,6 @@ use crate::IfModified;
|
||||||
|
|
||||||
use super::font::{FontHandle, FontManager};
|
use super::font::{FontHandle, FontManager};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash)]
|
#[derive(PartialEq, Eq, Hash)]
|
||||||
struct GlyphCacheKey {
|
struct GlyphCacheKey {
|
||||||
font_index: usize,
|
font_index: usize,
|
Loading…
Reference in a new issue