aboutsummaryrefslogtreecommitdiff
path: root/stockton-render/src/draw/ui
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-08-25 17:44:23 +0100
committertcmal <me@aria.rip>2024-08-25 17:44:23 +0100
commit6ab13f2d0cb345795f761181a06777ade61ff09c (patch)
tree42007acef9846d5e79f1bf418a96647f34b530d1 /stockton-render/src/draw/ui
parentccf0074b08ce835cf22e7d46153d1cb3f3d06d32 (diff)
refactor(all): separate rendering from framework
stockton-passes is mostly just a stand-in until this is properly separated
Diffstat (limited to 'stockton-render/src/draw/ui')
-rw-r--r--stockton-render/src/draw/ui/data/stockton.frag15
-rw-r--r--stockton-render/src/draw/ui/data/stockton.vert37
-rw-r--r--stockton-render/src/draw/ui/mod.rs52
3 files changed, 0 insertions, 104 deletions
diff --git a/stockton-render/src/draw/ui/data/stockton.frag b/stockton-render/src/draw/ui/data/stockton.frag
deleted file mode 100644
index c30c99e..0000000
--- a/stockton-render/src/draw/ui/data/stockton.frag
+++ /dev/null
@@ -1,15 +0,0 @@
-#version 450
-#extension GL_ARB_separate_shader_objects : enable
-
-// DescriptorSet 0 = Textures
-layout(set = 0, binding = 0) uniform texture2D tex[8];
-layout(set = 0, binding = 1) uniform sampler samp[8];
-
-layout (location = 1) in vec2 frag_uv;
-layout (location = 2) in vec4 frag_col;
-
-layout (location = 0) out vec4 color;
-
-void main() {
- color = texture(sampler2D(tex[0], samp[0]), frag_uv) * frag_col;
-} \ No newline at end of file
diff --git a/stockton-render/src/draw/ui/data/stockton.vert b/stockton-render/src/draw/ui/data/stockton.vert
deleted file mode 100644
index 8912e96..0000000
--- a/stockton-render/src/draw/ui/data/stockton.vert
+++ /dev/null
@@ -1,37 +0,0 @@
-#version 450
-
-layout (push_constant) uniform PushConsts {
- vec2 screen_size;
-} push;
-
-layout (location = 0) in vec2 pos;
-layout (location = 1) in vec2 uv;
-layout (location = 2) in vec4 col;
-
-out gl_PerVertex {
- vec4 gl_Position;
-};
-layout (location = 1) out vec2 frag_uv;
-layout (location = 2) out vec4 frag_col;
-
-vec3 linear_from_srgb(vec3 srgb) {
- bvec3 cutoff = lessThan(srgb, vec3(10.31475));
- vec3 lower = srgb / vec3(3294.6);
- vec3 higher = pow((srgb + vec3(14.025)) / vec3(269.025), vec3(2.4));
- return mix(higher, lower, cutoff);
-}
-
-vec4 linear_from_srgba(vec4 srgba) {
- return vec4(linear_from_srgb(srgba.rgb * 255.0), srgba.a);
-}
-
-void main() {
- gl_Position = vec4(
- 2.0 * pos.x / push.screen_size.x - 1.0,
- 2.0 * pos.y / push.screen_size.y - 1.0,
- 0.0,
- 1.0
- );
- frag_uv = uv;
- frag_col = linear_from_srgba(col);
-}
diff --git a/stockton-render/src/draw/ui/mod.rs b/stockton-render/src/draw/ui/mod.rs
deleted file mode 100644
index 1b52753..0000000
--- a/stockton-render/src/draw/ui/mod.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-use crate::draw::texture::{resolver::TextureResolver, LoadableImage};
-use egui::{CtxRef, Texture};
-use std::{convert::TryInto, sync::Arc};
-
-pub struct UiTextures {
- ctx: CtxRef,
-}
-
-impl TextureResolver for UiTextures {
- type Image = Arc<Texture>;
- fn resolve(&mut self, tex: u32) -> Option<Self::Image> {
- if tex == 0 {
- Some(self.ctx.texture())
- } else {
- None
- }
- }
-}
-
-impl UiTextures {
- pub fn new(ctx: CtxRef) -> Self {
- UiTextures { ctx }
- }
-}
-
-impl LoadableImage for Arc<Texture> {
- fn width(&self) -> u32 {
- self.width as u32
- }
- fn height(&self) -> u32 {
- self.height as u32
- }
- fn copy_row(&self, y: u32, ptr: *mut u8) {
- let row_size = self.width();
- let pixels = &self.pixels[(y * row_size) as usize..((y + 1) * row_size) as usize];
-
- for (i, x) in pixels.iter().enumerate() {
- unsafe {
- *ptr.offset(i as isize * 4) = 255;
- *ptr.offset((i as isize * 4) + 1) = 255;
- *ptr.offset((i as isize * 4) + 2) = 255;
- *ptr.offset((i as isize * 4) + 3) = *x;
- }
- }
- }
-
- unsafe fn copy_into(&self, ptr: *mut u8, row_size: usize) {
- for y in 0..self.height() {
- self.copy_row(y, ptr.offset((row_size * y as usize).try_into().unwrap()));
- }
- }
-}