Fix: properly sample white color (was off by half a texel)
This commit is contained in:
parent
4a36b2c1c1
commit
49cbd3fe07
2 changed files with 11 additions and 5 deletions
|
@ -69,9 +69,13 @@ impl Fonts {
|
|||
|
||||
let mut atlas = TextureAtlas::new(512, 8); // TODO: better default?
|
||||
|
||||
// Make one white pixel for use for various stuff:
|
||||
let pos = atlas.allocate((1, 1));
|
||||
atlas.texture_mut()[pos] = 255;
|
||||
// Make the top left four pixels fully white:
|
||||
let pos = atlas.allocate((2, 2));
|
||||
assert_eq!(pos, (0, 0));
|
||||
atlas.texture_mut()[(0, 0)] = 255;
|
||||
atlas.texture_mut()[(0, 1)] = 255;
|
||||
atlas.texture_mut()[(1, 0)] = 255;
|
||||
atlas.texture_mut()[(1, 1)] = 255;
|
||||
|
||||
let atlas = Arc::new(Mutex::new(atlas));
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ use crate::{
|
|||
types::PaintCmd,
|
||||
};
|
||||
|
||||
const WHITE_UV: (u16, u16) = (1, 1);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Serialize)]
|
||||
pub struct Vertex {
|
||||
/// Pixel coordinates
|
||||
|
@ -146,7 +148,7 @@ impl Mesher {
|
|||
let n = points.len() as u32;
|
||||
let vert = |pos, color| Vertex {
|
||||
pos,
|
||||
uv: (0, 0),
|
||||
uv: WHITE_UV,
|
||||
color,
|
||||
};
|
||||
let mesh = &mut self.mesh;
|
||||
|
@ -192,7 +194,7 @@ impl Mesher {
|
|||
|
||||
let vert = |pos, color| Vertex {
|
||||
pos,
|
||||
uv: (0, 0),
|
||||
uv: WHITE_UV,
|
||||
color,
|
||||
};
|
||||
let mesh = &mut self.mesh;
|
||||
|
|
Loading…
Reference in a new issue