summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common/shader_3d/gen_shaders_3d.sh
blob: 8bb6a2af017e30a2b79ef442f4c8beebf11b5788 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

# This script will generate a C file containing all the shaders used by Evas_3D

DIR=`dirname $0`

OUTPUT=${DIR}/evas_gl_3d_shaders.x

exec 1<&-
exec 1>${OUTPUT}

SHADERS="$@"
vert_shaders_source=""
frag_shaders_source=""

# Write header
printf "/* DO NOT MODIFY THIS FILE AS IT IS AUTO-GENERATED\n * See: $0 */\n\n"
for shd in ${SHADERS} ; do
  lname=`basename ${shd} .shd`

  if echo ${lname} |grep _vert 2>&1 >> /dev/null ; then
    vert_shaders_source="${vert_shaders_source}    ${lname}_glsl,\n"
  fi
  if echo ${lname} |grep _frag 2>&1 >> /dev/null ; then
    frag_shaders_source="${frag_shaders_source}    ${lname}_glsl,\n"
  fi
  OIFS=$IFS
  IFS=$'\n'
  printf "static const char const ${lname}_glsl[] ="
  for line in `cat ${shd}` ; do
      printf "\n   \"${line}\\\n\""
  done
  printf ";\n\n"
  IFS=${OIFS}
done

printf "static const char *vertex_shaders[] =
{\n"
      printf "${vert_shaders_source}"
printf "};\n\n"

printf "static const char *fragment_shaders[] =
{\n"
      printf "${frag_shaders_source}"
printf "};\n"