1#!/bin/sh 2############################################################################ 3# glsl2h.sh 4# 5# This script generates a C header file from a GLSL file. The header 6# just contains the glsl file as a static char buffer. 7# 8# Authors: 9# Morten Eriksen <mortene@sim.no> 10# Lars J. Aas <larsa@sim.no> 11# 12 13UPCASEBASE=`basename $1 .glsl | tr '[a-z]' '[A-Z]'` 14 15cat <<HERE_DOC_END 16/**************************************************************************\ 17 * Copyright (c) Kongsberg Oil & Gas Technologies AS 18 * All rights reserved. 19 * 20 * Redistribution and use in source and binary forms, with or without 21 * modification, are permitted provided that the following conditions are 22 * met: 23 * 24 * Redistributions of source code must retain the above copyright notice, 25 * this list of conditions and the following disclaimer. 26 * 27 * Redistributions in binary form must reproduce the above copyright 28 * notice, this list of conditions and the following disclaimer in the 29 * documentation and/or other materials provided with the distribution. 30 * 31 * Neither the name of the copyright holder nor the names of its 32 * contributors may be used to endorse or promote products derived from 33 * this software without specific prior written permission. 34 * 35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46\**************************************************************************/ 47 48#ifndef COIN_INTERNAL 49#error this is a private header file 50#endif /* !COIN_INTERNAL */ 51 52#ifndef SO_${UPCASEBASE}_GLSL_H 53#define SO_${UPCASEBASE}_GLSL_H 54 55static const char ${UPCASEBASE}_shadersource[] = 56HERE_DOC_END 57 58cat $1 | sed -e \ 59's/\\/\\\\/g 60s/"/\\"/g 613,$ s/^[ \t]*#.*// 62s/^/ "/ 63s/$/\\n"/ 64$ s/$/;/' 65 66# ATTN: the file did not just get corrupted ;-) 67 68cat <<HERE_DOC_END 69 70#endif /* ! SO_${UPCASEBASE}_GLSL_H */ 71HERE_DOC_END 72