aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-16 12:05:48 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-16 12:05:48 +0200
commit548fcede95d44a3486e43f24302809792754861a (patch)
tree60b27e52b1d3a6826c03e943141184541bb864c5
parent83ed40fd01120e1b46dba5d2bac895862731196d (diff)
WIP fragment shader hello world
-rw-r--r--.gitignore2
-rwxr-xr-xblobheader15
-rw-r--r--hello.frag6
-rw-r--r--hello.vert0
-rw-r--r--makefile9
5 files changed, 32 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index f0c9b81..47cfc5d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
*.o
main
+*_frag.*
+*_vert.*
diff --git a/blobheader b/blobheader
new file mode 100755
index 0000000..c188205
--- /dev/null
+++ b/blobheader
@@ -0,0 +1,15 @@
+#!/bin/sh
+source="$1"
+symbol_base="$(echo "$source" | tr '[:punct:]' '_')"
+cat << EOF
+#pragma once
+// NOTE: THIS FILE IS GENERATED, DO NOT EDIT
+#include <stddef.h>
+
+extern char _binary_${symbol_base}_start;
+extern char _binary_${symbol_base}_end;
+
+#define ${symbol_base} ((const char* const)(&_binary_${symbol_base}_start))
+#define ${symbol_base}_size ((size_t)(&_binary_${symbol_base}_end - &_binary_${symbol_base}_start))
+
+EOF
diff --git a/hello.frag b/hello.frag
new file mode 100644
index 0000000..b88dc43
--- /dev/null
+++ b/hello.frag
@@ -0,0 +1,6 @@
+#version 330 core
+
+void main() {
+ gl_FragColor = vec4(gl_FragCoord.xy, 0, 1);
+}
+
diff --git a/hello.vert b/hello.vert
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hello.vert
diff --git a/makefile b/makefile
index 49551f1..539ac68 100644
--- a/makefile
+++ b/makefile
@@ -8,6 +8,15 @@ all: main FORCE
main: main.o
main: die.o
main: draw.o
+main: hello_frag.o
+main: hello_vert.o
+
+%_frag.o %_frag.h &: %.frag
+ ld -r -b binary -o $*_frag.o $<
+ ./blobheader $< > $*_frag.h
+%_vert.o %_vert.h &: %.vert
+ ld -r -b binary -o $*_vert.o $<
+ ./blobheader $< > $*_vert.h
clean: FORCE
git clean -fxdi