diff mbox

[1/4] opengl: some shader infrastructure

Message ID 1425384427-2551-2-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann March 3, 2015, 12:07 p.m. UTC
---
 Makefile                 | 14 ++++++++++++++
 scripts/shaderinclude.pl | 16 ++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100644 scripts/shaderinclude.pl

Comments

Max Reitz March 3, 2015, 4:35 p.m. UTC | #1
On 2015-03-03 at 07:07, Gerd Hoffmann wrote:
> ---
>   Makefile                 | 14 ++++++++++++++
>   scripts/shaderinclude.pl | 16 ++++++++++++++++
>   2 files changed, 30 insertions(+)
>   create mode 100644 scripts/shaderinclude.pl

With your S-o-b added:

Reviewed-by: Max Reitz <mreitz@redhat.com>
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 6817c6f..285eb27 100644
--- a/Makefile
+++ b/Makefile
@@ -292,6 +292,7 @@  clean:
 	rm -f fsdev/*.pod
 	rm -rf .libs */.libs
 	rm -f qemu-img-cmds.h
+	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
 	@# May not be present in GENERATED_HEADERS
 	rm -f trace/generated-tracers-dtrace.dtrace*
 	rm -f trace/generated-tracers-dtrace.h*
@@ -437,6 +438,19 @@  cscope:
 	find "$(SRC_PATH)" -name "*.[chsS]" -print | sed 's,^\./,,' > ./cscope.files
 	cscope -b
 
+# opengl shader programs
+ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
+	@mkdir -p $(dir $@)
+	$(call quiet-command,\
+		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
+		"  VERT  $@")
+
+ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
+	@mkdir -p $(dir $@)
+	$(call quiet-command,\
+		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
+		"  FRAG  $@")
+
 # documentation
 MAKEINFO=makeinfo
 MAKEINFOFLAGS=--no-headers --no-split --number-sections
diff --git a/scripts/shaderinclude.pl b/scripts/shaderinclude.pl
new file mode 100644
index 0000000..81b5146
--- /dev/null
+++ b/scripts/shaderinclude.pl
@@ -0,0 +1,16 @@ 
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+my $file = shift;
+open FILE, "<", $file or die "open $file: $!";
+my $name = $file;
+$name =~ s|.*/||;
+$name =~ s/[-.]/_/g;
+print "static GLchar ${name}_src[] =\n";
+while (<FILE>) {
+    chomp;
+    printf "    \"%s\\n\"\n", $_;
+}
+print "    \"\\n\";\n";
+close FILE;