-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace preprocess_shaders.c with a shell script
Turns out, if we use #version 300 es profile, we don't need to make so many changes to the shaders at all. The ES is still the lowest common denominator, so shaders need to take it into account, but the same shaders will work just fine with core profile. The only change we need to make is the version header and add float precision declaration for the ES. This is easier done with sed from a shell script, which is also easier to maintain. The downside is that whoever ports this to windows will probably have to rewrite it in python. Signed-off-by: Alexander Shishkin <[email protected]>
- Loading branch information
Showing
5 changed files
with
64 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
project(CompileTimeTools) | ||
|
||
add_executable (preprocess_shaders preprocess_shaders.c) | ||
add_executable (ca3d ca3d.c) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/sh -e | ||
|
||
usage() { | ||
echo "Need -t <type> -o <outdir> <src>" | ||
} | ||
|
||
mk_glsl() { | ||
local src="$1" | ||
local dest="$2" | ||
|
||
cp "$src" "$dest" | ||
} | ||
|
||
mk_glsl_es() { | ||
local src="$1" | ||
local dest="$2" | ||
|
||
sed -e 's,#version.*,#version 300 es\nprecision highp float;\n,' \ | ||
< "$src" > "$dest" | ||
} | ||
|
||
if test -z "$1"; then | ||
usage() | ||
exit 1 | ||
fi | ||
|
||
while [ -n "$1" ]; do | ||
case "$1" in | ||
-t) | ||
shift | ||
type="$1" | ||
;; | ||
-o) | ||
shift | ||
outdir="$1" | ||
;; | ||
*) | ||
src="$1" | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
if test -z "$type" -o -z "$outdir" -o -z "$src"; then | ||
usage() | ||
exit 1 | ||
fi | ||
|
||
shader=$(basename "$src") | ||
case "$type" in | ||
glsl) | ||
mk_glsl "$src.vert" "$outdir/$shader.vert" | ||
mk_glsl "$src.frag" "$outdir/$shader.frag" | ||
;; | ||
glsl-es) | ||
mk_glsl_es "$src.vert" "$outdir/$shader.vert" | ||
mk_glsl_es "$src.frag" "$outdir/$shader.frag" | ||
;; | ||
*) | ||
exit 1 | ||
;; | ||
esac |