[oden] I gotta re-think scale and whatnot.
This commit is contained in:
parent
ecce7b64eb
commit
079006acdc
2 changed files with 11 additions and 9 deletions
12
src/lib.rs
12
src/lib.rs
|
|
@ -24,6 +24,8 @@ struct Vertex {
|
|||
tex_coords: [f32; 2],
|
||||
}
|
||||
|
||||
const TEXT_SCALE: f32 = 4.0;
|
||||
|
||||
impl Vertex {
|
||||
fn desc() -> wgpu::VertexBufferLayout<'static> {
|
||||
wgpu::VertexBufferLayout {
|
||||
|
|
@ -695,7 +697,7 @@ impl State {
|
|||
});
|
||||
|
||||
let inconsolata = include_bytes!("./Inconsolata-Regular.ttf") as &[u8];
|
||||
let inconsolata = text::FontCache::new(&device, inconsolata, 32.0);
|
||||
let inconsolata = text::FontCache::new(&device, inconsolata, 8.0 * TEXT_SCALE);
|
||||
|
||||
let mut font_textures = HashMap::new();
|
||||
{
|
||||
|
|
@ -1251,13 +1253,13 @@ impl<'a> FrameBuilder<'a> {
|
|||
src_top_left: [glyph.x, glyph.y],
|
||||
src_dims: [glyph.w, glyph.h],
|
||||
dest_top_left: [
|
||||
cursor_x + (glyph.adjust_x / 2.0),
|
||||
cursor_y + (glyph.adjust_y / 2.0),
|
||||
cursor_x + (glyph.adjust_x / TEXT_SCALE),
|
||||
cursor_y + (glyph.adjust_y / TEXT_SCALE),
|
||||
],
|
||||
dest_dims: [glyph.w / 2.0, glyph.h / 2.0],
|
||||
dest_dims: [glyph.w / TEXT_SCALE, glyph.h / TEXT_SCALE],
|
||||
color,
|
||||
});
|
||||
cursor_x += glyph.advance_width / 2.0;
|
||||
cursor_x += glyph.advance_width / TEXT_SCALE;
|
||||
}
|
||||
|
||||
for glyph in glyphs {
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ struct VertexOutput {
|
|||
@fragment fn fs_main(in : VertexOutput)->@location(0) vec4<f32> {
|
||||
// TODO: Should we be sampling here for the shader?
|
||||
|
||||
// let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y));
|
||||
// let c = textureLoad(t_diffuse, tc, 0);
|
||||
let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y));
|
||||
let c = textureLoad(t_diffuse, tc, 0);
|
||||
|
||||
let tc = in.tex_coords / vec2<f32>(textureDimensions(t_diffuse));
|
||||
let c = textureSample(t_diffuse, s_diffuse, tc);
|
||||
// let tc = in.tex_coords / vec2<f32>(textureDimensions(t_diffuse));
|
||||
// let c = textureSample(t_diffuse, s_diffuse, tc);
|
||||
|
||||
|
||||
return vec4<f32>(c.r,c.r,c.r,c.r);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue