diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | assets/text_shader.c | 4 | ||||
| -rw-r--r-- | assets/text_shader.glsl | 14 |
4 files changed, 20 insertions, 8 deletions
@@ -58,3 +58,6 @@ dkms.conf compile_commands.json wayclock .cache/ + +# Generated shader headers +assets/*.h @@ -65,6 +65,8 @@ SOKOL_BIN = $(WORK_DIR)/sokol_bin/bin SOKOL_SHDC = $(SOKOL_BIN)/$(PLATFORM)/sokol-shdc ASSETS_DIR = $(WORK_DIR)/assets +SHADER_LANG=glsl430 +SHADER_OUTPUT=sokol_impl SHADERS = \ $(ASSETS_DIR)/text_shader.glsl @@ -92,6 +94,7 @@ SOURCES = \ $(SRC_DIR)/graphics.cc \ $(SRC_DIR)/gfx.c \ $(GLAD_DIR)/glad.c \ + $(ASSETS_DIR)/text_shader.c \ $(HASHMAP_SOURCE) OBJECTS := $(SOURCES:.cc=.o) @@ -100,6 +103,8 @@ OBJECTS += $(MI_OBJECT) DEPS = $(OBJECTS:.o=.d) +$(OBJECTS): $(SHADER_HEADERS) + LIBRARIES = -lwayland-client -lEGL -lwayland-egl $(FREETYPE_ARCHIVE) -lGL all: $(WAYCLOCK) @@ -134,7 +139,7 @@ $(WAYCLOCK): $(OBJECTS) $(LIBRARIES) %.h: %.glsl @echo " SHDC $<" - @$(SOKOL_SHDC) --slang=glsl430 --format=sokol --input=$< --output=$@ + @$(SOKOL_SHDC) --slang=$(SHADER_LANG) --format=$(SHADER_OUTPUT) --input=$< --output=$@ .PHONY: clean clean: diff --git a/assets/text_shader.c b/assets/text_shader.c new file mode 100644 index 0000000..6657459 --- /dev/null +++ b/assets/text_shader.c @@ -0,0 +1,4 @@ +#include "sokol_gfx.h" +// ensure order +#define SOKOL_SHDC_IMPL +#include "text_shader.h"
\ No newline at end of file diff --git a/assets/text_shader.glsl b/assets/text_shader.glsl index 3b6ed18..b59b6eb 100644 --- a/assets/text_shader.glsl +++ b/assets/text_shader.glsl @@ -4,10 +4,10 @@ in vec2 in_position; in vec2 in_uv; -layout(binding = 0) uniform vs_text_params { +layout(binding = 0) uniform text_params { mat4 mvp; vec4 color; -} +}; out vec2 out_uv; out vec4 out_color; @@ -24,14 +24,14 @@ void main() { layout(binding = 0) uniform texture2D u_texture; layout(binding = 1) uniform sampler u_sampler; -in vec2 in_uv; -in vec4 in_color; +in vec2 out_uv; +in vec4 out_color; -out vec4 out_color; +out vec4 frag_color; void main() { - float alpha = texture(sampler2D(u_texture, u_sampler), in_uv).r; - out_color = vec4(in_color.rgb, in_color.a * alpha); + float alpha = texture(sampler2D(u_texture, u_sampler), out_uv).r; + frag_color = vec4(out_color.rgb, out_color.a * alpha); } @end |
