From 67b55ec3c1579c388c179e55ee5b14016cdc76b7 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Thu, 7 Mar 2024 23:03:13 +0100 Subject: [PATCH] stuff --- hui-glium/shaders/fragment.frag | 6 ------ hui/src/draw.rs | 1 + hui/src/draw/atlas.rs | 8 ++++++++ hui/src/instance.rs | 3 +-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hui-glium/shaders/fragment.frag b/hui-glium/shaders/fragment.frag index fd190b6..a0e632e 100644 --- a/hui-glium/shaders/fragment.frag +++ b/hui-glium/shaders/fragment.frag @@ -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; } diff --git a/hui/src/draw.rs b/hui/src/draw.rs index 3772d74..cf0b9f8 100644 --- a/hui/src/draw.rs +++ b/hui/src/draw.rs @@ -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 diff --git a/hui/src/draw/atlas.rs b/hui/src/draw/atlas.rs index a283b02..3d49e67 100644 --- a/hui/src/draw/atlas.rs +++ b/hui/src/draw/atlas.rs @@ -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!() } diff --git a/hui/src/instance.rs b/hui/src/instance.rs index 62511cc..ece8299 100644 --- a/hui/src/instance.rs +++ b/hui/src/instance.rs @@ -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(),