This commit is contained in:
griffi-gh 2024-03-07 23:03:13 +01:00
parent 8729e8f345
commit 67b55ec3c1
4 changed files with 10 additions and 8 deletions

View file

@ -9,11 +9,5 @@ in vec2 vtx_uv;
uniform sampler2D tex;
void main() {
//HACK: if vtx_uv is (0, 0) then the texture is not used
//disabling this will cause blinking
if (vtx_uv.x == 0.0 && vtx_uv.y == 0.0) {
out_color = vtx_color;
return;
}
out_color = texture(tex, vtx_uv) * vtx_color;
}

View file

@ -165,6 +165,7 @@ impl UiDrawCall {
.map(|x| atlas.get_uv(x))
.flatten()
.unwrap_or(Corners::all(Vec2::ZERO));
let vidx = draw_call.vertices.len() as u32;
if let Some(corner) = rounded_corners.filter(|x| x.radius.max_f32() > 0.0) {
//this code is stupid as fuck

View file

@ -219,6 +219,14 @@ impl TextureAtlasManager {
}
}
pub(crate) fn add_dummy(&mut self) {
let handle = self.allocate((1, 1).into());
assert!(handle.index == 0, "Dummy texture handle is not 0");
assert!(self.get(handle).unwrap().position == (0, 0).into(), "Dummy texture position is not (0, 0)");
self.data[0..4].copy_from_slice(&[255, 255, 255, 255]);
self.modified = true;
}
pub fn modify(&mut self, handle: ImageHandle) {
todo!()
}

View file

@ -43,8 +43,7 @@ impl UiInstance {
text_renderer: TextRenderer::new(),
atlas: {
let mut atlas = TextureAtlasManager::default();
//HACK: Ensure that vec(0, 0) uv is white square
atlas.add_rgba(1, &[255, 255, 255, 255]);
atlas.add_dummy();
atlas
},
events: EventQueue::new(),