PDA

View Full Version : Simple script for autogenerate extension loading library:



07-26-2002, 02:10 PM
Generate void EXTinit(void) function for all EXT:
-------------------------------
#!/bin/bash
echo "/*generated "`date`"*/" > h.tmp
echo -e "\t void EXTinit(void){\n" > f.tmp

grep "APIENTRY gl" /usr/X11R6/include/GL/glext.h | \
sed 's/^.*APIENTRY gl/gl/' | sed 's/(.*);//' | while read FunName
do

if grep $FunName /usr/X11R6/include/GL/gl.h > /dev/null
then
continue
#Don't EXT now? not sure
fi

FunPType=PFN`echo $FunName | tr '[:lower:]' '[:upper:]'`PROC
echo "$FunPType $FunName;" >> h.tmp
echo -e "$FunName=($FunPType)glXGetProcAddressARB(\"$FunName\");" >> f.tmp

done

echo -e "\n}" >> f.tmp

cat h.tmp > extinit.h
cat f.tmp >> extinit.h
rm h.tmp f.tmp
----------------------------------

Generate GLboolean EXTinit(void) function for used in *.c *.h files EXT only:
---------------------
#!/bin/bash
echo "/*generated "`date`"*/" > h.tmp
echo -e "\tGLboolean EXTinit(void){\n\
GLboolean Status=1;" > f.tmp

grep "APIENTRY gl" /usr/X11R6/include/GL/glext.h | \
sed 's/^.*APIENTRY gl/gl/' | sed 's/(.*);//' | while read FunName
do

if grep $FunName /usr/X11R6/include/GL/gl.h > /dev/null
then
continue
#Don't EXT now? not sure
fi

if grep $FunName *.c *.h > /dev/null
then
FunPType=PFN`echo $FunName | tr '[:lower:]' '[:upper:]'`PROC
echo "$FunPType $FunName;" >> h.tmp
echo -e "$FunName=($FunPType)glXGetProcAddressARB(\"$FunName\");\n\
if (!$FunName)\
{ printf(\"$FunName do'not present!\\\n\"); Status=0; }" >> f.tmp
fi

done

echo -e "return Status;\n}\n" >> f.tmp

cat h.tmp > extinit.h
cat f.tmp >> extinit.h
rm h.tmp f.tmp
-----------------------------------
Excuse my english.