[oden] I gotta re-think scale and whatnot.

This commit is contained in:
John Doty 2023-08-31 18:19:59 -07:00
parent ecce7b64eb
commit 079006acdc
2 changed files with 11 additions and 9 deletions

View file

@ -24,6 +24,8 @@ struct Vertex {
tex_coords: [f32; 2], tex_coords: [f32; 2],
} }
const TEXT_SCALE: f32 = 4.0;
impl Vertex { impl Vertex {
fn desc() -> wgpu::VertexBufferLayout<'static> { fn desc() -> wgpu::VertexBufferLayout<'static> {
wgpu::VertexBufferLayout { wgpu::VertexBufferLayout {
@ -695,7 +697,7 @@ impl State {
}); });
let inconsolata = include_bytes!("./Inconsolata-Regular.ttf") as &[u8]; 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(); let mut font_textures = HashMap::new();
{ {
@ -1251,13 +1253,13 @@ impl<'a> FrameBuilder<'a> {
src_top_left: [glyph.x, glyph.y], src_top_left: [glyph.x, glyph.y],
src_dims: [glyph.w, glyph.h], src_dims: [glyph.w, glyph.h],
dest_top_left: [ dest_top_left: [
cursor_x + (glyph.adjust_x / 2.0), cursor_x + (glyph.adjust_x / TEXT_SCALE),
cursor_y + (glyph.adjust_y / 2.0), 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, color,
}); });
cursor_x += glyph.advance_width / 2.0; cursor_x += glyph.advance_width / TEXT_SCALE;
} }
for glyph in glyphs { for glyph in glyphs {

View file

@ -40,11 +40,11 @@ struct VertexOutput {
@fragment fn fs_main(in : VertexOutput)->@location(0) vec4<f32> { @fragment fn fs_main(in : VertexOutput)->@location(0) vec4<f32> {
// TODO: Should we be sampling here for the shader? // TODO: Should we be sampling here for the shader?
// let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y)); let tc = vec2(u32(in.tex_coords.x), u32(in.tex_coords.y));
// let c = textureLoad(t_diffuse, tc, 0); let c = textureLoad(t_diffuse, tc, 0);
let tc = in.tex_coords / vec2<f32>(textureDimensions(t_diffuse)); // let tc = in.tex_coords / vec2<f32>(textureDimensions(t_diffuse));
let c = textureSample(t_diffuse, s_diffuse, tc); // let c = textureSample(t_diffuse, s_diffuse, tc);
return vec4<f32>(c.r,c.r,c.r,c.r); return vec4<f32>(c.r,c.r,c.r,c.r);