1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

[user textures] switch WHITE_UV to (0,0) and require clamped sampling

This commit is contained in:
Emil Ernerfeldt
2020-09-09 15:24:09 +02:00
parent 7093de0ff2
commit 8984302122
3 changed files with 18 additions and 13 deletions

View File

@@ -87,20 +87,16 @@ impl Fonts {
let mut atlas = TextureAtlas::new(512, 16); // TODO: better default?
// Make the top left four pixels fully white:
{
let pos = atlas.allocate((2, 2));
// Make the top left pixel fully white:
let pos = atlas.allocate((1, 1));
assert_eq!(pos, (0, 0));
let tex = atlas.texture_mut();
tex[(0, 0)] = 255;
tex[(0, 1)] = 255;
tex[(1, 0)] = 255;
tex[(1, 1)] = 255;
atlas.texture_mut()[pos] = 255;
}
let atlas = Arc::new(Mutex::new(atlas));
// TODO: figure out a way to make the wasm smaller despite including a font. Zip it?
// TODO: figure out a way to make the WASM smaller despite including a font. Zip it?
let monospace_typeface_data = include_bytes!("../../fonts/ProggyClean.ttf"); // Use 13 for this. NOTHING ELSE.
// let monospace_typeface_data = include_bytes!("../../fonts/Roboto-Regular.ttf");

View File

@@ -15,7 +15,10 @@ use {
};
/// The UV coordinate of a white region of the texture mesh.
pub const WHITE_UV: (u16, u16) = (1, 1);
/// The default Egui texture has the top-left corner pixel fully white.
/// You need need use a clamping texture sampler for this to work
/// (so it doesn't do bilinear blending with bottom right corner).
pub const WHITE_UV: (u16, u16) = (0, 0);
/// The vertex type.
///
@@ -26,8 +29,11 @@ pub struct Vertex {
/// Logical pixel coordinates (points).
/// (0,0) is the top left corner of the screen.
pub pos: Pos2, // 64 bit
/// Texel coordinates in the texture
/// Texel coordinates in the texture.
/// (0, 0) is the top left corner of the texture.
pub uv: (u16, u16), // 32 bit
/// sRGBA with premultiplied alpha
pub color: Srgba, // 32 bit
}