wgd-3.1/0000777000175000001440000000000011265576315007152 500000000000000wgd-3.1/install-sh0000755000175000001440000002176610750154243011074 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2004-09-10.20 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" chmodcmd="$chmodprog 0755" chowncmd= chgrpcmd= stripcmd= rmcmd="$rmprog -f" mvcmd="$mvprog" src= dst= dir_arg= dstarg= no_target_directory= usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: -c (ignored) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. --help display this help and exit. --version display version info and exit. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test -n "$1"; do case $1 in -c) shift continue;; -d) dir_arg=true shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; --help) echo "$usage"; exit 0;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t) dstarg=$2 shift shift continue;; -T) no_target_directory=true shift continue;; --version) echo "$0 $scriptversion"; exit 0;; *) # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. test -n "$dir_arg$dstarg" && break # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dstarg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dstarg" shift # fnord fi shift # arg dstarg=$arg done break;; esac done if test -z "$1"; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi for src do # Protect names starting with `-'. case $src in -*) src=./$src ;; esac if test -n "$dir_arg"; then dst=$src src= if test -d "$dst"; then mkdircmd=: chmodcmd= else mkdircmd=$mkdirprog fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dstarg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dstarg # Protect names starting with `-'. case $dst in -*) dst=./$dst ;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dstarg: Is a directory" >&2 exit 1 fi dst=$dst/`basename "$src"` fi fi # This sed command emulates the dirname command. dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # Skip lots of stat calls in the usual case. if test ! -d "$dstdir"; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` IFS=$oIFS pathcomp= while test $# -ne 0 ; do pathcomp=$pathcomp$1 shift if test ! -d "$pathcomp"; then $mkdirprog "$pathcomp" # mkdir can fail with a `File exist' error in case several # install-sh are creating the directory concurrently. This # is OK. test -d "$pathcomp" || exit fi pathcomp=$pathcomp/ done fi if test -n "$dir_arg"; then $doit $mkdircmd "$dst" \ && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } else dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. $doit $cpprog "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && # Now rename the file to the real destination. { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ || { # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { if test -f "$dstdir/$dstfile"; then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" } } fi || { (exit 1); exit; } done # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit } # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: wgd-3.1/configure.ac0000755000175000001440000000370611265575045011364 00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) AC_INIT(WGD, 3.1) AC_CONFIG_SRCDIR(src/base/base.cpp) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([no-dependencies]) AM_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_RANLIB AC_PROG_CXX AC_PROG_CC AC_LANG(C++) # Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_CHECK_HEADERS([fcntl.h stddef.h stdlib.h string.h sys/time.h unistd.h]) AC_CHECK_HEADERS([string vector list]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_C_INLINE AC_HEADER_TIME # Checks for library functions. AC_FUNC_ERROR_AT_LINE AC_PROG_GCC_TRADITIONAL AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_CHECK_FUNCS([memset sqrt strstr strdup]) CXXFLAGS="-g -Wall -DLINUX " CFLAGS="-DLINUX -O3" LDFLAGS="$LDFLAGS" if test "$target_cpu" == "x86_64"; then CXXFLAGS="$CXXFLAGS -DX86_64" LDFLAGS="$LDFLAGS -L/usr/X11R6/lib64" else CXXFLAGS="$CXXFLAGS -march=pentium3 -mfpmath=sse" LDFLAGS="$LDFLAGS -L/usr/X11R6/lib" fi AC_ARG_WITH(dostelib, [ --with-dostelib=PATH DOSTE library location], [ LIBS="$LIBS -L$withval"]) AC_ARG_WITH(dosteinc, [ --with-dosteinc=PATH DOSTE includes location], [ CPPFLAGS="$CPPFLAGS -I$withval"]) # Checks for libraries. noxara=0 AC_CHECK_HEADERS([doste/doste.h], [], [noxara=1]) #AC_CHECK_LIB(doste, if test "$noxara" == "1"; then AC_MSG_ERROR([DOSTE must be installed]) fi AC_OUTPUT(Makefile src/Makefile include/Makefile src/base/Makefile src/collision_2d/Makefile src/collision_3d/Makefile src/input/Makefile src/models/Makefile src/resources_base/Makefile src/base_3d/Makefile src/base_2d/Makefile src/sound/Makefile src/widgets/Makefile scripts/Makefile scripts/themes/Makefile src/wgd data/Makefile src/heightmap/Makefile include/wgd/Makefile include/wgd/widgets/Makefile include/wgd/zlib/Makefile include/wgd/png/Makefile src/xnet/Makefile src/ui/Makefile) wgd-3.1/NEWS0000644000175000001440000000000010750154243007541 00000000000000wgd-3.1/Makefile.am0000755000175000001440000000004011000437022011071 00000000000000SUBDIRS=src include scripts datawgd-3.1/configure0000755000175000001440000061067611265575056011016 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for WGD 3.1. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='WGD' PACKAGE_TARNAME='wgd' PACKAGE_VERSION='3.1' PACKAGE_STRING='WGD 3.1' PACKAGE_BUGREPORT='' ac_unique_file="src/base/base.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA am__isrc CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar RANLIB CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC CXXCPP GREP EGREP LIBOBJS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC CC CFLAGS CXXCPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures WGD 3.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/wgd] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of WGD 3.1:";; esac cat <<\_ACEOF Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-dostelib=PATH DOSTE library location --with-dosteinc=PATH DOSTE includes location Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CC C compiler command CFLAGS C compiler flags CXXCPP C++ preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF WGD configure 3.1 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by WGD $as_me 3.1, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking target system type" >&5 echo $ECHO_N "checking target system type... $ECHO_C" >&6; } if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_target" >&5 echo "${ECHO_T}$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 echo "$as_me: error: invalid value of canonical target" >&2;} { (exit 1); exit 1; }; };; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version='1.10' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { echo "$as_me:$LINENO: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftest.file ) then # Ok. : else { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm -f conftest.sed # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi { echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } if test -z "$MKDIR_P"; then if test "${ac_cv_path_mkdir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. test -d ./--version && rmdir ./--version MKDIR_P="$ac_install_sh -d" fi fi { echo "$as_me:$LINENO: result: $MKDIR_P" >&5 echo "${ECHO_T}$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { echo "$as_me:$LINENO: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$AWK" && break done { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='wgd' VERSION='3.1' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { echo "$as_me:$LINENO: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h" # Checks for programs. if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { echo "$as_me:$LINENO: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C++ compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C++ compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CXXFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu # Checks for header files. ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; } if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CXXCPP needs to be expanded for CXXCPP in "$CXX -E" "/lib/cpp" do ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CXXCPP=$CXXCPP fi CXXCPP=$ac_cv_prog_CXXCPP else ac_cv_prog_CXXCPP=$CXXCPP fi { echo "$as_me:$LINENO: result: $CXXCPP" >&5 echo "${ECHO_T}$CXXCPP" >&6; } ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi { echo "$as_me:$LINENO: checking for sys/wait.h that is POSIX.1 compatible" >&5 echo $ECHO_N "checking for sys/wait.h that is POSIX.1 compatible... $ECHO_C" >&6; } if test "${ac_cv_header_sys_wait_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_sys_wait_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_sys_wait_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYS_WAIT_H 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in fcntl.h stddef.h stdlib.h string.h sys/time.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in string vector list do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } if test "${ac_cv_header_stdbool_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; bool e = &s; char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; # if defined __xlc__ || defined __GNUC__ /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 reported by James Lemley on 2005-10-05; see http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html This test is not quite right, since xlc is allowed to reject this program, as the initializer for xlcbug is not one of the forms that C requires support for. However, doing the test right would require a runtime test, and that would make cross-compilation harder. Let us hope that IBM fixes the xlc bug, and also adds support for this kind of constant expression. In the meantime, this test will reject xlc, which is OK, since our stdbool.h substitute should suffice. We also test this with GCC, where it should work, to detect more quickly whether someone messes up the test in the future. */ char digs[] = "0123456789"; int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); # endif /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdbool_h=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; } { echo "$as_me:$LINENO: checking for _Bool" >&5 echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; } if test "${ac_cv_type__Bool+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default typedef _Bool ac__type_new_; int main () { if ((ac__type_new_ *) 0) return 0; if (sizeof (ac__type_new_)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type__Bool=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type__Bool=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 echo "${ECHO_T}$ac_cv_type__Bool" >&6; } if test $ac_cv_type__Bool = yes; then cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_STDBOOL_H 1 _ACEOF fi { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi { echo "$as_me:$LINENO: checking for inline" >&5 echo $ECHO_N "checking for inline... $ECHO_C" >&6; } if test "${ac_cv_c_inline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_inline=$ac_kw else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 echo "${ECHO_T}$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi # Checks for library functions. { echo "$as_me:$LINENO: checking for error_at_line" >&5 echo $ECHO_N "checking for error_at_line... $ECHO_C" >&6; } if test "${ac_cv_lib_error_at_line+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_error_at_line=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_lib_error_at_line" >&5 echo "${ECHO_T}$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi if test $ac_cv_c_compiler_gnu = yes; then { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } if test "${ac_cv_prog_gcc_traditional+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; } if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_malloc_0_nonnull=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_malloc_0_nonnull=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 1 _ACEOF else cat >>confdefs.h <<\_ACEOF #define HAVE_MALLOC 0 _ACEOF case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac cat >>confdefs.h <<\_ACEOF #define malloc rpl_malloc _ACEOF fi { echo "$as_me:$LINENO: checking for working memcmp" >&5 echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6; } if test "${ac_cv_func_memcmp_working+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_memcmp_working=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { /* Some versions of memcmp are not 8-bit clean. */ char c0 = '\100', c1 = '\200', c2 = '\201'; if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) return 1; /* The Next x86 OpenStep bug shows up only when comparing 16 bytes or more and with at least one buffer not starting on a 4-byte boundary. William Lewis provided this test program. */ { char foo[21]; char bar[21]; int i; for (i = 0; i < 4; i++) { char *a = foo + i; char *b = bar + i; strcpy (a, "--------01111111"); strcpy (b, "--------10000000"); if (memcmp (a, b, 16) >= 0) return 1; } return 0; } ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_memcmp_working=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_memcmp_working=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5 echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6; } test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in *" memcmp.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" ;; esac for ac_func in memset sqrt strstr strdup do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done CXXFLAGS="-g -Wall -DLINUX " CFLAGS="-DLINUX -O3" LDFLAGS="$LDFLAGS" if test "$target_cpu" == "x86_64"; then CXXFLAGS="$CXXFLAGS -DX86_64" LDFLAGS="$LDFLAGS -L/usr/X11R6/lib64" else CXXFLAGS="$CXXFLAGS -march=pentium3 -mfpmath=sse" LDFLAGS="$LDFLAGS -L/usr/X11R6/lib" fi # Check whether --with-dostelib was given. if test "${with_dostelib+set}" = set; then withval=$with_dostelib; LIBS="$LIBS -L$withval" fi # Check whether --with-dosteinc was given. if test "${with_dosteinc+set}" = set; then withval=$with_dosteinc; CPPFLAGS="$CPPFLAGS -I$withval" fi # Checks for libraries. noxara=0 for ac_header in doste/doste.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF else noxara=1 fi done #AC_CHECK_LIB(doste, if test "$noxara" == "1"; then { { echo "$as_me:$LINENO: error: DOSTE must be installed" >&5 echo "$as_me: error: DOSTE must be installed" >&2;} { (exit 1); exit 1; }; } fi ac_config_files="$ac_config_files Makefile src/Makefile include/Makefile src/base/Makefile src/collision_2d/Makefile src/collision_3d/Makefile src/input/Makefile src/models/Makefile src/resources_base/Makefile src/base_3d/Makefile src/base_2d/Makefile src/sound/Makefile src/widgets/Makefile scripts/Makefile scripts/themes/Makefile src/wgd data/Makefile src/heightmap/Makefile include/wgd/Makefile include/wgd/widgets/Makefile include/wgd/zlib/Makefile include/wgd/png/Makefile src/xnet/Makefile src/ui/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by WGD $as_me 3.1, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ WGD config.status 3.1 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "src/base/Makefile") CONFIG_FILES="$CONFIG_FILES src/base/Makefile" ;; "src/collision_2d/Makefile") CONFIG_FILES="$CONFIG_FILES src/collision_2d/Makefile" ;; "src/collision_3d/Makefile") CONFIG_FILES="$CONFIG_FILES src/collision_3d/Makefile" ;; "src/input/Makefile") CONFIG_FILES="$CONFIG_FILES src/input/Makefile" ;; "src/models/Makefile") CONFIG_FILES="$CONFIG_FILES src/models/Makefile" ;; "src/resources_base/Makefile") CONFIG_FILES="$CONFIG_FILES src/resources_base/Makefile" ;; "src/base_3d/Makefile") CONFIG_FILES="$CONFIG_FILES src/base_3d/Makefile" ;; "src/base_2d/Makefile") CONFIG_FILES="$CONFIG_FILES src/base_2d/Makefile" ;; "src/sound/Makefile") CONFIG_FILES="$CONFIG_FILES src/sound/Makefile" ;; "src/widgets/Makefile") CONFIG_FILES="$CONFIG_FILES src/widgets/Makefile" ;; "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; "scripts/themes/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/themes/Makefile" ;; "src/wgd") CONFIG_FILES="$CONFIG_FILES src/wgd" ;; "data/Makefile") CONFIG_FILES="$CONFIG_FILES data/Makefile" ;; "src/heightmap/Makefile") CONFIG_FILES="$CONFIG_FILES src/heightmap/Makefile" ;; "include/wgd/Makefile") CONFIG_FILES="$CONFIG_FILES include/wgd/Makefile" ;; "include/wgd/widgets/Makefile") CONFIG_FILES="$CONFIG_FILES include/wgd/widgets/Makefile" ;; "include/wgd/zlib/Makefile") CONFIG_FILES="$CONFIG_FILES include/wgd/zlib/Makefile" ;; "include/wgd/png/Makefile") CONFIG_FILES="$CONFIG_FILES include/wgd/png/Makefile" ;; "src/xnet/Makefile") CONFIG_FILES="$CONFIG_FILES src/xnet/Makefile" ;; "src/ui/Makefile") CONFIG_FILES="$CONFIG_FILES src/ui/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim build!$build$ac_delim build_cpu!$build_cpu$ac_delim build_vendor!$build_vendor$ac_delim build_os!$build_os$ac_delim host!$host$ac_delim host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim target!$target$ac_delim target_cpu!$target_cpu$ac_delim target_vendor!$target_vendor$ac_delim target_os!$target_os$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim am__isrc!$am__isrc$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim ACLOCAL!$ACLOCAL$ac_delim AUTOCONF!$AUTOCONF$ac_delim AUTOMAKE!$AUTOMAKE$ac_delim AUTOHEADER!$AUTOHEADER$ac_delim MAKEINFO!$MAKEINFO$ac_delim install_sh!$install_sh$ac_delim STRIP!$STRIP$ac_delim INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim mkdir_p!$mkdir_p$ac_delim AWK!$AWK$ac_delim SET_MAKE!$SET_MAKE$ac_delim am__leading_dot!$am__leading_dot$ac_delim AMTAR!$AMTAR$ac_delim am__tar!$am__tar$ac_delim am__untar!$am__untar$ac_delim RANLIB!$RANLIB$ac_delim CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CXX!$ac_ct_CXX$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim CXXCPP!$CXXCPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 87; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$ac_file_inputs $ac_f" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input="Generated from "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out"; rm -f "$tmp/out";; *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. _am_arg=$ac_file _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi wgd-3.1/aclocal.m40000644000175000001440000005077511265575052010741 00000000000000# generated automatically by aclocal 1.10.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(AC_AUTOCONF_VERSION, [2.61],, [m4_warning([this file was generated for autoconf 2.61. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.10' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.10.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.10.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 13 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.60])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) ]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR wgd-3.1/AUTHORS0000644000175000001440000000000010750154243010112 00000000000000wgd-3.1/config.sub0000755000175000001440000007511310750154243011046 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. timestamp='2004-08-29' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | msp430-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: wgd-3.1/Makefile.in0000644000175000001440000004553711265575055011151 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ config.guess config.sub install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d $(distdir) \ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr $(distdir); }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = src include scripts data all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu --ignore-deps'; \ cd $(srcdir) && $(AUTOMAKE) --gnu --ignore-deps \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) cd $(top_srcdir) && $(AUTOHEADER) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d $(distdir) || mkdir $(distdir) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r $(distdir) dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && cd $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @cd $(distuninstallcheck_dir) \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-exec-am: install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ dist-lzma dist-shar dist-tarZ dist-zip distcheck distclean \ distclean-generic distclean-hdr distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ install-html install-html-am install-info install-info-am \ install-man install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/data/0000777000175000001440000000000011265576315010063 500000000000000wgd-3.1/data/Makefile.am0000644000175000001440000000012311000437022012001 00000000000000resdir = $(datadir)/@PACKAGE@/data res_DATA=simple_dark.png EXTRA_DIST=$(res_DATA) wgd-3.1/data/Makefile.in0000644000175000001440000002241311265575054012045 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = data DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(resdir)" resDATA_INSTALL = $(INSTALL_DATA) DATA = $(res_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ resdir = $(datadir)/@PACKAGE@/data res_DATA = simple_dark.png EXTRA_DIST = $(res_DATA) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps data/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps data/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-resDATA: $(res_DATA) @$(NORMAL_INSTALL) test -z "$(resdir)" || $(MKDIR_P) "$(DESTDIR)$(resdir)" @list='$(res_DATA)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(resDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(resdir)/$$f'"; \ $(resDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(resdir)/$$f"; \ done uninstall-resDATA: @$(NORMAL_UNINSTALL) @list='$(res_DATA)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(resdir)/$$f'"; \ rm -f "$(DESTDIR)$(resdir)/$$f"; \ done tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(resdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-resDATA install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-resDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-resDATA install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ uninstall-am uninstall-resDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/data/simple_dark.png0000644000175000001440000002530711000437022012760 00000000000000‰PNG  IHDR€€Ã>aË pHYs  šœtIMEØ =y IDATxÚí}iŒ\ÙuÞ9÷¾¥êÕÒÕä#‡³É±¬‘fáÒä²-HH !@â8ŽlØúaHú3RÄ`J¤ùc$AöÈV)±…ÀhýÈ@H„HäÍ&gFûp†dwu÷«íU½ížü¸Ë»¯ºš½°·€]ƒaoÕ}ßy÷ܳßC°_µGॿói‚}zµšMøü—þÂäÞ†Ÿ]¾|Yºo뫾øâ‹3p执`åÎO÷mý¢ÈàÌOáÝÛo™ï=wq³·š{´ô¾5ófèO^úìç(¨×àG?þù¾Þý_zï{ Oàå¯|§€„ð'ú_öuý¿ñ›¿Œ1xñÅ+ësîçgΜdlßÖ¿óî»PE‘á øëp0¯¯Uà¥Ï~ŽîÜY†Ûï¼ó Cd P}dˆÀDŒ¡ü¾õ9„ @D@B€ AH”‰<ñø/üÉWÿƒ¹ —/_¦ÿøÕÿo«õ™ZŸ!˜µÊ52@ë{òoƒú¨ÖŸ¾&u=D?öØ ¿õ©ß0JÀ¹KO<ù8AÜjÏ¿@€T~ÜplÈ>>Õ/Éz‹mÓ†ýõ|ô/þZð裧áå¯|-8¨Í¯(›m¨bHýK¤ßR½#¤`݆iáͽ"„ïýŸïζÍdVRÿ¢µý×IþG¤~Dö~˜ß2ßC¬lØL57ÿáÔuk‘H¥SЇúP :$¨ "”ÿÉ_UçZíù×´‚M½zóÍšìþè‹tçÎ2üüí·_‘›)/í»H 6ŸÊÛoN™Ú.kÇK…˜áÕ ˲øñÇÎ]Ò§_¯Dòä©3D€æo«-¡×ò”K% uM`¾u‚mxûöíW^úì߇˗/Гêô“V0iÝPn¸Ü\^Ýx¦,¥QˆÒr––Jý Jk põêÕWîÜY†—>û9‚C´Ê±Á±è³Ý±j•M³ÕÿÚš`³¢< sóµi׿a©‚úUª(È“¿ð‹¯±~–Ô…På;€d”¶IÅ#iÖ…¾†òz‰µb€¹Žéç®9ý¨vÍ©Öî†3ý½rƒ9–›ÏÁ´2p©Ú]ZJpT^NÕ‡©I~D,O> TNCÞTD¹„JUDi–‰@PU)ô Ý쨃‹úo"I«¤?j÷„BH'!ô+`–4¶•¢ÎŠ†ÑØkT²Ëu˜¼zßôÔ{P¹5R?2z†Tuƒ¨N[ÈOâþ©Þ}4žWÙaså€X¹Ih™}"sÚõFèÏŸ6›4;Ñ#"Vš}TJHmŒ+˜VY}â±<ùD–+*]TùÞY \½¹ö祂 Ëå• "So!¡ü VÜÀ¦z»y5ëpå6›‰vÀäÕ ùÆ2@SŠƒúÔê_!+vÖAk³v@›v4@Ò§ª§Œ–'“tt`[iKP†×g ËÍÖÊ@(7ÛR ;r&†eB v•ôÁAaT”€¡Œ¯hsûw¸.Hûqf4X~©6˜ ‘ôgÆL—®Cèà´µiÙô†læ‹A[󣩭RG de Sæ~Z @”A,ÍV@é»M€Úo0(ý7Zjs$?/Ípõ¥Tn”×,àH©€c›`TOBn4© ÉÍW&¹ôÇ0•Ø›¡ÄJ8)#øÍ,€<ѤN™Š3luQ§A˜Ó TÚ\²d©Æ#PU ¨Ó7`zá’Òióorh‚Ö2wÔ̳€¡ŒSI«›Ä!‡ÊS,€! Àt6+­€*}Z c§ˆV S'ߘèÍ@Aƾêw‰ A³åûIn’íVì ¯šÒ%­(³L?šDQ†&+`©¥òC&€V¿K¤Y&¯A»ãN¢ (-1–n”¤L¢Ò€éôŽJÿ§O™Ð§HFêdm̆ý'S(B©lÓ ‚`²í—É*!ÈÃE@›º0î`Ú°ª Vü¾Ç£ Jk?•¿Šòë£äðï§Bi)XÚË”+Æë”̘`ýš4PhôizÓíŸÍtV”<}à™T.¤ò¦J—¡×ÁjѶ@Æéë™ë3Dþ˜â CcÖÁÊ ªî€ÊŒÈ(„JµÛ4q™Tðˆ*Gé³N¾)èÒ«U+–ùsÒÁÊ ¦Ó³iA 6ùhû}u „¤<²®WL—­ôÓ*—×±¹»Œk>ÆLY×>õ&ñ×˵Ml(fy:ÃÁ€ŒÉg*E!€”“Á‹VPfU †¥o'+€jf\l šÊ‘Ý7uy2 YÝšR)ªC•”þ“,ÀÚ|†Õogvl€ÖŠhk†º>Òuc¡JYéˆfå‰*×WÁ ¢ºz0þºllµŒLPžxËÐæ.@˜ðHõôÍ'Q[§Êò.N'ÊÔƒw€Õ#³@×﹯„e €+‚•"—ª– © ægˆ€B¹˜ TA@(K¯z¯õE¦:uÚþëH×ì(c Û÷Êb@¥yD÷qLê?" T›Ú×" Vsƒ²ìKÕR” $˜ÊNf•‚™2é2`*°+X)¢L팋(`i1å{P• 0S#9‚TUg×h솑 À¬ä|ªh•‡­œ\X ¢.@€] ¤2Y²ã@“q )À[(ØGÀnìܯÀ¬î±åd¤h”Â$sˆÊ‘)cŠRvÁ”K%]5=’Y€(ƒSÞU!—9}ÌÒt«pCÕ4Ð>¦Kh5i6sr뙺¡*+ÀÐ4]d“«}+“©$–ÓnȤ‰³X™2“ U&F“Ú=Ó˜jXÙ)´SÐu…£À&Ó/`…µÚìUœ¯Õå2u+(¬„b“@EÈÕ¶Z¥dw*+S„Õ%ÛüƒIE7kU‚@·À6”‡+× _§È¨­žeòQÒâ¨Æº@2`:Õ *­e“7`7„¬¼”‰1Ó«\²é:™4¶d|€ÿš ãt6bEþƉ™z^xª9dbPs‚X1e43 ¨åD«†Àde•!JËFt4c ¤L–•ÿ {PCm€ñ¹V妪&åC‚JM~3k#]Šh‚P@ÝkVšU]]\ÒY‹¥Õš@µ8µ©0ÕΘÙh†:з®@—y‘T<¬æ€™¸™´ å9j€…lÂösf„¬ GÙ*ÖZ•FþAÙ*&ªô *  jˆ–鯔S­µª ÈÌ¡ŒŒ“Rʆ6ÏL…Ksö¬Ÿ:ɺu,ã€ÊTv¦ÖU]T`òž–r0•ÙÅn ñÕJÓuÝÊwAªLÁh—a*ƒPÍH^ÖlÖ @;zÇòÖ¢=¬¸¡šHvmªe`¤r<¬œÛ¤¨•Àj ›® š²;…ÚY™.¿™— ãNíX¬i¦£—ék/ˆLºƒÖ´.ûb9¢«‚+«Ûg5I´¿öÅ2M½¾ÝïÓ§ Kó)B÷´rXj`M"éý¦yj®pV€¥ù·]‚›³»¡v?Hh5‰ÐjWóÀá!N i“-´äIßP‘IwîhF *AÖ´ÐfU*çötªÇt_MŸ$²c«g(ì:dyÂ.FÙñÇÌBU7Ϳ̮ 2“•$T™@¢l£—ÆËšµ¬ÞƒoÁጅ|‹Á†~ ™ Yº-¤V“¿ÂžÄ%…5.T€U2`ù?Uæñ= (Šl¦+ÖïK ‡JIƒù£ž†Ïþ=¨¤ÜƒþúG ¾De¯ÒF%"sª‰êÆ«“«loéê´Ù´Nÿf/»îdGøÔÉ&0Bb¬ë*4nAL¬–M^úå M)NM#UD¬6¯m=¦FS#^_;„½ÿZE6 Ž|ô±ÇömEîÞ½[Gê×åË—©( ø»ï÷Uêü¾œó àÐÃÇ p¨~yâ)¸{û-Òh™ýxXGÈû3¦ ⇠ÿ[¿ÿ;¤ÑRûñú÷_ýÆÑ„‡«p 5Ê»·ßÂM6àxý^ß±ÿد}ä@ìϫߚ¾ ÇëÎúh/~ü¯~ç5£‰zý+¯_}ÅŽœ* ?´g¬ž;XXþjÁrƒÓ…š‹f®ÿ0ÊïÌv ´!’-+sS˜Å@3ùì ^Ø"˜îö‚ Ý †eåµÂE€Õn%Z•Ì­Ö~˜äG­}?ûíWlMghök+W¯¾bk/Uʲ`šS`¦_!!1(Ðÿa³Teý½_Ÿ~1ÅRrPò—åx»Å{ùéü§+8­ÙznÀ re‰³À Óvæ¦AÁ݈åÎÐÉÉB‹VG¸i¦Ö— hÆ­ C#wô›³:Ñ/°˜#W4ˆó>䬹lkZýÝœuPþð#ì‡ü¦Ao¬A9a}?ù÷„ à9Æó©ßo¿•¶2¯õÃF¿1®XŽ´]~=ßgC²m´®éءƂÂñ.°8Eþäé´Ut ¯vÓëó aÂ,;¨§uf·¤›áAä7¥'›—Í0Å}å`~Á ŸHüõô:ÑÓƒ €jw½˜ ¾#~°JªG¯Ð~[e,[pùiò'ÒÎèBz "÷Žƒ¢o1‚—(q)OAº‡É°[ù+ ­¦X®6“ÿøˆå89™øëïtÖÎöÂd>­·ë>á…Ä`á¶ù4•J•œÁǶZÕz$›¸ÀüTá/$áó“0?YÔýŸ¹g ®†9$DÈÙ ’È\"€bc3rÇò$.s¦ Çîùv#? ¡@Rr!•Áb‰áØJþ]óÏqr"õ×ß?謟뇓“IPëzqû‡uoÙK0CÚ ?@l)ŸfE»Õ‹ê¨9óÓŸK;£ç'a~ªÜ'n¼Q_÷îù Ëiä0“`s’5‰!¦dÍÁ%•>^¯Gî2&¬@ÚŽüÛæ\`z2ó{OÇÞùÜü®w®µº­¥ òºN‚9±+~-¼†bÁ4(Ó!Ì”ðƒKq˜…yàuݸu%è¶ë‘×õjxŒé¨NM7«œ˜˜ü|ÖLî®ä_ucoݤóY- ³ :?‰ÚE#òºnÂH*Á¾É¿êÆîª3ÉNæµìT .Å!Bs±yËN‚…´ù÷“[üä¦'3¿ÿ̨ӿ0’f¿ëÅsW›ÝÖÍ òWÜ $ñüºoR3¥+5?=ûóãÎàb¹ùí+ ©|«n‚Ä™5øi˜*ð!™>ã&3‰;•ÿz³[{×OKë½sÃ09™J%­Aä­(w°Oò·®5ºµwÜñ䉬>87 Ó0 †—â¯×Íú÷“K~€y+wûïÛ½ Ã0y$mx«î¸}­ÑmÞ' $9…»æ@«¹Â°œÑ' ,:äÆOOÚƒKq˜<’5¼UgܾÖè¶—‘·ê&L0*#d2 •!)n©˜å6‘¿pÓ“¹?x6îô/ åk¿®äï9™ÛuÊ z ¦aô†!AëF=r—ÝÒ-îB~Á…:ùãÎàR¦'åÉŸ»Úì¶n‘Ós2o-OXл8 Ó0¥%hÝÀÈ[vÌ6“K~â²fîLI‚$ÌB`n×™øï¸±³Î3ÌPmýƒñTY8¬\˜#ˆ9É™G±U?aK,BDè]Êõ/Å!"Bk±9ËN”; Ù`S~âë, nÕúÂ%cHÃ,蟅PÀ† 8XÉé½ ~€’][=#ÀDÂŒÜËZo5úàëÁÒ0 úçG![b‘¿â%Xh WÿjeÓX~DU˜Q„ ³*J~Áf¡2»êæ»]™m4둳â$’lL”]œ ɽç$MQ‹ˆ¤d§ò 1I¢¹ËLf÷—_8€ù©Ìž«“/ÝÎÜëÍn{©ÕV½„ FÈÊaSHõULp©@©G!@ëF9Ë\¦ˆ–üÛ†È]æIãZ=è_*5œ )êÒ׈R¸ò +ƒV©‡#0Á¨¾Ê~#½…ôµ†!"ÂÜÊü»`¤K¡d`æñ¼aõÄY€0tOy;wã§ÒÖðÜøDv²¨ëT³q½.Í©P'Šȹç$ Qˆ—â0;YÔ‡Æ' ¢1ñ_ãÙ¬ @ËO(Ú…;z*i ÎÅ'ÒyÝëªTûf#òWý„“Šy¦I+‰SmÕOp #€èÂ0LOäõÁ¹øKYќԅ³†+Ù=¶Ï€9#w’Ƶš.=•ý…QH‚ )‚È]áÒ,í‚@ƒ/ Пk’Á¨¶ZKð‹X¿ •` ”@æß¼`2&AUA‰Ô2³!úFa9AžÏe@þÏÜAãVm½q£ÞsWx‚…Á=ÏäG@äÞcICøD£g&óàæs¹—.Çu;$Û(?p‚¢)xÞÉ=&ê·ýAûÍÆzûV£W[õF²Òg#˜4`–ˆÀœ`ÕKÚ7[£þûGf}Ñû<ƒg¹€mð$g™%R‚áó²3¸‡DëõÈ[沺C~€iж’‚Mrh%¨¯Õ¼É"@Ñù¾I½:K­ˆu½„ŒÈB'W°æLÀ,p®‘?'`ë˜×oú}÷7f)+ü;N⬳ $aø‰6çGÒ¤µÈ½ËÇœ÷YÎ"È!ŸÍkä^ßÉ›? úõ»µØIyQ[ö¯ç¥\pBV¥«7k2Ùì!p©¾† [Ĩ¶âŽ —8bîõÜœ« %íœ — ŸUÔIJ j‘«Žðà”Ù¯òõiG©ÁZ-a7eÀ³~®&'“ :¯,ÁV䯪üW¦Xm"lÆV.ﳜMpä©›Š#ÉU&¶Í€9ï²´¹™ÐQhФ'¥î#?±!Ë›?uFÀ$[ Ï9!CªÜ°šCh=ßF)/8ÕÖýÔ8™™MH5_̶Ûå–€'ë^D `ôü$ÌNåÁðùq\©En—¥ žíðØ&­RW(lfF!Õ×½„½ÑŠÖÏõÃI(-Rçz+òÖ¼T†’iLXùþ¬§‚ÙòÁDÞpBÝ ;æG„9#†6ªŠ¶!?#Ì­ ×#j€†Fªs††˜@b#¥C‰°²åß5?fHü.O‚€†‡Ùɼ?=™wÞec¾îe˜+S¼ ~€’ƒ‡U$°äíЩ! œê«,Á7¤%Ðóý_Í×—ý±Ûw3.PYÛrÀ§¹„v)ÿ^ó#ìT~Ó!ÀÒ:—,2ÐAÔeßÍå ~$ g™%µ«^$ˆ`¼œaQ+¸¤G§mó”…R\½PuÈ,œ¾²äR}xc.BXfx‚\BQùT D|&Bøpùv%¿5;\¦ÀŠJŸ±µüÎ œ{˜Ô¯xN¨(:ÂãË©Jóí¿}ä"TTÚzÌ›ÍàͬJ ‚C.5Ö˜Ì2^¤ÍÌs‡n.)\Pòti²SsBf6—a—òW(û‘„šV"!kK[ÈïLMEVY¾PGÊe2ÜÁ¨€€9¿Ç’Zâ Ñ Îz˜C $Hl t®°½LGaŒÉ›ª†Í °F¥´d&f„Dð[s"rîôxÎs^†j†Å7gê|ùuÆå¦£Õ ÙoùICÏ…”QXó[É_A¦\½*‘)45shZ,¸á;Õ1hL1eÙE!¨>MHΤo@æÜ¾ýÊFT6ŽÊ¬¾þ>–~Öàr@bzF_AÙW–Wf®ÿ òO÷CZ~ƒK7¶#ÿdîPüB•Q6ªÌË[ (,D N=E‹¶ó c„K+›$Py˜ƒú¼äà!V0«ãfOÍÓ,<,ì©ü´ño¤üå5¢ånî/?ÚàÄpþ`(Klí?^ÿp×?†‡?äë§¿åuÌð¯ÌÇü»ÇüpÌ`圀ˆàpbÀ§ƒÆÇË–œ~>/Ò^âãõúÇü0H˜7 'ŸŽ;æ…?t3N.>ž8¡h’StÈá#Vð2‰ˆÜ|üVò?ôüŸžÔ†ï‹ÛÞÀMÛ?n ‚uL˜àtøxp ‹'DmüLÚæOë7½vA8î>~+ùz~€¬•;ƒ¿0jC,|ÁáÖ\T_õ&ccö _0E‡œä©¼ ~KùïÀÖÍÞ/ùïÇ€`?¼kwòoÉ€’·–´~ØXσܙ„I°v®ʉ—Vä¯z œ„š¿ßs|¼ òîyIp«XMád§Š`ôÁ$DD`×™µÖhX}Zw€ßJþÍøÊ'‘£Âî‹ü›ðàÔƒ«v+ÿ–ü €œuž¶—‚€Àõóƒpr2 VÏöBA›­¨¶êH4Ù#V{F°Žic±ÞÆpx)–ãgœ„ˆ ÊÈAP+gÞ&>~–üBDP¨aTž9ÄHf¤0Ööã_íË–_ÀÂ-ä6*˜Êò'W6T9"@Š$ùÊg&TY„JgRËO@ˆ®@r¿1ƒ2`Aàføx–#ù]/i/5#"€è‚ÄůŸë…@í¥–DªŒhê {w„C|…%x]λŸ‡©šA,Ò€õ¤‘ó(Ú…“œÉjE[8<åEí®Ÿø/…‚‘v«ú ê€Õ4KË[0é\âO§~áÜðÜ»ëLxç³.ÀÈ΋9ùcy-o“ÃVxw„­cÊ„|€£ñ÷85àj†nÈ)0ŸÏ½äLî _p§ÏrçŸð>ËQÁ, GY6ÁÇg@ÞŠ›ÌA#X¿ G²×Î÷B"XjJ fÎö‡@8T버Ý3€e —Æ! %JXÞˆò¤íÂ<5nß;iCŽdÏåsólHï¬g¬À$LüÞFsƒÄóÄÖRë·ã Ç!æ˜á¦ò'râgÒöä}Y3 Æ­úzc‘õü.K˜š³@3¬Z–«tÜP0…)|.™==ž'°ö#·ßŒë9i”àôLàøx9êŒä.»I‹‚ˆˆ RàŒõóý€ }#ˆ¼®—°¬„Dï>ž!'¿Ë¼F ÒS  ¸XÜeV‚SvÃPΘl/ ZIDAT °!+xÏILŸLšEP8„á&E~×—°,óXk L\`r"õ{Ï ;=…Ìñ—Ý‘ñ” yÜ_~ Ƽpún <Ãä±¼)š±ƒ-‘·¢h`J[¯T@úù‚‰’Gà¢D&y÷œ‘ÛsS>æ›àî‡/kÞHHÞ²›´„T‚ÞB‰‹‚ } pr¯øИ;.€j]LØ’T Ä”àD€æ"Jš˜œÑnøœ³æ›Þ€ü:ï;‚¥aD†!ÀÜD~Waó¬lK¨“—œHýþ³jóÃ,p»Nܼ¬5Þô<ÂLz‰ûÊOn²Æ›þ|âƒK1ËNåAÿR"´1òW\¾Aó„3àó0¯bWœ¸y­¾¼Y¸}ž!"YȰ­ùtŽ%Ÿ†­”ƒ€¼'iÞ"bÑ%qzòHÒ  ˜’À¤¹«N& Ý=?@%@ÒCĤ%Xb8½KÃÓÉ™¬Ñ¿æL8Y#âk˜iò´óŒÜe'i]WXH…öí]†@­¥FTëº œP ’ Vàädæž*(¹ÜüöÝæbÍ s·#?±)w—†Y0¸‡ °%y+,ášG˜*üѳzó I"qUÒç¸]‰i¤ñ n?‰2·”’³Î3ÿ7vßãN’0k¤aŒÏ¤Aý'µ![gæå“³vË çÞ,8”z.'‡¼>dõwýxü é$=•7²0ÒGó ø >¨õaWüHHβ“4kAïâÈàþ h±ù]‰E,¸Àädêžuz ’¤Á3ÜERjòÛJÀIò‡Syп4 ´n4£ZWÆ<…C˜†¹?x.îô4ƒˆ#TƒÈ]-7çügi=¼Qå—œ0ËÜñ£IžLk @¸]'öï¸1ï£ÄÀí?–…òi^Š$²S¸ÉãY…Y „×uãÚ=/vF,gÄØîùPÅ<Î='i@]A¾c£@t#ˆÜÈɲ¹Ì>Ë“ÒÞüzäÞ³§<»Ÿ FlUY:¦ÈÂ,è/ŒdäF#r{®Y¿ad ä’D¢!‰³’°F;äëØòð3Éœ1x6îôÏÇa6—×ü»î¨u%è6nù}± ÑÞðXm·Ø²Ò0“~fsE­vÏͽÞì¶ßjô½¾›1=˜½ ~€Êuå÷ßõˆ` ðú½…a(¸€ÚmoŸ×Ü®7 yœe¹ùbù¢ ƒÓÞ{&“t>«eóyÍïzñÜë­îœ:ùHróï'ÿ¶ùÏ%mÊsÕ(³õMžÀUô/`¯ù$m af~ÿÙQ'º0PïÆëíîÜÍfäuÝ„ &ÍÝ.ù6“&?Â#Y39•5Py÷Ü¡¹Ë,aªÜ½?ÂäTÚLNe @µoعÖêvn6#W±¦n-ÿ¶ù F†6exIVâ¼'n}¿Þ ®×"g…™Í7 ‘=äœ0=¥6ÿüИ»ùkmI›²æ%œÉv[¨œòìˆ@“U6Õ}p—™¡Ì;~°™Z;7eo ‰Øöäß?@¡S ÍÐæ»ìÄï×»Á¢¹÷X‚ÊÍ×E =â µù½g‡†žÕ_õâùësÝέVT[—f_]xe:k§ü;áG€ „æêmÜòûî=¹ùdU?÷“Lh®âö[Í~mÝ5>»òoÉ@œ°8Qx£³ã9É¢X¹¿_ë6®{·Ù¯*æ´ÔÀá N˜žÈ½Á³£9½ùµ5¹ùóo´"ÝK˜à†'ÐÆÇƒPƒ;äØ.?B3­EùŠ¡3à9X¦7/å¿?‚s«e?χÎÈɽ¾“1Á‰v(ÿ–üÄ “Ó©?Ìg'‹º³ÂãÆÿõ»Á5_m>P&w?ðñÂ!LN'~ÿ}£ùôDV¯­ùñ‰ësÝÎm5” Øîññ[É?~Öe™» M„pPü\pâëNæ(íùµ=æ(AQ+¸pÝ»Î(¸ê¯Õ^÷#gY™}Uç/÷Œ@Ôˆ“X[©æo¶ÖæßhGõ5?aäî‰î¿•ü[ðHƒJ‡ÅÀöÛœmØ{~AÀz,÷ßâ}ñ´¶äœ.&P  }ÇÇ#!¸C'oþ¬Þ÷n:÷ãÖ ¾æ'œöàøø-凇œ2AÎm6©ýœ°à=åëT·m¿ññ¼@ –ý‰;qsw쵡—qâ´Wøø­ä?æPkË´R=ï€ññˆàpÁ€¡¤JÛ+|üväèù$îß4 +KÂ{ˆßŽüÇü{ü:ÆçóãóÈú• ùÔß|ùcÿó›ÿâÛû¹ø_úäïü«ÿü¥W·zßÙs_€GöhÙ{‹×¯¼ǯ™ÈŠöí7FýÕï¼¶é)8{îâ¿;¡¯_ùã­Ÿ‘>þ 7ÿX ª¯™üö_ÿó‡öc±Oþå¿ú½YøøƒÞ|½æ±0›àÏÿÛ×?´_‹}óϾþ!@€Ÿ¿ýö+á|óÀ‚žã×}ÀöÿýÏ¿ñ¡ý^P®q¼ïGNrKì¹;íÊë칋ÿðXàT ºÔ#‡(ÿ{Ž@ïÉš€cpô,ÀÁjÀñ?z€Ð+ÀC¿jplŽ ˆc8¶Ç ðPǨÇQÀCžˆc8z Ž]ÀCn2ýã³ç.;¸{û-<xø?øãï<û·ý‰›³~ö™?ø´ù|ñÖÊž®kÿm­tÚú<̯ÿ}1\¹!ÍIEND®B`‚wgd-3.1/config.guess0000755000175000001440000012450410750154243011402 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. timestamp='2004-09-07' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amd64:OpenBSD:*:*) echo x86_64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; cats:OpenBSD:*:*) echo arm-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; luna88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit 0 ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit 0 ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; *:OS400:*:*) echo powerpc-ibm-os400 exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then # avoid double evaluation of $set_cc_for_build test -n "$CC_FOR_BUILD" || eval $set_cc_for_build if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:[34]*) echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit 0 ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit 0 ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in *86) UNAME_PROCESSOR=i686 ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms && exit 0 ;; I*) echo ia64-dec-vms && exit 0 ;; V*) echo vax-dec-vms && exit 0 ;; esac esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: wgd-3.1/COPYING0000644000175000001440000004312210750154243010111 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. wgd-3.1/README0000644000175000001440000000005410757063700007737 00000000000000Note: Currently does not install correctly. wgd-3.1/config.h.in0000644000175000001440000000572111265575107011114 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_DOSTE_DOSTE_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LIST /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the header file. */ #undef HAVE_STRING /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_VECTOR /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc wgd-3.1/include/0000777000175000001440000000000011265576314010574 500000000000000wgd-3.1/include/wgd/0000777000175000001440000000000011265576315011356 500000000000000wgd-3.1/include/wgd/texturepng.h0000644000175000001440000000047511026705571013647 00000000000000#ifndef _WGD_TEXTUREPNG_H_ #define _WGD_TEXTUREPNG_H_ #include namespace wgd { class TexturePNG : public TextureLoader { public: LOADER(TexturePNG); TexturePNG(doste::File *f) : TextureLoader(f) {} ~TexturePNG() {}; bool load(); static bool validate(doste::File *f); }; }; #endif wgd-3.1/include/wgd/camera.h0000644000175000001440000000114011027176720012657 00000000000000#ifndef _WGD_CAMERA_ #define _WGD_CAMERA_ #include #ifdef _MSC_VER #pragma warning(disable:4251) #pragma warning(disable:4275) #endif namespace wgd { class Camera : public doste::Agent { public: Camera(const doste::dvm::OID &id) : Agent(id) {}; virtual ~Camera() {}; virtual void bind() = 0; virtual void unbind() = 0; void size(int w, int h){ m_width = w; m_height=h; }; int width() const { return m_width; } int height() const { return m_height; } VOBJECT(Agent, Camera); protected: int m_width, m_height; }; }; #endif wgd-3.1/include/wgd/drawable.h0000644000175000001440000003123611233311615013212 00000000000000#ifndef _DRAWABLE_ #define _DRAWABLE_ #ifdef WIN32 #include #endif #include #include #include #include #include #include namespace wgd { /** Draw flags for use with drawable items */ enum DrawFlags { LIGHTING=1, DEPTH_TEST=2, DEPTH_WRITE=4, ALPHA_TEST=8, WIREFRAME=16, DOUBLE_SIDED=32 }; class DrawableBase; //The curent openGL client state - for Drawable optimisation stuff //This will remember the client state and only change it when nessesary. class RESIMPORT DrawStatus { public: DrawStatus(); void begin(); //Activate draw status control void end(); //stop draw status control void reset(); //set OpenGL states to default void setState(bool n, bool c, unsigned int tx); //set client states void setSurface(const OID& surf); //bind a surface void setFlags(unsigned char f); //set draw flags to change OpenGL states bool active; //Drawstatus is in use Shader* currentShader() { return shader; } private: unsigned char flags; //Last flags active bool normals; //normal array active bool colours; //colour array active unsigned int texcoords; //number of active texture arrays OID surface; //last used surface Material* material; //currently bound material Texture *texture; //currently bound texture Shader* shader; //currently bound shader DrawableBase* last; //The last drawable that was drawn (for deactivating shaders) //... }; /** * Abstract Drawable base class. This contains the control data used to specify * how an item is drawn. */ class RESIMPORT DrawableBase { friend class DrawStatus; public: DrawableBase() : VBO(0), distance(0), mode(GL_TRIANGLES), discard(false), clearData(false), alpha(1.0f), flags(7), queued(0) {}; virtual ~DrawableBase() {} matrix transform; ///< Final transformation m atrix of the mesh GLuint VBO; ///< Vertex buffer object containing vertex data, 0=none float distance; ///< Distance from camera, for alpha sorting GLenum mode; ///< Drawing mode, GL_LINE, GL_TRIANGLES, etc.. OID surface; ///< Matrial or texture to use, if Null, leave as white. This takes an OID not a pointer so dont forget to dereference material/texture pointers. bool discard; ///< Will delete object after drawing bool clearData; ///< Deletes vertex data after use bool useVBO; ///< Will build a VBO to use - only if discard = false float alpha; ///< Drawable alpha - defaults to 1.0 - used to fade out objects that do not have a colour array unsigned char flags; ///< Draw flags =- was type Drawflags but it got anoying to cast everything int queued; //Drawable is in the drawing queue /** Draw the item! */ virtual void draw() = 0; /** delete vertex data */ virtual void deleteData() = 0; /** delete drawable object, this will wait until it has been drawn if in the drawing queue. * Use this instead of delete as it will break if you call deleto on a drawable that is queued for drawing. */ void destroy() { if(queued) { discard = true; clearData = true; } else { deleteData(); delete this; } } //begin and end drawstatus static void begin() { status.begin(); } static void end() { status.end(); } //Comparison for sorting, by distance, then by material static bool compare(DrawableBase* a, DrawableBase* b) { if(a->distance==b->distance) return a->surface < b->surface; return a->distance > b->distance; } protected: //Disable custom shader attribute variable client states virtual void disableCustom(wgd::Shader*) {}; static DrawStatus status; }; //Recursively enable, disable and set custom vertex data - A and B are each side of the tuple template struct CustomVarRecurse { //Recursively enable shader variables static void enable(wgd::Shader *shader) { shader->enableAttribArray(A::name); CustomVarRecurse::enable(shader); } //recursively disable them static void disable(wgd::Shader *shader) { shader->disableAttribArray(A::name); CustomVarRecurse::disable(shader); } //Recursive template function which will loop through all custom parameters //and will set the vertex pointer for each one. static void setPointer(wgd::Shader *shader, const char* offset, int stride) { shader->attribPointer(A::name, A::size, A::type, true, stride, offset); //set data offset += sizeof(A); //increment data offset CustomVarRecurse::setPointer(shader, offset, stride); } }; //Specialised recursive functions that are used to terminate the recursion - when 'next' does not exist template struct CustomVarRecurse { static void enable(wgd::Shader *shader) { shader->enableAttribArray(A::name); } static void disable(wgd::Shader *shader) { shader->disableAttribArray(A::name); } static void setPointer(wgd::Shader *shader, const char* offset, int stride) { shader->attribPointer(A::name, A::size, A::type, true, stride, offset); offset += sizeof(A); } }; //Wrapper for calling the recursive functions to enable, disable and set custom shader variables //E is the type of the fist tuple in the extended vertex format. template struct CustomVarWrap { //Call recursive enable function static void enable(wgd::Shader *shader) { CustomVarRecurse::enable(shader); } //call recursive function to set vertex data pointers static void setPointer(wgd::Shader *shader, const char* offset, int stride) { CustomVarRecurse::setPointer(shader, offset, stride); } //call recursive disable function static void disable(wgd::Shader *shader) { CustomVarRecurse::disable(shader); } }; //Specialised wrapper for when there are no custom shader variables template <> struct CustomVarWrap { static void enable(wgd::Shader *shader) {} static void setPointer(wgd::Shader *shader, const char* offset, int stride) {} static void disable(wgd::Shader *shader) {} }; /** * A Drawable item is a mesh consisting of vertices, materials and the * final transformation matrix needed to render the item. * Drawable items are alpha-sorted and material sorted. * May need other flags such as Lighting, depth testing, depth masking etc.
* The template parameter is the custom vertex type used by this item. */ template class Drawable : public DrawableBase { public: Drawable() : data(0), size(0), indices(0), nIndices(0), sData(0), sIndices(0), dataPointer(0), indicesPointer(0) {}; T* data; //vertex data unsigned int size; //How many vertices unsigned char* indices; //Indices unsigned int nIndices; //number of indices /** * Draw the item */ void draw(); /** Add stuff to drawable like a vector */ T& add(); //Add a blank vertex, return it so the user can give it data void add(const T&); //Add a vertex void add(unsigned char);//Add an index void add(Drawable *);//Add data from another drawable /** delete vertex data */ void deleteData() { if(data) delete [] data; data=0; size=0; if(indices) delete [] indices; indices=0; nIndices=0; }; protected: /// Set data pointers to vertex array; void bindArray(T* data); /// set data pointers to VBO void bindVBO(GLuint vbo); //enable custom vertex arrays (for shaders) void enableCustom(wgd::Shader* shader) { CustomVarWrap::enable(shader); } private: //array sizes for adding stuff void resizeData(unsigned int s); void resizeIndices(unsigned int s); unsigned int sData; unsigned int sIndices; T* dataPointer; //sdata will be invalid if the pointer changes unsigned char* indicesPointer; //same with indices void setPointers(const char* p); void setCustomPointer(wgd::Shader* shader, const char* offset, int stride) {CustomVarWrap::setPointer(shader, offset, stride); } void disableCustom(wgd::Shader* shader) { CustomVarWrap::disable(shader); } }; }; template void wgd::Drawable::setPointers(const char* p) { int stride = sizeof(T); glVertexPointer(T::nv, GL_FLOAT, stride, p); p += T::nv * sizeof(float); //set normal pointer (if normals are used) if(T::nn==3) { glNormalPointer(GL_FLOAT, stride, p); p += T::nn * sizeof(float); } //set texture coordinate pointers int i; for(i = 0; i0) WGDglClientActiveTextureARB(GL_TEXTURE0_ARB+i); glTexCoordPointer(2, GL_FLOAT, stride, p); p += 2 * sizeof(float); } if(i) WGDglClientActiveTextureARB(GL_TEXTURE0_ARB); //set colour pointer if(T::nc!=0) { glColorPointer(T::nc, GL_FLOAT, stride, p); p += T::nc * sizeof(float); } if(status.currentShader()) setCustomPointer(status.currentShader(), p, stride); } template void wgd::Drawable::bindArray(T* data) { setPointers((char*)data); } template void wgd::Drawable::bindVBO(GLuint vbo) { WGDglBindBufferARB( GL_ARRAY_BUFFER_ARB, vbo ); setPointers(0); WGDglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } template void wgd::Drawable::draw() { //transform matrix transform.apply(); //Enable client states if(!status.active) glEnableClientState(GL_VERTEX_ARRAY); status.setState(T::nn, T::nc, T::tc); status.setFlags(flags); status.setSurface(surface); //drawable alpha if(alpha!=1.0f && T::nc==0) { if(flags & LIGHTING) { GLfloat mat[4] = { 1.0f, 1.0f, 1.0f, alpha }; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); } else glColor4f(1.0f, 1.0f, 1.0f, alpha); } //shader has to be done here if(status.currentShader()) enableCustom(status.currentShader()); if(VBO) bindVBO(VBO); else bindArray(data); if(nIndices==0) { glDrawArrays(mode, 0, size); } else { glDrawElements(mode, nIndices, GL_UNSIGNED_BYTE, indices); } transform.unapply(); if(!status.active) status.end(); //may need to reset active colour if it has changed if(T::nc>0 || alpha!=1.0f) { GLfloat mat[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } } /** Add stuff to drawable like a vector */ template void wgd::Drawable::resizeData(unsigned int s) { if(dataPointer!=data) sData = size; //validate pointer if(s<=sData) return; //nothing to do if s is too small if(s < sData + 4) s = sData + 4; //always add at least 4 vertices if(sData==0) { deleteData(); data = new T[s]; } else { T* tmp = new T[s]; memcpy(tmp, data, size * sizeof(T)); delete [] data; data = tmp; } sData = s; dataPointer=data; } template void wgd::Drawable::resizeIndices(unsigned int s) { if(indicesPointer!=indices) sIndices = nIndices; //validate pointer //always add at least 4 indices if(s < nIndices + 4) s = nIndices + 4; if(s<=sIndices) return; //nothing to do if s is too small if(sIndices==0) { indices = new unsigned char[s]; } else { unsigned char* tmp = new unsigned char[s]; memcpy(tmp, indices, size*sizeof(unsigned char)); delete [] indices; indices = tmp; } sIndices = s; indicesPointer=indices; } template T& wgd::Drawable::add() { resizeData(size+1); return data[size++]; } template void wgd::Drawable::add(const T& vx) { resizeData(size+1); memcpy(&data[size], &vx, sizeof(T)); size++; } template void wgd::Drawable::add(unsigned char i) { if(indicesPointer!=indices) { sIndices = nIndices; indicesPointer=indices; } if(sIndices == nIndices) resizeIndices(nIndices+4); indices[size++] = i; } template void wgd::Drawable::add(Drawable *d) { //this one is slightly more complex //also needs to transform everything by the matrices //to use homogeneous coordinates - need to transform vertices and normals unsigned int offset = size; resizeData(size + d->size); memcpy(&data[size], d->data, d->size * sizeof(T)); size += d->size; //copy indices if they exist and adjust for offset. if(d->nIndices) { resizeIndices(nIndices + d->nIndices); for(unsigned int i=0; inIndices; i++) indices[nIndices+i] = d->indices[i] + offset; nIndices += d->nIndices; } } #endif wgd-3.1/include/wgd/bone.h0000644000175000001440000000223311026705447012361 00000000000000#ifndef _WGD_BONE_ #define _WGD_BONE_ #include #include namespace wgd{ class Bone { public: Bone(int id): m_bid(id) {}; ~Bone() {}; // Child bones // void addChild(const doste::dvm::OID &name) { m_child.push_back(name); }; int children(){ return m_child.size(); }; doste::dvm::OID& child(int i){ return m_child[i]; }; // Skin Offset Matrix // void sMatrix(float *mat){ m_sMatrix = matrix(mat); }; void sMatrix(const matrix &mat){ m_sMatrix = mat; }; const matrix &sMatrix(){ return m_sMatrix; } // Base Transform Matrix // void tMatrix(float *mat){ m_tMatrix = matrix(mat); }; void tMatrix(const matrix &mat){ m_tMatrix = matrix(mat); }; const matrix &tMatrix(){ return m_tMatrix; } // Bone ID for linking with mesh // int bid() const { return m_bid; }; private: //ID of this bone - used by IModel when transforming meshes int m_bid; //bone contains various matrices matrix m_sMatrix; // Skin Offset Matrix matrix m_tMatrix; // Base Transformation Matrix //child bones (by name) std::vector m_child; }; }; #endif wgd-3.1/include/wgd/instance2d.h0000644000175000001440000000203611233311615013457 00000000000000#ifndef _WGD_INSTANCE2D_ #define _WGD_INSTANCE2D_ #include #include #include #include namespace wgd { class BASE2DIMPORT Instance2D : public doste::Agent { public: OBJECT(Agent, Instance2D); Instance2D(); Instance2D(const doste::dvm::OID &id); virtual ~Instance2D(); virtual void draw(SceneGraph &graph, Camera2D *camera); PROPERTY_RF(vector2d, position, ix::position); PROPERTY_WF(vector2d, position, ix::position); void move(const vector2d&); void translate(const vector2d&); vector2d worldPosition(); PROPERTY_RF(float, orientation, ix::orientation); PROPERTY_WF(float, orientation, ix::orientation); void rotate(float); float worldOrientation(); /** Children */ PROPERTY_RF(doste::dvm::OID, children, ix::children); PROPERTY_WF(doste::dvm::OID, children, ix::children); /** parent instance */ PROPERTY_R(Instance2D, parent); PROPERTY_W(Instance2D, parent); }; }; #endifwgd-3.1/include/wgd/texturebmp.h0000644000175000001440000000047511026705571013641 00000000000000#ifndef _WGD_TEXTUREBMP_H_ #define _WGD_TEXTUREBMP_H_ #include namespace wgd { class TextureBMP : public TextureLoader { public: LOADER(TextureBMP); TextureBMP(doste::File *f) : TextureLoader(f) {} ~TextureBMP() {}; bool load(); static bool validate(doste::File *f); }; }; #endif wgd-3.1/include/wgd/animationset.h0000644000175000001440000000213511023162654014124 00000000000000#ifndef _ANIMATION_SET_ #define _ANIMATION_SET_ #include #include #include namespace wgd { class AnimationSet { public: struct KeyScale { int frame; vector3d scale; }; struct KeyPosition { int frame; vector3d position; }; struct KeyOrientation { int frame; quaternion orientation; }; // constructor - set size (number of bones with animations) // AnimationSet(int size); ~AnimationSet(); // get values at frames // vector3d scale(int id, float frame) const; vector3d position(int id, float frame) const; quaternion orientation(int id, float frame) const; // add keyframes // void keyScale(int id, int frame, const vector3d &scale); void keyPosition(int id, int frame, const vector3d &position); void keyOrientation(int id, int frame, const quaternion &orientation); private: std::vector *m_scale; std::vector *m_position; std::vector *m_orientation; int m_size; }; }; #endif wgd-3.1/include/wgd/common.h0000644000175000001440000000107211233311615012714 00000000000000#ifndef _WGD_COMMON_H_ #define _WGD_COMMON_H_ #include #include #include #if !defined(PACKED) #ifndef _MSC_VER #define PACKED __attribute__ ((packed)) #else #define PACKED #endif #endif #if !defined(ALIGNED) #ifndef _MSC_VER #define ALIGNED __attribute__ ((aligned(16))) #define ALIGNVS #else #define ALIGNED #define ALIGNVS __declspec(align(16)) #endif #endif #include namespace wgd { typedef doste::dvm::OID OID; static const OID Null = doste::dvm::Null; extern BASEIMPORT OID WGD; }; #endif wgd-3.1/include/wgd/scene2d.h0000644000175000001440000000067611233311615012760 00000000000000#ifndef _WGD_SCENE2D_ #define _WGD_SCENE2D_ #include #include #include namespace wgd { class BASE2DIMPORT Scene2D : public Scene { public: OBJECT(Scene, Scene2D); Scene2D(const OID&); ~Scene2D(); void update(); void draw(Camera *); SceneGraph &graph() { return m_graph; }; //quadtree stuff later private: SceneGraph m_graph; }; }; #endif wgd-3.1/include/wgd/model.h0000644000175000001440000000502211233311615012523 00000000000000#ifndef _WGD_MODEL_ #define _WGD_MODEL_ #include #include #include #include #include #include #include #include #include #include #include namespace wgd{ class Material; class ModelLoader; class MODELSIMPORT Model : public doste::Agent { friend class ModelLoader; public: Model(const char* filename); Model(doste::File *file); Model(const doste::dvm::OID&); ~Model(); void load(); /** is the model loaded? */ PROPERTY_RF(bool, loaded, "loaded"); /** Model file name */ PROPERTY_RF(doste::File, file, "file"); PROPERTY_WF(doste::File, file, "file"); PROPERTY_RF(float, fps, ix::fps); ///< the default fps for this model PROPERTY_WF(float, fps, ix::fps); ///< set the default fps for this model OBJECT(Agent, Model); BEGIN_EVENTS(Agent); EVENT(evt_file, (*this)("file")); END_EVENTS; /** Get a meterial from teh model */ Material *material(const doste::dvm::OID&) const; //Mesh functions int meshes(); Mesh *mesh(int) const; //Animation Sets AnimationSet *animationSet(const doste::dvm::OID &name); // Bone functions // int bones() const { return m_bones.size(); }; Bone *bone(const doste::dvm::OID &name); Bone *boneID(int bid) const; private: int m_nMeshes; //map of bones in this model doste::Map m_boneMap; std::vector m_bones; //AnimationSets doste::Map m_animationMap; //Bounding sphere float m_radius; wgd::vector3d m_centre; //Loading bool m_loaded; ModelLoader *m_loader; }; class ModelLoader : public Loader { public: BASE_LOADER(ModelLoader); ModelLoader(doste::File *f) : Loader(f), m_materialCounter(99), m_meshCounter(0) {}; virtual ~ModelLoader() {} // Set the parent model // void parent(Model* m) { m_model = m; }; // Load the model // virtual void load() = 0; protected: Model *m_model; Bone *createBone(const doste::dvm::OID &name); Mesh *createMesh(); Material *createMaterial(doste::dvm::OID &name); AnimationSet *createAnimation(const doste::dvm::OID &name); // texture directory // char* directory(doste::dstring, char*) const; private: //Used for automatically naming materials and meshes int m_materialCounter; int m_meshCounter; }; }; #endif wgd-3.1/include/wgd/isprite3d.h0000644000175000001440000000444311233311615013337 00000000000000#ifndef _WGD_ISPRITE3D_ #define _WGD_ISPRITE3D_ #include #include #include #include #include namespace wgd { class BASE3DIMPORT ISprite3D : public Instance3D { public: OBJECT(Instance3D, ISprite3D); ISprite3D(); ISprite3D(const OID &id); ~ISprite3D(); /** Draws the sprite */ void draw(SceneGraph &graph, Camera3D *camera); /** get the sprite that this instance uses */ PROPERTY_RF(Sprite, sprite, ix::sprite); /** Set the sprite that this object instanciates */ PROPERTY_WF(Sprite, sprite, ix::sprite); /** get the colour of the sprite */ PROPERTY_RF(wgd::colour, colour, ix::colour); /** set the sprite colour */ PROPERTY_WF(wgd::colour, colour, ix::colour); /** Get the direction the sprite points in if it is in aligned mode */ PROPERTY_RF(vector3d, direction, ix::direction); /** set the direction the sprite aligns to if in aligned mode */ PROPERTY_WF(vector3d, direction, ix::direction); /** Get the mode of this sprite */ PROPERTY_RF(OID, mode, ix::mode); /** * Set the mode this ISprite uses, can be 'point', 'aligned' or 'absolute'.
* point mode is used if no mode is set.
* In point mode, only the roll (z) coordinate of the orientation is used. */ PROPERTY_WF(OID, mode, ix::mode); /** The width of the sprite in world units */ PROPERTY_RF(float, width, ix::width); PROPERTY_WF(float, width, ix::width); /** The height of the sprite in world units */ PROPERTY_RF(float, height, ix::height); PROPERTY_WF(float, height, ix::height); /** The current frame */ PROPERTY_RF(int, frame, ix::frame); /** set the current frame */ void frame(int f); /** frame rate of the sprite */ PROPERTY_RF(float, fps, ix::fps); PROPERTY_WF(float, fps, ix::fps); // events to buffer database - will do the rest later BEGIN_EVENTS(Instance3D); EVENT(evt_sprite, (*this)(ix::sprite)); EVENT(evt_frame, (*this)(ix::frame)); EVENT(evt_size, (*this)(ix::width)(doste::dvm::modifiers::Seq)(*this)(ix::height)); EVENT_COLOUR(evt_colour, (*this)(ix::colour)); END_EVENTS; private: Sprite3D m_sprite; float m_start; }; }; #endif wgd-3.1/include/wgd/texture.h0000644000175000001440000002756711233311615013145 00000000000000/* * WGD Library * * Authors: * Date: 17/9/2007 * */ #ifndef _WGD_TEXTURE_ #define _WGD_TEXTURE_ #ifdef WIN32 #include #endif #include #include #include #include #include #include #include #include namespace wgd { /** * Used for texture names. */ typedef const doste::dvm::OID &TexName; //class Game; //class File; //class FrameBuffer; enum TextureFormat { RGBA, RGB, RGBA_HDR, RGB_HDR, DEPTH_16, DEPTH_24, DEPTH_32, ALPHA, LUMINANCE }; class RESIMPORT TextureLoader : public Loader { public: TextureLoader(doste::File *f) : Loader(f), m_data(0), m_width(0), m_height(0) {} virtual ~TextureLoader() { if (m_data != 0) delete [] m_data; }; virtual bool load()=0; unsigned char *data() const { return m_data; } int width() const { return m_width; } int height() const { return m_height; } //bool alpha() const { return m_alpha; } //bool hdr() const { return m_float; } TextureFormat format() const { return m_format; } BASE_LOADER(TextureLoader); //protected: void data(unsigned char *d) { m_data = d; } void width(int w) { m_width = w; } void height(int h) { m_height = h; } //void alpha(bool a) { m_alpha = a; } //void hdr(bool f) { m_float = f; } void format(TextureFormat f) { m_format = f; } private: unsigned char *m_data; int m_width; int m_height; //bool m_alpha; //bool m_float; TextureFormat m_format; }; class CustomTexture : public TextureLoader { public: CustomTexture() : TextureLoader(0) {} bool load() { return true; }; }; /** * A texture resource. This resource will be loaded from the specified file * when needed. TGA and BMP are currently supported. Multi-texturing is also * possible using this class by specifying the texture unit when binding, note * however that using multi-texturing is more involved than this. Instead of * using a texture directly you could use Material which provides more options.

* e.g.
* * //In initialisation.
* Resource::create\("plank")->filename("./data/plank.tga");
* //In update where you wish to use the texture.
* Resource::get\("plank")->bind();

*
* With the texture object you can call bind() when you want to use it. This * class supports multi-texturing so you can call bind and specify the texture * unit to use (defaults to 0). activate() is also provided to switch to * a specified texture unit.

* Here is an example of a texture in the config files:

* * wgd(textures)(plank) = {(filename, "./data/plank.tga"),(clamp,false),(mipmap,true)}; *

* @see Material */ class RESIMPORT Texture : public doste::Agent { //friend class wgd::FrameBuffer; public: OBJECT(Agent, Texture); Texture(); /// bool setPixels(int x, int y, int width, int height, const T *data) { FormatMap map; lookupFormat(map, m_format); if (map.colourformat != T::format || x < 0 || y < 0 || (x+width) > (int)m_width || (y+height) > (int)m_height || !m_loaded) return false; bind(); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, map.format, map.type, (char*)data); unbind(); return true; } template bool setPixel(int x, int y, const T &pixel) { FormatMap map; lookupFormat(map, m_format); if (map.colourformat != T::format || x < 0 || y < 0 || x >= m_width || y >= m_height || !m_loaded) return false; bind(); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, 1, 1, map.format, map.type, (char*)&pixel); unbind(); return true; } template bool getPixels(T *data) { FormatMap map; lookupFormat(map, m_format); if (map.colourformat != T::format || !m_loaded) return false; bind(); glGetTexImage(GL_TEXTURE_2D, 0, map.format, map.type, (char*)data); unbind(); return true; } template bool getPixels(int x, int y, int width, int height, T *data) { FormatMap map; lookupFormat(map, m_format); if (map.colourformat != T::format || x < 0 || y < 0 || (x+width) > (int)m_width || (y+height) > (int)m_height || !m_loaded || !keep() || !m_data) return false; int start = (x + (y*m_width)); int offset = start; int offset2 = 0; T *idata = (T*)m_data; for (int i=0; i bool getPixel(int x, int y, T &data) { FormatMap map; lookupFormat(map, m_format); if (map.colourformat != T::format || x < 0 || y < 0 || x >= m_width || y >= m_height || !m_loaded || !keep()) return false; data = *(T*)&m_data[(x + (y*m_width)) * sizeof(T)]; return true; } /** * Get the width of the texture in pixels. * @return Width. */ int width() const { return m_width; }; /** * Get the height of the texture in pixels. * @return Height. */ int height() const { return m_height; }; void width(int w) { m_width = w; set(ix::width, w); } void height(int h) { m_height = h; set(ix::height, h); } //bool depth() const { return m_depth; } //void depth(bool d) { m_depth = d; } /** * Get the colour depth in bits per pixel. * @return Colour Depth. */ //int colourDepth() const { return m_cdepth; }; /** * Use this texture by binding it to a specified texture unit. * If you are not multi-texturing then don't specify a parameter * and it will default to the first texture unit. * @param num Texture unit number, 0 to maxTextureUnits()-1. */ void bind(int num=0); /** * This will unbind and disable this texture. You do not need * to call this if you are simply binding to another texture on * the same texture unit. */ void unbind(); /** * Get the textures default colour. This is the colour used when make() is called. */ PROPERTY_RF(colour, defaultColour, "defaultcolour"); /** * Set the default colour. Used by make() when generating the texture. */ PROPERTY_WF(colour, defaultColour, "defaultcolour"); /** * Clamp the texture to the edge, do not repeat. Useful for * something like a skybox where there must be no seams. * @return True if the texture is clamped. */ PROPERTY_RF(bool, clamp, ix::clamp); /** * Clamp the texture to the edge, do not repeat. Useful for * something like a skybox where there must be no seams. * @param v True to clamp, false will repeat. */ PROPERTY_WF(bool, clamp, ix::clamp); /** * Should the texture be kept in system memory. * Needed if you wish to get pixel values, eg use it as a heightmap. */ PROPERTY_WF(bool, keep, ix::keep); /** Is this texture kept in system memory. */ PROPERTY_RF(bool, keep, ix::keep); /** * Is this texture mipmapped. * @return True if it is mipmapped. */ PROPERTY_RF(bool, mipmap, ix::mipmap); /** * Mipmapping. This will produce better looking results as it correctly * chooses texture detail with distance, however there are cases when you * do not want mipmapping for better results, eg for a shader or sprite. * @param v True to enable mipmapping. */ PROPERTY_WF(bool, mipmap, ix::mipmap); PROPERTY_RF(bool, nearest, "nearest"); PROPERTY_WF(bool, nearest, "nearest"); /** * Should DXF texture compression be used. By default this is true and * will allow you to use more or larger textures. This is OpenGL supported * hardware texture compression extension. The disadvantage is that some * gradient textures will have colour errors (e.g. skybox). */ PROPERTY_WF(bool, compress, ix::compress); /** Is this texture using hardware compression. */ PROPERTY_RF(bool, compress, ix::compress); //PROPERTY_WF(bool, hdr, "hdr"); //PROPERTY_RF(bool, hdr, "hdr"); /** * For HDR effects you can modify a normal texture with a glow texture. This can be * a 24 or 32 bit texture that scales the orginary texture based on value of each component. */ PROPERTY_WF(doste::dstring, glowFilename, ix::glowfilename); PROPERTY_RF(doste::dstring, glowFilename, ix::glowfilename); /** * Defines the maximum glow factor for a glow texture. In a glow texture 0 (black) corresponds * to a factor of 1.0 or no change from original image. 255 (white) corresponds to a factor * of glowMax(). This defaults to 10.0. */ PROPERTY_WF(float, glowMax, ix::glowmax); PROPERTY_RF(float, glowMax, ix::glowmax); /** * Current filename. * @return String representing the filename. */ //PROPERTY_RF(doste::dstring, filename, ix::filename); PROPERTY_RF(doste::File, file, "file"); /** * Textures filename. TGA (compressed and uncompressed) and BMP are supported * texture types currently. You must set the filename before loading or using * the texture. * @param v The filename string */ //PROPERTY_WF(doste::dstring, filename, ix::filename); PROPERTY_WF(doste::File, file, "file"); /** * Force load the texture. If not called then the texture will not be loaded until * bind is first called. If this first use is inside a display list then you * will have problems so called load() first. This also validates the GLID. */ void load(); /** * OpenGL texture ID. Only valid after first use or load() have been called. * @return OpenGL texture ID. */ GLuint getGLID() const { return m_glid; }; /** * Use to activate specific texturing units. Only needed if multi-texturing * and you need to be certain of which texture unit is active. bind() and * unbind() will automatically call this so immediately after bind() the * corresponding texture unit will still be active. * @param num Texture unit number, 0 to maxTextureUnits()-1. */ static void activate(int); /** * Get the maximum number of supported texture units. * @return Number of texture units. */ static int maxTextureUnits() { return s_maxtex; }; static void initialise(); static void finalise(); BEGIN_EVENTS(Agent); EVENT(evt_reload, (*this)("reload")); //hdr //mipmap //nearest //file //compress //clamp END_EVENTS; private: unsigned int m_width; unsigned int m_height; //int m_cdepth; unsigned char *m_data; GLuint m_glid; bool m_loading; bool m_loaded; bool m_failed; int m_bound; TextureFormat m_format; //bool m_ishdr; //bool m_depth; bool buildTexture(TextureLoader *); bool makeHDR(); static int s_maxtex; static int s_bind; static int s_maxmem; static int s_curmem; static Texture *s_curtex; struct FormatMap { int internal; int type; int format; ColourFormat colourformat; }; bool lookupFormat(FormatMap &map, TextureFormat format); }; }; #endif wgd-3.1/include/wgd/hmimagesource.h0000644000175000001440000000252311066447540014271 00000000000000#include #include #include namespace wgd { class HEIGHTMAPIMPORT HMImageSource : public HeightmapSource { public: OBJECT(HeightmapSource, HMImageSource); HMImageSource(doste::File* heights); HMImageSource(const doste::dvm::OID &o); ~HMImageSource(); PROPERTY_RF(float, defaultHeight, "defaultheight"); PROPERTY_WF(float, defaultHeight, "defaultheight"); PROPERTY_RF(doste::dvm::OID, mode, "mode"); PROPERTY_WF(doste::dvm::OID, mode, "mode"); /** Heightmap is repeated */ PROPERTY_RF(bool, repeat, "repeat"); PROPERTY_WF(bool, repeat, "repeat"); PROPERTY_RF(doste::File, file, "file"); PROPERTY_WF(doste::File, file, "file"); PROPERTY_RF(Material, material, ix::material); PROPERTY_WF(Material, material, ix::material); void begin(); void end(); HMRegion *region(int x, int y); //BEGIN_EVENTS(HeightmapSource); //EVENT(evt_height, (*this)("defaultheight")); //EVENT(evt_mode, (*this)("mode")); //EVENT(evt_repeat, (*this)("repeat")); //END_EVENTS; private: //Might use a hash table eventually. HMRegion *m_image; HMRegion *m_default; bool m_valid; //buffer repeat database variable bool m_repeat; void clearAll(); void buildImage(); void buildDefault(); float convertData(char *data); int countBits(int); }; }; wgd-3.1/include/wgd/sprite.h0000644000175000001440000000537011233311615012737 00000000000000/* * ÌÇÐÄTV Game Design Library * * Authors: * Date: 18/9/2007 * */ #ifndef _WGD_SPRITE_ #define _WGD_SPRITE_ #include #include namespace wgd { /** * A sprite resource. Here you describe a sprite, such as its textures, animation columns * and rows, number of frames and whether it is a billboard or not. Use an ISprite to * actually draw an instance of this sprite in the game. */ class RESIMPORT Sprite : public doste::Agent { public: OBJECT(Agent, Sprite); Sprite(); Sprite(const char* filename); Sprite(doste::File *texture); Sprite(const doste::dvm::OID &res); ~Sprite(); /** * Set the texture for this sprite. * Multiple frames are specified within a single texture by using tiles. */ PROPERTY_WF(wgd::Texture, texture, ix::texture); /** * Get the sprites texture. * @return Pointer to texture object or NULL if no object has been specified. */ PROPERTY_RF(wgd::Texture, texture, ix::texture); /** Width of sprite texture in pixels. */ PROPERTY_RF(int, width, ix::width); /** * Width of sprite texture in pixels. * This allows you to have non-power-of-two sprites within a power-of-two texture. */ PROPERTY_WF(int, width, ix::width); /** Height of sprite texture in pixels*/ PROPERTY_RF(int, height, ix::height); /** Height of sprite texture in pixels*/ PROPERTY_WF(int, height, ix::height); /** * Frame columns. If multiple frames are in one texture then specify * the number of frame columns with this. Defaults to 1 */ PROPERTY_WF(int, columns,ix::columns); /** Get frame columns. */ PROPERTY_RF(int, columns,ix::columns); /** * Frame rows. The number of animation frames in the Y direction. * Defaults to 1. */ PROPERTY_WF(int, rows,ix::rows); /** * Get number of frame rows */ PROPERTY_RF(int, rows,ix::rows); /** Flip the sprite vertically */ PROPERTY_WF(bool, flipv, ix::flipv); /** Is this sprite flipped vertically. */ PROPERTY_RF(bool, flipv, ix::flipv); /** Flip the sprite horizontally */ PROPERTY_WF(bool, fliph, ix::fliph); /** Is this sprite flipped horizontally */ PROPERTY_RF(bool, fliph, ix::fliph); /** * Specify the total number of animation frames. Frames are taken from * left to right and then row by row with the top left being frame one * and bottom right being the last frame. */ PROPERTY_WF(int, frames,ix::frames); /** Get number of animation frames. */ PROPERTY_RF(int, frames,ix::frames); /** specify the default frame rate for this sprite */ PROPERTY_WF(float, fps, ix::fps); /** get the default framerate for this sprite */ PROPERTY_RF(float, fps, ix::fps); static void initialise(); static void finalise(); private: void setup(); }; }; #endif wgd-3.1/include/wgd/morphcontroller.h0000644000175000001440000000161611046320307014661 00000000000000#ifndef _WGD_MORPH_CONTROLLER_ #define _WGD_MORPH_CONTROLLER_ #include #include namespace wgd { class MorphController { public: MorphController(wgd::Instance3D* inst); ~MorphController(); bool update(); void changeMorph(int mesh, float transition=0.0); /** get the number of meshes in this morph */ int meshes(){ return m_meshes; } private: void deform(wgd::Mesh* dest, wgd::Mesh *a, wgd::Mesh* b, float pcnt); //resize local memory void resize(int n); int m_meshes; wgd::Instance3D *m_inst; wgd::Model *m_model; //current morphs float *m_time; //time at the start of each morph float *m_duration; //duration of each morph //need temporary meshes if i do transitions - maybe do that later //as i havent finished transitions in animationcontroller yet }; }; #endif wgd-3.1/include/wgd/sprite2d.h0000644000175000001440000000615111233311615013163 00000000000000#ifndef _WGD_SPRITE2D_ #define _WGD_SPRITE2D_ #include #include #include #include #include #include namespace wgd { class BASE2DIMPORT Sprite2D { public: /// Create a new sprite Sprite2D(); /** create a sprite * @param sprite The sprite resource to use * @param position The position of the sprite in the world * @param scale The sprite scale compared to the source texture size * @param angle The angle in radians that the sprite is drawn at */ Sprite2D(Sprite* sprite, const vector2d &position, float scale=1.0f, float angle=0.0f, int frame=0); //Set the sprite resource void sprite(Sprite *spr); /// Set the position of the center of the sprite. void position(const vector2d &p); /// set the angle of the sprite void angle(float ang); ///set the sprite scale compared to the source texture size void scale(float s); ///specify different scales fro the x and y axes void stretch(float sx, float sy); /// set the absolute size of the sprite in pixels void size(float width, float height); //set the sprite colour void colour(const wgd::colour &c); //set the sprite frame void frame(int f); //the depth void depth(float d); void draw(SceneGraph &graph); Drawable *drawable(); private: Sprite *m_sprite; Drawable *m_drawable; vector2d m_position; float m_angle; vector2d m_size; int m_frame; float m_depth; bool m_changed; void setup(); void build(); }; class BASE2DIMPORT ISprite2D : public Instance2D { public: OBJECT(Instance2D, ISprite2D); ISprite2D(const OID &id); ISprite2D(); ~ISprite2D(); virtual void draw(SceneGraph &graph, Camera2D *camera); PROPERTY_RF(float, width, ix::width); ///< the width of the sprite on screen PROPERTY_WF(float, width, ix::width); ///< set width of the sprite PROPERTY_RF(float, height, ix::height); ///< the height of the sprite on screen PROPERTY_WF(float, height, ix::height); ///< set height of the sprite PROPERTY_RF(Sprite, sprite, ix::sprite); ///< The sprite resource PROPERTY_WF(Sprite, sprite, ix::sprite); ///< set the sprite to draw PROPERTY_RF(int, frame, ix::frame); ///< The current frame of the sprite PROPERTY_WF(int, frame, ix::frame); ///< set the sprite frame PROPERTY_RF(float, depth, ix::depth); ///< The depth of the sprite in the scene. Greater values are further away PROPERTY_WF(float, depth, ix::depth); ///< Set the depth of the sprite in the scene /// set the sprite scale - this sets the width and height property based on the original sprite void scale(float s); /// specify different scales fro the x and y axes void stretch(float sx, float sy); BEGIN_EVENTS(Instance2D); EVENT(evt_size, (*this)(ix::width)(doste::dvm::modifiers::Seq)(*this)(ix::height)); EVENT(evt_sprite, (*this)(ix::sprite)); EVENT(evt_frame, (*this)(ix::frame)); END_EVENTS; private: Sprite2D m_sprite; }; }; #endif wgd-3.1/include/wgd/iprimitive.h0000644000175000001440000000556411233311615013617 00000000000000/* * WGD Library * * Authors: * Date: 19/9/2007 * */ #ifndef _WGD_IPRIMATIVE_H_ #define _WGD_IPRIMATIVE_H_ #include #include #include #include #include namespace wgd { /** * Primitives are basic shapes you can use as part of something greater * they are not database objects so it will be faster to use many of them * The vertex data is also re-used (eg one vertex array for all cubes); */ class BASE3DIMPORT Primitive { public: Primitive(); ~Primitive(); /** get the drawable object */ //Drawable *drawable() { return m_drawable; } void draw(SceneGraph &graph, Camera3D *camera); private: float m_width, m_height, m_depth; // bounding box float m_tu, m_tv; // texture scale //cube: width, height, depth, tu, tv //cylinder: radius/width height, depth //sphere: //plane: }; /** * Draw simple shapes. Currently this class only provides a cube (rectangle). */ class BASE3DIMPORT IPrimitive3D : public wgd::Instance3D { public: IPrimitive3D(); IPrimitive3D(const doste::dvm::OID &); /** * Draw this primative. */ virtual void draw(SceneGraph &graph, Camera3D *camera); /** * Select type of primative. Currently can only do a cube and is * specified with IPrimative::CUBE. This is optional since it defaults * to cube anyway. */ PROPERTY_WF(doste::dvm::OID,primitive,ix::primitive); /** Get the primative this will draw. */ PROPERTY_RF(doste::dvm::OID,primitive,ix::primitive); /** Specify width of primative */ PROPERTY_WF(float,width,ix::width); /** Current width. */ PROPERTY_RF(float,width,ix::width); /** Specify height if primative. */ PROPERTY_WF(float,height,ix::height); /** Current height. */ PROPERTY_RF(float,height,ix::height); /** Specify depth of primative */ PROPERTY_WF(float,depth,ix::depth); /** Current depth */ PROPERTY_RF(float,depth,ix::depth); /** * Set the size of the primative. * @param w Width of primative * @param h Height of primative * @param d Depth of primative */ void size(float w, float h, float d); /** * If applicable this sets radius. Currently unused. */ PROPERTY_WF(float,radius,ix::radius); /** Get radius. May not always have a value, in which case it is 0. */ PROPERTY_RF(float,radius,ix::radius); /** Set number of sides in the sphere and cylinder */ PROPERTY_WF(int,sides, "sides"); /** Get the number of sides of this primative */ PROPERTY_RF(int,sides, "sides"); /** * Attach a material. This defines the appearance of the cube but giving it * a texture, shader and lighting effects. */ PROPERTY_WF(Material, material,ix::material); /** Get current material. */ PROPERTY_RF(Material, material,ix::material); OBJECT(Instance3D, IPrimitive3D); private: }; }; #endif wgd-3.1/include/wgd/animationcontroller.h0000644000175000001440000001175311233311615015516 00000000000000#ifndef _WGD_ANIMATION_CONTROLLER_ #define _WGD_ANIMATION_CONTROLLER_ #include #include #include #include #include #include #include #include #include #define MAX_ANIMATIONS 9 namespace wgd { class AnimationController; struct MODELSIMPORT Animation { friend class AnimationController; float weight; //weight float speed; //animation speed float time; //time into animation float length() { return m_length; } ///< length of animation in seconds bool loop; //animation looped, or clamped const OID& animation() const { return m_animation; } ///< get current animation /// start a new animation void start(const OID &name, float weight=1.0f, const OID &bone=ix::root, float speed=1.0f); //? Animation& operator=(Animation &a) { memcpy(this, &a, sizeof(Animation)); return *this; } private: float m_length; OID m_animation; AnimationController* m_parent; //parent animationController int m_index; //animation index }; class AnimationController { friend class SkinController; public: AnimationController(wgd::Instance3D* inst); ~AnimationController(); //update animation - returns true if changed bool update(bool force); void drawSkeleton(); /** get public animation data */ Animation &animation(int i) { return m_animation[i]; } //change animation void startAnimation(int anim, const OID &bone=Null); //local transformation matrix for each mesh matrix &transformMesh(Mesh *mesh); /** Get the transformation matrix of a bone */ matrix &boneMatrix(const wgd::OID &boneName); private: /** Recursively calculate bone transformations */ void calculateBone(const OID &boneName, const wgd::matrix &parent, int mask=0); //update specific animation bool update(int blend, float time); //final bone matrices matrix *m_transform; matrix *m_transformA; //current transformation vector3d *m_cscale; vector3d *m_cposition; quaternion *m_corientation; //animation blending struct Blend { float start; //start frame float end; //end frame wgd::OID next; //next animation float frames; //number of frames in animation float frame; //current frame AnimationSet *set; //animationSet of this animation int root; //root boneID float weight; //blend amount } m_blend[MAX_ANIMATIONS]; //public data for animation blending Animation m_animation[MAX_ANIMATIONS]; //get blended scale void transform(int bid, int mask, vector3d &position, vector3d &scale, quaternion &orientation); //also needs to know where the IBone objects are //and the model bones and the model animations and animationsets wgd::Model *m_model; wgd::Instance3D *m_inst; }; /** * This class is used for the user to have direct control of the * bones in the model. When override is true, the bone will be controlled * by this class. There is no effect if override is false.
* Bones can be manipulated by giving them a target to point at, or * by specifying an orientation. */ class MODELSIMPORT IBone : public doste::Agent { friend class AnimationController; public: IBone(); IBone(const doste::dvm::OID &id); /** A point in world space that the bone will point at */ PROPERTY_W(vector3d, target); /** Local orientation of a bone */ PROPERTY_WF(vector3d, orientation, ix::orientation); PROPERTY_RF(vector3d, orientation, ix::orientation); /** Minimum orientation of a bone */ PROPERTY_WF(vector3d, minimum, "min"); PROPERTY_RF(vector3d, minimum, "min"); /** Maximum orientation of a bone */ PROPERTY_WF(vector3d, maximum, "max"); PROPERTY_RF(vector3d, maximum, "max"); /** Rotation speed (0=infinite) - used with target */ PROPERTY_WF(float, speed, "speed"); PROPERTY_RF(float, speed, "speed"); /** Bone scale */ PROPERTY_WF(wgd::vector3d, scale, ix::scale); PROPERTY_RF(wgd::vector3d, scale, ix::scale); void scale(float s) { scale(vector3d(s,s,s)); } /** Does the IBone override the animation */ PROPERTY_W(bool, active); PROPERTY_R(bool, active); BEGIN_EVENTS(doste::Agent); EVENT_VECTOR( evt_target, (*this)("target")); EVENT_VECTOR( evt_pitchyawRoll, (*this)(ix::orientation)); //(doste::dvm::modifiers::Seq)(*this)(ix::scale)); END_EVENTS; OBJECT(Object, IBone); /** Used by IModel to get the transform matrix of this bone */ const matrix &transform(const matrix&, const matrix&); private: //The two methods of calculating it void calcPYR(); void calcTarget(const matrix&, const matrix&); //cache target wgd::vector3d m_target; bool m_useTarget; // user defined matrix for this bone // // or should be quaternion + scale ? // matrix m_matrix; }; }; #endif wgd-3.1/include/wgd/modelx.h0000644000175000001440000000401011051047200012701 00000000000000#ifndef _WGD_MODELX_ #define _WGD_MODELX_ #include #include #include namespace wgd { class vector3d; class vector2d; class Bone; struct MeshSkin; class AnimationSet; class ModelX : public wgd::ModelLoader { public: LOADER(ModelX); ModelX(doste::File* f) : ModelLoader(f) {}; static bool validate(doste::File*); void load(); private: void skipBlock(); OID getBlock(); OID startBlock(); void endBlock(); wgd::vector3d readVector(int n=3); OID readInline(); void readFrame(wgd::Bone *parent); void readMatrix(float* m); void readMesh(const OID&); int readVertices(wgd::vector3d *&); int readFaces(int*&, int*&); int readNormals(wgd::vector3d *&); int readTexCoords(wgd::vector2d *&); int readMaterials(int count, int *&, OID *&, int *&); OID readMaterial(); int readSkinHeader(wgd::MeshSkin *&); int readSkin(wgd::MeshSkin *&, int weights); void processMesh(const OID&, int, int*, wgd::vector3d*, wgd::vector3d*, wgd::vector2d*, int*, OID*, int, wgd::MeshSkin*); void readAnimationSet(); void readAnimation(AnimationSet*); void readAnimationKey(AnimationSet*, int); bool parseJunk(){ file()->parse(doste::token::WhiteSpace()); //Parse comment while(file()->parse(doste::token::Char<2>("//"))){ char c = 0; //doste::Warning(0, "Parsing Comment"); while(c!='\n' && !file()->eof()) file()->read(c); file()->parse(doste::token::WhiteSpace()); } return true; } template bool parse(T t){ return t.parse(*file()); }; template bool parseValue(T &t){ return t.parse(*file()); }; template wgd::vector3d parseVector(int n, T t){ doste::token::Float f[4]; for(int i=0; i #endif #include #ifdef LINUX #include #include #endif #include /* * Type definitions and function pointers for the OpenGl ARB * multitexturing extentions if the graphics card supports it. * These extensions are used by terrain mesh to add detail */ #ifdef WIN32 typedef void (APIENTRY *PFNGLACTIVETEXTUREARBPROC)(GLenum); typedef void (APIENTRY *PFNGLMULTITEXCOORD2FARBPROC)(GLenum, GLfloat, GLfloat); typedef void (APIENTRY *PFNGLCLIENTACTIVETEXTUREARBPROC)(GLenum); typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 #define GL_TEXTURE2_ARB 0x84C2 #define GL_TEXTURE3_ARB 0x84C3 #define GL_TEXTURE4_ARB 0x84C4 #define GL_TEXTURE5_ARB 0x84C5 #define GL_TEXTURE6_ARB 0x84C6 #define GL_TEXTURE7_ARB 0x84C7 #define GL_CLAMP_TO_EDGE 0x812F #define GL_COMPRESSED_RGB_ARB 0x84ED #define GL_COMPRESSED_RGBA_ARB 0x84EE #endif extern BASEIMPORT PFNGLACTIVETEXTUREARBPROC WGDglActiveTextureARB; extern BASEIMPORT PFNGLMULTITEXCOORD2FARBPROC WGDglMultiTexCoord2fARB; extern BASEIMPORT PFNGLCLIENTACTIVETEXTUREARBPROC WGDglClientActiveTextureARB; //#endif //#ifndef HAVE_GLCOMPRESSTEXTURE extern BASEIMPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC WGDglCompressedTexImage3DARB; extern BASEIMPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC WGDglCompressedTexImage2DARB; extern BASEIMPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC WGDglCompressedTexImage1DARB; extern BASEIMPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC WGDglCompressedTexSubImage3DARB; extern BASEIMPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC WGDglCompressedTexSubImage2DARB; extern BASEIMPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC WGDglCompressedTexSubImage1DARB; extern BASEIMPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC WGDglGetCompressedTexImageARB; //#endif //stuff stolen from glew ####################################################### #define GL_FRAGMENT_SHADER 0x8B30 #define GL_VERTEX_SHADER 0x8B31 #define GL_INFO_LOG_LENGTH 0x8B84 typedef char GLchar; #ifdef WIN32 typedef void (APIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); typedef void (APIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); typedef void (APIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); typedef void (APIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); typedef GLuint (APIENTRY * PFNGLCREATEPROGRAMPROC) (void); typedef GLuint (APIENTRY * PFNGLCREATESHADERPROC) (GLenum type); typedef void (APIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); typedef void (APIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); typedef void (APIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); typedef void (APIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); typedef void (APIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); typedef void (APIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); typedef void (APIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); typedef void (APIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); typedef void (APIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); typedef GLint (APIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); typedef void (APIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); typedef void (APIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); typedef void (APIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); typedef void (APIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); typedef void (APIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); typedef GLint (APIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLint programObj, const GLchar* name); typedef void (APIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); typedef void (APIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); typedef void (APIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid*); typedef void (APIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); typedef void (APIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); typedef void (APIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); typedef GLboolean (APIENTRY * PFNGLISPROGRAMPROC) (GLuint program); typedef GLboolean (APIENTRY * PFNGLISSHADERPROC) (GLuint shader); typedef void (APIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); typedef void (APIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); typedef void (APIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); typedef void (APIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); typedef void (APIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); typedef void (APIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); typedef void (APIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (APIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); typedef void (APIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (APIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (APIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); typedef void (APIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (APIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); typedef void (APIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (APIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); typedef void (APIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (APIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); typedef void (APIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); typedef void (APIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); typedef void (APIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); typedef void (APIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (APIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (APIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); typedef void (APIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); typedef void (APIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); typedef void (APIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); typedef void (APIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); typedef void (APIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); typedef void (APIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); typedef void (APIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); typedef void (APIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); typedef void (APIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); typedef void (APIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); typedef void (APIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); typedef void (APIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); typedef void (APIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); typedef void (APIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); typedef void (APIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); typedef void (APIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); typedef void (APIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); #endif extern BASEIMPORT PFNGLCREATESHADERPROC WGDglCreateShader; extern BASEIMPORT PFNGLSHADERSOURCEPROC WGDglShaderSource; extern BASEIMPORT PFNGLCOMPILESHADERPROC WGDglCompileShader; extern BASEIMPORT PFNGLCREATEPROGRAMPROC WGDglCreateProgram; extern BASEIMPORT PFNGLATTACHSHADERPROC WGDglAttachShader; extern BASEIMPORT PFNGLLINKPROGRAMPROC WGDglLinkProgram; extern BASEIMPORT PFNGLGETPROGRAMIVPROC WGDglGetProgramiv; extern BASEIMPORT PFNGLGETSHADERIVPROC WGDglGetShaderiv; extern BASEIMPORT PFNGLGETPROGRAMINFOLOGPROC WGDglGetProgramInfoLog; extern BASEIMPORT PFNGLGETSHADERINFOLOGPROC WGDglGetShaderInfoLog; extern BASEIMPORT PFNGLISPROGRAMPROC WGDglIsProgram; extern BASEIMPORT PFNGLGETUNIFORMLOCATIONPROC WGDglGetUniformLocation; extern BASEIMPORT PFNGLGETATTRIBLOCATIONPROC WGDglGetAttribLocation; extern BASEIMPORT PFNGLUSEPROGRAMPROC WGDglUseProgram; extern BASEIMPORT PFNGLUNIFORM1FVPROC WGDglUniform1fv; extern BASEIMPORT PFNGLUNIFORM1FPROC WGDglUniform1f; extern BASEIMPORT PFNGLUNIFORM2FPROC WGDglUniform2f; extern BASEIMPORT PFNGLUNIFORM3FPROC WGDglUniform3f; extern BASEIMPORT PFNGLUNIFORM4FPROC WGDglUniform4f; extern BASEIMPORT PFNGLUNIFORM1IVPROC WGDglUniform1iv; extern BASEIMPORT PFNGLUNIFORM1IPROC WGDglUniform1i; extern BASEIMPORT PFNGLVERTEXATTRIB1FVPROC WGDglVertexAttrib1fv; extern BASEIMPORT PFNGLVERTEXATTRIB1FPROC WGDglVertexAttrib1f; extern BASEIMPORT PFNGLVERTEXATTRIB2FPROC WGDglVertexAttrib2f; extern BASEIMPORT PFNGLVERTEXATTRIB3FPROC WGDglVertexAttrib3f; extern BASEIMPORT PFNGLVERTEXATTRIB4FPROC WGDglVertexAttrib4f; extern BASEIMPORT PFNGLBINDATTRIBLOCATIONPROC WGDglBindAttribLocation; extern BASEIMPORT PFNGLENABLEVERTEXATTRIBARRAYPROC WGDglEnableVertexAttribArray; extern BASEIMPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC WGDglDisableVertexAttribArray; extern BASEIMPORT PFNGLVERTEXATTRIBPOINTERPROC WGDglVertexAttribPointer; extern BASEIMPORT PFNGLDELETESHADERPROC WGDglDeleteShader; extern BASEIMPORT PFNGLDELETEPROGRAMPROC WGDglDeleteProgram; //############################################################################## #ifdef WIN32 typedef void (APIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); typedef void (APIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); #define GL_ALIASED_POINT_SIZE_RANGE 0x846d #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8861 #define GL_POINT_DISTANCE_ATTENUATION 0x8129 #endif extern BASEIMPORT PFNGLPOINTPARAMETERFVPROC WGDglPointParameterfv; extern BASEIMPORT PFNGLPOINTPARAMETERFPROC WGDglPointParameterf; //VBO #ifdef WIN32 #define GL_ARRAY_BUFFER_ARB 0x8892 #define GL_STATIC_DRAW_ARB 0x88E4 typedef void (APIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); typedef void (APIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); typedef void (APIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); typedef void (APIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, int size, const GLvoid *data, GLenum usage); #endif extern BASEIMPORT PFNGLGENBUFFERSARBPROC WGDglGenBuffersARB; // VBO Name Generation Procedure extern BASEIMPORT PFNGLBINDBUFFERARBPROC WGDglBindBufferARB; // VBO Bind Procedure extern BASEIMPORT PFNGLBUFFERDATAARBPROC WGDglBufferDataARB; // VBO Data Loading Procedure extern BASEIMPORT PFNGLDELETEBUFFERSARBPROC WGDglDeleteBuffersARB; // VBO Deletion Procedure //FBO + RenderBuffer #ifdef WIN32 #define GL_FRAMEBUFFER_EXT 0x8D40 #define GL_RENDERBUFFER_EXT 0x8D41 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 #define GL_DEPTH_COMPONENT24 0x81A6 #define GL_DEPTH_COMPONENT32 0x81A7 #define GL_RGBA16F_ARB 0x881A #define GL_HALF_FLOAT_ARB 0x140B #define GL_CLAMP_VERTEX_COLOR_ARB 0x891A #define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B #define GL_FIXED_ONLY_ARB 0x891D typedef void (APIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); typedef void (APIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); typedef void (APIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); typedef void (APIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); typedef void (APIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); typedef void (APIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); typedef void (APIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); typedef void (APIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); typedef GLenum (APIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); typedef void (APIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #endif extern BASEIMPORT PFNGLGENRENDERBUFFERSEXTPROC WGDglGenRenderbuffersEXT; extern BASEIMPORT PFNGLBINDFRAMEBUFFEREXTPROC WGDglBindFramebufferEXT; extern BASEIMPORT PFNGLBINDRENDERBUFFEREXTPROC WGDglBindRenderbufferEXT; extern BASEIMPORT PFNGLDELETEFRAMEBUFFERSEXTPROC WGDglDeleteFramebuffersEXT; extern BASEIMPORT PFNGLDELETERENDERBUFFERSEXTPROC WGDglDeleteRenderbuffersEXT; extern BASEIMPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC WGDglFramebufferRenderbufferEXT; extern BASEIMPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC WGDglFramebufferTexture2DEXT; extern BASEIMPORT PFNGLGENFRAMEBUFFERSEXTPROC WGDglGenFramebuffersEXT; extern BASEIMPORT PFNGLRENDERBUFFERSTORAGEEXTPROC WGDglRenderbufferStorageEXT; extern BASEIMPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC WGDglCheckFramebufferStatusEXT; extern BASEIMPORT PFNGLCLAMPCOLORARBPROC WGDglClampColorARB; namespace wgd { /** * Detects available OpenGL and processor extensions. */ class BASEIMPORT Extensions { public: /** * Do we have multi-texture support. * @return True if we have multi-texture support. */ static bool hasMultiTexture() { return s_multitex; }; /** * Can OpenGL use compressed textures. * @return True if DXF texture compression is supported. */ static bool hasTextureCompression() { return s_texcompress; }; /** * Is antialiasing possible with hardware. */ static bool hasMultisample() { return s_multisample; }; /** * Are vertex and fragment shaders available. * @return True if both vertex and fragment shaders exist. */ static bool hasShaders() { return s_shaders; }; /** * Do we have Vertex Buffer Objects. */ static bool hasVBO() { return s_vbo; }; static bool hasMMX() { return s_mmx; }; /** * Is this processor SSE capable. * @return True if we have SSE SIMD instructions. */ static bool hasSSE() { return s_sse; }; static bool hasFBO() { return s_framebuf; }; static bool hasHalfFloat() { return s_halffloat; }; static bool hasColourClamp() { return s_colorbuf; }; static void initialise(); static void finalise(); private: static bool isinstring(char *, const char *); struct SCpuidRegs { int eax; int ebx; int ecx; int edx; }; static void getCpuid(int num, SCpuidRegs ®s) { //Use _asm in VC++ #ifndef WINVC //asm ( "cpuid" // : "=a" (regs.eax), // "=b" (regs.ebx), // "=c" (regs.ecx), // "=d" (regs.edx) // : "a" (num)); #else #endif } static bool s_multitex; static bool s_texcompress; static bool s_shaders; static bool s_mmx; static bool s_sse; static bool s_framebuf; static bool s_halffloat; static bool s_multisample; static bool s_vbo; static bool s_colorbuf; }; }; #endif wgd-3.1/include/wgd/scene3d.h0000644000175000001440000000416311233311615012754 00000000000000#ifndef _WGD_SCENE3D_ #define _WGD_SCENE3D_ #include #include #include #include #include #include #include #include namespace wgd { class Camera; class BASE3DIMPORT Scene3D : public wgd::Scene { public: Scene3D(const doste::dvm::OID &); ~Scene3D(); void update(); void draw(Camera *); //Octree dimensions PROPERTY_RF(float, width, ix::width); PROPERTY_RF(float, height, ix::height); PROPERTY_RF(float, depth, ix::depth); PROPERTY_WF(float, levels, ix::levels); PROPERTY_RF(float, levels, ix::levels); //events BEGIN_EVENTS(Scene); EVENT(evt_add, (*this)(ix::instances)(doste::dvm::All)); END_EVENTS; OBJECT(Scene, Scene3D); /** get the scene graph object to manually add drawables */ SceneGraph &graph() { return m_graph; }; private: //octree node structure struct Node{ wgd::vector3d centre; //center point of node uint key; //Morton key for this node unsigned char hasChild; //Bitmask or each child (optional) std::list instances; //list of instances in this node }; //linear octree - 'Real Time Collision Detection' [ch7.3.1 p314] std::map m_octree; //Map of instance pointers to location codes std::map m_location; //lights std::vector m_lights; //Skyboxes //std::vector m_skyboxes; //Morton key calculations uint morton(const vector3d &); uint truncate(int depth, uint key); int calcDepth(uint key); //octree stuff - per instance void add(Instance3D* inst); uint insert(Node*, Instance3D*, const wgd::vector3d &low, const wgd::vector3d &high, int d=0); uint remove(Instance3D *inst); //global octree functions void build(); void build(const doste::dvm::OID&); void clear(); //has the octree been built bool m_built; bool m_doclear; //scene graphs SceneGraph m_graph; SceneGraph m_skyboxes; }; }; #endif wgd-3.1/include/wgd/material.h0000644000175000001440000001043511101056112013215 00000000000000/* * WGD Library * * Authors: * Date: 17/9/2007 * */ #ifndef _WGD_MATERIAL_ #define _WGD_MATERIAL_ #include #include #include #include #include #include namespace wgd { struct colour; //class Texture; /** * Surface material resource. A material specifies lighting properties of a * surface as well as its texture. You can apply a material to a surface * by calling bind() just before you draw that surface. It is also possible * to add a shader to a material instead of a texture.

* * //--- Initialise ---
* Material *mat = Resource::create\("shiney_metal1");
* mat->shininess(200);
* mat->specular(Colour(1.0,1.0,1.0,1.0));
* mat->diffuse(Colour(1.0,1.0,1.0,1.0));
* mat->texture(Resource::get\("metal1"));

* //--- Use ---
* Resource::get\("shiney_metal1")->bind();
* //...
* Resource::get\("shiney_metal1")->unbind();
*
*/ class RESIMPORT Material : public doste::Agent { public: OBJECT(Agent, Material); Material(); /** Create a new material containing a texture */ Material(doste::File *texturefile); /** Create a material of a colour */ Material(const wgd::colour &); Material(const doste::dvm::OID &); ~Material(); /** * Size of highlight. Value between 0 and 128 where 128 is the smallest * highlight and so appears shiniest. * @param v Value between 0 and 128. */ PROPERTY_WF(float,shininess,ix::shininess); /** * Get current shininess value. * @return Number between 0 and 128. */ PROPERTY_RF(float,shininess,ix::shininess); /** * Colour of specular highlight. Here you can specify its * rgb value. * @param c RGB Colour. */ PROPERTY_WF(colour,specular,ix::specular); /** * Get specular colour. * @return RGB colour object. */ PROPERTY_RF(colour,specular,ix::specular); /** * The diffuse colour of the material. Specify its RGBA value * so that you can make this material transparent. * @param c RGBA Colour. */ PROPERTY_WF(colour,diffuse,ix::diffuse); /** Get diffuse colour */ PROPERTY_RF(colour,diffuse,ix::diffuse); /** * Set the ambient colour. Usually this is the same as diffuse colour. */ PROPERTY_WF(colour,ambient,ix::ambient); /** Get diffuse colour. */ PROPERTY_RF(colour,ambient,ix::ambient); /** * Set the ambient colour. Usually this is the same as diffuse colour. */ PROPERTY_WF(colour,emission,ix::emission); /** Get diffuse colour. */ PROPERTY_RF(colour,emission,ix::emission); /** Set the blending effect to use. See BLEND_ */ PROPERTY_WF(doste::dvm::OID, blending,ix::blending); /** Get the blending effect. */ PROPERTY_RF(doste::dvm::OID, blending,ix::blending); /** set the alpha test value for this material. fragments with alpha less than this value will be ignored */ PROPERTY_WF(float, alphaTest, "alphatest"); /** get the alpha test value */ PROPERTY_RF(float, alphaTest, "alphatest"); /** Set this materials texture. */ void texture(wgd::Texture *t) { texture(0, t); } /** Set multiple textures for this material. Specify the texture * number between 0 and Texture::maxTextureUnits(). */ void texture(int num, wgd::Texture *); /** Get one of the materials textures. */ Texture *texture(int num=0); /** Assign a shader to this material. */ PROPERTY_WF(wgd::Shader, shader,ix::shader); /** Get the shader for this material, may return 0. */ PROPERTY_RF(wgd::Shader, shader,ix::shader); void variable(const char *name, const OID &v); OID variable(const char *name); /** * Apply the material. Everything drawn after this will use this material until * either it is unbound or another material is bound. */ void bind(); /** * Remove this material as the current one. Anything drawn after this will have no * material unless another material is bound. */ void unbind(); static doste::dvm::OID BLEND_NORMAL; static doste::dvm::OID BLEND_MULTIPLY; static doste::dvm::OID BLEND_ADD; static doste::dvm::OID BLEND_NONE; static doste::dvm::OID BLEND_ONE; static void initialise(); static void finalise(); private: static Material *s_current; }; }; #endif wgd-3.1/include/wgd/Makefile.am0000755000175000001440000000137011233311615013313 00000000000000pkgincludedir = $(includedir)/wgd pkginclude_HEADERS=animationcontroller.h animationset.h bone.h camera2d.h camera3d.h camera.h colour.h common.h dll.h extensions.h font.h heightmap.h heightmapsource.h hmdatasource.h hmimagesource.h iheightmap.h iline.h imodel.h index.h input.h instance2d.h instance3d.h iprimitive.h iterator.h keyboard.h loader.h material.h math.h matrix.h mesh.h model3ds.h model.h modelx.h morphcontroller.h mouse.h quaternion.h render.h rendertarget.h scene3d.h scene.h shader.h skincontroller.h sprite.h texturebmp.h texture.h texturepng.h texturetga.h vector.h vertex.h wiimote.h joystick.h window.h frustum.h sprite3d.h isprite3d.h drawable.h scenegraph.h spritefont.h text3d.h scene2d.h sprite2d.h clipmap.h SUBDIRS=png zlib widgets wgd-3.1/include/wgd/text3d.h0000644000175000001440000000540211233311615012640 00000000000000//3d text - works identically to Sprite3D, just with Font rather than Sprite #ifndef _WGD_TEXT3D_ #define _WGD_TEXT3D_ #include #include //included for matrix functions #include #include namespace wgd { class BASE3DIMPORT Text3D { public: Text3D(); /** Create a new orientated sprite3d. * @param font The font to use * @param position The center of the text * @param scale The scale of the text in world units (default 1.0) * @param align Is the text alighed left, right or centered at position. * @param angle The angle of sprite in relation to the camera (default 0) */ Text3D(const char* text, Font* font, const vector3d &position, float scale=1.0f, TextAlign align=CENTRE, float angle=0); ~Text3D(); /** Add the sprite to the scene graph */ DrawableBase *draw(SceneGraph &graph, Camera3D *camera); /** Get the sprite drawable. Generates the sprite */ Drawable *drawable(Camera3D* cam); /** Set the sprite resource */ void font(Font* font) { m_font=font; m_changed=true; } /** Set the font scale of the sprite */ void scale(float s) { m_scale = s; } /** set alignment */ void align(TextAlign align) { m_align=align; m_changed=true; } /** set the position of the center of the sprite, or the bottom of the sprite if direction is used */ void position(const vector3d &v) { m_position=v; } /** Set the angle of the sprite, makes the sprite orientated */ void angle(float ang) {m_angle = ang; } /** set the text */ void text(const char* t); /** text colour */ void colour(const wgd::colour& c); private: void setup(); void build(); bool m_changed; //text has changed Drawable *m_drawable; //drawable object vector3d m_position; float m_angle; float m_scale; TextAlign m_align; wgd::colour m_colour; char* m_text; Font *m_font; }; //instance class IText3D : public Instance3D { public: OBJECT(Instance3D, IText3D); IText3D(const wgd::OID &); IText3D(); virtual void draw(SceneGraph &graph, Camera3D *camera); PROPERTY(doste::dstring, text); PROPERTY(float, scale); PROPERTY(float, angle); PROPERTY(wgd::colour, colour); PROPERTY(Font, font); void align(TextAlign align); TextAlign align(); BEGIN_EVENTS(Instance3D); EVENT(evt_text, (*this)(ix::text)); EVENT(evt_scale, (*this)(ix::scale)); EVENT(evt_angle, (*this)("angle")); EVENT(evt_align, (*this)("align")); EVENT_COLOUR(evt_colour, (*this)(ix::colour)); EVENT_VECTOR(evt_position, (*this)(ix::position)); EVENT(evt_font, (*this)(ix::font)); END_EVENTS; private: Text3D m_text; }; }; #endif wgd-3.1/include/wgd/wiimote.h0000644000175000001440000002421211233311615013102 00000000000000#ifndef _WGD_WIIMOTE_ #define _WGD_WIIMOTE_ #include #include #include #include #ifdef WIN32 #include #endif #ifndef NO_BLUETOOTH #ifdef LINUX #include #include #include #include #include #endif #ifdef WIN32 #define near #define far #include #ifndef _MSC_VER #include #else #include #endif #include #include //queue for the thread #pragma comment ( lib, "irprops.lib") #pragma comment ( lib, "setupapi.lib") //#pragma comment ( lib, "hid.lib") #endif #endif /* button codes */ #define WIIMOTE_BUTTON_TWO 0x0001 #define WIIMOTE_BUTTON_ONE 0x0002 #define WIIMOTE_BUTTON_B 0x0004 #define WIIMOTE_BUTTON_A 0x0008 #define WIIMOTE_BUTTON_MINUS 0x0010 #define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 #define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 #define WIIMOTE_BUTTON_HOME 0x0080 #define WIIMOTE_BUTTON_LEFT 0x0100 #define WIIMOTE_BUTTON_RIGHT 0x0200 #define WIIMOTE_BUTTON_DOWN 0x0400 #define WIIMOTE_BUTTON_UP 0x0800 #define WIIMOTE_BUTTON_PLUS 0x1000 #define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 #define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 #define WIIMOTE_BUTTON_UNKNOWN 0x8000 /* nunchul button codes */ #define NUNCHUK_BUTTON_Z 0x01 #define NUNCHUK_BUTTON_C 0x02 /* classic controller button codes */ #define CLASSIC_CTRL_BUTTON_UP 0x0001 #define CLASSIC_CTRL_BUTTON_LEFT 0x0002 #define CLASSIC_CTRL_BUTTON_ZR 0x0004 #define CLASSIC_CTRL_BUTTON_X 0x0008 #define CLASSIC_CTRL_BUTTON_A 0x0010 #define CLASSIC_CTRL_BUTTON_Y 0x0020 #define CLASSIC_CTRL_BUTTON_B 0x0040 #define CLASSIC_CTRL_BUTTON_ZL 0x0080 #define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 #define CLASSIC_CTRL_BUTTON_PLUS 0x0400 #define CLASSIC_CTRL_BUTTON_HOME 0x0800 #define CLASSIC_CTRL_BUTTON_MINUS 0x1000 #define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 #define CLASSIC_CTRL_BUTTON_DOWN 0x4000 #define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 /* wiimote option flags */ #define WIIMOTE_USE_SMOOTHING 0x01 #define WIIMOTE_INIT_FLAGS WIIMOTE_USE_SMOOTHING struct WiiEvent; struct WiiReadReq { unsigned int addr; unsigned short length; char *data; }; #ifdef WIN32 #ifndef NO_BLUETOOTH struct HIDDevice{ HANDLE hDevice; HANDLE hWrite; HANDLE hRead; HANDLE event; HIDP_CAPS caps; OVERLAPPED overlapped; }; #endif #endif namespace wgd { /** * Wiimote input support. Currently this only works in Linux where you can have * a maximum of 4 wiimotes connected at any time. It behaves exactly like a joystick * and can be assigned to controls as if it where one. The axes are calibrated so that * a value of 1 or -1 is the maxium g in a rest state and 0 is the g when flat on the table. */ class INPUTIMPORT Wiimote : public doste::Agent { public: VOBJECT(Agent, Wiimote); #ifdef LINUX #ifndef NO_BLUETOOTH Wiimote(bdaddr_t id, const doste::dvm::OID &obj); #else Wiimote(int id, const doste::dvm::OID &obj); #endif #endif #ifdef WIN32 #ifdef NO_BLUETOOTH Wiimote(int id, const doste::dvm::OID &obj); #else Wiimote(HIDDevice id, const doste::dvm::OID &obj); #endif #endif ~Wiimote(); /** * Is a specific button pressed. See BUTTON_ constants for * possible button values. * @param btn Check this button * @return True if the button is being pressed. */ bool btnPressed(const doste::dvm::OID &btn) const { return get(ix::buttons)[btn]; }; /** * Check if an LED is enabled. * @param num LED number, 0 to 3. * @return True if the LED is on. */ bool led(int num) const { return get("leds")[num]; }; /** * Turn an LED on or off. * @param num LED number, 0 to 3. * @param on True to turn the LED on. */ void led(int num, bool on) { get("leds")[num] = on; }; /** * Enable or disable rumble. * @param v True to enable rumble. */ PROPERTY_WF(bool, rumble, "rumble"); /** * Is rumble enabled. */ PROPERTY_RF(bool, rumble, "rumble"); /** * Get the value of a specific axis. * @param num Axis number, 0-2. * @return Value of axis. */ float axis(int num) const { return get(ix::axes)[num][ix::value]; } /** * Enable or disable the infrared sensor. * @param e True to enable. */ PROPERTY_WF(bool, irEnabled, "ir"); /** Is the IR sensor enabled. */ PROPERTY_RF(bool, irEnabled, "ir"); /** * The number of IR dots detected, 0 to 4. * @return Number of dots. */ int irNumber() { if (m_dots[3].found) return 4; if (m_dots[2].found) return 3; if (m_dots[1].found) return 2; if (m_dots[0].found) return 1; return 0; }; /** * Get an IR dot X coordinate. These coordinates are normalised between * 0.0 and 1.0. * @param num Dot number. * @return Normalised X-Coordinate of dot. */ float irX(int num) { if (num < 0 || num >= 4) return 0.0; return m_dots[num].x; }; /** * Get an IR dot X coordinate. These coordinates are normalised between * 0.0 and 1.0. * @param num Dot number. * @return Normalised Y-Coordinate of dot. */ float irY(int num) { if (num < 0 || num >= 4) return 0.0; return m_dots[num].y; }; static const unsigned char LED_NONE = 0x00; static const unsigned char LED_1 = 0x10; static const unsigned char LED_2 = 0x20; static const unsigned char LED_3 = 0x40; static const unsigned char LED_4 = 0x80; static doste::dvm::OID BUTTON_LEFT; /**< Left button. */ static doste::dvm::OID BUTTON_RIGHT; /**< Right button. */ static doste::dvm::OID BUTTON_UP; /**< Up button. */ static doste::dvm::OID BUTTON_DOWN; /**< Down button. */ static doste::dvm::OID BUTTON_ONE; /**< One button. */ static doste::dvm::OID BUTTON_TWO; /**< Two button. */ static doste::dvm::OID BUTTON_MINUS; /**< Minus button. */ static doste::dvm::OID BUTTON_HOME; /**< Home button. */ static doste::dvm::OID BUTTON_PLUS; /**< Plus button. */ static doste::dvm::OID BUTTON_A; /**< A button. */ static doste::dvm::OID BUTTON_B; /**< B button. */ static doste::dvm::OID BUTTON_Z; /**< Z button. Nunchuk */ static doste::dvm::OID BUTTON_C; /**< C button. Nunchuk */ /** * Call this first to detect wiimotes. This must be done before you can use * a wiimote. Note that it is slow as it has to do a bluetooth inquiry. */ static void find(); /** * Number of Wiimotes detected. */ static int number() { return s_nummotes; }; /** * Get a specified Wiimote. * @param num Wiimote number, 0 to number(). * @return The wiimote object. */ static Wiimote *wiimote(int num) { if (num < 0 || num > s_nummotes) return 0; else return s_motes[num]; }; static void initialise(); static void finalise(); static void updateAll(); BEGIN_EVENTS(Agent); EVENT(evt_leds, (*this)("leds")(doste::dvm::All)); EVENT(evt_rumble, (*this)("rumble")); EVENT(evt_ir, (*this)("ir")); END_EVENTS; private: void connect_wii(); void disconnect_wii(); void handshake_wii(); void status(); void reportType(bool motion, bool expansion); void read_data(unsigned int addr, char *data, int length); void write_data(unsigned int addr, char *data, int length); void send_wii(unsigned char cmd, char *msg, int length); bool poll_wii(WiiEvent &evt); void postRequest(const WiiReadReq &req); void handleRead(); void update(); void gforce(); void orientation(); void flashWii(const char *filename); void dumpFlash(const char *filename); void leds(unsigned char leds); #ifndef NO_BLUETOOTH #ifdef LINUX int m_insock; int m_outsock; bdaddr_t m_addr; #endif #ifdef WIN32 //SOCKET m_insock; //SOCKET m_outsock; HIDDevice m_addr; //callback function for the thread static unsigned CALLBACK listener(void * param); unsigned int m_threadID; HANDLE m_thread; bool listening; std::queue msgs; CRITICAL_SECTION m_lock; #endif #else int m_addr; #endif unsigned char m_leds; bool m_rumble; unsigned char m_calib[8]; unsigned char m_nc_calib[14]; std::list m_requests; vector3d m_accel; vector3d m_calg; vector3d m_calzero; vector3d m_gforce; vector3d m_orient; vector3d m_nc_accel; vector3d m_nc_calg; vector3d m_nc_calzero; vector3d m_nc_gforce; vector3d m_nc_orient; vector2d m_js_max; vector2d m_js_min; vector2d m_js_centre; vector2d m_js; bool m_nchuk; struct Dots { bool found; int rawX; int rawY; float x; float y; } m_dots[4]; static const unsigned char CMD_LEDS = 0x11; static const unsigned char CMD_REPORT_TYPE = 0x12; static const unsigned char CMD_RUMBLE = 0x13; static const unsigned char CMD_CTRL_STATUS = 0x15; static const unsigned char CMD_READ_DATA = 0x17; static const unsigned char CMD_WRITE_DATA = 0x16; static const unsigned char CMD_IR = 0x13; static const unsigned char CMD_IR2 = 0x1a; static const unsigned char CMD_SPEAKER_ENABLE = 0x14; static const unsigned char CMD_SPEAKER_DATA = 0x18; static const unsigned char CMD_SPEAKER_MUTE = 0x19; static const unsigned char REPORT_CTRL_STATUS = 0x20; static const unsigned char REPORT_READ = 0x21; static const unsigned char REPORT_WRITE = 0x22; static const unsigned char REPORT_BTN = 0x30; static const unsigned char REPORT_BTN_MOTION = 0x31; static const unsigned char REPORT_BTN_MOTION_IR = 0x33; static const unsigned char REPORT_BTN_EXP = 0x36; static const unsigned char REPORT_BTN_MOTION_EXP = 0x37; static const unsigned int MEM_CALIBRATION = 0x16; static const unsigned int MEM_EXT_CALIB = 0x04A40020; static const unsigned int MEM_EXT_INIT = 0x04A40040; static const unsigned int MEM_EXT_TYPE = 0x04A400FE; static const unsigned int MEM_IR_SENSITIVITY = 0x04b00000; static const unsigned int MEM_IR_SENSITIVITY2 = 0x04b0001a; static const unsigned int MEM_IR_MODE = 0x04b00033; static const unsigned int MEM_IR = 0x04b00030; static const unsigned char IRMODE_OFF = 0x00; static const unsigned char IRMODE_BASIC = 0x01; static const unsigned char IRMODE_EXTENDED = 0x03; static const unsigned char IRMODE_FULL = 0x05; static int s_nummotes; static Wiimote *s_motes[4]; }; }; #endif wgd-3.1/include/wgd/hmdatasource.h0000644000175000001440000000130711027214256014110 00000000000000#include #include #include namespace wgd { class HEIGHTMAPIMPORT HMDataSource : HeightmapSource { public: OBJECT(HeightmapSource, HMDataSource); HMDataSource(); HMDataSource(const doste::dvm::OID &o); ~HMDataSource(); //PROPERTY_RF(float, defaultHeight, "defaultheight"); //PROPERTY_WF(float, defaultHeight, "defaultheight"); PROPERTY_RF(doste::File, file, "file"); PROPERTY_WF(doste::File, file, "file"); void begin(); void end(); HMRegion *region(int x, int y); //BEGIN_EVENTS(HeightmapSource); //EVENT(evt_height, (*this)("defaultheight")); //EVENT(evt_mode, (*this)("mode")); //END_EVENTS; private: }; }; wgd-3.1/include/wgd/Makefile.in0000644000175000001440000003720211265575054013342 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = include/wgd DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(pkgincludedir)" pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(pkginclude_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/wgd ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pkginclude_HEADERS = animationcontroller.h animationset.h bone.h camera2d.h camera3d.h camera.h colour.h common.h dll.h extensions.h font.h heightmap.h heightmapsource.h hmdatasource.h hmimagesource.h iheightmap.h iline.h imodel.h index.h input.h instance2d.h instance3d.h iprimitive.h iterator.h keyboard.h loader.h material.h math.h matrix.h mesh.h model3ds.h model.h modelx.h morphcontroller.h mouse.h quaternion.h render.h rendertarget.h scene3d.h scene.h shader.h skincontroller.h sprite.h texturebmp.h texture.h texturepng.h texturetga.h vector.h vertex.h wiimote.h joystick.h window.h frustum.h sprite3d.h isprite3d.h drawable.h scenegraph.h spritefont.h text3d.h scene2d.h sprite2d.h clipmap.h SUBDIRS = png zlib widgets all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps include/wgd/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps include/wgd/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ done # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-recursive install-exec-am: install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic ctags \ ctags-recursive distclean distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-pkgincludeHEADERS \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/include/wgd/frustum.h0000644000175000001440000000272611233311615013140 00000000000000#ifndef _WGD_FRUSTUM_ #define _WGD_FRUSTUM_ #include namespace wgd { class Camera3D; /** * View frustum used for culling */ class BASE3DIMPORT Frustum { public: void create(Camera3D* cam); /* Clip flags * plane index clip flag * ----- ----- --------- * Completely outside = 0x00 * inside - 0x01 - this is true if it is completely inside * top 0 0x02 - The rest are true if it is inside or intersects this plane * bottom 1 0x04 * right 2 0x08 * left 3 0x10 * near 4 0x20 * far 5 0x40 * * Outside = 0 * Inside > 0 */ /** Is a point inside the frustum * @param v The point to be tested * @param flags Clip flags of any parent in a heirachy to avoid some tests */ int inside(const vector3d &v, int flags=0) const; /** Is an AABB inside the frustum */ int inside(const vector3d &min, const vector3d &max, int flags=0) const; private: //a frustum has 6 planes: { top, bottom, right, left, near, far } struct Plane { wgd::vector3d normal; float d; } plane[6]; //point inside a plane bool inside(const Plane &plane, const wgd::vector3d &point) const; //AABB inside plane (0=outside, 1=inside, 2=intersect) int inside(const Plane &plane, const vector3d &min, const vector3d &max) const; }; }; #endif wgd-3.1/include/wgd/matrix.h0000755000175000001440000004641511233311615012745 00000000000000#ifndef _MATRIX_ #define _MATRIX_ #include #include #ifdef WIN32 #include #endif #include #include #ifndef __SSE__ #define __SSE__ #endif #undef __SSE__ #ifdef __SSE__ #include #endif namespace wgd { class vector3d; #ifdef _MSC_VER __declspec(align(16)) //class matrix { #endif /** * Representation of a matrix with operators. This class provides fast matrix operations * that are needed for transforming animated models. It requires Intel SSE which means you * need a Pentium 3 or better. */ class BASEIMPORT matrix { //#endif public: union { #ifdef __SSE__ struct { __m128 _L1, _L2, _L3, _L4; }; #endif float m[4][4]; }; /** Identity constructor. */ matrix(){ identity(); }; /** Create matrix from three vectors (TBN) */ matrix(const vector3d &tangent, const vector3d &binormal, const vector3d &normal); /** * Constructor from OpenGL matrix. */ matrix(float *mat){ #ifndef __SSE__ //for(int i=0; i<4; i++) // for(int j=0; j<4; j++) // m[i][j] = mat[i*4 + j]; m[0][0] = mat[0]; m[0][1] = mat[1]; m[0][2] = mat[2]; m[0][3] = mat[3]; m[1][0] = mat[4]; m[1][1] = mat[5]; m[1][2] = mat[6]; m[1][3] = mat[7]; m[2][0] = mat[8]; m[2][1] = mat[9]; m[2][2] = mat[10]; m[2][3] = mat[11]; m[3][0] = mat[12]; m[3][1] = mat[13]; m[3][2] = mat[14]; m[3][3] = mat[15]; #else _L1 = _mm_load_ps(mat); _L2 = _mm_load_ps(&mat[4]); _L3 = _mm_load_ps(&mat[8]); _L4 = _mm_load_ps(&mat[12]); #endif } void apply() const { #ifdef _MSC_VER __declspec(align(16)) float mat[16]; #else float mat[16] __attribute__((aligned(16))); #endif toOpenGL(mat); glPushMatrix(); glMultMatrixf(mat); } void unapply() const { glPopMatrix(); } /** * matrix multiplication operator. This allows a*b matrix multiplication, however it is faster * to use fastMultiply() instead of this. */ matrix operator*(const matrix &b) const { #ifndef __SSE__ matrix result; result.m[0][0] = m[0][0]*b.m[0][0] + m[1][0]*b.m[0][1] + m[2][0]*b.m[0][2] + m[3][0]*b.m[0][3]; result.m[0][1] = m[0][1]*b.m[0][0] + m[1][1]*b.m[0][1] + m[2][1]*b.m[0][2] + m[3][1]*b.m[0][3]; result.m[0][2] = m[0][2]*b.m[0][0] + m[1][2]*b.m[0][1] + m[2][2]*b.m[0][2] + m[3][2]*b.m[0][3]; result.m[0][3] = m[0][3]*b.m[0][0] + m[1][3]*b.m[0][1] + m[2][3]*b.m[0][2] + m[3][3]*b.m[0][3]; result.m[1][0] = m[0][0]*b.m[1][0] + m[1][0]*b.m[1][1] + m[2][0]*b.m[1][2] + m[3][0]*b.m[1][3]; result.m[1][1] = m[0][1]*b.m[1][0] + m[1][1]*b.m[1][1] + m[2][1]*b.m[1][2] + m[3][1]*b.m[1][3]; result.m[1][2] = m[0][2]*b.m[1][0] + m[1][2]*b.m[1][1] + m[2][2]*b.m[1][2] + m[3][2]*b.m[1][3]; result.m[1][3] = m[0][3]*b.m[1][0] + m[1][3]*b.m[1][1] + m[2][3]*b.m[1][2] + m[3][3]*b.m[1][3]; result.m[2][0] = m[0][0]*b.m[2][0] + m[1][0]*b.m[2][1] + m[2][0]*b.m[2][2] + m[3][0]*b.m[2][3]; result.m[2][1] = m[0][1]*b.m[2][0] + m[1][1]*b.m[2][1] + m[2][1]*b.m[2][2] + m[3][1]*b.m[2][3]; result.m[2][2] = m[0][2]*b.m[2][0] + m[1][2]*b.m[2][1] + m[2][2]*b.m[2][2] + m[3][2]*b.m[2][3]; result.m[2][3] = m[0][3]*b.m[2][0] + m[1][3]*b.m[2][1] + m[2][3]*b.m[2][2] + m[3][3]*b.m[2][3]; result.m[3][0] = m[0][0]*b.m[3][0] + m[1][0]*b.m[3][1] + m[2][0]*b.m[3][2] + m[3][0]*b.m[3][3]; result.m[3][1] = m[0][1]*b.m[3][0] + m[1][1]*b.m[3][1] + m[2][1]*b.m[3][2] + m[3][1]*b.m[3][3]; result.m[3][2] = m[0][2]*b.m[3][0] + m[1][2]*b.m[3][1] + m[2][2]*b.m[3][2] + m[3][2]*b.m[3][3]; result.m[3][3] = m[0][3]*b.m[3][0] + m[1][3]*b.m[3][1] + m[2][3]*b.m[3][2] + m[3][3]*b.m[3][3]; return result; #else matrix c; __m128 _T1,_T2,_T3,_T4; _T1 = _mm_load1_ps(&b.m[0][0]); _T1 = _mm_mul_ps(_T1,_L1); _T2 = _mm_load1_ps(&b.m[0][1]); _T2 = _mm_mul_ps(_T2,_L2); _T3 = _mm_load1_ps(&b.m[0][2]); _T3 = _mm_mul_ps(_T3,_L3); _T4 = _mm_load1_ps(&b.m[0][3]); _T4 = _mm_mul_ps(_T4,_L4); c._L1 = _mm_add_ps(_T1,_T2); c._L1 = _mm_add_ps(c._L1,_T3); c._L1 = _mm_add_ps(c._L1,_T4); _T1 = _mm_load1_ps(&b.m[1][0]); _T1 = _mm_mul_ps(_T1,_L1); _T2 = _mm_load1_ps(&b.m[1][1]); _T2 = _mm_mul_ps(_T2,_L2); _T3 = _mm_load1_ps(&b.m[1][2]); _T3 = _mm_mul_ps(_T3,_L3); _T4 = _mm_load1_ps(&b.m[1][3]); _T4 = _mm_mul_ps(_T4,_L4); c._L2 = _mm_add_ps(_T1,_T2); c._L2 = _mm_add_ps(c._L2,_T3); c._L2 = _mm_add_ps(c._L2,_T4); _T1 = _mm_load1_ps(&b.m[2][0]); _T1 = _mm_mul_ps(_T1,_L1); _T2 = _mm_load1_ps(&b.m[2][1]); _T2 = _mm_mul_ps(_T2,_L2); _T3 = _mm_load1_ps(&b.m[2][2]); _T3 = _mm_mul_ps(_T3,_L3); _T4 = _mm_load1_ps(&b.m[2][3]); _T4 = _mm_mul_ps(_T4,_L4); c._L3 = _mm_add_ps(_T1,_T2); c._L3 = _mm_add_ps(c._L3,_T3); c._L3 = _mm_add_ps(c._L3,_T4); _T1 = _mm_load1_ps(&b.m[3][0]); _T1 = _mm_mul_ps(_T1,_L1); _T2 = _mm_load1_ps(&b.m[3][1]); _T2 = _mm_mul_ps(_T2,_L2); _T3 = _mm_load1_ps(&b.m[3][2]); _T3 = _mm_mul_ps(_T3,_L3); _T4 = _mm_load1_ps(&b.m[3][3]); _T4 = _mm_mul_ps(_T4,_L4); c._L4 = _mm_add_ps(_T1,_T2); c._L4 = _mm_add_ps(c._L4,_T3); c._L4 = _mm_add_ps(c._L4,_T4); return c; #endif }; /** * High performance matrix multiplication. Instead of returning the matrix it takes a non-constant * reference that will be filled with the result. result = a*b. Note that this is row major matrix * multiplication unlike OpenGL, therefore you may need to multiply in the opposite order. * @param result Location for the result matrix. * @param a Left hand operand. * @param b Right hand operand. */ static void fastMultiply(matrix &result, const matrix &a, const matrix &b) { #ifndef __SSE__ result.m[0][0] = a.m[0][0]*b.m[0][0] + a.m[1][0]*b.m[0][1] + a.m[2][0]*b.m[0][2] + a.m[3][0]*b.m[0][3]; result.m[0][1] = a.m[0][1]*b.m[0][0] + a.m[1][1]*b.m[0][1] + a.m[2][1]*b.m[0][2] + a.m[3][1]*b.m[0][3]; result.m[0][2] = a.m[0][2]*b.m[0][0] + a.m[1][2]*b.m[0][1] + a.m[2][2]*b.m[0][2] + a.m[3][2]*b.m[0][3]; result.m[0][3] = a.m[0][3]*b.m[0][0] + a.m[1][3]*b.m[0][1] + a.m[2][3]*b.m[0][2] + a.m[3][3]*b.m[0][3]; result.m[1][0] = a.m[0][0]*b.m[1][0] + a.m[1][0]*b.m[1][1] + a.m[2][0]*b.m[1][2] + a.m[3][0]*b.m[1][3]; result.m[1][1] = a.m[0][1]*b.m[1][0] + a.m[1][1]*b.m[1][1] + a.m[2][1]*b.m[1][2] + a.m[3][1]*b.m[1][3]; result.m[1][2] = a.m[0][2]*b.m[1][0] + a.m[1][2]*b.m[1][1] + a.m[2][2]*b.m[1][2] + a.m[3][2]*b.m[1][3]; result.m[1][3] = a.m[0][3]*b.m[1][0] + a.m[1][3]*b.m[1][1] + a.m[2][3]*b.m[1][2] + a.m[3][3]*b.m[1][3]; result.m[2][0] = a.m[0][0]*b.m[2][0] + a.m[1][0]*b.m[2][1] + a.m[2][0]*b.m[2][2] + a.m[3][0]*b.m[2][3]; result.m[2][1] = a.m[0][1]*b.m[2][0] + a.m[1][1]*b.m[2][1] + a.m[2][1]*b.m[2][2] + a.m[3][1]*b.m[2][3]; result.m[2][2] = a.m[0][2]*b.m[2][0] + a.m[1][2]*b.m[2][1] + a.m[2][2]*b.m[2][2] + a.m[3][2]*b.m[2][3]; result.m[2][3] = a.m[0][3]*b.m[2][0] + a.m[1][3]*b.m[2][1] + a.m[2][3]*b.m[2][2] + a.m[3][3]*b.m[2][3]; result.m[3][0] = a.m[0][0]*b.m[3][0] + a.m[1][0]*b.m[3][1] + a.m[2][0]*b.m[3][2] + a.m[3][0]*b.m[3][3]; result.m[3][1] = a.m[0][1]*b.m[3][0] + a.m[1][1]*b.m[3][1] + a.m[2][1]*b.m[3][2] + a.m[3][1]*b.m[3][3]; result.m[3][2] = a.m[0][2]*b.m[3][0] + a.m[1][2]*b.m[3][1] + a.m[2][2]*b.m[3][2] + a.m[3][2]*b.m[3][3]; result.m[3][3] = a.m[0][3]*b.m[3][0] + a.m[1][3]*b.m[3][1] + a.m[2][3]*b.m[3][2] + a.m[3][3]*b.m[3][3]; #else __m128 _T1,_T2,_T3,_T4; _T1 = _mm_load1_ps(&b.m[0][0]); _T1 = _mm_mul_ps(_T1,a._L1); _T2 = _mm_load1_ps(&b.m[0][1]); _T2 = _mm_mul_ps(_T2,a._L2); _T3 = _mm_load1_ps(&b.m[0][2]); _T3 = _mm_mul_ps(_T3,a._L3); _T4 = _mm_load1_ps(&b.m[0][3]); _T4 = _mm_mul_ps(_T4,a._L4); result._L1 = _mm_add_ps(_T1,_T2); result._L1 = _mm_add_ps(result._L1,_T3); result._L1 = _mm_add_ps(result._L1,_T4); _T1 = _mm_load1_ps(&b.m[1][0]); _T1 = _mm_mul_ps(_T1,a._L1); _T2 = _mm_load1_ps(&b.m[1][1]); _T2 = _mm_mul_ps(_T2,a._L2); _T3 = _mm_load1_ps(&b.m[1][2]); _T3 = _mm_mul_ps(_T3,a._L3); _T4 = _mm_load1_ps(&b.m[1][3]); _T4 = _mm_mul_ps(_T4,a._L4); result._L2 = _mm_add_ps(_T1,_T2); result._L2 = _mm_add_ps(result._L2,_T3); result._L2 = _mm_add_ps(result._L2,_T4); _T1 = _mm_load1_ps(&b.m[2][0]); _T1 = _mm_mul_ps(_T1,a._L1); _T2 = _mm_load1_ps(&b.m[2][1]); _T2 = _mm_mul_ps(_T2,a._L2); _T3 = _mm_load1_ps(&b.m[2][2]); _T3 = _mm_mul_ps(_T3,a._L3); _T4 = _mm_load1_ps(&b.m[2][3]); _T4 = _mm_mul_ps(_T4,a._L4); result._L3 = _mm_add_ps(_T1,_T2); result._L3 = _mm_add_ps(result._L3,_T3); result._L3 = _mm_add_ps(result._L3,_T4); _T1 = _mm_load1_ps(&b.m[3][0]); _T1 = _mm_mul_ps(_T1,a._L1); _T2 = _mm_load1_ps(&b.m[3][1]); _T2 = _mm_mul_ps(_T2,a._L2); _T3 = _mm_load1_ps(&b.m[3][2]); _T3 = _mm_mul_ps(_T3,a._L3); _T4 = _mm_load1_ps(&b.m[3][3]); _T4 = _mm_mul_ps(_T4,a._L4); result._L4 = _mm_add_ps(_T1,_T2); result._L4 = _mm_add_ps(result._L4,_T3); result._L4 = _mm_add_ps(result._L4,_T4); #endif }; /** * Convert to an OpenGL matrix float array. * @param glmat Pointer to 16 float array. */ void toOpenGL(float *glmat) const { #ifdef __SSE__ _mm_store_ps(glmat, _L1); _mm_store_ps(&glmat[4], _L2); _mm_store_ps(&glmat[8], _L3); _mm_store_ps(&glmat[12], _L4); #else glmat[0] = m[0][0]; glmat[1] = m[0][1]; glmat[2] = m[0][2]; glmat[3] = m[0][3]; glmat[4] = m[1][0]; glmat[5] = m[1][1]; glmat[6] = m[1][2]; glmat[7] = m[1][3]; glmat[8] = m[2][0]; glmat[9] = m[2][1]; glmat[10] = m[2][2]; glmat[11] = m[2][3]; glmat[12] = m[3][0]; glmat[13] = m[3][1]; glmat[14] = m[3][2]; glmat[15] = m[3][3]; #endif } friend std::ostream &operator<<(std::ostream &os, const matrix &mat); /** * Add two matrices together. e.g. a+b. Use fastAdd if you need higher performance. */ matrix operator+(const matrix &b) { matrix c; #ifdef __SSE__ c._L1 = _mm_add_ps(_L1, b._L1); c._L2 = _mm_add_ps(_L2, b._L2); c._L3 = _mm_add_ps(_L3, b._L3); c._L4 = _mm_add_ps(_L4, b._L4); #else /*for (int i=0; i<4; i++) { for (int j=0; j<4; j++) { result.m[i][j] = m[i][j]+b.m[i][j]; } }*/ c.m[0][0] = m[0][0]+b.m[0][0]; c.m[0][1] = m[0][1]+b.m[0][1]; c.m[0][2] = m[0][2]+b.m[0][2]; c.m[0][3] = m[0][3]+b.m[0][3]; c.m[1][0] = m[1][0]+b.m[1][0]; c.m[1][1] = m[1][1]+b.m[1][1]; c.m[1][2] = m[1][2]+b.m[1][2]; c.m[1][3] = m[1][3]+b.m[1][3]; c.m[2][0] = m[2][0]+b.m[1][0]; c.m[2][1] = m[2][1]+b.m[1][1]; c.m[2][2] = m[2][2]+b.m[1][2]; c.m[2][3] = m[2][3]+b.m[1][3]; c.m[3][0] = m[3][0]+b.m[1][0]; c.m[3][1] = m[3][1]+b.m[1][1]; c.m[3][2] = m[3][2]+b.m[1][2]; c.m[3][3] = m[3][3]+b.m[1][3]; #endif return c; }; /** * Add two matrices together. Faster than operator as less temporaries are created. * @param result Resulting matrix it put in here. * @param a First matrix. * @param b Second matrix. */ static void fastAdd(matrix &result, const matrix &a, const matrix &b) { #ifdef __SSE__ result._L1 = _mm_add_ps(a._L1, b._L1); result._L2 = _mm_add_ps(a._L2, b._L2); result._L3 = _mm_add_ps(a._L3, b._L3); result._L4 = _mm_add_ps(a._L4, b._L4); #else /*for (int i=0; i<4; i++) { for (int j=0; j<4; j++) { result.m[i][j] = a.m[i][j]+b.m[i][j]; } }*/ result.m[0][0] = a.m[0][0]+b.m[0][0]; result.m[0][1] = a.m[0][1]+b.m[0][1]; result.m[0][2] = a.m[0][2]+b.m[0][2]; result.m[0][3] = a.m[0][3]+b.m[0][3]; result.m[1][0] = a.m[1][0]+b.m[1][0]; result.m[1][1] = a.m[1][1]+b.m[1][1]; result.m[1][2] = a.m[1][2]+b.m[1][2]; result.m[1][3] = a.m[1][3]+b.m[1][3]; result.m[2][0] = a.m[2][0]+b.m[1][0]; result.m[2][1] = a.m[2][1]+b.m[1][1]; result.m[2][2] = a.m[2][2]+b.m[1][2]; result.m[2][3] = a.m[2][3]+b.m[1][3]; result.m[3][0] = a.m[3][0]+b.m[1][0]; result.m[3][1] = a.m[3][1]+b.m[1][1]; result.m[3][2] = a.m[3][2]+b.m[1][2]; result.m[3][3] = a.m[3][3]+b.m[1][3]; #endif }; /** * Vector matrix multiplication operator. For higher performance use fastMultiply(). */ inline wgd::vector3d operator*(const wgd::vector3d &b) const; /** * Fast vector matrix multiplication. * @param result Result vector is put in here. * @param a matrix operand. * @param b Vector operand. */ inline static void fastMultiply(wgd::vector3d &result, const wgd::matrix &a, const wgd::vector3d &b); /** * Make this an identity matrix. */ void identity() { m[0][0] = 1; m[0][1] = 0; m[0][2] = 0; m[0][3] = 0; m[1][0] = 0; m[1][1] = 1; m[1][2] = 0; m[1][3] = 0; m[2][0] = 0; m[2][1] = 0; m[2][2] = 1; m[2][3] = 0; m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1; }; /** Is this matrix the identity */ bool isIdentity() const { if(m[0][0]!=1.0 || m[0][1]!=0.0 || m[0][2]!=0.0 || m[0][3]!=0.0) return false; if(m[1][0]!=0.0 || m[1][1]!=1.0 || m[1][2]!=0.0 || m[1][3]!=0.0) return false; if(m[2][0]!=0.0 || m[2][1]!=0.0 || m[2][2]!=1.0 || m[2][3]!=0.0) return false; if(m[3][0]!=0.0 || m[3][1]!=0.0 || m[3][2]!=0.0 || m[3][3]!=1.0) return false; return true; } /** * The transpose of this matrix. * @return The transposed matrix. */ inline matrix transpose(); /** * Fast matrix transpose. * @param res The transposed matrix is put in here. * @param m The matrix to transpose. */ inline static void fastTranspose(wgd::matrix &res, const wgd::matrix &m); static bool fastInverse(matrix & dest, const matrix& src); /** * Make this a translation matrix. * @param pos XYZ position vector. */ inline void translate(const vector3d &v); /** * Make this a scale matrix. * @param scale XYZ scale vector. */ inline void scale(const wgd::vector3d &v); /** * Make this a rotation matrix. * @param v Pitch, Yaw, Roll vector. */ inline void rotate(const wgd::vector3d &v); /** * Make this a rotation matrix around an arbituaty axis. * @param axis The axis to rotate around. * @param angle The angle to rotate in radians. */ inline void rotateAxis(const wgd::vector3d &axis, float angle); /** * Make this a translation matrix. */ inline void translate(float x, float y, float z); /** * Make this a scale matrix. */ inline void scale(float x, float y, float z); /** * Make this a rotation matrix. * @param x Pitch * @param y Yaw * @param z Roll */ inline void rotate(float x, float y, float z); /** Creates a transformation matrix that looks at a target point from a location * @param position The matrix origin * @param target The location the matrix points at * @param up The up vector - must be a unit vector, must not be parallel to the direction. */ inline void lookat(const vector3d& position, const vector3d &direction, const vector3d &up); #ifdef _MSC_VER }; #else } __attribute__((aligned(16),packed)); #endif }; #include #undef __SSE__ wgd::vector3d wgd::matrix::operator*(const wgd::vector3d &b) const { #ifndef __SSE__ return wgd::vector3d( m[0][0]*b.x + m[1][0]*b.y + m[2][0]*b.z + m[3][0], m[0][1]*b.x + m[1][1]*b.y + m[2][1]*b.z + m[3][1], m[0][2]*b.x + m[1][2]*b.y + m[2][2]*b.z + m[3][2], m[0][3]*b.x + m[1][3]*b.y + m[2][3]*b.z + m[3][3]); #else wgd::vector3d c; __m128 _T1, _T2, _X, _Y, _Z; _T1 = b._L1; _Z = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(2,2,2,2)); _Y = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(1,1,1,1)); _X = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(0,0,0,0)); //c._L1 = _L1*_X + _L2*_Y + _L3*_Z + _L4; _T1 = _mm_mul_ps(_L1,_X); _T2 = _mm_mul_ps(_L2,_Y); _T1 = _mm_add_ps(_T1,_T2); _T2 = _mm_mul_ps(_L3,_Z); _T1 = _mm_add_ps(_T1,_T2); c._L1 = _mm_add_ps(_T1,_L4); return c; #endif }; void wgd::matrix::fastMultiply(wgd::vector3d &result, const wgd::matrix &a, const wgd::vector3d &b) { #ifndef __SSE__ result.x = a.m[0][0]*b.x + a.m[1][0]*b.y + a.m[2][0]*b.z + a.m[3][0]; result.y = a.m[0][1]*b.x + a.m[1][1]*b.y + a.m[2][1]*b.z + a.m[3][1]; result.z = a.m[0][2]*b.x + a.m[1][2]*b.y + a.m[2][2]*b.z + a.m[3][2]; result.w = a.m[0][3]*b.x + a.m[1][3]*b.y + a.m[2][3]*b.z + a.m[3][3]; #else __m128 _T1, _T2, _X, _Y, _Z; _T1 = b._L1; //_Z = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(2,3,0,1)); _Z = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(2,2,2,2)); _Y = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(1,1,1,1)); _X = _mm_shuffle_ps(_T1,_T1,_MM_SHUFFLE(0,0,0,0)); //result._L1 = a._L1*_X + a._L2*_Y + a._L3*_Z + a._L4; _T1 = _mm_mul_ps(a._L1,_X); _T2 = _mm_mul_ps(a._L2,_Y); _T1 = _mm_add_ps(_T1,_T2); _T2 = _mm_mul_ps(a._L3,_Z); _T1 = _mm_add_ps(_T1,_T2); result._L1 = _mm_add_ps(_T1,a._L4); #endif }; wgd::matrix wgd::matrix::transpose() { matrix r; r.m[0][0] = m[0][0]; r.m[1][0] = m[0][1]; r.m[2][0] = m[0][2]; r.m[3][0] = m[0][3]; r.m[0][1] = m[1][0]; r.m[1][1] = m[1][1]; r.m[2][1] = m[1][2]; r.m[3][1] = m[1][3]; r.m[0][2] = m[2][0]; r.m[1][2] = m[2][1]; r.m[2][2] = m[2][2]; r.m[3][2] = m[2][3]; r.m[0][3] = m[3][0]; r.m[1][3] = m[3][1]; r.m[2][3] = m[3][2]; r.m[3][3] = m[3][3]; return r; } void wgd::matrix::fastTranspose(wgd::matrix &res, const wgd::matrix &m) { res.m[0][0] = m.m[0][0]; res.m[1][0] = m.m[0][1]; res.m[2][0] = m.m[0][2]; res.m[3][0] = m.m[0][3]; res.m[0][1] = m.m[1][0]; res.m[1][1] = m.m[1][1]; res.m[2][1] = m.m[1][2]; res.m[3][1] = m.m[1][3]; res.m[0][2] = m.m[2][0]; res.m[1][2] = m.m[2][1]; res.m[2][2] = m.m[2][2]; res.m[3][2] = m.m[2][3]; res.m[0][3] = m.m[3][0]; res.m[1][3] = m.m[3][1]; res.m[2][3] = m.m[3][2]; res.m[3][3] = m.m[3][3]; } void wgd::matrix::translate(const vector3d &v) { translate(v.x, v.y, v.z); } void wgd::matrix::scale(const wgd::vector3d &v) { scale(v.x, v.y, v.z); } void wgd::matrix::rotate(const wgd::vector3d &v) { rotate(v.x, v.y, v.z); } void wgd::matrix::translate(float x, float y, float z) { identity(); m[3][0] = x; m[3][1] = y; m[3][2] = z; }; void wgd::matrix::scale(float x, float y, float z) { identity(); m[0][0] = x; m[1][1] = y; m[2][2] = z; }; void wgd::matrix::rotate(float x, float y, float z) { wgd::matrix c; c.identity(); c.m[0][0] = cos(z); c.m[1][0] = -sin(z); c.m[0][1] = sin(z); c.m[1][1] = cos(z); wgd::matrix d; d.identity(); d.m[1][1] = cos(x); d.m[2][1] = -sin(x); d.m[1][2] = sin(x); d.m[2][2] = cos(x); c = d*c; d.identity(); d.m[0][0] = cos(y); d.m[2][0] = sin(y); d.m[0][2] = -sin(y); d.m[2][2] = cos(y); *this = d*c; }; void wgd::matrix::rotateAxis(const wgd::vector3d &axis, float angle){ vector3d v = axis.normalise(); identity(); float s = sin(angle); float c = cos(angle); float xx = v.x * v.x; float yy = v.y * v.y; float zz = v.z * v.z; float xy = v.x * v.y; float yz = v.y * v.z; float zx = v.z * v.x; float xs = v.x * s; float ys = v.y * s; float zs = v.z * s; float one_c = 1.0f - c; m[0][0] = (one_c * xx) + c; m[1][0] = (one_c * xy) - zs; m[2][0] = (one_c * zx) + ys; m[0][1] = (one_c * xy) + zs; m[1][1] = (one_c * yy) + c; m[2][1] = (one_c * yz) - xs; m[0][2] = (one_c * zx) - ys; m[1][2] = (one_c * yz) + xs; m[2][2] = (one_c * zz) + c; }; void wgd::matrix::lookat(const vector3d& position, const wgd::vector3d &target, const wgd::vector3d &up) { wgd::vector3d dir = (target - position).normalise(); wgd::vector3d t = wgd::vector3d::crossProduct(up, dir); wgd::vector3d b = wgd::vector3d::crossProduct(dir, t); matrix p; p.translate(position); matrix r(t, b, dir); fastMultiply(*this, r, p); } #endif wgd-3.1/include/wgd/scene.h0000644000175000001440000000106111233311615012517 00000000000000#ifndef _WGD_SCENE_ #define _WGD_SCENE_ #include #include #include #include #ifdef _MSC_VER #pragma warning(disable:4251) #pragma warning(disable:4275) #endif namespace wgd { //for the morton keys typedef unsigned long uint; class Camera; class RESIMPORT Scene : public doste::Agent { public: Scene(const doste::dvm::OID &id) : Agent(id) { }; virtual ~Scene() { }; virtual void draw(Camera *) = 0; VOBJECT(Agent, Scene); }; }; #endif wgd-3.1/include/wgd/shader.h0000644000175000001440000002042311233311615012673 00000000000000/* * WGD Library * * Authors: * Date: 17/9/2007 * */ #ifndef _WGD_SHADER_ #define _WGD_SHADER_ #ifdef WIN32 #include #endif #include #include #include #include #include #include #include #include namespace wgd { class vector3d; class Texture; /** * Shader Resource. This contains everything a shader needs to run, * you apply the shader to an object the same way you would apply a texture * with bind() and unbind(). The shader replaces normal textures so if * you use a shader, you dont bind textures directly to the object.
* You must specify both vertex shader and fragment shader source, as well as * all the textures that the shader uses.
* Shaders that need Binormals and Tangents will automatically get the tangent * if applied to models and primitives, bot you must calculate the binormal * in your vertex shader using: cross(gl_Normal, tangent);
* The tangent varying variable must be named "tangent" for it to work.
* If a shader program fails to compile, or will not run on your machine * nothing will happen when you try to bind it. *

* */ class RESIMPORT Shader : public doste::Agent { public: OBJECT(Agent, Shader); /** Create an empty shader object */ Shader(); /** Construct a shader from database - used by the library */ Shader(const doste::dvm::OID &); /** Create a shader, specifying the source files to use as File objects */ Shader(doste::File &vert, doste::File &frag); /** Create a shader, specifying the source files to use */ Shader(const char* vertfile, const char* fragfile); ~Shader(); /** * Vertex shader source filename. You must set both vertex and fragment * shader filenames before loading or using the shader. * @param v The filename string */ PROPERTY_WF(doste::File, vert, ix::vert); /** * Current vertex shader filename. * @return String representing the filename. */ PROPERTY_RF(doste::File, vert, ix::vert); /** * Fragment shader source filename. You must set both vertex and fragment * shader filenames before loading or using the shader. * @param v The filename string */ PROPERTY_WF(doste::File, frag, ix::frag); /** * Current fragment shader filename. * @return String representing the filename. */ PROPERTY_RF(doste::File, frag, ix::frag); PROPERTY_WF(bool, debug, ix::debug); PROPERTY_RF(bool, debug, ix::debug); /** * Build a shader program from string arrays instead of files. * @return Did it work... */ bool make(const char *vert, const char *frag); /** * Force load and compile the shader. If not called then the shader will not be loaded or compiled * until bind() is first called. */ bool load(); /** * Use this shader. */ void bind(); /** * Stop using the shader. * You need to call this when you have finished drawing with the shader. */ void unbind(); /** * Get the currently bound shader. Returns Null if no shaders are bound. * @return Current shader. */ static Shader *current(); static void current(Shader *sh); /** * This shows whether the shader uses a 'tangent' varying variable. * used by IModel to derermine whether to try to write to it. * @return 'tangent' variable used. */ bool tangents(){ return m_tangents; }; /** * Set a float variable in the shader. The function will determine it it * is uniform or varying. * @param name the variable to write to * @param v1 The value to set */ void setVariable(const char *name, float v1); /** * Set a vec2 variable in the shader. * @param name the variable to write to * @param v1 The 'x' part of the vector * @param v2 The 'y' part of the vector */ void setVariable(const char *name, float v1, float v2); /** * Set a vec3 variable in the shader. * @param name the variable to write to * @param v1 The 'x' part of the vector * @param v2 The 'y' part of the vector * @param v3 The 'z' part of the vector */ void setVariable(const char *name, float v1, float v2, float v3); /** * Set a vec4 variable in the shader. * @param name the variable to write to * @param v1 The 'x' part of the vector * @param v2 The 'y' part of the vector * @param v3 The 'z' part of the vector * @param v4 The 'w' part of the vector */ void setVariable(const char *name, float v1, float v2, float v3, float v4); /** * Set a vec3 variable in the shader. * @param name the variable to write to * @param vec3 The vector to set */ void setVariable(const char *name, const wgd::vector3d &vec3); /** * Set an integer variable in the shader. * @param name the variable to write to * @param v1 The integer value to set */ void setVariable(const char *name, int v1); /** * Set an integer variable array in the shader * Note variable name must be postfixed with [0] to write to the start of the array * @param name the variable to write to * @param size the number of elements in the array * @param data pointer to the array */ void setVariable(const char *name, int size, int* data); /** * Set an float variable array in the shader * Note variable name must be postfixed with [0] to write to the start of the array * @param name the variable to write to * @param size the number of elements in the array * @param data pointer to the array */ void setVariable(const char *name, int size, float* data); /** * Enable using an attribute variable in a vertex array * similar to glEnableClientState(); * Must call disableAttribArray() when done. * @param name the name of the varying variable to set */ void enableAttribArray(const char *name); /** * Set a pointer to an attribute variable array * when drawing from vertex arrays. * similar to glVertexPointer() * @param name the name of the varying variable to be modified. * @param size Specifies the number of values for each element of the vertex attribute array. Must be 1, 2, 3, or 4. * @param type Specifies the data type of each component in the array. Symbolic constants GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, and GL_DOUBLE are accepted. * @param normalised Specifies whether fixed-point data values should be normalized (GL_TRUE ) or converted directly as fixed-point values (GL_FALSE ) when they are accessed. * @param Specifies the byte offset between consecutive attribute values. If stride is 0, the attribute values are understood to be tightly packed in the array. * @param pointer Specifies a pointer to the first component of the first attribute value in the array. */ void attribPointer(const char *name, GLint size, GLenum type, GLboolean normalised, GLsizei stride, const void *pointer); /** * Disable using an attribute variable in a vertex array * similar to glDisableClientState(); * @param name the name of the varying variable to that was set */ void disableAttribArray(const char *name); /** * Set whether shaders are enabled * This has no effect if shaders are not supported. * @param b True to enable shaders, False to disable them. */ static void enabled(bool); /** * Get whether shaders are enabled by the user * This does not return whether shaders are supported. * @return enabled. */ static bool enabled(); BEGIN_EVENTS(Agent); EVENT(evt_reload, (*this)("reload")); END_EVENTS; private: static void initialise(); static bool s_available; static Shader *s_current; //get variable name GLint addVariable(const char *name); bool loadShader(); char *readFile(doste::File *); int logInfo(GLuint s, const char *name); GLuint m_vertexShader; GLuint m_fragmentShader; GLuint m_program; bool m_ready; bool m_loaded; //has a tangent attribute variable bool m_tangents; //maybe detect what kind of variable GLint getLocation(const char *name); class ShaderVar{ public: ShaderVar(int t, GLint loc): type(t), location(loc){}; int type; //1=uniform, 2=attribute GLint location; }; ShaderVar *getVar(const char *name); doste::dvm::OID m_vars; }; }; #endif wgd-3.1/include/wgd/spritefont.h0000644000175000001440000000216711233311615013627 00000000000000#ifndef _WGD_SPRITEFONT_ #define _WGD_SPRITEFONT_ #include #include namespace wgd { /** * Sprite fonts allow you to use a drawn font, rather than a system font. * They are basically a sprite, seperated into its frames, and a * list of characters that each frame represents. */ class RESIMPORT SpriteFont : public Font { public: OBJECT(Font, SpriteFont); SpriteFont(); SpriteFont(const OID &id); SpriteFont(Sprite *spr); ~SpriteFont(); PROPERTY_RF(Sprite, sprite, ix::sprite); ///< Get the sprite that this font uses PROPERTY_WF(Sprite, sprite, ix::sprite); ///< Set the sprite to use for this font PROPERTY_RF(doste::dstring, characters, "characters"); ///< The string of characters corresponding to the frames of the sprite PROPERTY_WF(doste::dstring, characters, "characters"); ///< The string of characters corresponding to the frames of the sprite BEGIN_EVENTS(Font); EVENT(evt_build, (*this)(ix::sprite)(doste::dvm::modifiers::Seq)(*this)("characters")); END_EVENTS; private: void buildFont(); }; }; #endif wgd-3.1/include/wgd/rendertarget.h0000644000175000001440000000461311026705571014126 00000000000000#ifndef _WGD_RENDERTARGET_ #define _WGD_RENDERTARGET_ #include #include #include #include #include #include namespace wgd { /** * A render target is something that can be rendered into. This * includes Framebuffers and Textures. The screen itself is a special * form of render target and as a result does not inherit this * class. It is possible to chain several targets together which has * the effect of one render target using another as its source. This * can enable fullscreen special effects such as bloom. */ class RESIMPORT RenderTarget : public doste::Agent { public: RenderTarget(const doste::dvm::OID &id); ~RenderTarget(); void draw(); /** * Get the camera used by this render target. If a RenderTarget * has a camera then it must also have a screen and cannot have * another RenderTarget as its source. If you do give both then * the result is undefined. * @return The camera object or null. */ PROPERTY_RF(Camera, camera, ix::camera); /** * Set the camera to be used by this target. Must be combined with * a scene object and not a source RenderTarget. * @param v A camera object used for drawing a scene. */ PROPERTY_WF(Camera, camera, ix::camera); /** * Get the current source RenderTarget if there is one. * @return Source RenderTarget object or null. */ PROPERTY_RF(RenderTarget, source, ix::source); PROPERTY_WF(RenderTarget, source, ix::source); PROPERTY_RF(Scene, scene, ix::scene); PROPERTY_WF(Scene, scene, ix::scene); PROPERTY_RF(Material, material, ix::material); PROPERTY_WF(Material, material, ix::material); PROPERTY_RF(Texture, texture, ix::texture); PROPERTY_WF(Texture, texture, ix::texture); PROPERTY_RF(Texture, depthTexture, "depthtexture"); PROPERTY_WF(Texture, depthTexture, "depthtexture"); PROPERTY_RF(bool, depth, ix::depth); PROPERTY_WF(bool, depth, ix::depth); PROPERTY_RF(bool, clear, "clear"); PROPERTY_WF(bool, clear, "clear"); OBJECT(Agent, RenderTarget); void doclear(); void bind(); void unbind(); void begin(); void end(); private: int m_width; int m_height; bool m_depth; bool m_hfloat; bool m_linear; unsigned int m_fbo; unsigned int m_dbuf; }; }; #endif wgd-3.1/include/wgd/camera2d.h0000644000175000001440000000225411233311615013105 00000000000000#ifndef _WGD_CAMERA2D_ #define _WGD_CAMERA2D_ #include #include namespace wgd { class BASE2DIMPORT Camera2D : public wgd::Camera { public: OBJECT(Camera, Camera2D); Camera2D(const OID&); ~Camera2D(); void bind(); void unbind(); /** Position of camera in the world */ PROPERTY_WF(vector2d, position, ix::position); PROPERTY_RF(vector2d, position, ix::position); /** Move the camera relative to its position */ void move(const vector2d&); /** Move the camera relative to its position and angle */ void translate(const vector2d&); /** The orientation of the camera in radians */ PROPERTY_WF(float, orientation, ix::orientation); PROPERTY_RF(float, orientation, ix::orientation); /** Rotate the camera (radians) */ void rotate(float); /** Set the camera zoom */ PROPERTY_WF(float, zoom, ix::zoom); PROPERTY_RF(float, zoom, ix::zoom); /** project a point in the scene to screen coordinates */ vector2d project(const vector2d&); /** get the point in the scene at a point in screen coordinates */ vector2d unproject(const vector2d&); }; }; #endif wgd-3.1/include/wgd/input.h0000644000175000001440000000045611233311615012570 00000000000000#ifndef _WGD_INPUT_ #define _WGD_INPUT_ #include #include #include namespace wgd { class BASEIMPORT Input : public doste::Agent { public: OBJECT(Agent,Input); Input(const doste::dvm::OID &o); ~Input(); static void update (); }; }; #endif wgd-3.1/include/wgd/math.h0000644000175000001440000000204111233311615012352 00000000000000#ifndef _WGD_MATH_ #define _WGD_MATH_ #include #include namespace wgd { /** Constant Pi */ static const double PI = 3.14159265; /** Constant 2 * pi */ static const double TWO_PI = 6.28318531; /** Constant pi / 2 */ static const double PI_HALF = 1.57079633; /** Convert degrees to radians */ inline float degToRad(float deg) { return (float)(deg * (PI/180.0)); }; /** Convert radians to degrees */ inline float radToDeg(float rad) { return (float)(rad * (180.0/PI)); }; /** Generate a random number from 0.0 to 1.0 */ inline float random() { return (float)(rand() % 10000) / 10000.0f; }; /** Generate a random number between 0 and n-1. */ inline int random(int n) { return rand() % n; }; /** Generate a random number between min and max-1 */ inline int random(int min, int max) { return min + (rand() % (max-min)); }; #ifndef _MSC_VER template A max(A a, A b) { return (a > b) ? a : b; }; template A min(A a, A b) { return (a < b) ? a : b; }; #endif }; #endif wgd-3.1/include/wgd/iheightmap.h0000644000175000001440000001104711233311615013546 00000000000000#ifndef _WGD_IHEIGHTMAP_ #define _WGD_IHEIGHTMAP_ #include #include #include namespace wgd { class HEIGHTMAPIMPORT IHeightmap : public wgd::Instance3D { public: IHeightmap(HeightmapSource* source); IHeightmap(const OID&); ~IHeightmap(); void draw(SceneGraph &graph, Camera3D *camera); OBJECT(Instance3D, IHeightmap); // Data source for heightmap data PROPERTY_RF(HeightmapSource, source, "source"); PROPERTY_WF(HeightmapSource, source, "source"); //LOD Patchsize - Must be a power of 2 PROPERTY_RF(int, patchSize, "patchsize"); PROPERTY_WF(int, patchSize, "patchsize"); //scale of the detailed spat textures PROPERTY_RF(wgd::vector2d, splatScale, "splatscale"); PROPERTY_WF(wgd::vector2d, splatScale, "splatscale"); void splatScale(float s) { splatScale(vector2d(s,s)); }; /** Draw the heightmap in wireframe mode */ PROPERTY_RF(bool, wireframe, "wireframe"); PROPERTY_WF(bool, wireframe, "wireframe"); /** Splat fade distance. * If this is 0, no splat textured are drawn. */ PROPERTY_RF(float, fade, "fade"); PROPERTY_WF(float, fade, "fade"); /** Level of detail metric (higher number = less detail) */ PROPERTY_RF(float, lod, "lod"); PROPERTY_WF(float, lod, "lod"); /** heightmap scale - defines how far apart the vertices are */ PROPERTY_RF(vector3d, scale, ix::scale); PROPERTY_WF(vector3d, scale, ix::scale); void scale(float s) { scale(vector3d(s,s,s)); }; /** * Get the height at any point * @param v The point to query the height at. Note y is ignored * @return height of the point (y coordinate) */ float height(const wgd::vector3d &v); /** * Get the height at any point * @param x The x coordinate of the point * @param z The z coordinate of the point * @return height of the point (y coordinate) */ float height(float x, float z); /** * Get the surface normal at any point * @param v The point to query the height at. Note y is ignored */ wgd::vector3d normal(const wgd::vector3d &v); /** * Get the point where a line segment intersects the heightmap * @param result The calculated intersection point * @param start The start point of the line in world coordinates * @param end The end point of the line in world coordinates * @return Whether the line segment intersects the heightmap */ bool intersect(wgd::vector3d &result, const wgd::vector3d &start, const wgd::vector3d &end); /** * Get the point where a ray hits the heightmap * @param result The calculated intersection point * @param point The start point of the ray in world coordinates * @param direction The direction of the ray * @return Whether the ray hits the heightmap */ bool ray(wgd::vector3d &result, const wgd::vector3d &point, const wgd::vector3d &direction); private: // Draw the region at said region coordinates void drawRegion(Camera3D *camera, int rx, int ry); //Get a patch (using patch coordinates) wgd::Patch *patch(int x, int y); //Calculate the glue values for a patch - takes absolute patch coordinates (not relative to region) unsigned int glue(wgd::Patch *p, int x, int y); // Calculate the error metric for getting mip levels from viewport distortion void errorMetric(float fovY, int viewHeight); //recursively draw patches void drawPatchR(HMRegion *region, int rx, int ry, int node, int x, int y, int size); void drawSplatR(HMRegion *region, int splat, int rx, int ry, int node, int x, int y, int size); //Index Array Generation void buildPatch (Patch *p, unsigned int glue); void acrossStrip(Patch *p, int start, int length, int step); void leftGlue (Patch *p, int nextLevel); //nextLevel being the mip level of the next patch void rightGlue (Patch *p, int nextLevel); void topGlue (Patch *p, int nextLevel); void bottomGlue (Patch *p, int nextLevel); //some local data float m_errorMetric; //Error metric to calculate mip level int m_regionSize; //Size of region in vertices int m_patchSize; //size of patch in vertices int m_patches; //Size of region in patches float m_fade; //splat fade distance (this is the cut-off distance) vector3d m_scale; //heightmap scale HeightmapSource* m_source; wgd::vector2d m_splatScale; float m_farClip; //info int m_polys; float m_maxError; int m_count; //ray debug wgd::vector3d vs, ve; }; }; #endif wgd-3.1/include/wgd/camera3d.h0000644000175000001440000000601111233311615013101 00000000000000#ifndef _WGD_CAMERA3D_ #define _WGD_CAMERA3D_ #include #include #include #include namespace wgd { class BASE3DIMPORT Camera3D : public wgd::Camera { public: Camera3D(const doste::dvm::OID&); ~Camera3D(); void bind(); void unbind(); /** Position of camera in the 3D world*/ PROPERTY_WF(vector3d, position, ix::position); PROPERTY_RF(vector3d, position, ix::position); /** Move the camera relative to its position */ void move(const vector3d&); /** Move the camera relative to its position and orientation */ void translate(const vector3d&); /** Set the pitch yaw and roll of the camera */ PROPERTY_WF(vector3d, orientation, ix::orientation); PROPERTY_RF(vector3d, orientation, ix::orientation); /** Rotate the camera using pitch, yaw and roll */ void rotate(const vector3d&); /** Get the quaternion of the camera's orientation */ const Quaternion quaternion() const; /** Set the camera orientation using a quaternion */ void quaternion(const Quaternion&); /** Make the camera look at a point, modify roll to change the 'up' vector */ void lookat(const vector3d&); /** get a vector describing the direction the camera is pointing */ vector3d direction() { return vector3d().translate(m_quat, vector3d(0.0, 0.0, -1.0)); } /** clipping */ #ifdef WIN32 #undef near #undef far #endif PROPERTY_WF(float, nearclip, ix::near); PROPERTY_RF(float, nearclip, ix::near); PROPERTY_WF(float, farclip, ix::far); PROPERTY_RF(float, farclip, ix::far); /** Field of view in X */ PROPERTY_WF(float, fov, ix::fov); PROPERTY_RF(float, fov, ix::fov); /** Field of view in Y */ float fovY() { return fov() / ((float)m_width / m_height); }; BEGIN_EVENTS(wgd::Camera); EVENT_VECTOR(evt_orientation, (*this)(ix::orientation)); END_EVENTS; OBJECT(Camera, Camera3D); //Frustum clipping int insideFrustum(const wgd::vector3d &point) const { return m_frustum.inside(point); } int insideFrustum(const wgd::vector3d &min, const wgd::vector3d &max) const { return m_frustum.inside(min, max); } /** Project a point from world coordinates to screen coordinates * @param world the world position of the point * @return screen coordinates relative to viewport widget */ wgd::vector3d project(const vector3d &world); /** transform a point from screen coordinates to world coordinates * * @param screen the screen coordinates relative to the viewport. * @return the position in the world */ wgd::vector3d unProject(const vector3d &screen); private: //calculate the OpenGL for manual projection //should really be one call to get the product of them, //but i couldn't get that to work properly. void projectionMatrix(double*); void modelViewMatrix(double*); Quaternion m_quat; //frustum for view culling wgd::Frustum m_frustum; }; }; #endif wgd-3.1/include/wgd/mesh.h0000644000175000001440000000351411077705131012371 00000000000000#ifndef _WGD_MESH_ #define _WGD_MESH_ #include #include #include #include #include namespace wgd { class vector3d; typedef vertex_t meshVertex; struct MeshSkin { float weight; wgd::Bone *bone; }; class MODELSIMPORT Mesh : public doste::Object { friend class SkinController; friend class MorphController; friend class IModel; public: OBJECT(Object, Mesh); Mesh(); Mesh(const doste::dvm::OID&); ~Mesh(); /** The material name for this mesh */ PROPERTY_RF(doste::dvm::OID, material, ix::material); PROPERTY_WF(doste::dvm::OID, material, ix::material); /** The bone that this mesh is attached to - skeletal animation overrides this */ PROPERTY_RF(doste::dvm::OID, bone, "bone"); PROPERTY_WF(doste::dvm::OID, bone, "bone"); //set data void vertices(int, meshVertex* vx); void skin(int, MeshSkin*); //get data int vertices() { if(m_drawable) return m_drawable->size; else return 0; }; meshVertex *data() { if(m_drawable) return m_drawable->data; else return 0; }; MeshSkin *skin() { return m_skin; }; int weights() { return m_weightsPerVertex; }; //for transformed meshes - setup space void create(int); /** get drawable object */ Drawable* drawable() { return m_drawable; } /** calculate normals from face data */ void calcNormals(); /** calculate tangents from normals and texture coordinates */ void calcTangents(); private: wgd::vector3d calcTangent(const meshVertex &vA, const meshVertex &vB, const meshVertex &vC); //Vertex Weights int m_weightsPerVertex; MeshSkin *m_skin; //drawable - contains mesh data void setup(); Drawable *m_drawable; }; }; #endif wgd-3.1/include/wgd/joystick.h0000644000175000001440000000424611233311615013271 00000000000000#ifndef _WGD_JOYSTICK_ #define _WGD_JOYSTICK_ #ifdef LINUX #include #endif #ifdef WIN32 #include #include #include #endif #include #include #include #define MAX_JOYSTICKS 6 namespace wgd { typedef doste::dvm::OID Hat; /** * Provides joystick, gamepad and XBox 360 controller input. You can query button * state and the current position of each axis. */ class INPUTIMPORT Joystick : public doste::Object { public: VOBJECT(doste::Object, Joystick); /** Query a particular button. */ bool btnPressed(int btn); /** Get the value of an axis. */ float axis(int ax); /** set an axis to be inverted */ void inverted(int ax, bool invert); /** get wherter an axis is inverted */ bool inverted(int ax); Hat hat(int num=0); /** Return the joystick name. */ const char *name(); /** The number of axes available on this joystick */ int numAxes() const { return m_numaxis; }; /** The number of buttons. */ int numButtons() const { return m_numbuts; }; /** Number of joysticks. */ static int number() { return s_numjs; }; /** Get a specific joystick, 0 to number()-1. */ static Joystick *joystick(int num); /* this seems to be correct for Microsoft joysticks */ static const int BUTTON_PRIMARY = 0; static const int BUTTON_SECONDARY = 1; static const int AXIS_X = 0; static const int AXIS_Y = 1; static const int AXIS_Z = 2; static const int AXIS_R = 3; static const int AXIS_U = 4; static const int AXIS_V = 5; static void initialise(); static void finalise(); static void updateAll(); private: int m_numbuts; int m_numaxis; char m_name[80]; #ifdef WIN32 int m_id; JOYCAPS m_joycaps; Joystick(const doste::dvm::OID obj, int id, const JOYCAPS &joycaps); #else int m_fp; char m_devname[100]; unsigned char m_keymap[KEY_MAX - BTN_MISC]; unsigned char m_absmap[ABS_MAX]; Joystick(const doste::dvm::OID &obj, int fp, const char *devname); #endif Joystick(); ~Joystick(); void update(); static int s_numjs; static Joystick *s_jsticks[MAX_JOYSTICKS]; }; }; #endif wgd-3.1/include/wgd/loader.h0000644000175000001440000000433211027211576012702 00000000000000#ifndef _WGD_LOADER_H_ #define _WGD_LOADER_H_ #include #include #include #include #define LOADER(k) static Loader* construct(doste::File *file){ return new k(file); }; #define BASE_LOADER(k) static const char *type() { return #k; }; static std::vector s_map; #define IMPLEMENT_LOADER(k) std::vector k::s_map; //dllexport warning #ifdef _MSC_VER #pragma warning ( disable : 4275 ) #endif namespace wgd { class Loader { public: //Example macro. //LOADER(Model3DS); Loader(doste::File *f) : m_file(f) {} struct LoaderStruct { void *construct; void *validate; }; doste::File *file() const { return m_file; } //virtual void load(Resource *r, doste::File *f) { std::cout << "Idiot\n"; } /** * Detects resource file type and attempts to return the relevant loader. * The template type specified is the base loader for that resource type. */ template static T *create(doste::File *file) { if (!file->open(doste::File::READ)) { //ERROR GOES HERE. doste::Error(0, doste::dstring("The file '") + file->filename() + "' does not exist or cannot be opened\n"); return 0; } for (unsigned int i=0; iclose(); return (T*)((Loader *(*)(doste::File*))T::s_map[i].construct)(file); } } file->close(); doste::Error(0, doste::dstring("I cannot create a ") + T::type() + " from the file '" + file->filename() + "'\n"); return 0; } /** * Register a loader for a specific file type. T is the actual loader type. */ template static void regFileType() { LoaderStruct s; s.construct = (void*)T::construct; s.validate = (void*)T::validate; T::s_map.push_back(s); }; static bool validate(doste::File *) { doste::DMsg msg(doste::DMsg::WARNING); msg << "Please implement a 'static bool validate(File*)' method.\n"; return false; } static Loader *construct(doste::File *f) { doste::DMsg msg(doste::DMsg::WARNING); msg << "You forgot to use the LOADER macro.\n"; return 0; } private: doste::File *m_file; }; }; #endif wgd-3.1/include/wgd/font.h0000644000175000001440000000535711233311615012404 00000000000000/* * WGD Library * * Authors: * Date: 19/9/2007 * */ #ifndef _WGD_FONT_ #define _WGD_FONT_ #ifdef WIN32 #include #endif #include #include #include #include #include #include #include namespace wgd { struct colour; /** Text alignment */ enum TextAlign { LEFT, CENTRE, RIGHT }; /** * Font resource. For each font you need to construct a Font * resource and then use that resource with IText etc. A * font has a name, size and can be bold. Here is an example * of how to create and use a font.

* * Font *myfont = Resource::create\("myfont");
* myfont->name("Arial");
* myfont->size(12);
* myfont->bold(true);

* IText *message = Instance::create\("message1");
* message->text("Hello World");
* message->font(myfont);
*
*/ class RESIMPORT Font : public doste::Agent { public: OBJECT(Agent, Font); Font(); Font(const char* name, int size, bool bold=false); Font(const doste::dvm::OID &res); ~Font(); /** * Change the font size. * @param v Font size. */ PROPERTY_WF(int, size, doste::dvm::Size); /** * Get this fonts size. * @return Font size. */ PROPERTY_RF(int, size, doste::dvm::Size); /** * Change this fonts name. * @param v The name of the font face. */ PROPERTY_WF(doste::dstring, name,ix::name); /** * This fonts current name. * @return Name of the font. */ PROPERTY_RF(doste::dstring, name,ix::name); /** * Set bold to true or false. * @param v True for bold text. */ PROPERTY_WF(bool, bold, ix::bold); /** * Is this font bold. * @return True if bold. */ PROPERTY_RF(bool, bold,ix::bold); PROPERTY_WF(wgd::Texture, texture, ix::texture); PROPERTY_RF(wgd::Texture, texture, ix::texture); void bind(); void unbind(); /** build the font if not already built (creates the texture) */ void build() { if(m_needsbuild) buildFont(); } //DB_GET_INT(width, ix::width); //DB_SET_INT(width, ix::width); //DB_GET_INT(height, ix::height); //DB_SET_INT(height, ix::height); int CharWidth(char c); int CharX(char c); int CharY(char c); int CharHeight(char c); BEGIN_EVENTS(Agent); EVENT(evt_make, (*this)("_make")); EVENT(evt_changed, (*this)(ix::name)(doste::dvm::modifiers::Seq)((*this))(ix::size)(doste::dvm::modifiers::Seq)((*this))(ix::bold)); END_EVENTS; protected: bool m_needsbuild; struct CData { int x; int y; int width; int height; }; CData m_cdata[128]; virtual void buildFont(); void destroyFont(); //static void initialise(); //static void finalise(); }; }; #endif wgd-3.1/include/wgd/png/0000777000175000001440000000000011265576314012141 500000000000000wgd-3.1/include/wgd/png/png.h0000644000175000001440000043641610757754260013033 00000000000000 /* png.h - header file for PNG reference library * * libpng version 1.2.20 - September 8, 2007 * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.2.20 - September 8, 2007: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: * * Due to various miscommunications, unforeseen code incompatibilities * and occasional factors outside the authors' control, version numbering * on the library has not always been consistent and straightforward. * The following table summarizes matters since version 0.89c, which was * the first widely used release: * * source png.h png.h shared-lib * version string int version * ------- ------ ----- ---------- * 0.89c "1.0 beta 3" 0.89 89 1.0.89 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] * 0.97c 0.97 97 2.0.97 * 0.98 0.98 98 2.0.98 * 0.99 0.99 98 2.0.99 * 0.99a-m 0.99 99 2.0.99 * 1.00 1.00 100 2.1.0 [100 should be 10000] * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] * 1.0.1 png.h string is 10001 2.1.0 * 1.0.1a-e identical to the 10002 from here on, the shared library * 1.0.2 source version) 10002 is 2.V where V is the source code * 1.0.2a-b 10003 version, except as noted. * 1.0.3 10003 * 1.0.3a-d 10004 * 1.0.4 10004 * 1.0.4a-f 10005 * 1.0.5 (+ 2 patches) 10005 * 1.0.5a-d 10006 * 1.0.5e-r 10100 (not source compatible) * 1.0.5s-v 10006 (not binary compatible) * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) * 1.0.6d-f 10007 (still binary incompatible) * 1.0.6g 10007 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) * 1.0.6i 10007 10.6i * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) * 1.0.7 1 10007 (still compatible) * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 * 1.0.8rc1 1 10008 2.1.0.8rc1 * 1.0.8 1 10008 2.1.0.8 * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 * 1.0.9rc1 1 10009 2.1.0.9rc1 * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 * 1.0.9rc2 1 10009 2.1.0.9rc2 * 1.0.9 1 10009 2.1.0.9 * 1.0.10beta1 1 10010 2.1.0.10beta1 * 1.0.10rc1 1 10010 2.1.0.10rc1 * 1.0.10 1 10010 2.1.0.10 * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 * 1.0.11rc1 1 10011 2.1.0.11rc1 * 1.0.11 1 10011 2.1.0.11 * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 * 1.0.12rc1 2 10012 2.1.0.12rc1 * 1.0.12 2 10012 2.1.0.12 * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 * 1.2.0rc1 3 10200 3.1.2.0rc1 * 1.2.0 3 10200 3.1.2.0 * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 * 1.2.1 3 10201 3.1.2.1 * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 * 1.0.13 10 10013 10.so.0.1.0.13 * 1.2.2 12 10202 12.so.0.1.2.2 * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 * 1.2.3 12 10203 12.so.0.1.2.3 * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 * 1.0.14 10 10014 10.so.0.1.0.14 * 1.2.4 13 10204 12.so.0.1.2.4 * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 * 1.0.15 10 10015 10.so.0.1.0.15 * 1.2.5 13 10205 12.so.0.1.2.5 * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 * 1.0.16 10 10016 10.so.0.1.0.16 * 1.2.6 13 10206 12.so.0.1.2.6 * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1 * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 * 1.0.17 10 10017 10.so.0.1.0.17 * 1.2.7 13 10207 12.so.0.1.2.7 * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5 * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 * 1.0.18 10 10018 10.so.0.1.0.18 * 1.2.8 13 10208 12.so.0.1.2.8 * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 * 1.2.9beta4-11 13 10209 12.so.0.9[.0] * 1.2.9rc1 13 10209 12.so.0.9[.0] * 1.2.9 13 10209 12.so.0.9[.0] * 1.2.10beta1-8 13 10210 12.so.0.10[.0] * 1.2.10rc1-3 13 10210 12.so.0.10[.0] * 1.2.10 13 10210 12.so.0.10[.0] * 1.2.11beta1-4 13 10211 12.so.0.11[.0] * 1.0.19rc1-5 10 10019 10.so.0.19[.0] * 1.2.11rc1-5 13 10211 12.so.0.11[.0] * 1.0.19 10 10019 10.so.0.19[.0] * 1.2.11 13 10211 12.so.0.11[.0] * 1.0.20 10 10020 10.so.0.20[.0] * 1.2.12 13 10212 12.so.0.12[.0] * 1.2.13beta1 13 10213 12.so.0.13[.0] * 1.0.21 10 10021 10.so.0.21[.0] * 1.2.13 13 10213 12.so.0.13[.0] * 1.2.14beta1-2 13 10214 12.so.0.14[.0] * 1.0.22rc1 10 10022 10.so.0.22[.0] * 1.2.14rc1 13 10214 12.so.0.14[.0] * 1.0.22 10 10022 10.so.0.22[.0] * 1.2.14 13 10214 12.so.0.14[.0] * 1.2.15beta1-6 13 10215 12.so.0.15[.0] * 1.0.23rc1-5 10 10023 10.so.0.23[.0] * 1.2.15rc1-5 13 10215 12.so.0.15[.0] * 1.0.23 10 10023 10.so.0.23[.0] * 1.2.15 13 10215 12.so.0.15[.0] * 1.2.16beta1-2 13 10216 12.so.0.16[.0] * 1.2.16rc1 13 10216 12.so.0.16[.0] * 1.0.24 10 10024 10.so.0.24[.0] * 1.2.16 13 10216 12.so.0.16[.0] * 1.2.17beta1-2 13 10217 12.so.0.17[.0] * 1.0.25rc1 10 10025 10.so.0.25[.0] * 1.2.17rc1-3 13 10217 12.so.0.17[.0] * 1.0.25 10 10025 10.so.0.25[.0] * 1.2.17 13 10217 12.so.0.17[.0] * 1.0.26 10 10026 10.so.0.26[.0] * 1.2.18 13 10218 12.so.0.18[.0] * 1.2.19beta1-31 13 10219 12.so.0.19[.0] * 1.0.27rc1-6 10 10027 10.so.0.27[.0] * 1.2.19rc1-6 13 10219 12.so.0.19[.0] * 1.0.27 10 10027 10.so.0.27[.0] * 1.2.19 13 10219 12.so.0.19[.0] * 1.2.20beta01-04 13 10220 12.so.0.20[.0] * 1.0.28rc1-6 10 10028 10.so.0.28[.0] * 1.2.20rc1-6 13 10220 12.so.0.20[.0] * 1.0.28 10 10028 10.so.0.28[.0] * 1.2.20 13 10220 12.so.0.20[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be * used for changes in backward compatibility, as it is intended. The * PNG_LIBPNG_VER macro, which is not used within libpng but is available * for applications, is an unsigned integer of the form xyyzz corresponding * to the source version x.y.z (leading zeros in y and z). Beta versions * were given the previous public release number plus a letter, until * version 1.0.6j; from then on they were given the upcoming public * release number plus "betaNN" or "rcN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled * application is loaded with a different version of the library. * * DLLNUM will change each time there are forward or backward changes * in binary compatibility (e.g., when a new feature is added). * * See libpng.txt or libpng.3 for more information. The PNG specification * is available as a W3C Recommendation and as an ISO Specification, * #endif /* include all user configurable info, including optional assembler routines */ #include /* * Added at libpng-1.2.8 */ /* Ref MSDN: Private as priority over Special * VS_FF_PRIVATEBUILD File *was not* built using standard release * procedures. If this value is given, the StringFileInfo block must * contain a PrivateBuild string. * * VS_FF_SPECIALBUILD File *was* built by the original company using * standard release procedures but is a variation of the standard * file of the same version number. If this value is given, the * StringFileInfo block must contain a SpecialBuild string. */ #if defined(PNG_USER_PRIVATEBUILD) # define PNG_LIBPNG_BUILD_TYPE \ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) #else # if defined(PNG_LIBPNG_SPECIALBUILD) # define PNG_LIBPNG_BUILD_TYPE \ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) # else # define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) # endif #endif #ifndef PNG_VERSION_INFO_ONLY /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* This file is arranged in several sections. The first section contains * structure and type definitions. The second section contains the external * library functions, while the third has the internal library functions, * which applications aren't expected to use directly. */ #ifndef PNG_NO_TYPECAST_NULL #define int_p_NULL (int *)NULL #define png_bytep_NULL (png_bytep)NULL #define png_bytepp_NULL (png_bytepp)NULL #define png_doublep_NULL (png_doublep)NULL #define png_error_ptr_NULL (png_error_ptr)NULL #define png_flush_ptr_NULL (png_flush_ptr)NULL #define png_free_ptr_NULL (png_free_ptr)NULL #define png_infopp_NULL (png_infopp)NULL #define png_malloc_ptr_NULL (png_malloc_ptr)NULL #define png_read_status_ptr_NULL (png_read_status_ptr)NULL #define png_rw_ptr_NULL (png_rw_ptr)NULL #define png_structp_NULL (png_structp)NULL #define png_uint_16p_NULL (png_uint_16p)NULL #define png_voidp_NULL (png_voidp)NULL #define png_write_status_ptr_NULL (png_write_status_ptr)NULL #else #define int_p_NULL NULL #define png_bytep_NULL NULL #define png_bytepp_NULL NULL #define png_doublep_NULL NULL #define png_error_ptr_NULL NULL #define png_flush_ptr_NULL NULL #define png_free_ptr_NULL NULL #define png_infopp_NULL NULL #define png_malloc_ptr_NULL NULL #define png_read_status_ptr_NULL NULL #define png_rw_ptr_NULL NULL #define png_structp_NULL NULL #define png_uint_16p_NULL NULL #define png_voidp_NULL NULL #define png_write_status_ptr_NULL NULL #endif /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) /* Version information for C files, stored in png.c. This had better match * the version above. */ #ifdef PNG_USE_GLOBAL_ARRAYS PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18]; /* need room for 99.99.99beta99z */ #else #define png_libpng_ver png_get_header_ver(NULL) #endif #ifdef PNG_USE_GLOBAL_ARRAYS /* This was removed in version 1.0.5c */ /* Structures to facilitate easy interlacing. See png.c for more details */ PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7]; PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7]; PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7]; PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7]; PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7]; PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7]; /* This isn't currently used. If you need it, see png.c for more details. PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7]; */ #endif #endif /* PNG_NO_EXTERN */ /* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to * be png_byte or png_uint_16 (as defined below). */ typedef struct png_color_struct { png_byte red; png_byte green; png_byte blue; } png_color; typedef png_color * png_colorp; typedef png_color * * png_colorpp; typedef struct png_color_16_struct { png_byte index; /* used for palette files */ png_uint_16 red; /* for use in red green blue files */ png_uint_16 green; png_uint_16 blue; png_uint_16 gray; /* for use in grayscale files */ } png_color_16; typedef png_color_16 * png_color_16p; typedef png_color_16 * * png_color_16pp; typedef struct png_color_8_struct { png_byte red; /* for use in red green blue files */ png_byte green; png_byte blue; png_byte gray; /* for use in grayscale files */ png_byte alpha; /* for alpha channel files */ } png_color_8; typedef png_color_8 * png_color_8p; typedef png_color_8 * * png_color_8pp; /* * The following two structures are used for the in-core representation * of sPLT chunks. */ typedef struct png_sPLT_entry_struct { png_uint_16 red; png_uint_16 green; png_uint_16 blue; png_uint_16 alpha; png_uint_16 frequency; } png_sPLT_entry; typedef png_sPLT_entry * png_sPLT_entryp; typedef png_sPLT_entry * * png_sPLT_entrypp; /* When the depth of the sPLT palette is 8 bits, the color and alpha samples * occupy the LSB of their respective members, and the MSB of each member * is zero-filled. The frequency member always occupies the full 16 bits. */ typedef struct png_sPLT_struct { png_charp name; /* palette name */ png_byte depth; /* depth of palette samples */ png_sPLT_entryp entries; /* palette entries */ png_int_32 nentries; /* number of palette entries */ } png_sPLT_t; typedef png_sPLT_t * png_sPLT_tp; typedef png_sPLT_t * * png_sPLT_tpp; #ifdef PNG_TEXT_SUPPORTED /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, * and whether that contents is compressed or not. The "key" field * points to a regular zero-terminated C string. The "text", "lang", and * "lang_key" fields can be regular C strings, empty strings, or NULL pointers. * However, the * structure returned by png_get_text() will always contain * regular zero-terminated C strings (possibly empty), never NULL pointers, * so they can be safely used in printf() and other string-handling functions. */ typedef struct png_text_struct { int compression; /* compression value: -1: tEXt, none 0: zTXt, deflate 1: iTXt, none 2: iTXt, deflate */ png_charp key; /* keyword, 1-79 character description of "text" */ png_charp text; /* comment, may be an empty string (ie "") or a NULL pointer */ png_size_t text_length; /* length of the text string */ #ifdef PNG_iTXt_SUPPORTED png_size_t itxt_length; /* length of the itxt string */ png_charp lang; /* language code, 0-79 characters or a NULL pointer */ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more chars or a NULL pointer */ #endif } png_text; typedef png_text * png_textp; typedef png_text * * png_textpp; #endif /* Supported compression types for text in PNG files (tEXt, and zTXt). * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ #define PNG_TEXT_COMPRESSION_NONE_WR -3 #define PNG_TEXT_COMPRESSION_zTXt_WR -2 #define PNG_TEXT_COMPRESSION_NONE -1 #define PNG_TEXT_COMPRESSION_zTXt 0 #define PNG_ITXT_COMPRESSION_NONE 1 #define PNG_ITXT_COMPRESSION_zTXt 2 #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ /* png_time is a way to hold the time in an machine independent way. * Two conversions are provided, both from time_t and struct tm. There * is no portable way to convert to either of these structures, as far * as I know. If you know of a portable way, send it to me. As a side * note - PNG has always been Year 2000 compliant! */ typedef struct png_time_struct { png_uint_16 year; /* full year, as in, 1995 */ png_byte month; /* month of year, 1 - 12 */ png_byte day; /* day of month, 1 - 31 */ png_byte hour; /* hour of day, 0 - 23 */ png_byte minute; /* minute of hour, 0 - 59 */ png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ } png_time; typedef png_time * png_timep; typedef png_time * * png_timepp; #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* png_unknown_chunk is a structure to hold queued chunks for which there is * no specific support. The idea is that we can use this to queue * up private chunks for output even though the library doesn't actually * know about their semantics. */ typedef struct png_unknown_chunk_t { png_byte name[5]; png_byte *data; png_size_t size; /* libpng-using applications should NOT directly modify this byte. */ png_byte location; /* mode of operation at read time */ } png_unknown_chunk; typedef png_unknown_chunk * png_unknown_chunkp; typedef png_unknown_chunk * * png_unknown_chunkpp; #endif /* png_info is a structure that holds the information in a PNG file so * that the application can find out the characteristics of the image. * If you are reading the file, this structure will tell you what is * in the PNG file. If you are writing the file, fill in the information * you want to put into the PNG file, then call png_write_info(). * The names chosen should be very close to the PNG specification, so * consult that document for information about the meaning of each field. * * With libpng < 0.95, it was only possible to directly set and read the * the values in the png_info_struct, which meant that the contents and * order of the values had to remain fixed. With libpng 0.95 and later, * however, there are now functions that abstract the contents of * png_info_struct from the application, so this makes it easier to use * libpng with dynamic libraries, and even makes it possible to use * libraries that don't have all of the libpng ancillary chunk-handing * functionality. * * In any case, the order of the parameters in png_info_struct should NOT * be changed for as long as possible to keep compatibility with applications * that use the old direct-access method with png_info_struct. * * The following members may have allocated storage attached that should be * cleaned up before the structure is discarded: palette, trans, text, * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these * are automatically freed when the info structure is deallocated, if they were * allocated internally by libpng. This behavior can be changed by means * of the png_data_freer() function. * * More allocation details: all the chunk-reading functions that * change these members go through the corresponding png_set_* * functions. A function to clear these members is available: see * png_free_data(). The png_set_* functions do not depend on being * able to point info structure members to any of the storage they are * passed (they make their own copies), EXCEPT that the png_set_text * functions use the same storage passed to them in the text_ptr or * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns * functions do not make their own copies. */ typedef struct png_info_struct { /* the following are necessary for every PNG file */ png_uint_32 width; /* width of image in pixels (from IHDR) */ png_uint_32 height; /* height of image in pixels (from IHDR) */ png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */ png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ /* The following three should have been named *_method not *_type */ png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ /* The following is informational only on read, and not used on writes. */ png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ png_byte pixel_depth; /* number of bits per pixel */ png_byte spare_byte; /* to align the data, and for future use */ png_byte signature[8]; /* magic bytes read by libpng from start of file */ /* The rest of the data is optional. If you are reading, check the * valid field to see if the information in these are valid. If you * are writing, set the valid field to those chunks you want written, * and initialize the appropriate fields below. */ #if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) /* The gAMA chunk describes the gamma characteristics of the system * on which the image was created, normally in the range [1.0, 2.5]. * Data is valid if (valid & PNG_INFO_gAMA) is non-zero. */ float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */ #endif #if defined(PNG_sRGB_SUPPORTED) /* GR-P, 0.96a */ /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */ png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */ #endif #if defined(PNG_TEXT_SUPPORTED) /* The tEXt, and zTXt chunks contain human-readable textual data in * uncompressed, compressed, and optionally compressed forms, respectively. * The data in "text" is an array of pointers to uncompressed, * null-terminated C strings. Each chunk has a keyword that describes the * textual data contained in that chunk. Keywords are not required to be * unique, and the text string may be empty. Any number of text chunks may * be in an image. */ int num_text; /* number of comments read/to write */ int max_text; /* current size of text array */ png_textp text; /* array of comments read/to write */ #endif /* PNG_TEXT_SUPPORTED */ #if defined(PNG_tIME_SUPPORTED) /* The tIME chunk holds the last time the displayed image data was * modified. See the png_time struct for the contents of this struct. */ png_time mod_time; #endif #if defined(PNG_sBIT_SUPPORTED) /* The sBIT chunk specifies the number of significant high-order bits * in the pixel data. Values are in the range [1, bit_depth], and are * only specified for the channels in the pixel data. The contents of * the low-order bits is not specified. Data is valid if * (valid & PNG_INFO_sBIT) is non-zero. */ png_color_8 sig_bit; /* significant bits in color channels */ #endif #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ defined(PNG_READ_BACKGROUND_SUPPORTED) /* The tRNS chunk supplies transparency data for paletted images and * other image types that don't need a full alpha channel. There are * "num_trans" transparency values for a paletted image, stored in the * same order as the palette colors, starting from index 0. Values * for the data are in the range [0, 255], ranging from fully transparent * to fully opaque, respectively. For non-paletted images, there is a * single color specified that should be treated as fully transparent. * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. */ png_bytep trans; /* transparent values for paletted image */ png_color_16 trans_values; /* transparent color for non-palette image */ #endif #if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) /* The bKGD chunk gives the suggested image background color if the * display program does not have its own background color and the image * is needs to composited onto a background before display. The colors * in "background" are normally in the same color space/depth as the * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. */ png_color_16 background; #endif #if defined(PNG_oFFs_SUPPORTED) /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards * and downwards from the top-left corner of the display, page, or other * application-specific co-ordinate space. See the PNG_OFFSET_ defines * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. */ png_int_32 x_offset; /* x offset on page */ png_int_32 y_offset; /* y offset on page */ png_byte offset_unit_type; /* offset units type */ #endif #if defined(PNG_pHYs_SUPPORTED) /* The pHYs chunk gives the physical pixel density of the image for * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. */ png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ png_uint_32 y_pixels_per_unit; /* vertical pixel density */ png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ #endif #if defined(PNG_hIST_SUPPORTED) /* The hIST chunk contains the relative frequency or importance of the * various palette entries, so that a viewer can intelligently select a * reduced-color palette, if required. Data is an array of "num_palette" * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) * is non-zero. */ png_uint_16p hist; #endif #ifdef PNG_cHRM_SUPPORTED /* The cHRM chunk describes the CIE color characteristics of the monitor * on which the PNG was created. This data allows the viewer to do gamut * mapping of the input image to ensure that the viewer sees the same * colors in the image as the creator. Values are in the range * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero. */ #ifdef PNG_FLOATING_POINT_SUPPORTED float x_white; float y_white; float x_red; float y_red; float x_green; float y_green; float x_blue; float y_blue; #endif #endif #if defined(PNG_pCAL_SUPPORTED) /* The pCAL chunk describes a transformation between the stored pixel * values and original physical data values used to create the image. * The integer range [0, 2^bit_depth - 1] maps to the floating-point * range given by [pcal_X0, pcal_X1], and are further transformed by a * (possibly non-linear) transformation function given by "pcal_type" * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ * defines below, and the PNG-Group's PNG extensions document for a * complete description of the transformations and how they should be * implemented, and for a description of the ASCII parameter strings. * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. */ png_charp pcal_purpose; /* pCAL chunk description string */ png_int_32 pcal_X0; /* minimum value */ png_int_32 pcal_X1; /* maximum value */ png_charp pcal_units; /* Latin-1 string giving physical units */ png_charpp pcal_params; /* ASCII strings containing parameter values */ png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ png_byte pcal_nparams; /* number of parameters given in pcal_params */ #endif /* New members added in libpng-1.0.6 */ #ifdef PNG_FREE_ME_SUPPORTED png_uint_32 free_me; /* flags items libpng is responsible for freeing */ #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* storage for unknown chunks that the library doesn't recognize. */ png_unknown_chunkp unknown_chunks; png_size_t unknown_chunks_num; #endif #if defined(PNG_iCCP_SUPPORTED) /* iCCP chunk data. */ png_charp iccp_name; /* profile name */ png_charp iccp_profile; /* International Color Consortium profile data */ /* Note to maintainer: should be png_bytep */ png_uint_32 iccp_proflen; /* ICC profile data length */ png_byte iccp_compression; /* Always zero */ #endif #if defined(PNG_sPLT_SUPPORTED) /* data on sPLT chunks (there may be more than one). */ png_sPLT_tp splt_palettes; png_uint_32 splt_palettes_num; #endif #if defined(PNG_sCAL_SUPPORTED) /* The sCAL chunk describes the actual physical dimensions of the * subject matter of the graphic. The chunk contains a unit specification * a byte value, and two ASCII strings representing floating-point * values. The values are width and height corresponsing to one pixel * in the image. This external representation is converted to double * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero. */ png_byte scal_unit; /* unit of physical scale */ #ifdef PNG_FLOATING_POINT_SUPPORTED double scal_pixel_width; /* width of one pixel */ double scal_pixel_height; /* height of one pixel */ #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_charp scal_s_width; /* string containing height */ png_charp scal_s_height; /* string containing width */ #endif #endif #if defined(PNG_INFO_IMAGE_SUPPORTED) /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */ /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ png_bytepp row_pointers; /* the image bits */ #endif #if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED) png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */ #endif #if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED) png_fixed_point int_x_white; png_fixed_point int_y_white; png_fixed_point int_x_red; png_fixed_point int_y_red; png_fixed_point int_x_green; png_fixed_point int_y_green; png_fixed_point int_x_blue; png_fixed_point int_y_blue; #endif } png_info; typedef png_info * png_infop; typedef png_info * * png_infopp; /* Maximum positive integer used in PNG is (2^31)-1 */ #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffff) #define PNG_UINT_32_MAX ((png_uint_32)(-1)) #define PNG_SIZE_MAX ((png_size_t)(-1)) #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */ #define PNG_MAX_UINT PNG_UINT_31_MAX #endif /* These describe the color_type field in png_info. */ /* color type masks */ #define PNG_COLOR_MASK_PALETTE 1 #define PNG_COLOR_MASK_COLOR 2 #define PNG_COLOR_MASK_ALPHA 4 /* color types. Note that not all combinations are legal */ #define PNG_COLOR_TYPE_GRAY 0 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) /* aliases */ #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA #define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA /* This is for compression type. PNG 1.0-1.2 only define the single type. */ #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE /* This is for filter type. PNG 1.0-1.2 only define the single type. */ #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE /* These are for the interlacing type. These values should NOT be changed. */ #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ #define PNG_INTERLACE_LAST 2 /* Not a valid value */ /* These are for the oFFs chunk. These values should NOT be changed. */ #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ #define PNG_OFFSET_LAST 2 /* Not a valid value */ /* These are for the pCAL chunk. These values should NOT be changed. */ #define PNG_EQUATION_LINEAR 0 /* Linear transformation */ #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ #define PNG_EQUATION_LAST 4 /* Not a valid value */ /* These are for the sCAL chunk. These values should NOT be changed. */ #define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ #define PNG_SCALE_METER 1 /* meters per pixel */ #define PNG_SCALE_RADIAN 2 /* radians per pixel */ #define PNG_SCALE_LAST 3 /* Not a valid value */ /* These are for the pHYs chunk. These values should NOT be changed. */ #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ #define PNG_RESOLUTION_METER 1 /* pixels/meter */ #define PNG_RESOLUTION_LAST 2 /* Not a valid value */ /* These are for the sRGB chunk. These values should NOT be changed. */ #define PNG_sRGB_INTENT_PERCEPTUAL 0 #define PNG_sRGB_INTENT_RELATIVE 1 #define PNG_sRGB_INTENT_SATURATION 2 #define PNG_sRGB_INTENT_ABSOLUTE 3 #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ /* This is for text chunks */ #define PNG_KEYWORD_MAX_LENGTH 79 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */ #define PNG_MAX_PALETTE_LENGTH 256 /* These determine if an ancillary chunk's data has been successfully read * from the PNG header, or if the application has filled in the corresponding * data in the info_struct to be written into the output file. The values * of the PNG_INFO_ defines should NOT be changed. */ #define PNG_INFO_gAMA 0x0001 #define PNG_INFO_sBIT 0x0002 #define PNG_INFO_cHRM 0x0004 #define PNG_INFO_PLTE 0x0008 #define PNG_INFO_tRNS 0x0010 #define PNG_INFO_bKGD 0x0020 #define PNG_INFO_hIST 0x0040 #define PNG_INFO_pHYs 0x0080 #define PNG_INFO_oFFs 0x0100 #define PNG_INFO_tIME 0x0200 #define PNG_INFO_pCAL 0x0400 #define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ #define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using * the routines for other purposes. */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ png_uint_32 rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; typedef png_row_info * png_row_infop; typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the * user read/write data functions. */ typedef struct png_struct_def png_struct; typedef png_struct * png_structp; typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp)); typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t)); typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp)); typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32, int)); typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop)); typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop)); typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep, png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp, png_row_infop, png_bytep)); #endif #if defined(PNG_USER_CHUNKS_SUPPORTED) typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp)); #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t)); typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp)); /* The structure that holds the information to read and write PNG files. * The only people who need to care about what is inside of this are the * people who will be modifying the library for their own special needs. * It should NOT be accessed directly by an application, except to store * the jmp_buf. */ struct png_struct_def { #ifdef PNG_SETJMP_SUPPORTED jmp_buf jmpbuf; /* used in png_error */ #endif png_error_ptr error_fn; /* function for printing errors and aborting */ png_error_ptr warning_fn; /* function for printing warnings */ png_voidp error_ptr; /* user supplied struct for error functions */ png_rw_ptr write_data_fn; /* function for writing output data */ png_rw_ptr read_data_fn; /* function for reading input data */ png_voidp io_ptr; /* ptr to application struct for I/O functions */ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_user_transform_ptr read_user_transform_fn; /* user read transform */ #endif #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) png_user_transform_ptr write_user_transform_fn; /* user write transform */ #endif /* These were added in libpng-1.0.2 */ #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) png_voidp user_transform_ptr; /* user supplied struct for user transform */ png_byte user_transform_depth; /* bit depth of user transformed pixels */ png_byte user_transform_channels; /* channels in user transformed pixels */ #endif #endif png_uint_32 mode; /* tells us where we are in the PNG file */ png_uint_32 flags; /* flags indicating various things to libpng */ png_uint_32 transformations; /* which transformations to perform */ z_stream zstream; /* pointer to decompression structure (below) */ png_bytep zbuf; /* buffer for zlib */ png_size_t zbuf_size; /* size of zbuf */ int zlib_level; /* holds zlib compression level */ int zlib_method; /* holds zlib compression method */ int zlib_window_bits; /* holds zlib compression window bits */ int zlib_mem_level; /* holds zlib compression memory level */ int zlib_strategy; /* holds zlib compression strategy */ png_uint_32 width; /* width of image in pixels */ png_uint_32 height; /* height of image in pixels */ png_uint_32 num_rows; /* number of rows in current pass */ png_uint_32 usr_width; /* width of row at start of write */ png_uint_32 rowbytes; /* size of row in bytes */ png_uint_32 irowbytes; /* size of current interlaced row in bytes */ png_uint_32 iwidth; /* width of current interlaced row in pixels */ png_uint_32 row_number; /* current row in interlace pass */ png_bytep prev_row; /* buffer to save previous (unfiltered) row */ png_bytep row_buf; /* buffer to save current (unfiltered) row */ png_bytep sub_row; /* buffer to save "sub" row when filtering */ png_bytep up_row; /* buffer to save "up" row when filtering */ png_bytep avg_row; /* buffer to save "avg" row when filtering */ png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */ png_row_info row_info; /* used for transformation routines */ png_uint_32 idat_size; /* current IDAT size for read */ png_uint_32 crc; /* current chunk CRC value */ png_colorp palette; /* palette from the input file */ png_uint_16 num_palette; /* number of color entries in palette */ png_uint_16 num_trans; /* number of transparency values */ png_byte chunk_name[5]; /* null-terminated name of current chunk */ png_byte compression; /* file compression type (always 0) */ png_byte filter; /* file filter type (always 0) */ png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ png_byte pass; /* current interlace pass (0 - 6) */ png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ png_byte color_type; /* color type of file */ png_byte bit_depth; /* bit depth of file */ png_byte usr_bit_depth; /* bit depth of users row */ png_byte pixel_depth; /* number of bits per pixel */ png_byte channels; /* number of channels in file */ png_byte usr_channels; /* channels at start of write */ png_byte sig_bytes; /* magic bytes read/written from start of file */ #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) #ifdef PNG_LEGACY_SUPPORTED png_byte filler; /* filler byte for pixel expansion */ #else png_uint_16 filler; /* filler bytes for pixel expansion */ #endif #endif #if defined(PNG_bKGD_SUPPORTED) png_byte background_gamma_type; # ifdef PNG_FLOATING_POINT_SUPPORTED float background_gamma; # endif png_color_16 background; /* background color in screen gamma space */ #if defined(PNG_READ_GAMMA_SUPPORTED) png_color_16 background_1; /* background normalized to gamma 1.0 */ #endif #endif /* PNG_bKGD_SUPPORTED */ #if defined(PNG_WRITE_FLUSH_SUPPORTED) png_flush_ptr output_flush_fn;/* Function for flushing output */ png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ png_uint_32 flush_rows; /* number of rows written since last flush */ #endif #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) int gamma_shift; /* number of "insignificant" bits 16-bit gamma */ #ifdef PNG_FLOATING_POINT_SUPPORTED float gamma; /* file gamma value */ float screen_gamma; /* screen gamma value (display_exponent) */ #endif #endif #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) png_bytep gamma_table; /* gamma table for 8-bit depth files */ png_bytep gamma_from_1; /* converts from 1.0 to screen */ png_bytep gamma_to_1; /* converts from file to 1.0 */ png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ #endif #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) png_color_8 sig_bit; /* significant bits in each available channel */ #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) png_color_8 shift; /* shift for significant bit tranformation */ #endif #if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) png_bytep trans; /* transparency values for paletted files */ png_color_16 trans_values; /* transparency values for non-paletted files */ #endif png_read_status_ptr read_row_fn; /* called after each row is decoded */ png_write_status_ptr write_row_fn; /* called after each row is encoded */ #ifdef PNG_PROGRESSIVE_READ_SUPPORTED png_progressive_info_ptr info_fn; /* called after header data fully read */ png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */ png_progressive_end_ptr end_fn; /* called after image is complete */ png_bytep save_buffer_ptr; /* current location in save_buffer */ png_bytep save_buffer; /* buffer for previously read data */ png_bytep current_buffer_ptr; /* current location in current_buffer */ png_bytep current_buffer; /* buffer for recently used data */ png_uint_32 push_length; /* size of current input chunk */ png_uint_32 skip_length; /* bytes to skip in input data */ png_size_t save_buffer_size; /* amount of data now in save_buffer */ png_size_t save_buffer_max; /* total size of save_buffer */ png_size_t buffer_size; /* total amount of available input data */ png_size_t current_buffer_size; /* amount of data now in current_buffer */ int process_mode; /* what push library is currently doing */ int cur_palette; /* current push library palette index */ # if defined(PNG_TEXT_SUPPORTED) png_size_t current_text_size; /* current size of text input data */ png_size_t current_text_left; /* how much text left to read in input */ png_charp current_text; /* current text chunk buffer */ png_charp current_text_ptr; /* current location in current_text */ # endif /* PNG_TEXT_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) /* for the Borland special 64K segment handler */ png_bytepp offset_table_ptr; png_bytep offset_table; png_uint_16 offset_table_number; png_uint_16 offset_table_count; png_uint_16 offset_table_count_free; #endif #if defined(PNG_READ_DITHER_SUPPORTED) png_bytep palette_lookup; /* lookup table for dithering */ png_bytep dither_index; /* index translation for palette files */ #endif #if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED) png_uint_16p hist; /* histogram */ #endif #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) png_byte heuristic_method; /* heuristic for row filter selection */ png_byte num_prev_filters; /* number of weights for previous rows */ png_bytep prev_filters; /* filter type(s) of previous row(s) */ png_uint_16p filter_weights; /* weight(s) for previous line(s) */ png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */ png_uint_16p filter_costs; /* relative filter calculation cost */ png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */ #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) png_charp time_buffer; /* String to hold RFC 1123 time text */ #endif /* New members added in libpng-1.0.6 */ #ifdef PNG_FREE_ME_SUPPORTED png_uint_32 free_me; /* flags items libpng is responsible for freeing */ #endif #if defined(PNG_USER_CHUNKS_SUPPORTED) png_voidp user_chunk_ptr; png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) int num_chunk_list; png_bytep chunk_list; #endif /* New members added in libpng-1.0.3 */ #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) png_byte rgb_to_gray_status; /* These were changed from png_byte in libpng-1.0.6 */ png_uint_16 rgb_to_gray_red_coeff; png_uint_16 rgb_to_gray_green_coeff; png_uint_16 rgb_to_gray_blue_coeff; #endif /* New member added in libpng-1.0.4 (renamed in 1.0.9) */ #if defined(PNG_MNG_FEATURES_SUPPORTED) || \ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) /* changed from png_byte to png_uint_32 at version 1.2.0 */ #ifdef PNG_1_0_X png_byte mng_features_permitted; #else png_uint_32 mng_features_permitted; #endif /* PNG_1_0_X */ #endif /* New member added in libpng-1.0.7 */ #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) png_fixed_point int_gamma; #endif /* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ #if defined(PNG_MNG_FEATURES_SUPPORTED) png_byte filter_type; #endif #if defined(PNG_1_0_X) /* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */ png_uint_32 row_buf_size; #endif /* New members added in libpng-1.2.0 */ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) # if !defined(PNG_1_0_X) # if defined(PNG_MMX_CODE_SUPPORTED) png_byte mmx_bitdepth_threshold; png_uint_32 mmx_rowbytes_threshold; # endif png_uint_32 asm_flags; # endif #endif /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ #ifdef PNG_USER_MEM_SUPPORTED png_voidp mem_ptr; /* user supplied struct for mem functions */ png_malloc_ptr malloc_fn; /* function for allocating memory */ png_free_ptr free_fn; /* function for freeing memory */ #endif /* New member added in libpng-1.0.13 and 1.2.0 */ png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ #if defined(PNG_READ_DITHER_SUPPORTED) /* The following three members were added at version 1.0.14 and 1.2.4 */ png_bytep dither_sort; /* working sort array */ png_bytep index_to_palette; /* where the original index currently is */ /* in the palette */ png_bytep palette_to_index; /* which original index points to this */ /* palette color */ #endif /* New members added in libpng-1.0.16 and 1.2.6 */ png_byte compression_type; #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_uint_32 user_width_max; png_uint_32 user_height_max; #endif /* New member added in libpng-1.0.25 and 1.2.17 */ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* storage for unknown chunk that the library doesn't recognize. */ png_unknown_chunk unknown_chunk; #endif }; /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ typedef png_structp version_1_2_20; typedef png_struct * * png_structpp; /* Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. */ /* Returns the version number of the library */ extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void)); /* Tell lib we have already handled the first magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start, png_size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num)); /* Allocate and initialize png_ptr struct for reading, and any other memory. */ extern PNG_EXPORT(png_structp,png_create_read_struct) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)); /* Allocate and initialize png_ptr struct for writing, and any other memory */ extern PNG_EXPORT(png_structp,png_create_write_struct) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)); #ifdef PNG_WRITE_SUPPORTED extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size) PNGARG((png_structp png_ptr)); #endif #ifdef PNG_WRITE_SUPPORTED extern PNG_EXPORT(void,png_set_compression_buffer_size) PNGARG((png_structp png_ptr, png_uint_32 size)); #endif /* Reset the compression stream */ extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr)); /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED extern PNG_EXPORT(png_structp,png_create_read_struct_2) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); extern PNG_EXPORT(png_structp,png_create_write_struct_2) PNGARG((png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); #endif /* Write a PNG chunk - size, type, (optional) data, CRC. */ extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr, png_bytep chunk_name, png_bytep data, png_size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr, png_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr)); /* Allocate and initialize the info structure */ extern PNG_EXPORT(png_infop,png_create_info_struct) PNGARG((png_structp png_ptr)); #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* Initialize the info structure (old interface - DEPRECATED) */ extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr)); #undef png_info_init #define png_info_init(info_ptr) png_info_init_3(&info_ptr,\ png_sizeof(png_info)); #endif extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr, png_size_t png_info_struct_size)); /* Writes all the PNG information before the image. */ extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr, png_infop info_ptr)); extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* read the information before the actual image data. */ extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) PNGARG((png_structp png_ptr, png_timep ptime)); #endif #if !defined(_WIN32_WCE) /* "time.h" functions are not supported on WindowsCE */ #if defined(PNG_WRITE_tIME_SUPPORTED) /* convert from a struct tm to png_time */ extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, struct tm * ttime)); /* convert from time_t to png_time. Uses gmtime() */ extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, time_t ttime)); #endif /* PNG_WRITE_tIME_SUPPORTED */ #endif /* _WIN32_WCE */ #if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr)); #if !defined(PNG_1_0_X) extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); #endif extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr)); #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* Deprecated */ extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr)); #endif #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* Expand the grayscale to 24-bit RGB if necessary. */ extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) /* Reduce RGB to grayscale. */ #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr, int error_action, double red, double green )); #endif extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr, int error_action, png_fixed_point red, png_fixed_point green )); extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp png_ptr)); #endif extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth, png_colorp palette)); #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ #define PNG_FILLER_BEFORE 0 #define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ #if !defined(PNG_1_0_X) extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr, png_uint_32 filler, int flags)); #endif #endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr, png_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Have the code handle the interlacing. Returns the number of passes. */ extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) /* Handle alpha and tRNS by replacing with a background color. */ #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)); #endif #define PNG_BACKGROUND_GAMMA_UNKNOWN 0 #define PNG_BACKGROUND_GAMMA_SCREEN 1 #define PNG_BACKGROUND_GAMMA_FILE 2 #define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) /* strip the second byte of information from a 16-bit depth file. */ extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_DITHER_SUPPORTED) /* Turn on dithering, and reduce the palette to the number of colors available. */ extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither)); #endif #if defined(PNG_READ_GAMMA_SUPPORTED) /* Handle gamma correction. Screen_gamma=(display_exponent) */ #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr, double screen_gamma, double default_file_gamma)); #endif #endif #if defined(PNG_1_0_X) || defined (PNG_1_2_X) #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) /* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */ /* Deprecated and will be removed. Use png_permit_mng_features() instead. */ extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr, int empty_plte_permitted)); #endif #endif #if defined(PNG_WRITE_FLUSH_SUPPORTED) /* Set how many lines between output flushes - 0 for no flushing */ extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); /* Flush the current PNG output buffer */ extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); #endif /* optional update palette with requested transformations */ extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); /* optional call to update the users info structure */ extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* read one or more rows of image data. */ extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* read a row of data. */ extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* read the whole image into memory at once. */ extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, png_bytepp image)); #endif /* write a row of image data */ extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, png_bytep row)); /* write a few rows of image data */ extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, png_bytepp row, png_uint_32 num_rows)); /* write the image data */ extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, png_bytepp image)); /* writes the end of the PNG file. */ extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* read the end of the PNG file. */ extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif /* free any memory associated with the png_info_struct */ extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, png_infopp info_ptr_ptr)); /* free any memory associated with the png_struct and the png_info_structs */ extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); /* free all memory used by the read (old method - NOT DLL EXPORTED) */ extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)); /* free any memory associated with the png_struct and the png_info_structs */ extern PNG_EXPORT(void,png_destroy_write_struct) PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); /* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ extern void png_write_destroy PNGARG((png_structp png_ptr)); /* set the libpng method of handling chunk CRC errors */ extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, int crit_action, int ancil_action)); /* Values for png_set_crc_action() to say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, * whereas in version 0.90 and later, the action for CRC errors in ancillary * chunks is warn/discard. These values should NOT be changed. * * value action:critical action:ancillary */ #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ /* These functions give the user control over the scan-line filtering in * libpng and the compression methods used by zlib. These functions are * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library * header file (zlib.h) for an explination of the compression functions. */ /* set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, int filters)); /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. * These values should NOT be changed. */ #define PNG_NO_FILTERS 0x00 #define PNG_FILTER_NONE 0x08 #define PNG_FILTER_SUB 0x10 #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 #define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. */ #define PNG_FILTER_VALUE_NONE 0 #define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_UP 2 #define PNG_FILTER_VALUE_AVG 3 #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 #if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ * defines, either the default (minimum-sum-of-absolute-differences), or * the experimental method (weighted-minimum-sum-of-absolute-differences). * * Weights are factors >= 1.0, indicating how important it is to keep the * filter type consistent between rows. Larger numbers mean the current * filter is that many times as likely to be the same as the "num_weights" * previous filters. This is cumulative for each previous row with a weight. * There needs to be "num_weights" values in "filter_weights", or it can be * NULL if the weights aren't being specified. Weights have no influence on * the selection of the first row filter. Well chosen weights can (in theory) * improve the compression for a given image. * * Costs are factors >= 1.0 indicating the relative decoding costs of a * filter type. Higher costs indicate more decoding expense, and are * therefore less likely to be selected over a filter with lower computational * costs. There needs to be a value in "filter_costs" for each valid filter * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't * setting the costs. Costs try to improve the speed of decompression without * unduly increasing the compressed image size. * * A negative weight or cost indicates the default value is to be used, and * values in the range [0.0, 1.0) indicate the value is to remain unchanged. * The default values for both weights and costs are currently 1.0, but may * change if good general weighting/cost heuristics can be found. If both * the weights and costs are set to 1.0, this degenerates the WEIGHTED method * to the UNWEIGHTED method, but with added encoding time/computation. */ #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr, int heuristic_method, int num_weights, png_doublep filter_weights, png_doublep filter_costs)); #endif #endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ /* Heuristic used for row filter selection. These defines should NOT be * changed. */ #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr, int level)); extern PNG_EXPORT(void,png_set_compression_mem_level) PNGARG((png_structp png_ptr, int mem_level)); extern PNG_EXPORT(void,png_set_compression_strategy) PNGARG((png_structp png_ptr, int strategy)); extern PNG_EXPORT(void,png_set_compression_window_bits) PNGARG((png_structp png_ptr, int window_bits)); extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr, int method)); /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a * different manner by calling png_set_???_fn(). See libpng.txt for * more information. */ #if !defined(PNG_NO_STDIO) /* Initialize the input/output for the PNG file to the default functions. */ extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still * write and use replacement functions. The replacement error_fn should * still do a longjmp to the last setjmp location if you are using this * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). */ extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr, png_read_status_ptr read_row_fn)); extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr, png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr) PNGARG((png_structp png_ptr)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); /* returns the user pointer associated with the push read functions */ extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) PNGARG((png_structp png_ptr)); /* function to be called when data becomes available */ extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); /* function that combines rows. Not very much different than the * png_combine_row() call. Is this even used????? */ extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, png_bytep old_row, png_bytep new_row)); #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr, png_uint_32 size)); #if defined(PNG_1_0_X) # define png_malloc_warn png_malloc #else /* Added at libpng version 1.2.4 */ extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, png_uint_32 size)); #endif /* frees a pointer allocated by png_malloc() */ extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); #if defined(PNG_1_0_X) /* Function to allocate memory for zlib. */ extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items, uInt size)); /* Function to free memory for zlib */ extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr)); #endif /* Free data that was allocated internally */ extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num)); #ifdef PNG_FREE_ME_SUPPORTED /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application */ extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask)); #endif /* assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ #define PNG_FREE_HIST 0x0008 #define PNG_FREE_ICCP 0x0010 #define PNG_FREE_SPLT 0x0020 #define PNG_FREE_ROWS 0x0040 #define PNG_FREE_PCAL 0x0080 #define PNG_FREE_SCAL 0x0100 #define PNG_FREE_UNKN 0x0200 #define PNG_FREE_LIST 0x0400 #define PNG_FREE_PLTE 0x1000 #define PNG_FREE_TRNS 0x2000 #define PNG_FREE_TEXT 0x4000 #define PNG_FREE_ALL 0x7fff #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr, png_uint_32 size)); extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr, png_voidp ptr)); #endif extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr, png_voidp s1, png_voidp s2, png_uint_32 size)); extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr, png_voidp s1, int value, png_uint_32 size)); #if defined(USE_FAR_KEYWORD) /* memory model conversion function */ extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr, int check)); #endif /* USE_FAR_KEYWORD */ #ifndef PNG_NO_ERROR_TEXT /* Fatal error in PNG image of libpng - can't continue */ extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr, png_const_charp error_message)); /* The same, but the chunk name is prepended to the error string. */ extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr, png_const_charp error_message)); #else /* Fatal error in PNG image of libpng - can't continue */ extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr)); #endif #ifndef PNG_NO_WARNINGS /* Non-fatal error in libpng. Can continue, but may have a problem. */ extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr, png_const_charp warning_message)); #ifdef PNG_READ_SUPPORTED /* Non-fatal error in libpng, chunk name is prepended to message. */ extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr, png_const_charp warning_message)); #endif /* PNG_READ_SUPPORTED */ #endif /* PNG_NO_WARNINGS */ /* The png_set_ functions are for storing values in the png_info_struct. * Similarly, the png_get_ calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or * setting pointers into the png_info_struct where the data is stored. The * png_get_ functions return a non-zero value if the data was available * in info_ptr, or return zero and do not change any of the parameters if the * data was not available. * * These functions should be used instead of directly accessing png_info * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr, png_infop info_ptr)); #if defined(PNG_INFO_IMAGE_SUPPORTED) /* Returns row_pointers, which is an array of pointers to scanlines that was returned from png_read_png(). */ extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use by png_write_png(). */ extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image height in pixels. */ extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image bit_depth. */ extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image color_type. */ extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image filter_type. */ extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image interlace_type. */ extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image compression_type. */ extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp png_ptr, png_infop info_ptr)); extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp png_ptr, png_infop info_ptr)); extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp png_ptr, png_infop info_ptr)); extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp png_ptr, png_infop info_ptr)); extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp png_ptr, png_infop info_ptr)); extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif /* PNG_EASY_ACCESS_SUPPORTED */ /* Returns pointer to signature string read from PNG header */ extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr, png_infop info_ptr)); #if defined(PNG_bKGD_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr, png_infop info_ptr, png_color_16p *background)); #endif #if defined(PNG_bKGD_SUPPORTED) extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr, png_infop info_ptr, png_color_16p background)); #endif #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr, png_infop info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)); #endif #ifdef PNG_FIXED_POINT_SUPPORTED extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr, png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)); #endif #endif #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)); #endif #ifdef PNG_FIXED_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr, png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)); #endif #endif #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr, png_infop info_ptr, double *file_gamma)); #endif extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr, png_infop info_ptr, png_fixed_point *int_file_gamma)); #endif #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr, png_infop info_ptr, double file_gamma)); #endif extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr, png_infop info_ptr, png_fixed_point int_file_gamma)); #endif #if defined(PNG_hIST_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)); #endif #if defined(PNG_hIST_SUPPORTED) extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)); #endif extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)); #if defined(PNG_oFFs_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr, png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif #if defined(PNG_oFFs_SUPPORTED) extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr, png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)); #endif #if defined(PNG_pCAL_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr, png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)); #endif #if defined(PNG_pCAL_SUPPORTED) extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr, png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)); #endif #if defined(PNG_pHYs_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #if defined(PNG_pHYs_SUPPORTED) extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette)); extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr, png_infop info_ptr, png_colorp palette, int num_palette)); #if defined(PNG_sBIT_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)); #endif #if defined(PNG_sBIT_SUPPORTED) extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit)); #endif #if defined(PNG_sRGB_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr, png_infop info_ptr, int *intent)); #endif #if defined(PNG_sRGB_SUPPORTED) extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr, png_infop info_ptr, int intent)); extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr, png_infop info_ptr, int intent)); #endif #if defined(PNG_iCCP_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr, png_infop info_ptr, png_charpp name, int *compression_type, png_charpp profile, png_uint_32 *proflen)); /* Note to maintainer: profile should be png_bytepp */ #endif #if defined(PNG_iCCP_SUPPORTED) extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr, png_infop info_ptr, png_charp name, int compression_type, png_charp profile, png_uint_32 proflen)); /* Note to maintainer: profile should be png_bytep */ #endif #if defined(PNG_sPLT_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr, png_infop info_ptr, png_sPLT_tpp entries)); #endif #if defined(PNG_sPLT_SUPPORTED) extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr, png_infop info_ptr, png_sPLT_tp entries, int nentries)); #endif #if defined(PNG_TEXT_SUPPORTED) /* png_get_text also returns the number of text chunks in *num_text */ extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, int *num_text)); #endif /* * Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure * returned by png_get_text will always contain regular * zero-terminated C strings. They might be empty strings but * they will never be NULL pointers. */ #if defined(PNG_TEXT_SUPPORTED) extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text)); #endif #if defined(PNG_tIME_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)); #endif #if defined(PNG_tIME_SUPPORTED) extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr, png_infop info_ptr, png_timep mod_time)); #endif #if defined(PNG_tRNS_SUPPORTED) extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values)); #endif #if defined(PNG_tRNS_SUPPORTED) extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, png_color_16p trans_values)); #endif #if defined(PNG_tRNS_SUPPORTED) #endif #if defined(PNG_sCAL_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr, png_infop info_ptr, int *unit, double *width, double *height)); #else #ifdef PNG_FIXED_POINT_SUPPORTED extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr, png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); #endif #endif #endif /* PNG_sCAL_SUPPORTED */ #if defined(PNG_sCAL_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr, png_infop info_ptr, int unit, double width, double height)); #else #ifdef PNG_FIXED_POINT_SUPPORTED extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, png_infop info_ptr, int unit, png_charp swidth, png_charp sheight)); #endif #endif #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) /* provide a list of chunks and how they are to be handled, if the built-in handling or default unknown chunk handling is not desired. Any chunks not listed will be handled in the default manner. The IHDR and IEND chunks must not be listed. keep = 0: follow default behaviour = 1: do not keep = 2: keep only if safe-to-copy = 3: keep even if unsafe-to-copy */ extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp png_ptr, int keep, png_bytep chunk_list, int num_chunks)); extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); extern PNG_EXPORT(void, png_set_unknown_chunk_location) PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location)); extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); #endif #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep chunk_name)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. If you need to turn it off for a chunk that your application has freed, you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, png_infop info_ptr, int mask)); #if defined(PNG_INFO_IMAGE_SUPPORTED) /* The "params" pointer is currently not used and is for future expansion. */ extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr, png_infop info_ptr, int transforms, png_voidp params)); extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, png_infop info_ptr, int transforms, png_voidp params)); #endif /* Define PNG_DEBUG at compile time for debugging information. Higher * numbers for PNG_DEBUG mean more debugging information. This has * only been added since version 0.95 so it is not implemented throughout * libpng yet, but more support will be added as needed. */ #ifdef PNG_DEBUG #if (PNG_DEBUG > 0) #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) #include #if (PNG_DEBUG > 1) #define png_debug(l,m) _RPT0(_CRT_WARN,m) #define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) #define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) #endif #else /* PNG_DEBUG_FILE || !_MSC_VER */ #ifndef PNG_DEBUG_FILE #define PNG_DEBUG_FILE stderr #endif /* PNG_DEBUG_FILE */ #if (PNG_DEBUG > 1) #define png_debug(l,m) \ { \ int num_tabs=l; \ fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ } #define png_debug1(l,m,p1) \ { \ int num_tabs=l; \ fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ } #define png_debug2(l,m,p1,p2) \ { \ int num_tabs=l; \ fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ } #endif /* (PNG_DEBUG > 1) */ #endif /* _MSC_VER */ #endif /* (PNG_DEBUG > 0) */ #endif /* PNG_DEBUG */ #ifndef png_debug #define png_debug(l, m) #endif #ifndef png_debug1 #define png_debug1(l, m, p1) #endif #ifndef png_debug2 #define png_debug2(l, m, p1, p2) #endif extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 /* Added to version 1.2.0 */ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) #if defined(PNG_MMX_CODE_SUPPORTED) #define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */ #define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */ #define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04 #define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08 #define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10 #define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20 #define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40 #define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80 #define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */ #define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ | PNG_ASM_FLAG_MMX_READ_INTERLACE \ | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ) #define PNG_MMX_WRITE_FLAGS ( 0 ) #define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \ | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \ | PNG_MMX_READ_FLAGS \ | PNG_MMX_WRITE_FLAGS ) #define PNG_SELECT_READ 1 #define PNG_SELECT_WRITE 2 #endif /* PNG_MMX_CODE_SUPPORTED */ #if !defined(PNG_1_0_X) /* pngget.c */ extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask) PNGARG((int flag_select, int *compilerID)); /* pngget.c */ extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask) PNGARG((int flag_select)); /* pngget.c */ extern PNG_EXPORT(png_uint_32,png_get_asm_flags) PNGARG((png_structp png_ptr)); /* pngget.c */ extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold) PNGARG((png_structp png_ptr)); /* pngget.c */ extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold) PNGARG((png_structp png_ptr)); /* pngset.c */ extern PNG_EXPORT(void,png_set_asm_flags) PNGARG((png_structp png_ptr, png_uint_32 asm_flags)); /* pngset.c */ extern PNG_EXPORT(void,png_set_mmx_thresholds) PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold, png_uint_32 mmx_rowbytes_threshold)); #endif /* PNG_1_0_X */ #if !defined(PNG_1_0_X) /* png.c, pnggccrd.c, or pngvcrd.c */ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp png_ptr, png_uint_32 strip_mode)); #endif #endif /* PNG_1_0_X */ /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp png_ptr)); extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp png_ptr)); #endif /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. * * Note that the rounding factors are NOT supposed to be the same! 128 and * 32768 are correct for the NODIV code; 127 and 32767 are correct for the * standard method. * * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ # define png_composite(composite, fg, alpha, bg) \ { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \ + (png_uint_16)(bg)*(png_uint_16)(255 - \ (png_uint_16)(alpha)) + (png_uint_16)128); \ (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } # define png_composite_16(composite, fg, alpha, bg) \ { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \ + (png_uint_32)(bg)*(png_uint_32)(65535L - \ (png_uint_32)(alpha)) + (png_uint_32)32768L); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } #else /* standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ (png_uint_16)127) / 255) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \ (png_uint_32)32767) / (png_uint_32)65535L) #endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ /* Inline macros to do direct reads of bytes from the input buffer. These * require that you are using an architecture that uses PNG byte ordering * (MSB first) and supports unaligned data storage. I think that PowerPC * in big-endian mode and 680x0 are the only ones that will support this. * The x86 line of processors definitely do not. The png_get_int_32() * routine also assumes we are using two's complement format for negative * values, which is almost certainly true. */ #if defined(PNG_READ_BIG_ENDIAN_SUPPORTED) # define png_get_uint_32(buf) ( *((png_uint_32p) (buf))) # define png_get_uint_16(buf) ( *((png_uint_16p) (buf))) # define png_get_int_32(buf) ( *((png_int_32p) (buf))) #else extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf)); extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf)); extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf)); #endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */ extern PNG_EXPORT(png_uint_32,png_get_uint_31) PNGARG((png_structp png_ptr, png_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ extern PNG_EXPORT(void,png_save_uint_32) PNGARG((png_bytep buf, png_uint_32 i)); extern PNG_EXPORT(void,png_save_int_32) PNGARG((png_bytep buf, png_int_32 i)); /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ extern PNG_EXPORT(void,png_save_uint_16) PNGARG((png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ /* *** */ /* These next functions are used internally in the code. They generally * shouldn't be used unless you are writing code to add or replace some * functionality in libpng. More information about most functions can * be found in the files where the functions are located. */ /* Various modes of operation, that are visible to applications because * they are used for unknown chunk location. */ #define PNG_HAVE_IHDR 0x01 #define PNG_HAVE_PLTE 0x02 #define PNG_HAVE_IDAT 0x04 #define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */ #define PNG_HAVE_IEND 0x10 #if defined(PNG_INTERNAL) /* More modes of operation. Note that after an init, mode is set to * zero automatically when the structure is created. */ #define PNG_HAVE_gAMA 0x20 #define PNG_HAVE_cHRM 0x40 #define PNG_HAVE_sRGB 0x80 #define PNG_HAVE_CHUNK_HEADER 0x100 #define PNG_WROTE_tIME 0x200 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400 #define PNG_BACKGROUND_IS_GRAY 0x800 #define PNG_HAVE_PNG_SIGNATURE 0x1000 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ /* flags for the transformations the PNG library does on the image data */ #define PNG_BGR 0x0001 #define PNG_INTERLACE 0x0002 #define PNG_PACK 0x0004 #define PNG_SHIFT 0x0008 #define PNG_SWAP_BYTES 0x0010 #define PNG_INVERT_MONO 0x0020 #define PNG_DITHER 0x0040 #define PNG_BACKGROUND 0x0080 #define PNG_BACKGROUND_EXPAND 0x0100 /* 0x0200 unused */ #define PNG_16_TO_8 0x0400 #define PNG_RGBA 0x0800 #define PNG_EXPAND 0x1000 #define PNG_GAMMA 0x2000 #define PNG_GRAY_TO_RGB 0x4000 #define PNG_FILLER 0x8000L #define PNG_PACKSWAP 0x10000L #define PNG_SWAP_ALPHA 0x20000L #define PNG_STRIP_ALPHA 0x40000L #define PNG_INVERT_ALPHA 0x80000L #define PNG_USER_TRANSFORM 0x100000L #define PNG_RGB_TO_GRAY_ERR 0x200000L #define PNG_RGB_TO_GRAY_WARN 0x400000L #define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */ /* 0x800000L Unused */ #define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */ #define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */ /* 0x4000000L unused */ /* 0x8000000L unused */ /* 0x10000000L unused */ /* 0x20000000L unused */ /* 0x40000000L unused */ /* flags for png_create_struct */ #define PNG_STRUCT_PNG 0x0001 #define PNG_STRUCT_INFO 0x0002 /* Scaling factor for filter heuristic weighting calculations */ #define PNG_WEIGHT_SHIFT 8 #define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT)) #define PNG_COST_SHIFT 3 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) /* flags for the png_ptr->flags rather than declaring a byte for each one */ #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 #define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008 #define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010 #define PNG_FLAG_ZLIB_FINISHED 0x0020 #define PNG_FLAG_ROW_INIT 0x0040 #define PNG_FLAG_FILLER_AFTER 0x0080 #define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 #define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 #define PNG_FLAG_CRC_CRITICAL_USE 0x0400 #define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 #define PNG_FLAG_FREE_PLTE 0x1000 #define PNG_FLAG_FREE_TRNS 0x2000 #define PNG_FLAG_FREE_HIST 0x4000 #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L #define PNG_FLAG_LIBRARY_MISMATCH 0x20000L #define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L #define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L #define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L #define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */ #define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */ /* 0x800000L unused */ /* 0x1000000L unused */ /* 0x2000000L unused */ /* 0x4000000L unused */ /* 0x8000000L unused */ /* 0x10000000L unused */ /* 0x20000000L unused */ /* 0x40000000L unused */ #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ PNG_FLAG_CRC_ANCILLARY_NOWARN) #define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ PNG_FLAG_CRC_CRITICAL_IGNORE) #define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ PNG_FLAG_CRC_CRITICAL_MASK) /* save typing and make code easier to understand */ #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ abs((int)((c1).green) - (int)((c2).green)) + \ abs((int)((c1).blue) - (int)((c2).blue))) /* Added to libpng-1.2.6 JB */ #define PNG_ROWBYTES(pixel_bits, width) \ ((pixel_bits) >= 8 ? \ ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \ (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) /* PNG_OUT_OF_RANGE returns true if value is outside the range ideal-delta..ideal+delta. Each argument is evaluated twice. "ideal" and "delta" should be constants, normally simple integers, "value" a variable. Added to libpng-1.2.6 JB */ #define PNG_OUT_OF_RANGE(value, ideal, delta) \ ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) /* place to hold the signature string for a PNG file. */ #ifdef PNG_USE_GLOBAL_ARRAYS PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; #else #endif #endif /* PNG_NO_EXTERN */ /* Constant strings for known chunk types. If you need to add a chunk, * define the name here, and add an invocation of the macro in png.c and * wherever it's needed. */ #define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'} #define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'} #define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'} #define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'} #define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'} #define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'} #define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'} #define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'} #define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'} #define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'} #define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'} #define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'} #define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'} #define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'} #define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'} #define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'} #define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'} #define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'} #define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'} #define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'} #define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'} #ifdef PNG_USE_GLOBAL_ARRAYS PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5]; PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5]; #endif /* PNG_USE_GLOBAL_ARRAYS */ #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* Initialize png_ptr struct for reading, and allocate any other memory. * (old interface - DEPRECATED - use png_create_read_struct instead). */ extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr)); #undef png_read_init #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \ PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); #endif extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr, png_const_charp user_png_ver, png_size_t png_struct_size)); #if defined(PNG_1_0_X) || defined (PNG_1_2_X) extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size)); #endif #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* Initialize png_ptr struct for writing, and allocate any other memory. * (old interface - DEPRECATED - use png_create_write_struct instead). */ extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr)); #undef png_write_init #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \ PNG_LIBPNG_VER_STRING, png_sizeof(png_struct)); #endif extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr, png_const_charp user_png_ver, png_size_t png_struct_size)); extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size)); /* Allocate memory for an internal libpng struct */ PNG_EXTERN png_voidp png_create_struct PNGARG((int type)); /* Free memory from internal libpng struct */ PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr)); PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)); PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr)); /* Free any memory that info_ptr points to and reset struct. */ PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_1_0_X /* Function to allocate memory for zlib. */ PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size)); /* Function to free memory for zlib */ PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); #ifdef PNG_SIZE_T /* Function to convert a sizeof an item to png_sizeof item */ PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); #endif /* Next four functions are used internally as callbacks. PNGAPI is required * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr, png_bytep buffer, png_size_t length)); #endif PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); #if defined(PNG_WRITE_FLUSH_SUPPORTED) #if !defined(PNG_NO_STDIO) PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr)); #endif #endif #else /* PNG_1_0_X */ #ifdef PNG_PROGRESSIVE_READ_SUPPORTED PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr, png_bytep buffer, png_size_t length)); #endif #endif /* PNG_1_0_X */ /* Reset the CRC variable */ PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr)); /* Write the "data" buffer to whatever output you are using. */ PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); /* Read data from whatever input you are using into the "data" buffer */ PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); /* Read bytes into buf, and update png_ptr->crc */ PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, png_size_t length)); /* Decompress data in a chunk that uses compression */ #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, int comp_type, png_charp chunkdata, png_size_t chunklength, png_size_t prefix_length, png_size_t *data_length)); #endif /* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip)); /* Read the CRC from the file and compare it to the libpng calculated CRC */ PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr)); /* Calculate the CRC over a section of data. Note that we are only * passing a maximum of 64K on systems that have this as a memory limit, * since this is the maximum buffer size we can specify. */ PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, png_size_t length)); #if defined(PNG_WRITE_FLUSH_SUPPORTED) PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); #endif /* simple function to write the signature */ PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); /* write various chunks */ /* Write the IHDR chunk, and update the png_struct with the necessary * information. */ PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int compression_method, int filter_method, int interlace_method)); PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)); PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr)); #if defined(PNG_WRITE_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma)); #endif #ifdef PNG_FIXED_POINT_SUPPORTED PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point file_gamma)); #endif #endif #if defined(PNG_WRITE_sBIT_SUPPORTED) PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit, int color_type)); #endif #if defined(PNG_WRITE_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)); #endif #ifdef PNG_FIXED_POINT_SUPPORTED PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)); #endif #endif #if defined(PNG_WRITE_sRGB_SUPPORTED) PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr, int intent)); #endif #if defined(PNG_WRITE_iCCP_SUPPORTED) PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr, png_charp name, int compression_type, png_charp profile, int proflen)); /* Note to maintainer: profile should be png_bytep */ #endif #if defined(PNG_WRITE_sPLT_SUPPORTED) PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr, png_sPLT_tp palette)); #endif #if defined(PNG_WRITE_tRNS_SUPPORTED) PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans, png_color_16p values, int number, int color_type)); #endif #if defined(PNG_WRITE_bKGD_SUPPORTED) PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr, png_color_16p values, int color_type)); #endif #if defined(PNG_WRITE_hIST_SUPPORTED) PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist, int num_hist)); #endif #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr, png_charp key, png_charpp new_key)); #endif #if defined(PNG_WRITE_tEXt_SUPPORTED) PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len)); #endif #if defined(PNG_WRITE_zTXt_SUPPORTED) PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len, int compression)); #endif #if defined(PNG_WRITE_iTXt_SUPPORTED) PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr, int compression, png_charp key, png_charp lang, png_charp lang_key, png_charp text)); #endif #if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */ PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text)); #endif #if defined(PNG_WRITE_oFFs_SUPPORTED) PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type)); #endif #if defined(PNG_WRITE_pCAL_SUPPORTED) PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)); #endif #if defined(PNG_WRITE_pHYs_SUPPORTED) PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, int unit_type)); #endif #if defined(PNG_WRITE_tIME_SUPPORTED) PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr, png_timep mod_time)); #endif #if defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr, int unit, double width, double height)); #else #ifdef PNG_FIXED_POINT_SUPPORTED PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr, int unit, png_charp width, png_charp height)); #endif #endif #endif /* Called when finished processing a row of data */ PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr)); /* Internal use only. Called before first row of data */ PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); #if defined(PNG_READ_GAMMA_SUPPORTED) PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); #endif /* combine a row of data, dealing with alpha, etc. if requested */ PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, int mask)); #if defined(PNG_READ_INTERLACING_SUPPORTED) /* expand an interlaced row */ /* OLD pre-1.0.9 interface: PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations)); */ PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); #endif /* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ #if defined(PNG_WRITE_INTERLACING_SUPPORTED) /* grab pixels out of a row for an interlaced pass */ PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, png_bytep row, int pass)); #endif /* unfilter a row */ PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); /* Choose the best filter to use and filter the row data */ PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, png_row_infop row_info)); /* Write out the filtered row. */ PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, png_bytep filtered_row)); /* finish a row while reading, dealing with interlacing passes, etc. */ PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); /* initialize the row buffers, etc. */ PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); /* optional call to update the users info structure */ PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, png_infop info_ptr)); /* these are the functions that do the transformations */ #if defined(PNG_READ_FILLER_SUPPORTED) PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info, png_bytep row, png_uint_32 flags)); #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED) PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_PACK_SUPPORTED) PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row, png_color_8p sig_bits)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_READ_DITHER_SUPPORTED) PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info, png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)); # if defined(PNG_CORRECT_PALETTE_SUPPORTED) PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr, png_colorp palette, int num_palette)); # endif #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_WRITE_PACK_SUPPORTED) PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)); #endif #if defined(PNG_WRITE_SHIFT_SUPPORTED) PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row, png_color_8p bit_depth)); #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_GAMMA_SUPPORTED) PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, png_color_16p trans_values, png_color_16p background, png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int gamma_shift)); #else PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row, png_color_16p trans_values, png_color_16p background)); #endif #endif #if defined(PNG_READ_GAMMA_SUPPORTED) PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row, png_bytep gamma_table, png_uint_16pp gamma_16_table, int gamma_shift)); #endif #if defined(PNG_READ_EXPAND_SUPPORTED) PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info, png_bytep row, png_colorp palette, png_bytep trans, int num_trans)); PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, png_bytep row, png_color_16p trans_value)); #endif /* The following decodes the appropriate chunks, and does error correction, * then calls the appropriate callback for the chunk if it is valid. */ /* decode the IHDR chunk */ PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #if defined(PNG_READ_bKGD_SUPPORTED) PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_cHRM_SUPPORTED) PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_gAMA_SUPPORTED) PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_hIST_SUPPORTED) PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_iCCP_SUPPORTED) extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif /* PNG_READ_iCCP_SUPPORTED */ #if defined(PNG_READ_iTXt_SUPPORTED) PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_oFFs_SUPPORTED) PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_pCAL_SUPPORTED) PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_pHYs_SUPPORTED) PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_sBIT_SUPPORTED) PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_sCAL_SUPPORTED) PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_sPLT_SUPPORTED) extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif /* PNG_READ_sPLT_SUPPORTED */ #if defined(PNG_READ_sRGB_SUPPORTED) PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_tEXt_SUPPORTED) PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_tIME_SUPPORTED) PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_tRNS_SUPPORTED) PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif #if defined(PNG_READ_zTXt_SUPPORTED) PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); #endif PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, png_bytep chunk_name)); /* handle the transformations for reading and writing */ PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr)); PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr, png_uint_32 length)); PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr)); PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr)); PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr, png_bytep buffer, png_size_t buffer_length)); PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr)); PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr, png_bytep buffer, png_size_t buffer_length)); PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr)); PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row)); PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr)); #if defined(PNG_READ_tEXt_SUPPORTED) PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif #if defined(PNG_READ_zTXt_SUPPORTED) PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif #if defined(PNG_READ_iTXt_SUPPORTED) PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ #ifdef PNG_MNG_FEATURES_SUPPORTED PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info, png_bytep row)); PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info, png_bytep row)); #endif #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) #if defined(PNG_MMX_CODE_SUPPORTED) /* png.c */ /* PRIVATE */ PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr)); #endif #endif #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr, png_infop info_ptr)); PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr, png_infop info_ptr)); #if defined(PNG_pHYs_SUPPORTED) PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ /* do not put anything past this line */ #endif /* PNG_H */ wgd-3.1/include/wgd/png/Makefile.am0000755000175000001440000000011111044044157014073 00000000000000pkgincludedir = $(includedir)/wgd/png pkginclude_HEADERS=pngconf.h png.h wgd-3.1/include/wgd/png/pngconf.h0000644000175000001440000012703010643336777013671 00000000000000 /* pngconf.h - machine configurable file for libpng * * libpng version 1.2.20 - September 8, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ /* Any machine specific code is near the front of this file, so if you * are configuring libpng for a machine, you may want to read the section * starting here down to where it starts to typedef png_color, png_text, * and png_info. */ #ifndef PNGCONF_H #define PNGCONF_H #define PNG_1_2_X /* * PNG_USER_CONFIG has to be defined on the compiler command line. This * includes the resource compiler for Windows DLL configurations. */ #ifdef PNG_USER_CONFIG # ifndef PNG_USER_PRIVATEBUILD # define PNG_USER_PRIVATEBUILD # endif #include "pngusr.h" #endif /* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */ #ifdef PNG_CONFIGURE_LIBPNG #ifdef HAVE_CONFIG_H #include "config.h" #endif #endif /* * Added at libpng-1.2.8 * * If you create a private DLL you need to define in "pngusr.h" the followings: * #define PNG_USER_PRIVATEBUILD * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons." * #define PNG_USER_DLLFNAME_POSTFIX * e.g. // private DLL "libpng13gx.dll" * #define PNG_USER_DLLFNAME_POSTFIX "gx" * * The following macros are also at your disposal if you want to complete the * DLL VERSIONINFO structure. * - PNG_USER_VERSIONINFO_COMMENTS * - PNG_USER_VERSIONINFO_COMPANYNAME * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS */ #ifdef __STDC__ #ifdef SPECIALBUILD # pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\ are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.") #endif #ifdef PRIVATEBUILD # pragma message("PRIVATEBUILD is deprecated.\ Use PNG_USER_PRIVATEBUILD instead.") # define PNG_USER_PRIVATEBUILD PRIVATEBUILD #endif #endif /* __STDC__ */ #ifndef PNG_VERSION_INFO_ONLY /* End of material added to libpng-1.2.8 */ /* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble # define PNG_WARN_UNINITIALIZED_ROW 1 */ /* End of material added at libpng-1.2.19 */ /* This is the size of the compression buffer, and thus the size of * an IDAT chunk. Make this whatever size you feel is best for your * machine. One of these will be allocated per png_struct. When this * is full, it writes the data to the disk, and does some other * calculations. Making this an extremely small size will slow * the library down, but you may want to experiment to determine * where it becomes significant, if you are concerned with memory * usage. Note that zlib allocates at least 32Kb also. For readers, * this describes the size of the buffer available to read the data in. * Unless this gets smaller than the size of a row (compressed), * it should not make much difference how big this is. */ #ifndef PNG_ZBUF_SIZE # define PNG_ZBUF_SIZE 8192 #endif /* Enable if you want a write-only libpng */ #ifndef PNG_NO_READ_SUPPORTED # define PNG_READ_SUPPORTED #endif /* Enable if you want a read-only libpng */ //#ifndef PNG_NO_WRITE_SUPPORTED //# define PNG_WRITE_SUPPORTED //#endif /* Enabled by default in 1.2.0. You can disable this if you don't need to support PNGs that are embedded in MNG datastreams */ #if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES) # ifndef PNG_MNG_FEATURES_SUPPORTED # define PNG_MNG_FEATURES_SUPPORTED # endif #endif #ifndef PNG_NO_FLOATING_POINT_SUPPORTED # ifndef PNG_FLOATING_POINT_SUPPORTED # define PNG_FLOATING_POINT_SUPPORTED # endif #endif /* If you are running on a machine where you cannot allocate more * than 64K of memory at once, uncomment this. While libpng will not * normally need that much memory in a chunk (unless you load up a very * large file), zlib needs to know how big of a chunk it can use, and * libpng thus makes sure to check any memory allocation to verify it * will fit into memory. #define PNG_MAX_MALLOC_64K */ #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) # define PNG_MAX_MALLOC_64K #endif /* Special munging to support doing things the 'cygwin' way: * 'Normal' png-on-win32 defines/defaults: * PNG_BUILD_DLL -- building dll * PNG_USE_DLL -- building an application, linking to dll * (no define) -- building static library, or building an * application and linking to the static lib * 'Cygwin' defines/defaults: * PNG_BUILD_DLL -- (ignored) building the dll * (no define) -- (ignored) building an application, linking to the dll * PNG_STATIC -- (ignored) building the static lib, or building an * application that links to the static lib. * ALL_STATIC -- (ignored) building various static libs, or building an * application that links to the static libs. * Thus, * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and * this bit of #ifdefs will define the 'correct' config variables based on * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but * unnecessary. * * Also, the precedence order is: * ALL_STATIC (since we can't #undef something outside our namespace) * PNG_BUILD_DLL * PNG_STATIC * (nothing) == PNG_USE_DLL * * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent * of auto-import in binutils, we no longer need to worry about * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes * to __declspec() stuff. However, we DO need to worry about * PNG_BUILD_DLL and PNG_STATIC because those change some defaults * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. */ #if defined(__CYGWIN__) # if defined(ALL_STATIC) # if defined(PNG_BUILD_DLL) # undef PNG_BUILD_DLL # endif # if defined(PNG_USE_DLL) # undef PNG_USE_DLL # endif # if defined(PNG_DLL) # undef PNG_DLL # endif # if !defined(PNG_STATIC) # define PNG_STATIC # endif # else # if defined (PNG_BUILD_DLL) # if defined(PNG_STATIC) # undef PNG_STATIC # endif # if defined(PNG_USE_DLL) # undef PNG_USE_DLL # endif # if !defined(PNG_DLL) # define PNG_DLL # endif # else # if defined(PNG_STATIC) # if defined(PNG_USE_DLL) # undef PNG_USE_DLL # endif # if defined(PNG_DLL) # undef PNG_DLL # endif # else # if !defined(PNG_USE_DLL) # define PNG_USE_DLL # endif # if !defined(PNG_DLL) # define PNG_DLL # endif # endif # endif # endif #endif /* This protects us against compilers that run on a windowing system * and thus don't have or would rather us not use the stdio types: * stdin, stdout, and stderr. The only one currently used is stderr * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will * prevent these from being compiled and used. #defining PNG_NO_STDIO * will also prevent these, plus will prevent the entire set of stdio * macros and functions (FILE *, printf, etc.) from being compiled and used, * unless (PNG_DEBUG > 0) has been #defined. * * #define PNG_NO_CONSOLE_IO * #define PNG_NO_STDIO */ #if defined(_WIN32_WCE) # include /* Console I/O functions are not supported on WindowsCE */ # define PNG_NO_CONSOLE_IO # ifdef PNG_DEBUG # undef PNG_DEBUG # endif #endif #ifdef PNG_BUILD_DLL # ifndef PNG_CONSOLE_IO_SUPPORTED # ifndef PNG_NO_CONSOLE_IO # define PNG_NO_CONSOLE_IO # endif # endif #endif # ifdef PNG_NO_STDIO # ifndef PNG_NO_CONSOLE_IO # define PNG_NO_CONSOLE_IO # endif # ifdef PNG_DEBUG # if (PNG_DEBUG > 0) # include # endif # endif # else # if !defined(_WIN32_WCE) /* "stdio.h" functions are not supported on WindowsCE */ # include # endif # endif /* This macro protects us against machines that don't have function * prototypes (ie K&R style headers). If your compiler does not handle * function prototypes, define this macro and use the included ansi2knr. * I've always been able to use _NO_PROTO as the indicator, but you may * need to drag the empty declaration out in front of here, or change the * ifdef to suit your own needs. */ #ifndef PNGARG #ifdef OF /* zlib prototype munger */ # define PNGARG(arglist) OF(arglist) #else #ifdef _NO_PROTO # define PNGARG(arglist) () # ifndef PNG_TYPECAST_NULL # define PNG_TYPECAST_NULL # endif #else # define PNGARG(arglist) arglist #endif /* _NO_PROTO */ #endif /* OF */ #endif /* PNGARG */ /* Try to determine if we are compiling on a Mac. Note that testing for * just __MWERKS__ is not good enough, because the Codewarrior is now used * on non-Mac platforms. */ #ifndef MACOS # if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) # define MACOS # endif #endif /* enough people need this for various reasons to include it here */ #if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE) # include #endif #if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED) # define PNG_SETJMP_SUPPORTED #endif #ifdef PNG_SETJMP_SUPPORTED /* This is an attempt to force a single setjmp behaviour on Linux. If * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. */ # ifdef __linux__ # ifdef _BSD_SOURCE # define PNG_SAVE_BSD_SOURCE # undef _BSD_SOURCE # endif # ifdef _SETJMP_H /* If you encounter a compiler error here, see the explanation * near the end of INSTALL. */ __png.h__ already includes setjmp.h; __dont__ include it again.; # endif # endif /* __linux__ */ /* include setjmp.h for error handling */ # include # ifdef __linux__ # ifdef PNG_SAVE_BSD_SOURCE # define _BSD_SOURCE # undef PNG_SAVE_BSD_SOURCE # endif # endif /* __linux__ */ #endif /* PNG_SETJMP_SUPPORTED */ #ifdef BSD # include #else # include #endif /* Other defines for things like memory and the like can go here. */ #ifdef PNG_INTERNAL #include /* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which * aren't usually used outside the library (as far as I know), so it is * debatable if they should be exported at all. In the future, when it is * possible to have run-time registry of chunk-handling functions, some of * these will be made available again. #define PNG_EXTERN extern */ #define PNG_EXTERN /* Other defines specific to compilers can go here. Try to keep * them inside an appropriate ifdef/endif pair for portability. */ #if defined(PNG_FLOATING_POINT_SUPPORTED) # if defined(MACOS) /* We need to check that hasn't already been included earlier * as it seems it doesn't agree with , yet we should really use * if possible. */ # if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) # include # endif # else # include # endif # if defined(_AMIGA) && defined(__SASC) && defined(_M68881) /* Amiga SAS/C: We must include builtin FPU functions when compiling using * MATH=68881 */ # include # endif #endif /* Codewarrior on NT has linking problems without this. */ #if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__) # define PNG_ALWAYS_EXTERN #endif /* This provides the non-ANSI (far) memory allocation routines. */ #if defined(__TURBOC__) && defined(__MSDOS__) # include # include #endif /* I have no idea why is this necessary... */ #if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \ defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__)) # include #endif /* This controls how fine the dithering gets. As this allocates * a largish chunk of memory (32K), those who are not as concerned * with dithering quality can decrease some or all of these. */ #ifndef PNG_DITHER_RED_BITS # define PNG_DITHER_RED_BITS 5 #endif #ifndef PNG_DITHER_GREEN_BITS # define PNG_DITHER_GREEN_BITS 5 #endif #ifndef PNG_DITHER_BLUE_BITS # define PNG_DITHER_BLUE_BITS 5 #endif /* This controls how fine the gamma correction becomes when you * are only interested in 8 bits anyway. Increasing this value * results in more memory being used, and more pow() functions * being called to fill in the gamma tables. Don't set this value * less then 8, and even that may not work (I haven't tested it). */ #ifndef PNG_MAX_GAMMA_8 # define PNG_MAX_GAMMA_8 11 #endif /* This controls how much a difference in gamma we can tolerate before * we actually start doing gamma conversion. */ #ifndef PNG_GAMMA_THRESHOLD # define PNG_GAMMA_THRESHOLD 0.05 #endif #endif /* PNG_INTERNAL */ /* The following uses const char * instead of char * for error * and warning message functions, so some compilers won't complain. * If you do not want to use const, define PNG_NO_CONST here. */ #ifndef PNG_NO_CONST # define PNG_CONST const #else # define PNG_CONST #endif /* The following defines give you the ability to remove code from the * library that you will not be using. I wish I could figure out how to * automate this, but I can't do that without making it seriously hard * on the users. So if you are not using an ability, change the #define * to and #undef, and that part of the library will not be compiled. If * your linker can't find a function, you may want to make sure the * ability is defined here. Some of these depend upon some others being * defined. I haven't figured out all the interactions here, so you may * have to experiment awhile to get everything to compile. If you are * creating or using a shared library, you probably shouldn't touch this, * as it will affect the size of the structures, and this will cause bad * things to happen if the library and/or application ever change. */ /* Any features you will not be using can be undef'ed here */ /* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS * on the compile line, then pick and choose which ones to define without * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED * if you only want to have a png-compliant reader/writer but don't need * any of the extra transformations. This saves about 80 kbytes in a * typical installation of the library. (PNG_NO_* form added in version * 1.0.1c, for consistency) */ /* The size of the png_text structure changed in libpng-1.0.6 when * iTXt support was added. iTXt support was turned off by default through * libpng-1.2.x, to support old apps that malloc the png_text structure * instead of calling png_set_text() and letting libpng malloc it. It * was turned on by default in libpng-1.3.0. */ #if defined(PNG_1_0_X) || defined (PNG_1_2_X) # ifndef PNG_NO_iTXt_SUPPORTED # define PNG_NO_iTXt_SUPPORTED # endif # ifndef PNG_NO_READ_iTXt # define PNG_NO_READ_iTXt # endif # ifndef PNG_NO_WRITE_iTXt # define PNG_NO_WRITE_iTXt # endif #endif #if !defined(PNG_NO_iTXt_SUPPORTED) # if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt) # define PNG_READ_iTXt # endif # if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt) # define PNG_WRITE_iTXt # endif #endif /* The following support, added after version 1.0.0, can be turned off here en * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility * with old applications that require the length of png_struct and png_info * to remain unchanged. */ #ifdef PNG_LEGACY_SUPPORTED # define PNG_NO_FREE_ME # define PNG_NO_READ_UNKNOWN_CHUNKS # define PNG_NO_WRITE_UNKNOWN_CHUNKS # define PNG_NO_READ_USER_CHUNKS # define PNG_NO_READ_iCCP # define PNG_NO_WRITE_iCCP # define PNG_NO_READ_iTXt # define PNG_NO_WRITE_iTXt # define PNG_NO_READ_sCAL # define PNG_NO_WRITE_sCAL # define PNG_NO_READ_sPLT # define PNG_NO_WRITE_sPLT # define PNG_NO_INFO_IMAGE # define PNG_NO_READ_RGB_TO_GRAY # define PNG_NO_READ_USER_TRANSFORM # define PNG_NO_WRITE_USER_TRANSFORM # define PNG_NO_USER_MEM # define PNG_NO_READ_EMPTY_PLTE # define PNG_NO_MNG_FEATURES # define PNG_NO_FIXED_POINT_SUPPORTED #endif /* Ignore attempt to turn off both floating and fixed point support */ #if !defined(PNG_FLOATING_POINT_SUPPORTED) || \ !defined(PNG_NO_FIXED_POINT_SUPPORTED) # define PNG_FIXED_POINT_SUPPORTED #endif #ifndef PNG_NO_FREE_ME # define PNG_FREE_ME_SUPPORTED #endif #if defined(PNG_READ_SUPPORTED) #if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ !defined(PNG_NO_READ_TRANSFORMS) # define PNG_READ_TRANSFORMS_SUPPORTED #endif #ifdef PNG_READ_TRANSFORMS_SUPPORTED # ifndef PNG_NO_READ_EXPAND # define PNG_READ_EXPAND_SUPPORTED # endif # ifndef PNG_NO_READ_SHIFT # define PNG_READ_SHIFT_SUPPORTED # endif # ifndef PNG_NO_READ_PACK # define PNG_READ_PACK_SUPPORTED # endif # ifndef PNG_NO_READ_BGR # define PNG_READ_BGR_SUPPORTED # endif # ifndef PNG_NO_READ_SWAP # define PNG_READ_SWAP_SUPPORTED # endif # ifndef PNG_NO_READ_PACKSWAP # define PNG_READ_PACKSWAP_SUPPORTED # endif # ifndef PNG_NO_READ_INVERT # define PNG_READ_INVERT_SUPPORTED # endif # ifndef PNG_NO_READ_DITHER # define PNG_READ_DITHER_SUPPORTED # endif # ifndef PNG_NO_READ_BACKGROUND # define PNG_READ_BACKGROUND_SUPPORTED # endif # ifndef PNG_NO_READ_16_TO_8 # define PNG_READ_16_TO_8_SUPPORTED # endif # ifndef PNG_NO_READ_FILLER # define PNG_READ_FILLER_SUPPORTED # endif # ifndef PNG_NO_READ_GAMMA # define PNG_READ_GAMMA_SUPPORTED # endif # ifndef PNG_NO_READ_GRAY_TO_RGB # define PNG_READ_GRAY_TO_RGB_SUPPORTED # endif # ifndef PNG_NO_READ_SWAP_ALPHA # define PNG_READ_SWAP_ALPHA_SUPPORTED # endif # ifndef PNG_NO_READ_INVERT_ALPHA # define PNG_READ_INVERT_ALPHA_SUPPORTED # endif # ifndef PNG_NO_READ_STRIP_ALPHA # define PNG_READ_STRIP_ALPHA_SUPPORTED # endif # ifndef PNG_NO_READ_USER_TRANSFORM # define PNG_READ_USER_TRANSFORM_SUPPORTED # endif # ifndef PNG_NO_READ_RGB_TO_GRAY # define PNG_READ_RGB_TO_GRAY_SUPPORTED # endif #endif /* PNG_READ_TRANSFORMS_SUPPORTED */ #if !defined(PNG_NO_PROGRESSIVE_READ) && \ !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */ # define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */ #endif /* about interlacing capability! You'll */ /* still have interlacing unless you change the following line: */ #define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */ #ifndef PNG_NO_READ_COMPOSITE_NODIV # ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */ # define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */ # endif #endif #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* Deprecated, will be removed from version 2.0.0. Use PNG_MNG_FEATURES_SUPPORTED instead. */ #ifndef PNG_NO_READ_EMPTY_PLTE # define PNG_READ_EMPTY_PLTE_SUPPORTED #endif #endif #endif /* PNG_READ_SUPPORTED */ #if defined(PNG_WRITE_SUPPORTED) # if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ !defined(PNG_NO_WRITE_TRANSFORMS) # define PNG_WRITE_TRANSFORMS_SUPPORTED #endif #ifdef PNG_WRITE_TRANSFORMS_SUPPORTED # ifndef PNG_NO_WRITE_SHIFT # define PNG_WRITE_SHIFT_SUPPORTED # endif # ifndef PNG_NO_WRITE_PACK # define PNG_WRITE_PACK_SUPPORTED # endif # ifndef PNG_NO_WRITE_BGR # define PNG_WRITE_BGR_SUPPORTED # endif # ifndef PNG_NO_WRITE_SWAP # define PNG_WRITE_SWAP_SUPPORTED # endif # ifndef PNG_NO_WRITE_PACKSWAP # define PNG_WRITE_PACKSWAP_SUPPORTED # endif # ifndef PNG_NO_WRITE_INVERT # define PNG_WRITE_INVERT_SUPPORTED # endif # ifndef PNG_NO_WRITE_FILLER # define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */ # endif # ifndef PNG_NO_WRITE_SWAP_ALPHA # define PNG_WRITE_SWAP_ALPHA_SUPPORTED # endif # ifndef PNG_NO_WRITE_INVERT_ALPHA # define PNG_WRITE_INVERT_ALPHA_SUPPORTED # endif # ifndef PNG_NO_WRITE_USER_TRANSFORM # define PNG_WRITE_USER_TRANSFORM_SUPPORTED # endif #endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */ #if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \ !defined(PNG_WRITE_INTERLACING_SUPPORTED) #define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant encoders, but can cause trouble if left undefined */ #endif #if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \ !defined(PNG_WRITE_WEIGHTED_FILTER) && \ defined(PNG_FLOATING_POINT_SUPPORTED) # define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #endif #ifndef PNG_NO_WRITE_FLUSH # define PNG_WRITE_FLUSH_SUPPORTED #endif #if defined(PNG_1_0_X) || defined (PNG_1_2_X) /* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */ #ifndef PNG_NO_WRITE_EMPTY_PLTE # define PNG_WRITE_EMPTY_PLTE_SUPPORTED #endif #endif #endif /* PNG_WRITE_SUPPORTED */ #ifndef PNG_1_0_X # ifndef PNG_NO_ERROR_NUMBERS # define PNG_ERROR_NUMBERS_SUPPORTED # endif #endif /* PNG_1_0_X */ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) # ifndef PNG_NO_USER_TRANSFORM_PTR # define PNG_USER_TRANSFORM_PTR_SUPPORTED # endif #endif #ifndef PNG_NO_STDIO # define PNG_TIME_RFC1123_SUPPORTED #endif /* This adds extra functions in pngget.c for accessing data from the * info pointer (added in version 0.99) * png_get_image_width() * png_get_image_height() * png_get_bit_depth() * png_get_color_type() * png_get_compression_type() * png_get_filter_type() * png_get_interlace_type() * png_get_pixel_aspect_ratio() * png_get_pixels_per_meter() * png_get_x_offset_pixels() * png_get_y_offset_pixels() * png_get_x_offset_microns() * png_get_y_offset_microns() */ #if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED) # define PNG_EASY_ACCESS_SUPPORTED #endif /* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 * and removed from version 1.2.20. The following will be removed * from libpng-1.4.0 */ #if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE) # ifndef PNG_OPTIMIZED_CODE_SUPPORTED # define PNG_OPTIMIZED_CODE_SUPPORTED # endif #endif #if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE) # ifndef PNG_ASSEMBLER_CODE_SUPPORTED # define PNG_ASSEMBLER_CODE_SUPPORTED # endif # if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4) /* work around 64-bit gcc compiler bugs in gcc-3.x */ # if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) # define PNG_NO_MMX_CODE # endif # endif # if defined(__APPLE__) # if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) # define PNG_NO_MMX_CODE # endif # endif # if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh)) # if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) # define PNG_NO_MMX_CODE # endif # endif # if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE) # define PNG_MMX_CODE_SUPPORTED # endif #endif /* end of obsolete code to be removed from libpng-1.4.0 */ #if !defined(PNG_1_0_X) #if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED) # define PNG_USER_MEM_SUPPORTED #endif #endif /* PNG_1_0_X */ /* Added at libpng-1.2.6 */ #if !defined(PNG_1_0_X) #ifndef PNG_SET_USER_LIMITS_SUPPORTED #if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED) # define PNG_SET_USER_LIMITS_SUPPORTED #endif #endif #endif /* PNG_1_0_X */ /* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter * how large, set these limits to 0x7fffffffL */ #ifndef PNG_USER_WIDTH_MAX # define PNG_USER_WIDTH_MAX 1000000L #endif #ifndef PNG_USER_HEIGHT_MAX # define PNG_USER_HEIGHT_MAX 1000000L #endif /* These are currently experimental features, define them if you want */ /* very little testing */ /* #ifdef PNG_READ_SUPPORTED # ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED # define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED # endif #endif */ /* This is only for PowerPC big-endian and 680x0 systems */ /* some testing */ /* #ifndef PNG_READ_BIG_ENDIAN_SUPPORTED # define PNG_READ_BIG_ENDIAN_SUPPORTED #endif */ /* Buggy compilers (e.g., gcc 2.7.2.2) need this */ /* #define PNG_NO_POINTER_INDEXING */ /* These functions are turned off by default, as they will be phased out. */ /* #define PNG_USELESS_TESTS_SUPPORTED #define PNG_CORRECT_PALETTE_SUPPORTED */ /* Any chunks you are not interested in, you can undef here. The * ones that allocate memory may be expecially important (hIST, * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info * a bit smaller. */ #if defined(PNG_READ_SUPPORTED) && \ !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ !defined(PNG_NO_READ_ANCILLARY_CHUNKS) # define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #endif #if defined(PNG_WRITE_SUPPORTED) && \ !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \ !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS) # define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #endif #ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #ifdef PNG_NO_READ_TEXT # define PNG_NO_READ_iTXt # define PNG_NO_READ_tEXt # define PNG_NO_READ_zTXt #endif #ifndef PNG_NO_READ_bKGD # define PNG_READ_bKGD_SUPPORTED # define PNG_bKGD_SUPPORTED #endif #ifndef PNG_NO_READ_cHRM # define PNG_READ_cHRM_SUPPORTED # define PNG_cHRM_SUPPORTED #endif #ifndef PNG_NO_READ_gAMA # define PNG_READ_gAMA_SUPPORTED # define PNG_gAMA_SUPPORTED #endif #ifndef PNG_NO_READ_hIST # define PNG_READ_hIST_SUPPORTED # define PNG_hIST_SUPPORTED #endif #ifndef PNG_NO_READ_iCCP # define PNG_READ_iCCP_SUPPORTED # define PNG_iCCP_SUPPORTED #endif #ifndef PNG_NO_READ_iTXt # ifndef PNG_READ_iTXt_SUPPORTED # define PNG_READ_iTXt_SUPPORTED # endif # ifndef PNG_iTXt_SUPPORTED # define PNG_iTXt_SUPPORTED # endif #endif #ifndef PNG_NO_READ_oFFs # define PNG_READ_oFFs_SUPPORTED # define PNG_oFFs_SUPPORTED #endif #ifndef PNG_NO_READ_pCAL # define PNG_READ_pCAL_SUPPORTED # define PNG_pCAL_SUPPORTED #endif #ifndef PNG_NO_READ_sCAL # define PNG_READ_sCAL_SUPPORTED # define PNG_sCAL_SUPPORTED #endif #ifndef PNG_NO_READ_pHYs # define PNG_READ_pHYs_SUPPORTED # define PNG_pHYs_SUPPORTED #endif #ifndef PNG_NO_READ_sBIT # define PNG_READ_sBIT_SUPPORTED # define PNG_sBIT_SUPPORTED #endif #ifndef PNG_NO_READ_sPLT # define PNG_READ_sPLT_SUPPORTED # define PNG_sPLT_SUPPORTED #endif #ifndef PNG_NO_READ_sRGB # define PNG_READ_sRGB_SUPPORTED # define PNG_sRGB_SUPPORTED #endif #ifndef PNG_NO_READ_tEXt # define PNG_READ_tEXt_SUPPORTED # define PNG_tEXt_SUPPORTED #endif #ifndef PNG_NO_READ_tIME # define PNG_READ_tIME_SUPPORTED # define PNG_tIME_SUPPORTED #endif #ifndef PNG_NO_READ_tRNS # define PNG_READ_tRNS_SUPPORTED # define PNG_tRNS_SUPPORTED #endif #ifndef PNG_NO_READ_zTXt # define PNG_READ_zTXt_SUPPORTED # define PNG_zTXt_SUPPORTED #endif #ifndef PNG_NO_READ_UNKNOWN_CHUNKS # define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED # define PNG_UNKNOWN_CHUNKS_SUPPORTED # endif # ifndef PNG_NO_HANDLE_AS_UNKNOWN # define PNG_HANDLE_AS_UNKNOWN_SUPPORTED # endif #endif #if !defined(PNG_NO_READ_USER_CHUNKS) && \ defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) # define PNG_READ_USER_CHUNKS_SUPPORTED # define PNG_USER_CHUNKS_SUPPORTED # ifdef PNG_NO_READ_UNKNOWN_CHUNKS # undef PNG_NO_READ_UNKNOWN_CHUNKS # endif # ifdef PNG_NO_HANDLE_AS_UNKNOWN # undef PNG_NO_HANDLE_AS_UNKNOWN # endif #endif #ifndef PNG_NO_READ_OPT_PLTE # define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ #endif /* optional PLTE chunk in RGB and RGBA images */ #if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ defined(PNG_READ_zTXt_SUPPORTED) # define PNG_READ_TEXT_SUPPORTED # define PNG_TEXT_SUPPORTED #endif #endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ #ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #ifdef PNG_NO_WRITE_TEXT # define PNG_NO_WRITE_iTXt # define PNG_NO_WRITE_tEXt # define PNG_NO_WRITE_zTXt #endif #ifndef PNG_NO_WRITE_bKGD # define PNG_WRITE_bKGD_SUPPORTED # ifndef PNG_bKGD_SUPPORTED # define PNG_bKGD_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_cHRM # define PNG_WRITE_cHRM_SUPPORTED # ifndef PNG_cHRM_SUPPORTED # define PNG_cHRM_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_gAMA # define PNG_WRITE_gAMA_SUPPORTED # ifndef PNG_gAMA_SUPPORTED # define PNG_gAMA_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_hIST # define PNG_WRITE_hIST_SUPPORTED # ifndef PNG_hIST_SUPPORTED # define PNG_hIST_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_iCCP # define PNG_WRITE_iCCP_SUPPORTED # ifndef PNG_iCCP_SUPPORTED # define PNG_iCCP_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_iTXt # ifndef PNG_WRITE_iTXt_SUPPORTED # define PNG_WRITE_iTXt_SUPPORTED # endif # ifndef PNG_iTXt_SUPPORTED # define PNG_iTXt_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_oFFs # define PNG_WRITE_oFFs_SUPPORTED # ifndef PNG_oFFs_SUPPORTED # define PNG_oFFs_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_pCAL # define PNG_WRITE_pCAL_SUPPORTED # ifndef PNG_pCAL_SUPPORTED # define PNG_pCAL_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_sCAL # define PNG_WRITE_sCAL_SUPPORTED # ifndef PNG_sCAL_SUPPORTED # define PNG_sCAL_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_pHYs # define PNG_WRITE_pHYs_SUPPORTED # ifndef PNG_pHYs_SUPPORTED # define PNG_pHYs_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_sBIT # define PNG_WRITE_sBIT_SUPPORTED # ifndef PNG_sBIT_SUPPORTED # define PNG_sBIT_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_sPLT # define PNG_WRITE_sPLT_SUPPORTED # ifndef PNG_sPLT_SUPPORTED # define PNG_sPLT_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_sRGB # define PNG_WRITE_sRGB_SUPPORTED # ifndef PNG_sRGB_SUPPORTED # define PNG_sRGB_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_tEXt # define PNG_WRITE_tEXt_SUPPORTED # ifndef PNG_tEXt_SUPPORTED # define PNG_tEXt_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_tIME # define PNG_WRITE_tIME_SUPPORTED # ifndef PNG_tIME_SUPPORTED # define PNG_tIME_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_tRNS # define PNG_WRITE_tRNS_SUPPORTED # ifndef PNG_tRNS_SUPPORTED # define PNG_tRNS_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_zTXt # define PNG_WRITE_zTXt_SUPPORTED # ifndef PNG_zTXt_SUPPORTED # define PNG_zTXt_SUPPORTED # endif #endif #ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS # define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED # define PNG_UNKNOWN_CHUNKS_SUPPORTED # endif # ifndef PNG_NO_HANDLE_AS_UNKNOWN # ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED # define PNG_HANDLE_AS_UNKNOWN_SUPPORTED # endif # endif #endif #if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ defined(PNG_WRITE_zTXt_SUPPORTED) # define PNG_WRITE_TEXT_SUPPORTED # ifndef PNG_TEXT_SUPPORTED # define PNG_TEXT_SUPPORTED # endif #endif #endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ /* Turn this off to disable png_read_png() and * png_write_png() and leave the row_pointers member * out of the info structure. */ #ifndef PNG_NO_INFO_IMAGE # define PNG_INFO_IMAGE_SUPPORTED #endif /* need the time information for reading tIME chunks */ #if defined(PNG_tIME_SUPPORTED) # if !defined(_WIN32_WCE) /* "time.h" functions are not supported on WindowsCE */ # include # endif #endif /* Some typedefs to get us started. These should be safe on most of the * common platforms. The typedefs should be at least as large as the * numbers suggest (a png_uint_32 must be at least 32 bits long), but they * don't have to be exactly that size. Some compilers dislike passing * unsigned shorts as function parameters, so you may be better off using * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may * want to have unsigned int for png_uint_32 instead of unsigned long. */ typedef unsigned int png_uint_32; typedef long png_int_32; typedef unsigned short png_uint_16; typedef short png_int_16; typedef unsigned char png_byte; /* This is usually size_t. It is typedef'ed just in case you need it to change (I'm not sure if you will or not, so I thought I'd be safe) */ #ifdef PNG_SIZE_T typedef PNG_SIZE_T png_size_t; # define png_sizeof(x) png_convert_size(sizeof (x)) #else typedef size_t png_size_t; # define png_sizeof(x) sizeof (x) #endif /* The following is needed for medium model support. It cannot be in the * PNG_INTERNAL section. Needs modification for other compilers besides * MSC. Model independent support declares all arrays and pointers to be * large using the far keyword. The zlib version used must also support * model independent data. As of version zlib 1.0.4, the necessary changes * have been made in zlib. The USE_FAR_KEYWORD define triggers other * changes that are needed. (Tim Wegner) */ /* Separate compiler dependencies (problem here is that zlib.h always defines FAR. (SJT) */ #ifdef __BORLANDC__ # if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) # define LDATA 1 # else # define LDATA 0 # endif /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ # if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) # define PNG_MAX_MALLOC_64K # if (LDATA != 1) # ifndef FAR # define FAR __far # endif # define USE_FAR_KEYWORD # endif /* LDATA != 1 */ /* Possibly useful for moving data out of default segment. * Uncomment it if you want. Could also define FARDATA as * const if your compiler supports it. (SJT) # define FARDATA FAR */ # endif /* __WIN32__, __FLAT__, __CYGWIN__ */ #endif /* __BORLANDC__ */ /* Suggest testing for specific compiler first before testing for * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, * making reliance oncertain keywords suspect. (SJT) */ /* MSC Medium model */ #if defined(FAR) # if defined(M_I86MM) # define USE_FAR_KEYWORD # define FARDATA FAR # include # endif #endif /* SJT: default case */ #ifndef FAR # define FAR #endif /* At this point FAR is always defined */ #ifndef FARDATA # define FARDATA #endif /* Typedef for floating-point numbers that are converted to fixed-point with a multiple of 100,000, e.g., int_gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void * png_voidp; typedef png_byte * png_bytep; typedef png_uint_32 * png_uint_32p; typedef png_int_32 * png_int_32p; typedef png_uint_16 * png_uint_16p; typedef png_int_16 * png_int_16p; typedef PNG_CONST char * png_const_charp; typedef char * png_charp; typedef png_fixed_point * png_fixed_point_p; #ifndef PNG_NO_STDIO #if defined(_WIN32_WCE) typedef HANDLE png_FILE_p; #else typedef FILE * png_FILE_p; #endif #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * png_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte * * png_bytepp; typedef png_uint_32 * * png_uint_32pp; typedef png_int_32 * * png_int_32pp; typedef png_uint_16 * * png_uint_16pp; typedef png_int_16 * * png_int_16pp; typedef PNG_CONST char * * png_const_charpp; typedef char * * png_charpp; typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char * * * png_charppp; #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* SPC - Is this stuff deprecated? */ /* It'll be removed as of libpng-1.3.0 - GR-P */ /* libpng typedefs for types in zlib. If zlib changes * or another compression library is used, then change these. * Eliminates need to change all the source files. */ typedef charf * png_zcharp; typedef charf * * png_zcharpp; typedef z_stream * png_zstreamp; #endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */ /* * Define PNG_BUILD_DLL if the module being built is a Windows * LIBPNG DLL. * * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL. * It is equivalent to Microsoft predefined macro _DLL that is * automatically defined when you compile using the share * version of the CRT (C Run-Time library) * * The cygwin mods make this behavior a little different: * Define PNG_BUILD_DLL if you are building a dll for use with cygwin * Define PNG_STATIC if you are building a static library for use with cygwin, * -or- if you are building an application that you want to link to the * static library. * PNG_USE_DLL is defined by default (no user action needed) unless one of * the other flags is defined. */ #if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL)) # define PNG_DLL #endif /* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib. * When building a static lib, default to no GLOBAL ARRAYS, but allow * command-line override */ #if defined(__CYGWIN__) # if !defined(PNG_STATIC) # if defined(PNG_USE_GLOBAL_ARRAYS) # undef PNG_USE_GLOBAL_ARRAYS # endif # if !defined(PNG_USE_LOCAL_ARRAYS) # define PNG_USE_LOCAL_ARRAYS # endif # else # if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS) # if defined(PNG_USE_GLOBAL_ARRAYS) # undef PNG_USE_GLOBAL_ARRAYS # endif # endif # endif # if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) # define PNG_USE_LOCAL_ARRAYS # endif #endif /* Do not use global arrays (helps with building DLL's) * They are no longer used in libpng itself, since version 1.0.5c, * but might be required for some pre-1.0.5c applications. */ #if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS) # if defined(PNG_NO_GLOBAL_ARRAYS) || \ (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER) # define PNG_USE_LOCAL_ARRAYS # else # define PNG_USE_GLOBAL_ARRAYS # endif #endif #if defined(__CYGWIN__) # undef PNGAPI # define PNGAPI __cdecl # undef PNG_IMPEXP # define PNG_IMPEXP #endif /* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", * you may get warnings regarding the linkage of png_zalloc and png_zfree. * Don't ignore those warnings; you must also reset the default calling * convention in your compiler to match your PNGAPI, and you must build * zlib and your applications the same way you build libpng. */ #if defined(__MINGW32__) && !defined(PNG_MODULEDEF) # ifndef PNG_NO_MODULEDEF # define PNG_NO_MODULEDEF # endif #endif #if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF) # define PNG_IMPEXP #endif #if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \ (( defined(_Windows) || defined(_WINDOWS) || \ defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) # ifndef PNGAPI # if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) # define PNGAPI __cdecl # else # define PNGAPI _cdecl # endif # endif # if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \ 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */) # define PNG_IMPEXP # endif # if !defined(PNG_IMPEXP) # define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol # define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol /* Borland/Microsoft */ # if defined(_MSC_VER) || defined(__BORLANDC__) # if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500) # define PNG_EXPORT PNG_EXPORT_TYPE1 # else # define PNG_EXPORT PNG_EXPORT_TYPE2 # if defined(PNG_BUILD_DLL) # define PNG_IMPEXP __export # else # define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in VC++ */ # endif /* Exists in Borland C++ for C++ classes (== huge) */ # endif # endif # if !defined(PNG_IMPEXP) # if defined(PNG_BUILD_DLL) # define PNG_IMPEXP __declspec(dllexport) # else # define PNG_IMPEXP __declspec(dllimport) # endif # endif # endif /* PNG_IMPEXP */ #else /* !(DLL || non-cygwin WINDOWS) */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # ifndef PNGAPI # define PNGAPI _System # endif # else # if 0 /* ... other platforms, with other meanings */ # endif # endif #endif #ifndef PNGAPI # define PNGAPI #endif #ifndef PNG_IMPEXP # define PNG_IMPEXP #endif #ifdef PNG_BUILDSYMS # ifndef PNG_EXPORT # define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END # endif # ifdef PNG_USE_GLOBAL_ARRAYS # ifndef PNG_EXPORT_VAR # define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT # endif # endif #endif #ifndef PNG_EXPORT # define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol #endif #ifdef PNG_USE_GLOBAL_ARRAYS # ifndef PNG_EXPORT_VAR # define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type # endif #endif /* User may want to use these so they are not in PNG_INTERNAL. Any library * functions that are passed far data must be model independent. */ #ifndef PNG_ABORT # define PNG_ABORT() abort() #endif #ifdef PNG_SETJMP_SUPPORTED # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED) #endif #if defined(USE_FAR_KEYWORD) /* memory model independent fns */ /* use this to make far-to-near assignments */ # define CHECK 1 # define NOCHECK 0 # define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK)) # define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK)) # define png_snprintf _fsnprintf /* Added to v 1.2.19 */ # define png_strcpy _fstrcpy # define png_strncpy _fstrncpy /* Added to v 1.2.6 */ # define png_strlen _fstrlen # define png_memcmp _fmemcmp /* SJT: added */ # define png_memcpy _fmemcpy # define png_memset _fmemset #else /* use the usual functions */ # define CVT_PTR(ptr) (ptr) # define CVT_PTR_NOCHECK(ptr) (ptr) # ifndef PNG_NO_SNPRINTF # ifdef _MSC_VER # define png_snprintf _snprintf /* Added to v 1.2.19 */ # define png_snprintf2 _snprintf # define png_snprintf6 _snprintf # else # define png_snprintf snprintf /* Added to v 1.2.19 */ # define png_snprintf2 snprintf # define png_snprintf6 snprintf # endif # else /* You don't have or don't want to use snprintf(). Caution: Using * sprintf instead of snprintf exposes your application to accidental * or malevolent buffer overflows. If you don't have snprintf() * as a general rule you should provide one (you can get one from * Portable OpenSSH). */ # define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1) # define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2) # define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \ sprintf(s1,fmt,x1,x2,x3,x4,x5,x6) # endif # define png_strcpy strcpy # define png_strncpy strncpy /* Added to v 1.2.6 */ # define png_strlen strlen # define png_memcmp memcmp /* SJT: added */ # define png_memcpy memcpy # define png_memset memset #endif /* End of memory model independent support */ /* Just a little check that someone hasn't tried to define something * contradictory. */ #if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) # undef PNG_ZBUF_SIZE # define PNG_ZBUF_SIZE 65536L #endif /* Added at libpng-1.2.8 */ #endif /* PNG_VERSION_INFO_ONLY */ #endif /* PNGCONF_H */ wgd-3.1/include/wgd/png/Makefile.in0000644000175000001440000002611711265575054014131 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = include/wgd/png DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(pkgincludedir)" pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(pkginclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/wgd/png ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pkginclude_HEADERS = pngconf.h png.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps include/wgd/png/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps include/wgd/png/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ ctags distclean distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-pkgincludeHEADERS install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ uninstall uninstall-am uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/include/wgd/iline.h0000644000175000001440000000131311233311615012522 00000000000000#ifndef _WGD_ILINE_H_ #define _WGD_ILINE_H_ #include #include #include namespace wgd { class BASE3DIMPORT ILine3D : public wgd::Instance3D { public: ILine3D(const doste::dvm::OID&); ~ILine3D(); OBJECT(Instance3D, ILine3D); PROPERTY_RF(vector3d, point1, "point1"); PROPERTY_WF(vector3d, point1, "point1"); PROPERTY_RF(vector3d, point2, "point2"); PROPERTY_WF(vector3d, point2, "point2"); PROPERTY_RF(wgd::colour, colour, "colour"); PROPERTY_WF(wgd::colour, colour, "colour"); PROPERTY_RF(int, width, "width"); PROPERTY_WF(int, width, "width"); virtual void draw(SceneGraph &graph, Camera3D *camera); }; }; #endif wgd-3.1/include/wgd/heightmapsource.h0000644000175000001440000000246511065123720014623 00000000000000#ifndef _WGD_HEIGHTMAP_SOURCE_ #define _WGD_HEIGHTMAP_SOURCE_ #include #include namespace wgd { /** * This class is where the heightmap data comes from, be it from a texture, streamed from * a file or procedurally generated. It must create HMRegion objects to store the heightmap data. */ class HEIGHTMAPIMPORT HeightmapSource : public doste::Agent { public: VOBJECT(Agent, HeightmapSource); HeightmapSource() : Agent() {} HeightmapSource(const doste::dvm::OID &o) : Agent(o) {} virtual ~HeightmapSource() {}; /** * number of vertices along a side of the region This does not include the extra overlap vertices * and therefore must be a multiple of patchsize. */ int regionSize() const { return m_size; } /** begin and end drawing of the height map so you know when to delete unused regions */ virtual void begin() {}; virtual void end() {}; /** * Get the region at region coordinates (x, y). * This will create the region asynchronously if it does not exist * and return either null, or a default flat region until it is loaded. * */ virtual HMRegion *region(int x, int y) = 0; protected: void regionSize(int s) { m_size = s; } private: int m_size; }; }; #endif wgd-3.1/include/wgd/vector.h0000644000175000001440000003431611233311615012735 00000000000000#ifndef _WGDVECTOR_ #define _WGDVECTOR_ #include #include #include #include #include #ifndef __SSE__ #define __SSE__ #endif #ifdef __SSE__ #include #endif #ifdef _MSC_VER #pragma warning(disable:4251) #pragma warning(disable:4275) #endif //Crazy macro to shorten events #include #define EVENT_VECTOR(A,B) EVENT(A,B(wgd::ix::x)(doste::dvm::modifiers::Seq)B(wgd::ix::y)(doste::dvm::modifiers::Seq)B(wgd::ix::z)(doste::dvm::modifiers::Seq)B) namespace wgd { class matrix; class quaternion; class vector3d; /** * A two dimensional floating point vector. All common vector * operations are supported, mostly through operator * overloading so you can to c = a+b to add vectors. */ class vector2d { public: float x; float y; vector2d(const doste::dvm::OID &o) { x = o[ix::x]; y = o[ix::y]; } void fillObject(const doste::dvm::OID &obj) const { //std::cout << "FILL VECTOR\n"; obj.set(ix::x, x, true); obj.set(ix::y, y, false); } operator doste::dvm::OID() const { //TODO: Do something? //std::cout << "MAKE VECTOR2D\n"; doste::dvm::OID v = doste::dvm::OID::create(); v[ix::x] = x; v[ix::y] = y; return v; } vector2d() : x(0), y(0) {}; vector2d(float px, float py) : x(px), y(py) {}; vector2d(float *pf) //Assumes only of size 3... w is ignored. : x(pf[0]), y(pf[1]) {}; vector2d(const vector2d &v) : x(v.x), y(v.y) {}; inline vector2d(const vector3d &v); float length() const { return sqrt(x*x + y*y); } float lengthSquared() const { return (x*x + y*y); } float distance (const vector2d &v) const { float dx = x - v.x; float dy = y - v.y; return sqrt(dx * dx + dy * dy); } float distanceSquared (const vector2d &v) const { float dx = x - v.x; float dy = y - v.y; return dx * dx + dy * dy; } /** * Calculate the distance between two vectors. * @return Distance between vectors. */ static float distance(const vector2d &a, const vector2d &b) { return a.distance(b); }; /** * Calculate the distance squared between two vectors. * @return Distance squared between vectors. */ static float distanceSquared(const vector2d &a, const vector2d &b) { return a.distanceSquared(b); }; vector2d normalise() { float l = length(); if (l == 0) return *this; return vector2d(x / l, y / l); }; const float *getArray() const { return &x; }; void fillArray(float *a) { a[0] = x; a[1] = y; }; float dot (const vector2d &v) const { return dotProduct(*this, v); } /** Unary negation */ vector2d operator-() const { return vector2d(-x, -y); }; vector2d operator+(const vector2d &v) const { return vector2d(x+v.x, y+v.y); }; vector2d operator-(const vector2d &v) const { return vector2d(x-v.x, y-v.y); }; vector2d operator*(float scale) const { return vector2d(x*scale, y*scale); }; vector2d operator*(const vector2d &v) const { return vector2d(x*v.x, y*v.y); }; vector2d operator/(float scale) const { return vector2d(x/scale, y/scale); }; vector2d operator/(const vector2d &v) const { return vector2d(x/v.x, y/v.y); }; vector2d& operator+=(const vector2d &v) { x += v.x; y += v.y; return *this; }; vector2d& operator-=(const vector2d &v) { x -= v.x; y -= v.y; return *this; }; vector2d& operator*=(float scale) { x *= scale; y *= scale; return *this; }; vector2d& operator*=(const vector2d &v) { x *= v.x; y *= v.y; return *this; }; vector2d& operator/=(float scale) { x /= scale; y /= scale; return *this; }; bool operator==(const vector2d& v) { return (x == v.x && y == v.y); } bool operator!=(const vector2d& v) { return (x != v.x || y != v.y); } static float dotProduct(const vector2d &a, const vector2d &b) { return (a.x*b.x + a.y*b.y); }; static vector2d lerp(const vector2d &a, const vector2d &b, float t) { return vector2d(a.x+((b.x-a.x)*t), a.y+((b.y-a.y)*t)); } vector2d translate(float angle, const vector2d &v) { return vector2d(x + v.x * cos(angle), y + v.y * sin(angle)); } friend std::ostream &operator<<(std::ostream &os, const vector2d &vec); inline friend vector2d operator*(float scale, const vector2d &v); }; /** * A three dimensional floating point vector. It actually contains a fourth * dimension so that it can be used with the Matrix class. All common * vector operators can be performed, mostly by using the overloaded * operators. */ #ifdef _MSC_VER __declspec(align(16)) class vector3d #else class vector3d #endif { public: union { #ifdef __SSE__ __m128 _L1; #endif struct { float x; /**< X-Coordinate */ float y; /**< Y-Coordinate */ float z; /**< Z-Coordinate */ float w; /**< Dummy Coordinate */ }; }; vector3d(const doste::dvm::OID &o) { x = o[ix::x]; y = o[ix::y]; z = o[ix::z]; w = 1.0; } void fillObject(const doste::dvm::OID &obj) const { //std::cout << "FILL VECTOR\n"; obj.set(ix::x, x, true); obj.set(ix::y, y, true); obj.set(ix::z, z, false); } operator doste::dvm::OID() const { //TODO: Do something? //std::cout << "MAKE VECTOR3D: x=" << x << " y=" << y << " z=" << z << "\n"; doste::dvm::OID v = doste::dvm::OID::create(); v[ix::x] = x; v[ix::y] = y; v[ix::z] = z; return v; } /** Zero vector. */ vector3d() :x(0), y(0), z(0), w(1.0) {}; /** * 2d constructor, z defaults to 0.0. This is used for 2d games when specifying * position of sprites etc. In a 2d game the values correspond to pixels. * @param px X-Coordinate. * @param py Y-Coordinate. */ vector3d(float px, float py) : x(px), y(py), z(0.0), w(1.0) {}; /** * XYZ constructor. The W-Coordinate defaults to 1.0. * @param px X-Coordinate. * @param py Y-Coordinate. * @param pz Z-Coordinate. */ vector3d(float px, float py, float pz) : x(px), y(py), z(pz), w(1.0) {}; /** * XYZW constructor. You will not usually need this, use XYZ instead. * @param px X-Coordinate. * @param py Y-Coordinate. * @param pz Z-Coordinate. * @param pw W-Coordinate. */ vector3d(float px, float py, float pz, float pw) : x(px), y(py), z(pz), w(pw) {}; /** * Construct from a 3 float array. * @param pf Pointer to 3 floats. */ vector3d(float *pf) //Assumes only of size 3... w is ignored. : x(pf[0]), y(pf[1]), z(pf[2]), w(1.0) {}; vector3d(const vector2d &v) : x(v.x), y(v.y), z(0), w(1.0) {}; vector3d(const vector3d &v) : x(v.x), y(v.y), z(v.z), w(v.w) {}; /** * Calculate the vectors length. Note that this uses square root and may be slow. * @return Length of vector. */ float length() const { return sqrt(x*x + y*y + z*z); } /** * Calculate the squared length of this vector. This avoids the square root so is faster. * @return Squared length of vector */ float lengthSquared() const { return (x*x + y*y + z*z); } /** * Calculate the distance to a vector * @return Distance to the other vector. */ float distance (const vector3d &v) const { float dx = x - v.x; float dy = y - v.y; float dz = z - v.z; return sqrt(dx * dx + dy * dy + dz * dz); } /** * Calculate the distance to a vector * @return Distance to the other vector. */ float distanceSquared (const vector3d &v) const { float dx = x - v.x; float dy = y - v.y; float dz = z - v.z; return dx * dx + dy * dy + dz * dz; } /** * Calculate the distance between two vectors. * @return Distance between vectors. */ static float distance(const vector3d &a, const vector3d &b) { return a.distance(b); }; /** * Calculate the distance squared between two vectors. * @return Distance squared between vectors. */ static float distanceSquared(const vector3d &a, const vector3d &b) { return a.distanceSquared(b); }; /** * Normalise the vector. This will make it have a length of 1. */ vector3d normalise() const { float l = length(); if (l == 0) return *this; return vector3d(x / l, y / l, z / l); }; /** * Get this vector as an array of floats. Note that this is read-only. * @return Pointer to 3 (or 4) floats. */ const float *getArray() const { return &x; }; /** * Put this vector into a specified array. Similar to getArray. This will only * fill the array with XYZ not W. * @param a Pointer to 3 float array. */ void fillArray(float *a) { a[0] = x; a[1] = y; a[2] = z; //Don't assume w. }; /** * Make this vector from a float array. Useful if you want to reuse a vector * instead of making a new one. * @param a 3 float array. */ void fromArray(const float *a) { x = a[0]; y = a[1]; z = a[2]; }; float dot (const vector3d &v) const { return dotProduct(*this, v); } vector3d cross (const vector3d &v) const { return crossProduct(*this, v); } /** Unary negation */ vector3d operator-() const { return vector3d(-x, -y, -z); }; /** Add two vectors. */ vector3d operator+(const vector3d &v) const { return vector3d(x+v.x, y+v.y, z+v.z); }; /** Subtract a vector from another. */ vector3d operator-(const vector3d &v) const { return vector3d(x-v.x, y-v.y, z-v.z); }; /** Scale a vector */ vector3d operator*(float scale) const { return vector3d(x*scale, y*scale, z*scale); }; /** Scale a vector */ vector3d operator/(float scale) const { return vector3d(x/scale, y/scale, z/scale); }; vector3d operator/(const vector3d &v) const { return vector3d(x/v.x, y/v.y, z/v.z); }; vector3d& operator+=(const vector3d &v) { x += v.x; y += v.y; z += v.z; return *this; }; vector3d& operator-=(const vector3d &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }; vector3d& operator*=(float scale) { x *= scale; y *= scale; z *= scale; return *this; }; vector3d& operator/=(float scale) { x /= scale; y /= scale; z /= scale; return *this; }; vector3d& operator*=(const vector3d &v) { x *= v.x; y *= v.y; z *= v.z; return *this; }; bool operator==(const vector3d& v) { return (x == v.x && y == v.y && z == v.z); } bool operator!=(const vector3d& v) { return (x != v.x || y != v.y || z != v.z); } /** * Scale a vector. This is faster as fewer vector temporaries are created. * @param result Scaled result goes here. * @param a vector to scale. * @param b Scale factor. */ static void fastScale(vector3d &result, const vector3d &a, float scale) { result.x = a.x*scale; result.y = a.y*scale; result.z = a.z*scale; }; /** * Translate this vector based on a vector with an arbitrary axis. * It can be used for movement and velocities where you need to * take the rotation into account. * @param q Rotation quaternion for axis. * @param v Translate by this vector in the given axis * @return Translated vector. */ inline vector3d translate(const wgd::quaternion &q, const wgd::vector3d &v) const; /** * Translate this vector based on a vector with an arbitrary axis. * It can be used for movement and velocities where you need to * take the rotation into account. * @param q Rotation matrix for axis. * @param v Translate by this vector in the given axis * @return Translated vector. */ inline vector3d translate(const wgd::matrix &m, const wgd::vector3d &v) const; /** Multiply two vectors. */ vector3d operator*(const vector3d &v) const { return vector3d(x*v.x, y*v.y, z*v.z); }; /** * Calculate the dot product of two vectors. This corresponds to the angle between them. * @param a First vector. * @param b Second vector. * @return Dot product of a.b. */ static float dotProduct(const vector3d &a, const vector3d &b) { return (a.x*b.x + a.y*b.y + a.z*b.z); }; /** * Cross product of two vectors a and b. * @param a First vector. * @param b Second vector. * @return Cross product of a and b. */ static vector3d crossProduct(const vector3d &a, const vector3d &b) { return vector3d( (a.y*b.z) - (a.z*b.y), (a.z*b.x) - (a.x*b.z), (a.x*b.y) - (a.y*b.x)); }; /** * Linear interpolation between two vectors. * @param a Start vector. * @param b End vector. * @param t Interpolation coeficient. * @return The interpolated vector. */ static vector3d lerp(const vector3d &a, const vector3d &b, float t) { return vector3d(a.x+((b.x-a.x)*t), a.y+((b.y-a.y)*t), a.z+((b.z-a.z)*t), a.w+((b.w-a.w)*t)); } /** * Get normal from 3 vectors. Useful if you have a triangle and need to find its normal. * @param a vector A * @param b vector B * @param c vector C * @return Normal to plane described by A B and C. */ static vector3d makeNormal(const vector3d &a, const vector3d &b, const vector3d &c) { return vector3d::crossProduct(b-a,c-a).normalise(); }; friend std::ostream &operator<<(std::ostream &os, const vector3d &vec); inline friend vector3d operator*(float scale, const vector3d &v); } ALIGNED; }; namespace doste { namespace dvm { template <> class is_pod : public true_type {}; template <> class is_pod : public true_type {}; template <> class is_reuseable : public true_type {}; template <> class is_reuseable : public true_type {}; }; }; #include #include wgd::vector3d wgd::vector3d::translate(const wgd::quaternion &q, const wgd::vector3d &v) const { wgd::matrix mat; wgd::quaternion quat = q.conjugate(); quat.createMatrix(mat); vector3d w = v; w = mat * w; w += *this; return w; } wgd::vector3d wgd::vector3d::translate(const wgd::matrix &mat, const wgd::vector3d &v) const { return *this + (mat * v); } wgd::vector2d::vector2d(const wgd::vector3d &v) : x(v.x), y(v.y) {}; wgd::vector2d wgd::operator*(float scale, const wgd::vector2d &v) { return vector2d(v.x * scale, v.y * scale); } wgd::vector3d wgd::operator*(float scale, const wgd::vector3d &v) { return vector3d(v.x * scale, v.y * scale, v.z * scale); } #endif wgd-3.1/include/wgd/vertex.h0000644000175000001440000002141411233311615012743 00000000000000#ifndef _WGD_VERTEX_ #define _WGD_VERTEX_ #ifdef WIN32 #include #endif #include #include #include namespace wgd { #ifdef _MSC_VER #pragma pack(push) #pragma pack(1) #endif struct vertex{ float x; //Position float y; float z; float nx; //Normal float ny; float nz; float u; //Texture coords float v; float tx; //tangent float ty; float tz; #ifdef _MSC_VER }; #else } __attribute__((packed)); #endif /** Null structure. Used to fill in * the non-existant patrs of the vertex structure. */ struct null_type { /*null_type(){}*/ }; /** * Test to see if a structure is null_type, * use: bool isNullType::type; */ template class is_nulltype : public doste::dvm::false_type {}; template <> class is_nulltype : public doste::dvm::true_type {}; /** * Defauld vector selector class used by custom_vertex. * Vertors with 2, 3 and 4 elements are specialised, anything else * becomes the null type.
* Template is the number of elements in the */ template struct vector_selector { typedef null_type type; }; /** * Specialised vector with four elements * Can either use x,y,z,w or r,g,b,a to access the elements */ template <> struct vector_selector<4> { union { struct { float x,y,z,w; } PACKED; struct { float r,g,b,a; } PACKED; }; void operator=(const vector3d &v) { x=v.x; y=v.y; z=v.z; w=1.0f; } void operator=(const colour &c) { r=c.r; g=c.g; b=c.b; a=c.a; } }; /** * Specialised vector with three elements * Can either use x,y,z or r,g,b to access the elements */ template <> struct vector_selector<3> { union { struct { float x,y,z; } PACKED; struct { float r,g,b; } PACKED; }; void operator=(const vector3d &v) { x=v.x; y=v.y; z=v.z; } void operator=(const colour &c) { r=c.r; g=c.g; b=c.b; } }; /** * Specialised vector with two elements * Can either use x,y or u,v or s,t to access the elements */ template <> struct vector_selector<2> { union { struct { float x,y; } PACKED; struct { float u,v; } PACKED; struct { float s,t; } PACKED; }; void operator=(const vector2d &v) { x=v.x; y=v.y; } }; /** * Optional structure for texture coordinates consisting * of an array of two element vectors. * Access these elements with x,y or u,v or s,t.
* The array is of length TC.
*/ template struct texcoord_selector { typedef struct { union { struct { float x,y; } PACKED; struct { float u,v; } PACKED; struct { float s,t; } PACKED; }; void operator=(const vector2d &v) { x=v.x; y=v.y; } } PACKED type[TC]; }; /** * Specialised texture coordinate structure when there are no * coordinates. This becomes null_type. */ template <> struct texcoord_selector<0> { typedef null_type type; }; //Crazy custom vertex stuff #ifdef _MSC_VER #pragma pack(1) #endif /** * Custom vertex template. Use this class to create your own custom vertex structures.
* The template paramerters are used to define what data the structure contains.
* NV - Number of elements for the vertex position, Must be 2,3 or 4.
* NN - Number of elements for the vertex normal. can be 0, or 3. zero is used when there are no normals.
* TC - Number of Texture coordinate sets. Each set contains two elements. Generally use 0-8.
* NC - Number of vertex colour elements, can be 0, 3 or 4, corresponding to r,g,b,a.
* T - Custom vertex data for use with shaders. This must be type_null if there is no extra data * to be added to the vertex. If there are, then T must be a tuple containing a custom structure * and the next custom format or type_null.
* Use typedef to make it easier to use a custom structure. * Example:
* * //Create a custom vertex 'myVertex' containing 3 position elements, 3 normal elements and a set of texture coordinates:
* typedef vertex_template<3, 3, 1, 0, null_type> myVertex; *
* To use extra custom variables: * * //Create a custom vertex structure 'blah' containing 3 position elements, and a set of per vertex shader attribute variables:
* typedef vertex_template<3, 0, 0, 0, tuple< customClass, null_type> > blah; *
* The customClass structure must be a packed structure consisting of the variables to send. * All the variables in the structure MUST be of the same type as they are sent to the shader as an array. * It also needs to contain static variables to define the structure:
* * static const int size = x; //where x is the number of variables in the structure
* static const GLenum type = x; //where x is the type of the variables, GL_FLOAT, GL_INT, etc. * static char* name; //Name is the name of the shader variable we are writing to. it must be set in a cpp file somewhere. *
* For an example of this, see vertex_tangent structure below. */ template struct vertex_template { vertex_template() {}; union { typename wgd::vector_selector position; struct { char _d1[sizeof(float)*NV - (!NN? 1:0)]; typename wgd::vector_selector normal; }; struct { char _d2[sizeof(float)*(NV+NN) - (!TC? 1:0)]; typename wgd::texcoord_selector::type texcoords; }; struct { char _d3[sizeof(float)*(NV+NN+TC*2) - (!NC? 1:0)]; typename wgd::vector_selector colour; }; struct { char _d4[sizeof(float)*(NV+NN+TC*2+NC) - (is_nulltype::value? 1:0)]; T custom; }; }; typedef T type_custom; static const int nv = NV; static const int nn = NN; static const int nc = NC; static const int tc = TC; } PACKED; /** * Tuple structure - used to add extra structures to a custom vertex structure. * This data is used only for shader vertex attribute variables.
* template A is the type of the custom variable structure
* template B is either another tuple, or type_null specifting the end of a chain. * You can chain as many custom classes as you like using nested tuples.
* Example: * * //create a chain containing two custom classes:
* tuple< myClass1, tuple< myclass2, null_type > >; *
* This is used fot the T template parameter in custom_vertex. */ template struct tuple { A var; B next; typedef A type_A; typedef B type_B; } PACKED; /** * Tuple specialisation for the terminating tuple in a chain. * This version does not have the 'next' element. It occurs when * the second template parameter is null_type. */ template struct tuple { A var; typedef A type_A; typedef null_type type_B; } PACKED; /** * Vertex tangents are a commonly used shader attribute variable, * This is an extension for the custom_vertex class use with the tuples. * It contains three floats, and the information the shader needs to apply them * as static elements.
* size must be number of elements in the structure,
* type must be the data type used for the elements,
* name must be the variable name used in the shader that these values correspond to.
* All data elements MUST be of the same type in a structure. */ struct vertex_tangent { float x,y,z; static const int size = 3; static const GLenum type = GL_FLOAT; static BASEIMPORT char* name; //"tangent"; } PACKED; /** * A standard vertex format consisting of 3 position elements (x,y,z), 3 normal elements, * and one set of texture coordinates. */ typedef vertex_template<3,3,1,0, null_type> vertex1; /** * A standard vertex format consisting of 3 position elements (x,y,z), 3 normal elements, * one set of texture coordinates, and a set of 'tangent' shader attribute variables. */ typedef vertex_template<3,3,1,0, tuple > vertex_t; /** vertex structure used for sprites */ typedef vertex_template<3,3,1,4,null_type> SpriteVertex; /** vetrex structure used for lines */ typedef vertex_template<3,0,0,4,null_type> LineVertex; /** * Texture Coordinate structure. Contains uv texture data for a vertex */ #ifdef _MSC_VER #pragma pack(1) #endif struct GLTexCoord{ float u; float v; #ifdef _MSC_VER }; #else } __attribute__((packed)); #endif /** * Vertex structure, used for position, normals and tangents * Generally all vertex data needing three components */ #ifdef _MSC_VER #pragma pack(1) #endif struct GLVertex{ float x; float y; float z; #ifdef _MSC_VER }; #else } __attribute__((packed)); #endif /** * Vertex Colour information using four components (rgba). */ #ifdef _MSC_VER #pragma pack(1) #endif struct GLColour{ float r; float g; float b; float a; #ifdef _MSC_VER }; #pragma pack(pop) #else } __attribute__((packed)); #endif }; #endif wgd-3.1/include/wgd/model3ds.h0000644000175000001440000000076211026705571013153 00000000000000#ifndef _WGD_MODEL3DS_ #define _WGD_MODEL3DS_ #include namespace wgd { class vector3d; class vector2d; class Model3DS : public wgd::ModelLoader { public: LOADER(Model3DS); Model3DS(doste::File *f) : ModelLoader(f) {}; void load(); static bool validate(doste::File*); private: void processMesh(int index, char *material, int nFaces, unsigned short *faces, wgd::vector3d *vertices, wgd::vector2d *tex); }; }; #endif wgd-3.1/include/wgd/imodel.h0000644000175000001440000000436211233311615012702 00000000000000#ifndef _WGD_IMODEL_ #define _WGD_IMODEL_ #include #include #include #include #include #include namespace wgd { class MODELSIMPORT IModel : public wgd::Instance3D { public: IModel(); IModel(Model* mdl); IModel(const doste::dvm::OID&); ~IModel(); OBJECT(Instance3D, IModel); /** The model this instance is of */ PROPERTY_RF(Model, model, ix::model); PROPERTY_WF(Model, model, ix::model); /** Get a material by name */ wgd::Material* material(const doste::dvm::OID &); /** Object scale (in each dimension) */ PROPERTY_RF(vector3d, scale, ix::scale); PROPERTY_WF(vector3d, scale, ix::scale); /** set the current animation, using default transition time */ PROPERTY_RF(OID, animation, ix::animation); PROPERTY_WF(OID, animation, ix::animation); /** get the animation object to set multiple blended animations */ Animation *animation(int index) { if(m_anim) return &m_anim->animation(index); return 0; } /** Object scale */ void scale(float s) { scale(vector3d(s,s,s)); }; virtual void draw(SceneGraph &graph, Camera3D *camera); /** get global transform matrix for a named bone */ matrix boneMatrix(const OID &boneName); /** get an IBone object from the model. * Creates the IBone object if it dosent exist. * IBones override any animation when active * @return IBone object, or NULL if bone does not exist */ IBone* bone(const OID& bone); BEGIN_EVENTS(Instance3D); EVENT(evt_update, WGD(ix::time)); //Need something to trigger the update function - preferably not every instant EVENT(evt_setup, (*this)(ix::model)("loaded")); EVENT(evt_animation, (*this)(ix::animation)); EVENT(evt_morph, (*this)(ix::meshes)(doste::dvm::All)); EVENT(evt_bone, Null); //For the bones. END_EVENTS; bool handler(int); protected: //the model VBOs are built bool m_built; //a bone has been changed - force update bool m_forceUpdate; //controlers AnimationController *m_anim; MorphController *m_morph; SkinController *m_skin; }; }; #endif wgd-3.1/include/wgd/dll.h0000644000175000001440000000317311233311615012203 00000000000000#ifndef _WGD_DLL_ #define _WGD_DLL_ #ifdef WIN32 #if BUILD_BASE_DLL # define BASEIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define BASEIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_RESOURCES_DLL # define RESIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define RESIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_WIDGETS_DLL # define WIDIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define WIDIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_BASE2D_DLL # define BASE2DIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define BASE2DIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_BASE3D_DLL # define BASE3DIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define BASE3DIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_MODELS_DLL # define MODELSIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define MODELSIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_HEIGHTMAP_DLL # define HEIGHTMAPIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define HEIGHTMAPIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #if BUILD_INPUT_DLL # define INPUTIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define INPUTIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #else #define BASEIMPORT #define RESIMPORT #define WIDIMPORT #define BASE2DIMPORT #define BASE3DIMPORT #define MODELSIMPORT #define HEIGHTMAPIMPORT #define INPUTIMPORT #endif #endif wgd-3.1/include/wgd/sprite3d.h0000644000175000001440000000760711233311615013173 00000000000000#ifndef _WGD_SPRITE_3D_ #define _WGD_SPRITE_3D_ #include #include #include #include #include #include namespace wgd { /** * Sprite3D is a c++ only sprite class to draw sprites in the 3D world. * There are three types of sprites you can use:
* absolute - where you specify the absolute orientation.
* orientated - where you specify the centre point, and it always faces the camera.
* aligned - where you specify a direction the sprite is aligned to, and it rotates around that to face the camera. */ class BASE3DIMPORT Sprite3D { public: Sprite3D(); /** Create a new sprite3d with absolute positioning. * @param sprite The sprite resource to use * @param position The center of the sprite * @param orientation Quaternion describing the orientation of the sprite * @param width The width of the sprite in world units (default 1.0) * @param height The height of the sprite in world units (default 1.0) * @param frame The frame to initialise the sprite to (default 0) */ Sprite3D(Sprite* sprite, const vector3d &position, const quaternion &orientation, float width=1.0f, float height=1.0f, int frame=0); /** Create a new orientated sprite3d. * @param sprite The sprite resource to use * @param position The center of the sprite * @param width The width of the sprite in world units (default 1.0) * @param height The height of the sprite in world units (default 1.0) * @param frame The frame to initialise the sprite to (default 0) * @param angle The angle of sprite in relation to the camera (default 0) */ Sprite3D(Sprite* sprite, const vector3d &position, float width=1.0f, float height=1.0f, int frame=0, float angle=0); /** Create a new aligned sprite3d. * @param sprite The sprite resource to use * @param position The base position of the sprite * @param direction The direction to align the sprite to * @param width The width of the sprite in world units (default 1.0) * @param height The height of the sprite in world units (default 1.0) * @param frame The frame to initialise the sprite to (default 0) */ Sprite3D(Sprite* sprite, const vector3d &position, const vector3d &direction, float width=1.0f, float height=1.0f, int frame=0); ~Sprite3D(); /** Add the sprite to the scene graph */ DrawableBase *draw(SceneGraph &graph, Camera3D *camera); /** Get the sprite drawable. Generates the sprite */ Drawable *drawable(Camera3D* cam); /** Set the sprite resource */ void sprite(Sprite* spr); /** Set the width and height of the sprite */ void size(float width, float height); /** set the position of the center of the sprite, or the bottom of the sprite if direction is used */ void position(const vector3d &v); /** Set the direction of the sprite if it is aligned, makes the sprite aligned */ void direction(const vector3d &v); /** Set the absoulute orientation of the sprite */ void orientation(const quaternion &v); /** Set the angle of the sprite, makes the sprite orientated */ void angle(float ang); /** set the curent frame */ void frame(int f) {if(m_frame!=f) setFrame(f); }; /** be able to tint sprites */ void colour(const wgd::colour& c); private: //create geometry void setup(); //Initialise drawable void setFrame(int f); //set texture coords for frame void makeOrientated(Camera3D* cam); void makeAligned(Camera3D *cam); void makeAbsolute(); void drawSprite(); Drawable *m_drawable; float m_width; float m_height; Sprite *m_sprite; int m_frame; vector3d m_position; vector3d m_direction; quaternion m_orientation; float m_angle; int m_mode; // orientated, aligned, absolute }; }; #endif wgd-3.1/include/wgd/clipmap.h0000644000175000001440000001243211233311615013053 00000000000000#ifndef _WGD_CLIPMAP_ #define _WGD_CLIPMAP_ #include #include #include #include namespace wgd { /** * The Clipmap object is an interface to do per-polygon collision detection on a model * generally used for levels or static structures. The polygon data is stored in an octree * structure to reduce the number of tests needed. (this will be optional for speed purposes)
* The object acts like a static IModel instance that does not get drawn, so you can have * a simple clipmap over more complex geometry.
* Currently supports line segment intersection (rays) and sphere collision detection.
* You have the option of caching transformed vertices in an octree to reduce the number * of polygon tests and transformations for each collision test. */ class MODELSIMPORT ClipMap : public doste::Agent { public: OBJECT(doste::Agent, ClipMap); ClipMap(const wgd::OID&); /** Create a new clipmap object from a model * @param model The model object to use as a data source * @param depth The depth of the octree to use if cache is true * @param cache Cache transformed vertices in an octree */ ClipMap(wgd::Model* model, int depth=0, bool cache = true); ~ClipMap(); /** The model to use for collision */ PROPERTY(wgd::Model, model); /** depth of octree - defaults to 0 = no octree optimisations. Only applies if cache is true */ PROPERTY(int, depth); /** * Cache transformed vertices in an octree * massive speedup for large static objects, but not * good for objects that move. * When cache is false, the transformations occur for each test. */ PROPERTY(bool, cache); /** clipmap position */ PROPERTY_F(wgd::vector3d, position, wgd::ix::position); /** orientation */ PROPERTY_F(wgd::vector3d, orientation, wgd::ix::orientation); /** scale */ PROPERTY_F(wgd::vector3d, scale, wgd::ix::scale); /** * Test a line segment to see if it intersects any polygons in the clip map. * This gets the closest collision to the start of the segment if it hits. * @param start The start of the line segment * @param end The end of the line segment * @param point The point of collision - return value * @param normal The normal of the polygon collided with (not normlised) * @return the number of colisions on the line segment. */ int test(const wgd::vector3d &start, const wgd::vector3d &end, wgd::vector3d &point, wgd::vector3d &normal); /** Test a capsule with the clipmap - not implemented */ int test(const wgd::vector3d &a, const wgd::vector3d &b, float radius, wgd::vector3d *point, wgd::vector3d *normal, int max); /** * Test a sphere for collision with the clipmap. * This returns all collisions with the sphere and the clipmap geometry * sorted by the penetration distance (greatest first) * @param centre The centre of the sphere * @param radius The sphere radius * @param point Array of collision points * @param normal Array of collision normals * @param max The maximum number of collisions to return * @return The number of collisions */ int test(const wgd::vector3d ¢re, float radius, wgd::vector3d *point, wgd::vector3d *normal, int max); //events BEGIN_EVENTS(doste::Agent); EVENT(evt_build, (*this)(wgd::ix::model)("loaded")); EVENT_VECTOR(evt_scale, (*this)(wgd::ix::scale)); EVENT_VECTOR(evt_position, (*this)(wgd::ix::position)); EVENT_VECTOR(evt_orientation, (*this)(wgd::ix::orientation)); EVENT_VECTOR(evt_cache, (*this)("cache")); END_EVENTS; ///DEBUG: get number of polygons tested in the last call to test() int tests() { return m_tests; } private: //collision data struct struct CData { CData(const wgd::vector3d &pos,const wgd::vector3d &nrm, float dst) { memcpy(p, &pos.x, 3 * sizeof(float)); memcpy(n, &nrm.x, 3 * sizeof(float)); d = dst; } bool operator<(const CData &a) const { return a.d < d; } float p[3]; float n[3]; float d; }; //number of polygons tested in the last test int m_tests; /** build clipmap from model - gets AABB and creates octree */ void build(); bool m_built; //vertex data for octree struct NodeData { int mesh, polygon; }; //pointer based octree struct Node { Node* n[8]; //child nodes wgd::vector3d centre; //node centre wgd::vector3d size; //node size int depth; //node depth //the data - polygon indices std::vector data; } m_tree; int m_depth; //maximum depth of octree //add a polygon to the octree void clearTree(Node &n); void addTree(Node &n, NodeData &data); Node &addNode(Node &n, int index); //add node to tree //local matrix for transformation void calcLocal(); wgd::matrix m_localMatrix; wgd::matrix m_inverseMatrix; //transformed vertices wgd::vector3d *m_vertex; int m_vcount; //cached vertex count wgd::Mesh **m_mesh; //caches meshes (when not caching vertices) int m_meshes; //AABB wgd::vector3d m_high, m_low; //octree ray test - this one seems very slow so is not currently used int testTree(Node &n, const wgd::vector3d &a, const wgd::vector3d &b, std::vector &data, float length); //octree sphere test int testTree(Node &n, const wgd::vector3d ¢re, float radius, std::vector &data); }; }; #endif wgd-3.1/include/wgd/texturetga.h0000644000175000001440000000047511026705571013636 00000000000000#ifndef _WGD_TEXTURETGA_H_ #define _WGD_TEXTURETGA_H_ #include namespace wgd { class TextureTGA : public TextureLoader { public: LOADER(TextureTGA); TextureTGA(doste::File *f) : TextureLoader(f) {} ~TextureTGA() {}; bool load(); static bool validate(doste::File *f); }; }; #endif wgd-3.1/include/wgd/colour.h0000644000175000001440000000740011233311615012730 00000000000000/* * WGD Library * * Authors: * Date: 17/9/2007 * */ #ifndef _WGD_COLOUR_ #define _WGD_COLOUR_ #include #include #include #include #include #define EVENT_COLOUR(A,B) EVENT(A,B(wgd::ix::r)(doste::dvm::modifiers::Seq)B(wgd::ix::g)(doste::dvm::modifiers::Seq)B(wgd::ix::b)(doste::dvm::modifiers::Seq)B(wgd::ix::a)(doste::dvm::modifiers::Seq)B) namespace wgd { enum ColourFormat { RGBA_CHAR, RGB_CHAR, RGB_FLOAT, RGBA_FLOAT, R_CHAR, R_FLOAT, RG_CHAR }; #ifdef _MSC_VER #pragma pack(push) #pragma pack(1) #endif struct colour4i { unsigned char r; unsigned char g; unsigned char b; unsigned char a; static const ColourFormat format = RGBA_CHAR; } PACKED; struct colour4f { float r; float g; float b; float a; static const ColourFormat format = RGBA_FLOAT; } PACKED; struct colour3i { unsigned char r; unsigned char g; unsigned char b; static const ColourFormat format = RGB_CHAR; } PACKED; struct colour3f { float r; float g; float b; static const ColourFormat format = RGB_FLOAT; } PACKED; struct colour2i { unsigned short r; static const ColourFormat format = RG_CHAR; } PACKED; struct colour1i { unsigned char l; static const ColourFormat format = R_CHAR; } PACKED; struct colour1f { float i; static const ColourFormat format = R_FLOAT; } PACKED; #ifdef _MSC_VER #pragma pack(pop) #endif /** * Represents a 32 bit floating point colour. The values of the RGBA * components can be between 0.0 and 1.0. Additional operations are * provided to manipulate colours, such as linear interpolation from one * colour to another.
* All colours in this library are represented with this class. */ struct colour { colour() {}; /** RGB Constructor. Alpha is 1.0 by default. */ colour(float _r, float _g, float _b) : r(_r),g(_g),b(_b),a(1.0f) {}; /** RGBA Constructor */ colour(float _r, float _g, float _b, float _a) : r(_r),g(_g),b(_b),a(_a) {}; colour(const doste::dvm::OID &o) { r = o[ix::r]; g = o[ix::g]; b = o[ix::b]; if(o[ix::a]==Null) a = 1.0f; //default alpha to 1.0f if not specified else a = o[ix::a]; } void fillObject(const doste::dvm::OID &obj) const { //std::cout << "FILL VECTOR\n"; obj.set(ix::r, r, true); obj.set(ix::g, g, true); obj.set(ix::b, b, true); obj.set(ix::a, a, false); } operator doste::dvm::OID() const { //TODO: Do something? doste::dvm::OID c = doste::dvm::OID::create(); c[ix::r] = r; c[ix::g] = g; c[ix::b] = b; c[ix::a] = a; return c; } /** * Convert to an array of floats. You pass a pointer to an array of 4 floats and this method * will fill it with this colour. This is used for OpenGL which takes an array of floats. * @param v Pointer for 4 float array. */ void toArray(float *ar) { ar[0] = r; ar[1] = g; ar[2] = b; ar[3] = a; }; /** * Interpolated between two colours. Given two colours it will linearly interpolate between then using the * parameter t. If t is 0.0 then the colour is the first one, if it is 1.0 then it is the second one. Any * value of t between 0 and 1 gives an interpolated colour. * @param a First colour, returned if t = 0.0. * @param b Second colour, returned if t = 1.0. * @param t Position between colours, 0.0 is start, 1.0 is end. * @return Interpolated colour. */ static colour lerp(const colour &a, const colour &b, float t) { return colour(a.r+((b.r-a.r)*t), a.g+((b.g-a.g)*t), a.b+((b.b-a.b)*t), a.a+((b.a-a.a)*t)); } float r, g, b, a; }; }; namespace doste { namespace dvm { template <> class is_pod : public true_type {}; template <> class is_reuseable : public true_type {}; }; }; #endif wgd-3.1/include/wgd/skincontroller.h0000644000175000001440000000117411025650214014477 00000000000000#ifndef _WGD_SKIN_CONTROLLER_ #define _WGD_SKIN_CONTROLLER_ #include #include namespace wgd { class SkinController { public: SkinController(wgd::AnimationController *c); ~SkinController(); bool update(); private: //calculate final matrices the offset to nullify translation when transforming normals void calculateFinal(); void deform(wgd::Mesh* dest, wgd::Mesh *src); vector3d *m_offset; AnimationController *m_anim; //final transformation matrices (includes skin offset) matrix *m_final; matrix *m_finalA; }; }; #endif wgd-3.1/include/wgd/instance3d.h0000644000175000001440000000377611233311615013474 00000000000000#ifndef _WGD_INSTANCE3D_ #define _WGD_INSTANCE3D_ #include #include #include #include #include #include #include namespace wgd { class BASE3DIMPORT Instance3D : public doste::Agent { public: Instance3D(); Instance3D(const doste::dvm::OID &id); virtual ~Instance3D(){}; /** must be called by all instances to update local data */ virtual void draw(SceneGraph &graph, Camera3D *camera); OBJECT(Agent, Instance3D); PROPERTY_RF(vector3d, position, ix::position); PROPERTY_WF(vector3d, position, ix::position); void move(const vector3d &v) { position(position()+v); }; void translate(const vector3d &v) { position(position().translate(m_quat.conjugate(), v)); }; vector3d worldPosition(); PROPERTY_RF(vector3d, orientation, ix::orientation); PROPERTY_WF(vector3d, orientation, ix::orientation); void rotate(const vector3d &r) { orientation(orientation() + r); }; vector3d worldOrientation(); /** Quaternions */ const Quaternion &quaternion() const {return m_quat; }; void quaternion(const Quaternion &q) { m_quat=q; }; //Get object AABB information for Scene wgd::vector3d boundingBoxLow() { return m_low; }; wgd::vector3d boundingBoxHigh() { return m_high; }; /** Children */ PROPERTY_RF(doste::dvm::OID, children, ix::children); PROPERTY_WF(doste::dvm::OID, children, ix::children); /** parent instance */ PROPERTY_R(Instance3D, parent); PROPERTY_W(Instance3D, parent); BEGIN_EVENTS(Agent); EVENT_VECTOR(evt_orientation, (*this)(ix::orientation)); EVENT_VECTOR(evt_position, (*this)(ix::position)); END_EVENTS; const matrix &localMatrix(); void localMatrix(const matrix& m); private: //AABB for object wgd::vector3d m_low, m_high; bool m_update; //quaternion Quaternion m_quat; matrix m_localMatrix; }; }; #endif wgd-3.1/include/wgd/render.h0000644000175000001440000000225511027450314012710 00000000000000#ifndef _WGD_RENDER_H_ #define _WGD_RENDER_H_ #include #include #include namespace wgd { class matrix; class BASE3DIMPORT Render { public: static void begin(Camera3D *cam); static void being(Camera2D *cam); static void end(); //static void sprite(Sprite *spr, int frame, const vector2d &pos); //static void sprite(Sprite *spr, int frame, const vector2d &pos, float orientation); static void sprite(Sprite *spr, int frame, const vector3d &pos); static void sprite(Sprite *spr, int frame, const vector3d &pos, const quaternion &orientation); static void sprite(Sprite *spr, int frame); //Sprite batch? //static void text(Font *fnt, const vector3d &pos, const char *str); //static void line(const vector3d &a, const vector3d &b) { line(a,b,colour(1.0,1.0,1.0,1.0),1); }; //static void line(const vector3d &a, const vector3d &b, const colour &col) { line(a,b,col,1); }; //static void line(const vector3d &a, const vector3d &b, const colour &col, int width); static void transform(const matrix &mat); static void untransform(); private: static Camera3D *s_cam3d; static Camera2D *s_cam2d; }; }; #endif wgd-3.1/include/wgd/iterator.h0000644000175000001440000000720111233311615013255 00000000000000#ifndef _WGD_ITERATOR_ #define _WGD_ITERATOR_ #include #include #include namespace wgd { /** * An iterator to loop through all objects of a type.
* There is no specific order in which the objects will be returned * so you can only iterate forwards.
* This example draws all IModel objects. This does not include child objects.
* for(Scene::Iterator i = Scene::current()->begin(); i * *i->draw();
* }

* You can iterate through all child objects of an object too.
* This example will draw all child IModel objects of the "myModel" object
* IModel *mdl = object::get("myModel");
* for(Scene::Iterator i = mdl->begin(); i * *i->draw();
* }

* Iterators can also be recrusive, ie they will also loop through all child items as well.
* This example will draw all IModel objects in the scene
* Scene::Iterator i;
* i.recursive(true);
* for(i = Scene::current()->begin(); !i.end(); i++){
* *i->draw();
* }
*/ template class Iterator { public: Iterator(bool recursive=false) : m_recurse(recursive) {}; Iterator(const doste::dvm::OID::iterator &iter) : m_recurse(false) { build(iter.object()); } ~Iterator(){}; /** Return true if the iterator is at the end of the list */ bool end(){ return m_position>=list.size() || m_position<0; }; /** Return the number of instances of this type */ int size(){ return list.size(); }; /** Set if this iterator recurses to child instances */ void recursive(bool r){ m_recurse = r; }; Iterator& operator++() { ++m_position; return *this; }; /// Move to the next item in the list Iterator& operator++(int){ ++m_position; return *this; }; /// Move to the next item in the list Iterator& operator--() { --m_position; return *this; }; /// Move to the previous item in the list Iterator& operator--(int){ --m_position; return *this; }; /// Move to the previous item in the list /* Start the iterator for a given instance/scene */ Iterator& operator=(const doste::dvm::OID::iterator &start){ build(start.object()); return *this; }; /* set the iterator position */ Iterator& operator=(int loc) { m_position = loc; return *this; } template friend bool operator==(Iterator &i, const doste::dvm::OID::iterator &e); template friend bool operator!=(Iterator &i, const doste::dvm::OID::iterator &e); /** Get a pointer to the current instance. * Will return NULL if invalid */ T* operator*(){ if(end()) return NULL; else return list[m_position]; }; private: void build(const doste::dvm::OID &loc); std::vector list; unsigned int m_position; bool m_recurse; }; template bool operator==(Iterator &i, const doste::dvm::OID::iterator &e) { return ( i.end()); } template bool operator!=(Iterator &i, const doste::dvm::OID::iterator &e) { return (!i.end()); }; template void Iterator::build(const doste::dvm::OID &loc){ for(doste::dvm::OID::iterator i = loc.begin(); i!=loc.end(); i++) { if(loc[*i][doste::dvm::Type]==Null) continue; //get object doste::Object *obj = loc[*i]; if(obj!=NULL){ //Add to list if(obj->isa(T::type())) list.push_back(loc[*i]); //recurse to children if(m_recurse && obj->get(ix::children)!=doste::dvm::Null) build(obj->get(ix::children)); } } m_position = 0; }; }; #endif wgd-3.1/include/wgd/mouse.h0000644000175000001440000000740311233311615012560 00000000000000/* * WGD Library * * Authors: * Date: 23/9/2007 * */ #ifndef _WGD_MOUSE_ #define _WGD_MOUSE_ #include #include #include #include #include #include namespace wgd { /** Represents mouse buttons */ typedef doste::dvm::OID Button; /** * Provides access to mouse events and position. */ class BASEIMPORT Mouse : public doste::Agent { friend class Input; public: OBJECT(Agent, Mouse); Mouse(const doste::dvm::OID &o); ~Mouse(); /** * Make the mouse visible or invisible. You cannot move the mouse out of the * window if the mouse is invisible as it is moved back to the center each frame. */ PROPERTY_WF(bool, visible, ix::visible); /** Is the mouse visible. */ PROPERTY_RF(bool, visible, ix::visible); /** Grab the mouse. Brings it back to the centre of the screen each frame. */ PROPERTY_WF(bool, grab, ix::grab); PROPERTY_RF(bool, grab, ix::grab); /** * Get mouse X position. Note that this is not useful when the mouse is not visible. */ PROPERTY_RF(int, x, ix::x); /** * Get mouse Y position. Note that this is not useful when the mouse is not visible. */ PROPERTY_RF(int, y, ix::y); /** Get the cursor position on screen */ wgd::vector2d position(); /** Set the cursor position */ void position(int x, int y); /** Set the cursor position */ void position(const wgd::vector2d &); /** * Change in X since last frame. */ PROPERTY_RF(int, deltaX, ix::deltax); /** * Change in Y since last frame. */ PROPERTY_RF(int, deltaY, ix::deltay); /** Get change in mouse wheel since last update */ PROPERTY_RF(int, deltaZ, ix::deltaz); /** Used by Controls */ doste::dvm::OID buttons() { return get(ix::buttons); }; /** Used by Controls */ doste::dvm::OID axes() { return get(ix::axes); }; /** * Query if a mouse button is currently pressed. */ bool btnPressed(const Button &b) { return (*this)[ix::buttons][b]; }; /// Same as btnPressed bool pressed(const Button &b) const { return (*this)[ix::buttons][b]; }; // Extra functions for non-event based usage /// has a button been clicked in the last frame (pressed and released without moving the mouse) bool click(const Button &button) const { return buttonUp(button) && !m_moved[bNo(button)]; } /// are you dragging with a mouse button pressed bool drag(const Button &button) const { return pressed(button) && m_moved[bNo(button)]; } /// Was the button released in tha last frame bool buttonUp(const Button &button) const { return !pressed(button) && m_last[bNo(button)]; } /// Was the button pressed in the last frame bool buttonDown(const Button &button) const { return pressed(button) && !m_last[bNo(button)]; } BEGIN_EVENTS(Agent); EVENT(evt_cursor, (*this)(ix::cursor)); EVENT(evt_visible, (*this)(ix::visible)); EVENT(evt_position, (*this)(ix::x)(doste::dvm::modifiers::Seq)(*this)(ix::y)); END_EVENTS; static Button BTN_LEFT; /**< Left mouse button */ static Button BTN_MIDDLE; /**< Middle mouse button. Aka Scroll wheel button */ static Button BTN_RIGHT; /**< Right mouse button. */ //static Button BTN_A; //static Button BTN_B; //static Button BTN_C; //static Button BTN_D; static const int AXIS_X = 0; static const int AXIS_Y = 1; //static doste::OID AXIS_Z; void reset(); private: int bNo(const Button&) const; bool m_last[6]; //state of buttons last frame bool m_moved[6]; //has the mouse been moved since the button was pressed void btnDown(int); void btnUp(int); void wheel(int d) { s_wheel += d; } void update(); static int lastX; static int lastY; static bool s_vis; static int s_wheel; }; extern BASEIMPORT Mouse *mouse; }; #endif wgd-3.1/include/wgd/scenegraph.h0000644000175000001440000000144711233311615013551 00000000000000#ifndef _WGD_SCENEGRAPH_ #define _WGD_SCENEGRAPH_ #include namespace wgd { class RESIMPORT SceneGraph { public: SceneGraph() {}; ~SceneGraph() {}; /** Draw the scene graph */ bool draw(); /** Add a drawable to scene graph - works out which list to add to */ DrawableBase* add(DrawableBase *d); /** Add solid drawable to scene graph */ DrawableBase* addSolid(DrawableBase *d); /** Add transparent drawable to scene graph - does alpha sorting on there */ DrawableBase* addAlpha(DrawableBase *d); private: //Drawable drawing queues std::vector m_solid; //List of solid items, sorted by material std::vector m_alpha; //list of non-solid items - sorted by distance }; }; #endif wgd-3.1/include/wgd/index.h0000644000175000001440000002240511077651472012554 00000000000000/* * WGD Library * * Authors: * Date: 25/9/2007 * */ #ifndef _WGD_INDEX_ #define _WGD_INDEX_ #include #include namespace wgd{ namespace ix{ extern BASEIMPORT doste::dvm::OID position; extern BASEIMPORT doste::dvm::OID orientation; extern BASEIMPORT doste::dvm::OID direction; extern BASEIMPORT doste::dvm::OID changed; extern BASEIMPORT doste::dvm::OID material; extern BASEIMPORT doste::dvm::OID materials; extern BASEIMPORT doste::dvm::OID model; extern BASEIMPORT doste::dvm::OID models; extern BASEIMPORT doste::dvm::OID animationset; extern BASEIMPORT doste::dvm::OID animations; extern BASEIMPORT doste::dvm::OID animation; extern BASEIMPORT doste::dvm::OID animated; extern BASEIMPORT doste::dvm::OID transformed; extern BASEIMPORT doste::dvm::OID transition; extern BASEIMPORT doste::dvm::OID meshes; extern BASEIMPORT doste::dvm::OID morphs; extern BASEIMPORT doste::dvm::OID morph; extern BASEIMPORT doste::dvm::OID root; extern BASEIMPORT doste::dvm::OID bones; extern BASEIMPORT doste::dvm::OID animset; extern BASEIMPORT doste::dvm::OID start; extern BASEIMPORT doste::dvm::OID end; extern BASEIMPORT doste::dvm::OID fps; extern BASEIMPORT doste::dvm::OID loop; extern BASEIMPORT doste::dvm::OID next; extern BASEIMPORT doste::dvm::OID solid; extern BASEIMPORT doste::dvm::OID mode; extern BASEIMPORT doste::dvm::OID debug; extern BASEIMPORT doste::dvm::OID x; extern BASEIMPORT doste::dvm::OID y; extern BASEIMPORT doste::dvm::OID z; extern BASEIMPORT doste::dvm::OID w; extern BASEIMPORT doste::dvm::OID r; extern BASEIMPORT doste::dvm::OID g; extern BASEIMPORT doste::dvm::OID b; extern BASEIMPORT doste::dvm::OID a; extern BASEIMPORT doste::dvm::OID sx; extern BASEIMPORT doste::dvm::OID sy; extern BASEIMPORT doste::dvm::OID sz; extern BASEIMPORT doste::dvm::OID pitch; extern BASEIMPORT doste::dvm::OID yaw; extern BASEIMPORT doste::dvm::OID roll; extern BASEIMPORT doste::dvm::OID console; extern BASEIMPORT doste::dvm::OID lines; extern BASEIMPORT doste::dvm::OID visible; extern BASEIMPORT doste::dvm::OID showdebug; extern BASEIMPORT doste::dvm::OID font; extern BASEIMPORT doste::dvm::OID bgcolour; extern BASEIMPORT doste::dvm::OID text; extern BASEIMPORT doste::dvm::OID ambient; extern BASEIMPORT doste::dvm::OID specular; extern BASEIMPORT doste::dvm::OID diffuse; extern BASEIMPORT doste::dvm::OID emission; extern BASEIMPORT doste::dvm::OID directional; extern BASEIMPORT doste::dvm::OID linear; extern BASEIMPORT doste::dvm::OID quadratic; extern BASEIMPORT doste::dvm::OID enabled; extern BASEIMPORT doste::dvm::OID lights; extern BASEIMPORT doste::dvm::OID size; extern BASEIMPORT doste::dvm::OID name; extern BASEIMPORT doste::dvm::OID bold; extern BASEIMPORT doste::dvm::OID fonts; extern BASEIMPORT doste::dvm::OID shininess; extern BASEIMPORT doste::dvm::OID shader; extern BASEIMPORT doste::dvm::OID texture; extern BASEIMPORT doste::dvm::OID textures; extern BASEIMPORT doste::dvm::OID clamp; extern BASEIMPORT doste::dvm::OID filename; extern BASEIMPORT doste::dvm::OID mipmap; extern BASEIMPORT doste::dvm::OID objects; extern BASEIMPORT doste::dvm::OID world; extern BASEIMPORT doste::dvm::OID positionvar; extern BASEIMPORT doste::dvm::OID rate; extern BASEIMPORT doste::dvm::OID life; extern BASEIMPORT doste::dvm::OID particles; extern BASEIMPORT doste::dvm::OID primitive; extern BASEIMPORT doste::dvm::OID primitives; extern BASEIMPORT doste::dvm::OID width; extern BASEIMPORT doste::dvm::OID height; extern BASEIMPORT doste::dvm::OID depth; extern BASEIMPORT doste::dvm::OID radius; extern BASEIMPORT doste::dvm::OID pitch; extern BASEIMPORT doste::dvm::OID playing; extern BASEIMPORT doste::dvm::OID attenuation; extern BASEIMPORT doste::dvm::OID volume; extern BASEIMPORT doste::dvm::OID sounds; extern BASEIMPORT doste::dvm::OID playing; extern BASEIMPORT doste::dvm::OID sound; extern BASEIMPORT doste::dvm::OID velocity; extern BASEIMPORT doste::dvm::OID sprite; extern BASEIMPORT doste::dvm::OID sprites; extern BASEIMPORT doste::dvm::OID frame; extern BASEIMPORT doste::dvm::OID font; extern BASEIMPORT doste::dvm::OID text; extern BASEIMPORT doste::dvm::OID music; extern BASEIMPORT doste::dvm::OID number; extern BASEIMPORT doste::dvm::OID velocityvar; extern BASEIMPORT doste::dvm::OID growth; extern BASEIMPORT doste::dvm::OID growthvar; extern BASEIMPORT doste::dvm::OID endsize; extern BASEIMPORT doste::dvm::OID endsizevar; extern BASEIMPORT doste::dvm::OID startsize; extern BASEIMPORT doste::dvm::OID startsizevar; extern BASEIMPORT doste::dvm::OID lifevar; extern BASEIMPORT doste::dvm::OID fade; extern BASEIMPORT doste::dvm::OID fadevar; extern BASEIMPORT doste::dvm::OID startcolour; extern BASEIMPORT doste::dvm::OID startcolourvar; extern BASEIMPORT doste::dvm::OID endcolour; extern BASEIMPORT doste::dvm::OID endcolourvar; extern BASEIMPORT doste::dvm::OID acceleration; extern BASEIMPORT doste::dvm::OID accelerationvar; extern BASEIMPORT doste::dvm::OID resources; extern BASEIMPORT doste::dvm::OID vert; extern BASEIMPORT doste::dvm::OID frag; extern BASEIMPORT doste::dvm::OID shaders; extern BASEIMPORT doste::dvm::OID left; extern BASEIMPORT doste::dvm::OID right; extern BASEIMPORT doste::dvm::OID top; extern BASEIMPORT doste::dvm::OID bottom; extern BASEIMPORT doste::dvm::OID front; extern BASEIMPORT doste::dvm::OID back; extern BASEIMPORT doste::dvm::OID skybox; extern BASEIMPORT doste::dvm::OID skyboxes; extern BASEIMPORT doste::dvm::OID cur; extern BASEIMPORT doste::dvm::OID frames; extern BASEIMPORT doste::dvm::OID columns; extern BASEIMPORT doste::dvm::OID rows; extern BASEIMPORT doste::dvm::OID billboard; extern BASEIMPORT doste::dvm::OID distance; extern BASEIMPORT doste::dvm::OID atmosphere; extern BASEIMPORT doste::dvm::OID density; extern BASEIMPORT doste::dvm::OID camera; extern BASEIMPORT doste::dvm::OID fov; #undef far extern BASEIMPORT doste::dvm::OID far; #undef near extern BASEIMPORT doste::dvm::OID near; extern BASEIMPORT doste::dvm::OID zoom; extern BASEIMPORT doste::dvm::OID running; extern BASEIMPORT doste::dvm::OID flipped; extern BASEIMPORT doste::dvm::OID keyboard; extern BASEIMPORT doste::dvm::OID keys; extern BASEIMPORT doste::dvm::OID commands; extern BASEIMPORT doste::dvm::OID lighting; extern BASEIMPORT doste::dvm::OID smooth; extern BASEIMPORT doste::dvm::OID mouse; extern BASEIMPORT doste::dvm::OID deltax; extern BASEIMPORT doste::dvm::OID deltay; extern BASEIMPORT doste::dvm::OID buttons; extern BASEIMPORT doste::dvm::OID visible; extern BASEIMPORT doste::dvm::OID cursor; extern BASEIMPORT doste::dvm::OID colour; extern BASEIMPORT doste::dvm::OID window; extern BASEIMPORT doste::dvm::OID cube; extern BASEIMPORT doste::dvm::OID deltaz; extern BASEIMPORT doste::dvm::OID game; extern BASEIMPORT doste::dvm::OID scene; extern BASEIMPORT doste::dvm::OID levels; extern BASEIMPORT doste::dvm::OID instances; extern BASEIMPORT doste::dvm::OID instance2D; extern BASEIMPORT doste::dvm::OID instance3D; extern BASEIMPORT doste::dvm::OID resolutions; extern BASEIMPORT doste::dvm::OID clearcolour; extern BASEIMPORT doste::dvm::OID colourdepth; extern BASEIMPORT doste::dvm::OID depthbuffer; extern BASEIMPORT doste::dvm::OID title; extern BASEIMPORT doste::dvm::OID fullscreen; extern BASEIMPORT doste::dvm::OID movespeed; extern BASEIMPORT doste::dvm::OID paused; extern BASEIMPORT doste::dvm::OID blending; extern BASEIMPORT doste::dvm::OID resistance; extern BASEIMPORT doste::dvm::OID resistancevar; extern BASEIMPORT doste::dvm::OID axes; extern BASEIMPORT doste::dvm::OID compress; extern BASEIMPORT doste::dvm::OID controls; extern BASEIMPORT doste::dvm::OID scale; extern BASEIMPORT doste::dvm::OID value; extern BASEIMPORT doste::dvm::OID deadzone; extern BASEIMPORT doste::dvm::OID invert; extern BASEIMPORT doste::dvm::OID keep; extern BASEIMPORT doste::dvm::OID flipv; extern BASEIMPORT doste::dvm::OID fliph; extern BASEIMPORT doste::dvm::OID tint; extern BASEIMPORT doste::dvm::OID layer; extern BASEIMPORT doste::dvm::OID widgets; extern BASEIMPORT doste::dvm::OID caption; extern BASEIMPORT doste::dvm::OID grab; extern BASEIMPORT doste::dvm::OID focus; extern BASEIMPORT doste::dvm::OID parent; extern BASEIMPORT doste::dvm::OID screenx; extern BASEIMPORT doste::dvm::OID screeny; extern BASEIMPORT doste::dvm::OID volumes; extern BASEIMPORT doste::dvm::OID children; extern BASEIMPORT doste::dvm::OID type; extern BASEIMPORT doste::dvm::OID light; extern BASEIMPORT doste::dvm::OID glowfilename; extern BASEIMPORT doste::dvm::OID glowmax; extern BASEIMPORT doste::dvm::OID reload; extern BASEIMPORT doste::dvm::OID variables; extern BASEIMPORT doste::dvm::OID input; extern BASEIMPORT doste::dvm::OID source; extern BASEIMPORT doste::dvm::OID location; extern BASEIMPORT doste::dvm::OID time; }; }; #endif wgd-3.1/include/wgd/window.h0000644000175000001440000001017311056217230012736 00000000000000/* * WGD Library * * Authors: * Date: 16/9/2007 * */ #ifndef _WGD_WINDOW_ #define _WGD_WINDOW_ #ifdef WIN32 #include #endif #include #include #include #include #include #include #ifdef LINUX #include #include #include #endif namespace wgd { //class Colour; /** * The OpenGL window for this game. This static class enables you to * access and change properties of the window including its resolution * and fullscreen status. It corresponds to the wgd(window) object in * the configuration database. Note that you do not need to create a * window as this is done for you by Game. * @see Game */ class BASEIMPORT GameWindow : public doste::Agent { public: OBJECT(Agent, GameWindow); GameWindow(const doste::dvm::OID &o); ~GameWindow(); /** * Set the windows title. * @param title A null terminated string. */ PROPERTY_WF(doste::dstring, title, ix::title); /** * Get the current title string for the window. * @return The title string. */ PROPERTY_RF(doste::dstring, title, ix::title); /** * Change the windows or screens resolution. This must * be a valid resolution or nothing will happen. Valid resolutions * are specified in the configuration database but this will also * check hardware for fullscreen mode. * @param width Width in pixels. * @param height Height in pixels. */ void resolution(int,int); /** * Get the pixel width of the window. * @return Width in pixels. */ PROPERTY_RF(int, width, ix::width); /** * Get the pixel height of the window. * @return Height in pixels. */ int height() { return m_height; } /** * Get the number of colour bits. * @return Colour bits. */ PROPERTY_RF(int, colourDepth, ix::colourdepth); /** * Get the number of depth buffer bits. * @return Depth buffer bits. */ PROPERTY_RF(int, depthBuffer, ix::depthbuffer); /** * Change the depth buffer bits for the window. * @param bits Number of depth bits. */ PROPERTY_WF(int, depthBuffer, ix::depthbuffer); /** * Set the fullscreen status of this window. True will make * it fullscreen and false will make it a window. * @param fscreen Boolean to change fullscreen status. */ PROPERTY_WF(bool, fullScreen, ix::fullscreen); /** * Get the current fullscreen status. * @return True if currently in fullscreen mode. */ PROPERTY_RF(bool, fullScreen, ix::fullscreen); /** * Change the default OpenGL clear colour to this colour. * @param c RGB Colour. */ //static void clearColour(const Colour &); /** * Get the current clear colour. * @return A colour object containing the RGB values. */ //static Colour clearColour(); /** * Set the windows position on the screen. * @param x X-Coordinate * @param y Y-Coordinate */ void position(int,int); BEGIN_EVENTS(GameWindow); EVENT(evt_position, (*this)(ix::x)(doste::dvm::modifiers::Seq)(*this)(ix::y)); EVENT(evt_size, (*this)(ix::width)(doste::dvm::modifiers::Seq)(*this)(ix::height)); EVENT(evt_title, (*this)(ix::title)); EVENT(evt_draw, (*this)("draw")); //EVENT(evt_end, (*this)("enddraw")); END_EVENTS; #ifdef WIN32 HDC getHDC() { return m_hDC; }; HWND getHWND() { return m_hWnd; }; #endif #ifdef LINUX Display *getXDisplay() { return m_display; }; Window getXWindow() { return m_window; }; int getXScreen() { return m_screen; }; #endif void draw(); private: bool m_init; bool m_makecontext; //buffer height as it is used a lot int m_height; #ifdef LINUX Display *m_display; XVisualInfo *m_visual; Colormap m_colormap; XSetWindowAttributes m_swa; GLXContext m_context; Window m_window; XF86VidModeModeInfo m_deskMode; int m_screen; #endif #ifdef WIN32 HWND m_hWnd; HDC m_hDC; HGLRC m_hRC; HINSTANCE m_hInst; bool m_hasmultisample; int m_pixformat; #endif void make(); void finaliseInternal(); void defaults(); //bool validRes(); }; extern BASEIMPORT GameWindow *window; }; #endif wgd-3.1/include/wgd/heightmap.h0000644000175000001440000001460011071454426013403 00000000000000#ifndef _WGD_HEIGHTMAP_REGION_ #define _WGD_HEIGHTMAP_REGION_ #include #include #include #include #include namespace wgd { //HMRegion needs camara data class Camera3D; // a single patch of a heightmap that will have level of detail applied to // struct Patch { int offset; //vertex offset to get vertex data from region (worked out from position) unsigned int *indices; //Index array of which vertices in the region get drawn int nIndices; //size of index array int level; //current mip level float *error; //maximum error at each mip level for the patch unsigned int glue; //used to seamlessly join patches together bool changed; //does the patch need rebuilding int node; //The quadtree node - used to get the AABB for collision }; /** * The raw height data passed from HeightmapLoader to HMRegion. * Heights are normalised between -1.0 and 1.0 * Material isthe material that is stretched over the entire heightmap * Materials is an array of nMat material pointers for texture splatting */ struct HMData { int size; float *heights; int nMat; wgd::Material **materials; wgd::Material *material; }; /** * One extra height on all sides of the heightmap to correctly calculate the normals * at the edge of the region Each array is of length size+1 where size is the power of two size of the region * Any of the arrays can be null to just use the edge of the existing heightmap for the normals */ struct HMPadding { float *left; float *right; float *top; float *bottom; }; /** * Heightmap regions are uniform blocks of patches, They store the vertex data for the entire region * that will be divided into the lod patches. * The region must be square and a multiple of patchsize, + 1 (the +1 is an overlap to the next region) * There is only one extra overlap column on the right, and row on the bottom from other regions. * Each vertex must have x and z coordinates 1.0 apart and as a uniform grid. * The heightmap instance will do any scaling required. * All vertices are relative to the region position (so the top left vertex is always (0.0, y, 0.0) * The size variable is the number of patches across the region (sqrt patch count) */ class HEIGHTMAPIMPORT HMRegion { public: struct HMNode { char clipFlags; //Frustum clipping flags float min; //minimum height float max; //maximum height int splat; //splat textures used in this node (per bit) float distance; //distance to camera }; /** * Heightmap Region constructor * @param data Structure containing the height data for this region * @param padding Structure of surrounding heights to calculate normals, Can be null. * @param size The number of vertices along an edge of the region - 1, this value must be a power of 2 */ HMRegion(HMData *data, HMPadding *padding, int size); ~HMRegion(); /** Get the vertex data of the region */ wgd::vertex *vertices() const { return m_vertices; } unsigned int vbo() const { return m_VBO; }; /** Get a specific patch in this region, in patch coordinates relative to the patch */ Patch* patch(int x, int y) const { return &m_patches[x + y * m_size/m_patchSize]; } /** Set up patches, This is be called once by IHeightmap before the region is used */ void setup(int patchSize, const wgd::vector2d &splatScale); /** Query interpolated height of a point in the region */ float height(float x, float y) const; /** Query interpolated normal of a point in the region */ wgd::vector3d normal(float x, float y) const; /** Get the first intersection of a line segment with the heightmap */ bool intersect(wgd::vector3d& point, const wgd::vector3d &start, const wgd::vector3d &end); /** Drawing stuff */ void clip(Camera3D *cam, const wgd::vector3d &scale,const wgd::vector3d &position, int rx, int ry); void setLevels(Camera3D *cam, const wgd::vector3d &scale, float errorMetric); /* get the quadtree node */ HMNode &node(int n) const { return m_tree[n]; } //Texture stuff wgd::Material *baseMaterial() const { return m_baseMaterial; }; int splatCount() const { return m_splatCount; }; wgd::Material *splatMaterial(int i) const { return m_splatMaterial[i]; } wgd::GLTexCoord *splatCoord() const { return m_spatCoord; }; private: void calculateNormals( HMPadding *padding ); /** Query height of a vertex in the region */ float height(int x, int y) const; wgd::vector3d normal(int x, int y) const; //get the intersecion between a line segment and the heightmap - uses vertex data //returns whether there is an intersection. bool intersectPolygons(wgd::vector3d &point, const wgd::vector3d &start, const wgd::vector3d &end); //Similar to the above function but uses the patch AABBs in stead of the vertex data //This function calls the intersect function to get the actual point if the patch is intersected. bool intersectPatches(wgd::vector3d &point, const wgd::vector3d &start, const wgd::vector3d &end); //vertex data wgd::vertex *m_vertices; unsigned int m_VBO; //Size of region int m_size; //regional data for drawing int m_rx, m_ry; //region position wgd::vector3d m_pos; //heightmap position wgd::vector3d m_scale; //heightmap scale int m_patchSize; //patch size float m_camFar; wgd::vector3d m_camPos; //implicit complete quadtree of patches int nodeCount(int); //Calculate the number of quadtree in the region HMNode *m_tree; //recursive functions void setLevelsR(int node, int x, int y, int size); void clipR(Camera3D *cam, int node, int x, int y, int size, int parent); //calculate heights for AABBs (x=min, y=max) wgd::vector2d calcBoxR(int node, int x, int y, int size); //calculate maximum error for a patch for a specific mip level float calcError(int patchSize, int x, int y, int level); //error metric for viewport distortion float m_errorMetric; //patches Patch *m_patches; //The number of mip levels a patch has int levels(int patchSize); int m_levels; // TEXTURING // wgd::Material* m_baseMaterial; wgd::GLTexCoord *m_spatCoord; wgd::Material**m_splatMaterial; int m_splatCount; }; }; #endif wgd-3.1/include/wgd/keyboard.h0000644000175000001440000000446311233311615013233 00000000000000/* * WGD Library * * Authors: * Date: 17/9/2007 * */ #ifndef _WGD_KEYBOARD_ #define _WGD_KEYBOARD_ #include #include #include #include namespace wgd { /** Keyboard key type. */ typedef doste::dvm::OID Key; /** * Provides access to keyboard input. */ class BASEIMPORT Keyboard : public doste::Agent { friend class Input; public: OBJECT(Agent,Keyboard); Keyboard(const doste::dvm::OID &o); ~Keyboard(); doste::dvm::OID keys() const { return (*this)[ix::keys]; } /// get whether a key is pressed bool keyDown(const Key &key) const { return keys()[key]; } /// get whether a key was pressed in the last frame bool keyPressed(const Key &key) { return m_pressed[key]; } static Key KEY_LEFT; /**< Left Arrow */ static Key KEY_UP; /**< Up Arrow */ static Key KEY_RIGHT; /**< Right Arrow */ static Key KEY_DOWN; /**< Down Arrow */ static Key KEY_RETURN; /**< Main return */ static Key KEY_ENTER; /**< Numpad Enter */ static Key KEY_SPACE; /**< Space, same as ' ' */ static Key KEY_CTRL; /**< Left Ctrl */ static Key KEY_SHIFT; /**< Left Shift */ static Key KEY_RCTRL; /**< Right Ctrl */ static Key KEY_RSHIFT; /**< Right Shift */ static Key KEY_ALT; /**< Alt */ static Key KEY_ALTGR; /**< Alt Gr */ static Key KEY_DEL; /**< Delete */ static Key KEY_BKSPACE; /**< Backspace */ static Key KEY_END; /**< End */ static Key KEY_PGDOWN; /**< Page Down */ static Key KEY_PGUP; /**< Page Up */ static Key KEY_HOME; /**< Home */ static Key KEY_INSERT; /**< Insert */ static Key KEY_PAUSE; /**< Pause */ static Key KEY_TAB; /**< Tab */ static Key KEY_ESCAPE; /**< Escape */ static Key KEY_F1; /**< F1 */ static Key KEY_F2; /**< F2 */ static Key KEY_F3; /**< F3 */ static Key KEY_F4; /**< F4 */ static Key KEY_F5; /**< F5 */ static Key KEY_F6; /**< F6 */ static Key KEY_F7; /**< F7 */ static Key KEY_F8; /**< F8 */ static Key KEY_F9; /**< F9 */ static Key KEY_F10; /**< F10 */ static Key KEY_F11; /**< F11 */ static Key KEY_F12; /**< F12 */ private: void update() { m_pressed.clear(); } void keyPress(char key); void keyRelease(char key); std::map m_pressed; char ascii(const Key &key, bool shift); Key convert(char key); }; extern BASEIMPORT Keyboard *keyboard; }; #endif wgd-3.1/include/wgd/quaternion.h0000755000175000001440000001435211023162320013613 00000000000000#ifndef _QUATERNION_ #define _QUATERNION_ #include namespace wgd { class matrix; class vector3d; /** * Alternative for representing rotations. Advantages are that it does not suffer * from gimble lock and produces much better interpolation. */ class quaternion { public: /** Default to 0. */ quaternion() : m_x(0.0), m_y(0.0), m_z(0.0), m_w(1.0) {}; /** Specify components, not pitch, yaw, roll. */ quaternion(float x, float y, float z, float w) : m_x(x), m_y(y), m_z(z), m_w(w) {}; /** Take from a 4 float array. */ quaternion(float *f) : m_x(f[0]), m_y(f[1]), m_z(f[2]), m_w(f[3]){}; ~quaternion() {}; /** * Same as glRotate, it generates the specified rotation int the * specified axis. e.g. createAxisRotation(2.0,1.0,0.0,0.0) = 2 radians in X. */ void createAxisRotation(float radians, float x, float y, float z) { float res = sin(radians / 2.0f); m_x = x*res; m_y = y*res; m_z = z*res; m_w = cos(radians / 2.0f); }; /** * Simpler to use except it can suffer from problems, it is best to * use createAxisRotation. * @param pitch Pitch (X-axis). * @param yaw Yaw (Y-axis). * @param roll Roll (Z-axis). */ void createRotation(float pitch, float yaw, float roll) { /* float p = pitch / 2.0; float y = yaw / 2.0; float r = roll / 2.0; float sinp = sin(p); float siny = sin(y); float sinr = sin(r); float cosp = cos(p); float cosy = cos(y); float cosr = cos(r); m_x = sinr * cosp * cosy - cosr * sinp * siny; m_y = cosr * sinp * cosy + sinr * cosp * siny; m_z = cosr * cosp * siny - sinr * sinp * cosy; m_w = cosr * cosp * cosy + sinr * sinp * siny; normalise(); */ quaternion tmp1, tmpr; tmpr.createAxisRotation(roll, 0.0, 0.0, 1.0); tmp1.createAxisRotation(pitch, 1.0, 0.0, 0.0); tmpr = tmp1*tmpr; tmp1.createAxisRotation(yaw, 0.0, 1.0, 0.0); tmpr = tmp1 * tmpr; m_x = tmpr.m_x; m_y = tmpr.m_y; m_z = tmpr.m_z; m_w = tmpr.m_w; }; inline void createRotation(const vector3d &v); /** Scale the quaternion. */ quaternion operator*(float s) const { return quaternion(m_x*s, m_y*s, m_z*s, m_w*s); }; /** Add two quaternions together */ quaternion operator+(const quaternion &q) const { return quaternion(m_x+q.m_x, m_y+q.m_y, m_z+q.m_z, m_w+q.m_w); } /** * Interpolate between two quaternion rotations. * @param a Start quaternion (t = 0). * @param b End quaternion (t = 1). * @param t Interpolation value between 0 and 1. */ static quaternion slerp(const quaternion &a, const quaternion &b, float t) { float w1; float w2; float dot = a.m_x*b.m_x+a.m_y*b.m_y+a.m_z*b.m_z+a.m_w*b.m_w; float theta = acos(dot); float sintheta = sin(theta); if (sintheta > 0.001) { w1 = sin((1.0f-t)*theta) / sintheta; w2 = sin(t*theta) / sintheta; } else { w1 = 1.0f - t; w2 = t; } return a*w1+b*w2; }; /** * Converts to and OpenGL matrix. This is a 16 float array. */ void createMatrix(float *matrix) const { // First row matrix[ 0] = 1.0f - 2.0f * ( m_y * m_y + m_z * m_z ); matrix[ 1] = 2.0f * (m_x * m_y + m_z * m_w); matrix[ 2] = 2.0f * (m_x * m_z - m_y * m_w); matrix[ 3] = 0.0f; // Second row matrix[ 4] = 2.0f * ( m_x * m_y - m_z * m_w ); matrix[ 5] = 1.0f - 2.0f * ( m_x * m_x + m_z * m_z ); matrix[ 6] = 2.0f * (m_z * m_y + m_x * m_w ); matrix[ 7] = 0.0f; // Third row matrix[ 8] = 2.0f * ( m_x * m_z + m_y * m_w ); matrix[ 9] = 2.0f * ( m_y * m_z - m_x * m_w ); matrix[10] = 1.0f - 2.0f * ( m_x * m_x + m_y * m_y ); matrix[11] = 0.0f; // Fourth row matrix[12] = 0; matrix[13] = 0; matrix[14] = 0; matrix[15] = 1.0f; }; /** * Converts to a Matrix object. * @see Matrix */ inline void createMatrix(wgd::matrix &m) const; /** * Extract a pitch yaw roll vector. */ inline wgd::vector3d pitchYawRoll(); /** Normalise. */ void normalise() { float mag2 = m_w*m_w+m_x*m_x+m_y*m_y+m_z*m_z; if (fabs(mag2-1.0) > 0.00001) { float mag = sqrt(mag2); m_w /= mag; m_x /= mag; m_y /= mag; m_z /= mag; } }; /** Conjugate, a kind of inverse. */ quaternion conjugate() const { return quaternion(-m_x,-m_y,-m_z,m_w); }; /** * Multiply two quaternions together. This combines the rotation as would * combining two rotation matrices. */ quaternion operator*(const quaternion &q) const { return quaternion( m_w*q.m_x + m_x*q.m_w + m_y*q.m_z - m_z*q.m_y, m_w*q.m_y + m_y*q.m_w + m_z*q.m_x - m_x*q.m_z, m_w*q.m_z + m_z*q.m_w + m_x*q.m_y - m_y*q.m_x, m_w*q.m_w - m_x*q.m_x - m_y*q.m_y - m_z*q.m_z); }; float m_x; float m_y; float m_z; float m_w; }; typedef quaternion Quaternion; }; #include #include void wgd::quaternion::createMatrix(wgd::matrix &m) const { m.m[0][0] = 1.0f - 2.0f * ( m_y * m_y + m_z * m_z ); m.m[1][0] = 2.0f * ( m_x * m_y - m_z * m_w ); m.m[2][0] = 2.0f * ( m_x * m_z + m_y * m_w ); m.m[3][0] = 0.0; m.m[0][1] = 2.0f * (m_x * m_y + m_z * m_w); m.m[1][1] = 1.0f - 2.0f * ( m_x * m_x + m_z * m_z ); m.m[2][1] = 2.0f * ( m_y * m_z - m_x * m_w ); m.m[3][1] = 0.0; m.m[0][2] = 2.0f * (m_x * m_z - m_y * m_w); m.m[1][2] = 2.0f * (m_z * m_y + m_x * m_w ); m.m[2][2] = 1.0f - 2.0f * ( m_x * m_x + m_y * m_y ); m.m[3][2] = 0.0; m.m[0][3] = 0.0; m.m[1][3] = 0.0; m.m[2][3] = 0.0; m.m[3][3] = 1.0; }; void wgd::quaternion::createRotation(const vector3d &v){ createRotation(v.x, v.y, v.z); } wgd::vector3d wgd::quaternion::pitchYawRoll(){ //tan(yaw) = 2(q1q2+q4q3)/ (q42 + q12 - q22- q32) //sin(pitch) = -2(q1q3-q4q2) //tan(roll) = 2(q4q1+q2q3)/ (q42 - q12 - q22+ q32) float yaw = atan(2*(m_x*m_y+m_w*m_z)/ (m_w*m_y + m_x*m_y - m_y*m_y- m_z*m_y)); float pitch = asin(-2*(m_x*m_z-m_w*m_y)); float roll = atan(2*(m_w*m_x+m_y*m_z)/ (m_w*m_y - m_x*m_y - m_y*m_y+ m_z*m_y)); return wgd::vector3d(pitch, yaw, roll); }; #endif wgd-3.1/include/wgd/zlib/0000777000175000001440000000000011265576315012316 500000000000000wgd-3.1/include/wgd/zlib/crc32.h0000644000175000001440000007355010755642347013333 00000000000000/* crc32.h -- tables for rapid CRC calculation * Generated automatically by crc32.c */ local const unsigned long FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL, 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL, 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL, 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL, 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL, 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL, 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL, 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL, 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL, 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL, 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL, 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL, 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL, 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL, 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL, 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL, 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL, 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL, 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL, 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL, 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL, 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL, 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL, 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL, 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL, 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL, 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL, 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL, 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL, 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL, 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL, 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL, 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL, 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL, 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL, 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL, 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL, 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL, 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL, 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL, 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL, 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL, 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL, 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL, 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL, 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL, 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL, 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL, 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x2d02ef8dUL #ifdef BYFOUR }, { 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL, 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL, 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL, 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL, 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL, 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL, 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL, 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL, 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL, 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL, 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL, 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL, 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL, 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL, 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL, 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL, 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL, 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL, 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL, 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL, 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL, 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL, 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL, 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL, 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL, 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL, 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL, 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL, 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL, 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL, 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL, 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL, 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL, 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL, 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL, 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL, 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL, 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL, 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL, 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL, 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL, 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL, 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL, 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL, 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL, 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL, 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL, 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL, 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL, 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL, 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL, 0x9324fd72UL }, { 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL, 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL, 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL, 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL, 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL, 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL, 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL, 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL, 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL, 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL, 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL, 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL, 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL, 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL, 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL, 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL, 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL, 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL, 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL, 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL, 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL, 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL, 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL, 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL, 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL, 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL, 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL, 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL, 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL, 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL, 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL, 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL, 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL, 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL, 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL, 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL, 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL, 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL, 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL, 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL, 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL, 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL, 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL, 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL, 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL, 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL, 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL, 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL, 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL, 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL, 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL, 0xbe9834edUL }, { 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL, 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL, 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL, 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL, 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL, 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL, 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL, 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL, 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL, 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL, 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL, 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL, 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL, 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL, 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL, 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL, 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL, 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL, 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL, 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL, 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL, 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL, 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL, 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL, 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL, 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL, 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL, 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL, 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL, 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL, 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL, 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL, 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL, 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL, 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL, 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL, 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL, 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL, 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL, 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL, 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL, 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL, 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL, 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL, 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL, 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL, 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL, 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL, 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL, 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL, 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL, 0xde0506f1UL }, { 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL, 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL, 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL, 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL, 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL, 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL, 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL, 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL, 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL, 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL, 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL, 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL, 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL, 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL, 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL, 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL, 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL, 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL, 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL, 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL, 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL, 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL, 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL, 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL, 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL, 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL, 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL, 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL, 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL, 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL, 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL, 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL, 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL, 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL, 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL, 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL, 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL, 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL, 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL, 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL, 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL, 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL, 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL, 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL, 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL, 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL, 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL, 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL, 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL, 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL, 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL, 0x8def022dUL }, { 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL, 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL, 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL, 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL, 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL, 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL, 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL, 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL, 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL, 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL, 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL, 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL, 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL, 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL, 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL, 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL, 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL, 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL, 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL, 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL, 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL, 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL, 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL, 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL, 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL, 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL, 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL, 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL, 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL, 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL, 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL, 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL, 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL, 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL, 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL, 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL, 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL, 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL, 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL, 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL, 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL, 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL, 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL, 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL, 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL, 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL, 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL, 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL, 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL, 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL, 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL, 0x72fd2493UL }, { 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL, 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL, 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL, 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL, 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL, 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL, 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL, 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL, 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL, 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL, 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL, 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL, 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL, 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL, 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL, 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL, 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL, 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL, 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL, 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL, 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL, 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL, 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL, 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL, 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL, 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL, 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL, 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL, 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL, 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL, 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL, 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL, 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL, 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL, 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL, 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL, 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL, 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL, 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL, 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL, 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL, 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL, 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL, 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL, 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL, 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL, 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL, 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL, 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL, 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL, 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL, 0xed3498beUL }, { 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL, 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL, 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL, 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL, 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL, 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL, 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL, 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL, 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL, 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL, 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL, 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL, 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL, 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL, 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL, 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL, 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL, 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL, 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL, 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL, 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL, 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL, 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL, 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL, 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL, 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL, 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL, 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL, 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL, 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL, 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL, 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL, 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL, 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL, 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL, 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL, 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL, 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL, 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL, 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL, 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL, 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL, 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL, 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL, 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL, 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL, 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL, 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL, 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL, 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL, 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL, 0xf10605deUL #endif } }; wgd-3.1/include/wgd/zlib/inflate.h0000644000175000001440000001343410755642347014034 00000000000000/* inflate.h -- internal inflate state definition * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* define NO_GZIP when compiling if you want to disable gzip header and trailer decoding by inflate(). NO_GZIP would be used to avoid linking in the crc code when it is not needed. For shared libraries, gzip decoding should be left enabled. */ #ifndef NO_GZIP # define GUNZIP #endif /* Possible inflate modes between inflate() calls */ typedef enum { HEAD, /* i: waiting for magic header */ FLAGS, /* i: waiting for method and flags (gzip) */ TIME, /* i: waiting for modification time (gzip) */ OS, /* i: waiting for extra flags and operating system (gzip) */ EXLEN, /* i: waiting for extra length (gzip) */ EXTRA, /* i: waiting for extra bytes (gzip) */ NAME, /* i: waiting for end of file name (gzip) */ COMMENT, /* i: waiting for end of comment (gzip) */ HCRC, /* i: waiting for header crc (gzip) */ DICTID, /* i: waiting for dictionary check value */ DICT, /* waiting for inflateSetDictionary() call */ TYPE, /* i: waiting for type bits, including last-flag bit */ TYPEDO, /* i: same, but skip check to exit inflate on new block */ STORED, /* i: waiting for stored size (length and complement) */ COPY, /* i/o: waiting for input or output to copy stored block */ TABLE, /* i: waiting for dynamic block table lengths */ LENLENS, /* i: waiting for code length code lengths */ CODELENS, /* i: waiting for length/lit and distance code lengths */ LEN, /* i: waiting for length/lit code */ LENEXT, /* i: waiting for length extra bits */ DIST, /* i: waiting for distance code */ DISTEXT, /* i: waiting for distance extra bits */ MATCH, /* o: waiting for output space to copy string */ LIT, /* o: waiting for output space to write literal */ CHECK, /* i: waiting for 32-bit check value */ LENGTH, /* i: waiting for 32-bit length (gzip) */ DONE, /* finished check, done -- remain here until reset */ BAD, /* got a data error -- remain here until reset */ MEM, /* got an inflate() memory error -- remain here until reset */ SYNC /* looking for synchronization bytes to restart inflate() */ } inflate_mode; /* State transitions between above modes - (most modes can go to the BAD or MEM mode -- not shown for clarity) Process header: HEAD -> (gzip) or (zlib) (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME NAME -> COMMENT -> HCRC -> TYPE (zlib) -> DICTID or TYPE DICTID -> DICT -> TYPE Read deflate blocks: TYPE -> STORED or TABLE or LEN or CHECK STORED -> COPY -> TYPE TABLE -> LENLENS -> CODELENS -> LEN Read deflate codes: LEN -> LENEXT or LIT or TYPE LENEXT -> DIST -> DISTEXT -> MATCH -> LEN LIT -> LEN Process trailer: CHECK -> LENGTH -> DONE */ /* state maintained between inflate() calls. Approximately 7K bytes. */ struct inflate_state { inflate_mode mode; /* current inflate mode */ int last; /* true if processing last block */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ int havedict; /* true if dictionary provided */ int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned long check; /* protected copy of check value */ unsigned long total; /* protected copy of output count */ gz_headerp head; /* where to save gzip header information */ /* sliding window */ unsigned wbits; /* log base 2 of requested window size */ unsigned wsize; /* window size or zero if not using window */ unsigned whave; /* valid bytes in the window */ unsigned write; /* window write index */ unsigned char FAR *window; /* allocated sliding window, if needed */ /* bit accumulator */ unsigned long hold; /* input bit accumulator */ unsigned bits; /* number of bits in "in" */ /* for string and stored block copying */ unsigned length; /* literal or length of data to copy */ unsigned offset; /* distance back to copy string from */ /* for table and code decoding */ unsigned extra; /* extra bits needed */ /* fixed and dynamic code tables */ code const FAR *lencode; /* starting table for length/literal codes */ code const FAR *distcode; /* starting table for distance codes */ unsigned lenbits; /* index bits for lencode */ unsigned distbits; /* index bits for distcode */ /* dynamic table building */ unsigned ncode; /* number of code length code lengths */ unsigned nlen; /* number of length code lengths */ unsigned ndist; /* number of distance code lengths */ unsigned have; /* number of code lengths in lens[] */ code FAR *next; /* next available space in codes[] */ unsigned short lens[320]; /* temporary storage for code lengths */ unsigned short work[288]; /* work area for code table building */ code codes[ENOUGH]; /* space for code tables */ }; wgd-3.1/include/wgd/zlib/inffast.h0000644000175000001440000000062710755642347014044 00000000000000/* inffast.h -- header to use inffast.c * Copyright (C) 1995-2003 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ void inflate_fast OF((z_streamp strm, unsigned start)); wgd-3.1/include/wgd/zlib/Makefile.am0000755000175000001440000000022511044044130014244 00000000000000pkgincludedir = $(includedir)/wgd/zlib pkginclude_HEADERS=crc32.h deflate.h inffast.h inffixed.h inflate.h inftrees.h trees.h zconf.h zlib.h zutil.h wgd-3.1/include/wgd/zlib/zutil.h0000644000175000001440000001531310755642347013557 00000000000000/* zutil.h -- internal interface and configuration of the compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef ZUTIL_H #define ZUTIL_H #define ZLIB_INTERNAL #include "zlib.h" #ifdef STDC # ifndef _WIN32_WCE # include # endif # include # include #endif #ifdef NO_ERRNO_H # ifdef _WIN32_WCE /* The Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. We rename it to * avoid conflict with other libraries that use the same workaround. */ # define errno z_errno # endif extern int errno; #else # ifndef _WIN32_WCE # include # endif #endif #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ typedef unsigned char uch; typedef uch FAR uchf; typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] #define ERR_RETURN(strm,err) \ return (strm->msg = (char*)ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ /* common constants */ #ifndef DEF_WBITS # define DEF_WBITS MAX_WBITS #endif /* default windowBits for decompression. MAX_WBITS is for compression only */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default memLevel */ #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 /* The three kinds of block type */ #define MIN_MATCH 3 #define MAX_MATCH 258 /* The minimum and maximum match lengths */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ /* target dependencies */ #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) # define OS_CODE 0x00 # if defined(__TURBOC__) || defined(__BORLANDC__) # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) /* Allow compilation with ANSI keywords only enabled */ void _Cdecl farfree( void *block ); void *_Cdecl farmalloc( unsigned long nbytes ); # else # include # endif # else /* MSC or DJGPP */ # include # endif #endif #ifdef AMIGA # define OS_CODE 0x01 #endif #if defined(VAXC) || defined(VMS) # define OS_CODE 0x02 # define F_OPEN(name, mode) \ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #if defined(ATARI) || defined(atarist) # define OS_CODE 0x05 #endif #ifdef OS2 # define OS_CODE 0x06 # ifdef M_I86 #include # endif #endif #if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 0x07 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include /* for fdopen */ # else # ifndef fdopen # define fdopen(fd,mode) NULL /* No fdopen() */ # endif # endif #endif #ifdef TOPS20 # define OS_CODE 0x0a #endif #ifdef WIN32 # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ # define OS_CODE 0x0b # endif #endif #ifdef __50SERIES /* Prime/PRIMOS */ # define OS_CODE 0x0f #endif #if defined(_BEOS_) || defined(RISCOS) # define fdopen(fd,mode) NULL /* No fdopen() */ #endif #if (defined(_MSC_VER) && (_MSC_VER > 600)) # if defined(_WIN32_WCE) # define fdopen(fd,mode) NULL /* No fdopen() */ # ifndef _PTRDIFF_T_DEFINED typedef int ptrdiff_t; # define _PTRDIFF_T_DEFINED # endif # else # define fdopen(fd,type) _fdopen(fd,type) # endif #endif /* common defaults */ #ifndef OS_CODE # define OS_CODE 0x03 /* assume Unix */ #endif #ifndef F_OPEN # define F_OPEN(name, mode) fopen((name), (mode)) #endif /* functions */ #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) # ifndef HAVE_VSNPRINTF # define HAVE_VSNPRINTF # endif #endif #if defined(__CYGWIN__) # ifndef HAVE_VSNPRINTF # define HAVE_VSNPRINTF # endif #endif #ifndef HAVE_VSNPRINTF # ifdef MSDOS /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), but for now we just assume it doesn't. */ # define NO_vsnprintf # endif # ifdef __TURBOC__ # define NO_vsnprintf # endif # ifdef WIN32 /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ # if !defined(vsnprintf) && !defined(NO_vsnprintf) # define vsnprintf _vsnprintf # endif # endif # ifdef __SASC # define NO_vsnprintf # endif #endif #ifdef VMS # define NO_vsnprintf #endif #if defined(pyr) # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) /* Use our own functions for small and medium model with MSC <= 5.0. * You may have to use the same strategy for Borland C (untested). * The __SC__ check is for Symantec. */ # define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_MEMCPY #endif #ifdef HAVE_MEMCPY # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ # define zmemcpy _fmemcpy # define zmemcmp _fmemcmp # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy memcpy # define zmemcmp memcmp # define zmemzero(dest, len) memset(dest, 0, len) # endif #else extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len)); #endif /* Diagnostic functions */ #ifdef DEBUG # include extern int z_verbose; extern void z_error OF((char *m)); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracevv(x) {if (z_verbose>1) fprintf x ;} # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else # define Assert(cond,msg) # define Trace(x) # define Tracev(x) # define Tracevv(x) # define Tracec(c,x) # define Tracecv(c,x) #endif voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); void zcfree OF((voidpf opaque, voidpf ptr)); #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} #endif /* ZUTIL_H */ wgd-3.1/include/wgd/zlib/inffixed.h0000644000175000001440000001430710755642347014206 00000000000000 /* inffixed.h -- table for decoding fixed codes * Generated automatically by makefixed(). */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ static const code lenfix[512] = { {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, {0,9,255} }; static const code distfix[32] = { {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, {22,5,193},{64,5,0} }; wgd-3.1/include/wgd/zlib/zconf.h0000644000175000001440000002245310755642347013532 00000000000000/* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. */ #ifdef Z_PREFIX # define deflateInit_ z_deflateInit_ # define deflate z_deflate # define deflateEnd z_deflateEnd # define inflateInit_ z_inflateInit_ # define inflate z_inflate # define inflateEnd z_inflateEnd # define deflateInit2_ z_deflateInit2_ # define deflateSetDictionary z_deflateSetDictionary # define deflateCopy z_deflateCopy # define deflateReset z_deflateReset # define deflateParams z_deflateParams # define deflateBound z_deflateBound # define deflatePrime z_deflatePrime # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateCopy z_inflateCopy # define inflateReset z_inflateReset # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define zError z_zError # define alloc_func z_alloc_func # define free_func z_free_func # define in_func z_in_func # define out_func z_out_func # define Byte z_Byte # define uInt z_uInt # define uLong z_uLong # define Bytef z_Bytef # define charf z_charf # define intf z_intf # define uIntf z_uIntf # define uLongf z_uLongf # define voidpf z_voidpf # define voidp z_voidp #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) # define NO_DUMMY_DECL #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus a few kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte Bytef; #endif typedef char charf; typedef int intf; typedef uInt uIntf; typedef uLong uLongf; #ifdef STDC typedef void const *voidpc; typedef void *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ # include /* for off_t */ # include /* for SEEK_* and off_t */ # ifdef VMS # include /* for off_t */ # endif # define z_off_t off_t #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif #if defined(__OS400__) # define NO_vsnprintf #endif #if defined(__MVS__) # define NO_vsnprintf # ifdef FAR # undef FAR # endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) # pragma map(deflateInit_,"DEIN") # pragma map(deflateInit2_,"DEIN2") # pragma map(deflateEnd,"DEEND") # pragma map(deflateBound,"DEBND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(compressBound,"CMBND") # pragma map(inflate_table,"INTABL") # pragma map(inflate_fast,"INFA") # pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ wgd-3.1/include/wgd/zlib/Makefile.in0000644000175000001440000002623611265575054014307 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = include/wgd/zlib DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(pkgincludedir)" pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(pkginclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/wgd/zlib ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pkginclude_HEADERS = crc32.h deflate.h inffast.h inffixed.h inflate.h inftrees.h trees.h zconf.h zlib.h zutil.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps include/wgd/zlib/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps include/wgd/zlib/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ ctags distclean distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-pkgincludeHEADERS install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ uninstall uninstall-am uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/include/wgd/zlib/zlib.h0000644000175000001440000020115110755642347013345 00000000000000/* zlib.h -- interface of the 'zlib' general purpose compression library version 1.2.3, July 18th, 2005 Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ #ifndef ZLIB_H #define ZLIB_H #include #ifdef __cplusplus extern "C" { #endif #define ZLIB_VERSION "1.2.3" #define ZLIB_VERNUM 0x1230 /* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) but other algorithms will be added later and will have the same stream interface. Compression can be done in a single step if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. The compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. This library can optionally read and write gzip streams in memory as well. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total nb of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: binary or text */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream *z_streamp; /* gzip header information passed to and from zlib routines. See RFC 1952 for more details on the meanings of these fields. */ typedef struct gz_header_s { int text; /* true if compressed data believed to be text */ uLong time; /* modification time */ int xflags; /* extra flags (not used when writing a gzip file) */ int os; /* operating system */ Bytef *extra; /* pointer to extra field or Z_NULL if none */ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ uInt extra_max; /* space at extra (only when reading header) */ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ uInt name_max; /* space at name (only when reading header) */ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ uInt comm_max; /* space at comment (only when reading header) */ int hcrc; /* true if there was or will be a header crc */ int done; /* true when done reading gzip header (not used when writing a gzip file) */ } gz_header; typedef gz_header *gz_headerp; /* The application must update next_in and avail_in when avail_in has dropped to zero. It must update next_out and avail_out when avail_out has dropped to zero. The application must initialize zalloc, zfree and opaque before calling the init function. All other fields are set by the compression library and must not be updated by the application. The opaque value provided by the application will be passed as the first parameter for calls of zalloc and zfree. This can be useful for custom memory management. The compression library attaches no meaning to the opaque value. zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be thread safe. On 16-bit systems, the functions zalloc and zfree must be able to allocate exactly 65536 bytes, but will not be required to allocate more than this if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers returned by zalloc for objects of exactly 65536 bytes *must* have their offset normalized to zero. The default allocation function provided by this library ensures this (see zutil.c). To reduce memory requirements and avoid any allocation of 64K objects, at the expense of compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). The fields total_in and total_out can be used for statistics or progress reports. After compression, total_in holds the total size of the uncompressed data and may be saved for use in the decompressor (particularly if the decompressor wants to decompress everything in a single step). */ /* constants */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 #define Z_BLOCK 5 /* Allowed flush values; see deflate() and inflate() below for details */ #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative * values are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_RLE 3 #define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field (though see inflate()) */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ /* basic functions */ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ /* ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default allocation functions. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary (in interactive applications). Some output may be provided even if flush is not set. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating avail_in or avail_out accordingly; avail_out should never be zero before the call. The application can consume the compressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to decide how much data to accumualte before producing output, in order to maximize compression. If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so that the decompressor can get all input data available so far. (In particular avail_in is zero after the call if enough output space has been provided before the call.) Flushing may degrade compression for some compression algorithms and so it should be used only when necessary. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out is greater than six to avoid repeated flush markers due to avail_out == 0 on return. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was enough output space; if deflate returns with Z_OK, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. Z_FINISH can be used immediately after deflateInit if all the compression is to be done in a single step. In this case, avail_out must be at least the value returned by deflateBound (see below). If deflate does not return Z_STREAM_END, then it must be called again as described above. deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). deflate() may update strm->data_type if it can make a good guess about the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and deflate() can be called again with more input and more output space to continue compressing. */ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded). In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. If next_in is not Z_NULL and avail_in is large enough (the exact value depends on the compression method), inflateInit determines the compression method from the zlib header and allocates all data structures accordingly; otherwise the allocation will be deferred to the first call of inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller. msg is set to null if there is no error message. inflateInit does not perform any decompression apart from reading the zlib header if present: this will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much output as possible to the output buffer. Z_BLOCK requests that inflate() stop if and when it gets to the next deflate block boundary. When decoding the zlib or gzip format, this will cause inflate() to return immediately after the header and before the first block. When doing a raw inflate, inflate() will go ahead and process the first block, and will return when it gets to the end of that block, or when it runs out of data. The Z_BLOCK option assists in appending to or combining deflate streams. Also to assist in this, on return inflate() will set strm->data_type to the number of unused bits in the last byte taken from strm->next_in, plus 64 if inflate() is currently decoding the last block in the deflate stream, plus 128 if inflate() returned immediately after decoding an end-of-block code or decoding the complete header up to just before the first byte of the deflate stream. The end-of-block will not be indicated until all of the uncompressed data from that block has been written to strm->next_out. The number of unused bits may in general be greater than seven, except when bit 7 of data_type is set, in which case the number of unused bits will be less than eight. inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be inflateEnd to deallocate the decompression state. The use of Z_FINISH is never required, but can be used to inform inflate that a faster approach may be used for the single inflate() call. In this implementation, inflate() always flushes as much output as possible to the output buffer, and always uses the faster approach on the first call. So the only effect of the flush parameter in this implementation is on the return value of inflate(), as noted below, or when it returns early because Z_BLOCK is used. If a preset dictionary is needed after this call (see inflateSetDictionary below), inflate sets strm->adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() will decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically. Any information contained in the gzip header is not retained, so applications that need that information should instead use raw inflate, see inflateInit2() below, or inflateBack() and perform their own processing of the gzip header and trailer. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check value), Z_STREAM_ERROR if the stream structure was inconsistent (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial recovery of the data is desired. */ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* Advanced functions */ /* The following functions are needed only in some special applications. */ /* ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy)); This is another version of deflateInit with more compression options. The fields next_in, zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute an adler32 check value. windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no header crc, and the operating system will be set to 255 (unknown). If a gzip stream is being written, strm->adler is a crc32 instead of an adler32. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed. The default value is 8. See zconf.h for total memory usage as a function of windowBits and memLevel. The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no string match), or Z_RLE to limit match distances to one (run-length encoding). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid method). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called immediately after deflateInit, deflateInit2 or deflateReset, before any call of deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size in deflate or deflate2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. In addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary. Upon return of this function, strm->adler is set to the adler32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The adler32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the adler32 value is not computed and strm->adler is not set. deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent (for example if deflate has already been called for this stream or if the compression method is bsort). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, z_streamp source)); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate all the internal compression state. The stream will keep the same compression level and any other attributes that may have been set by deflateInit2. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL). */ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, int level, int strategy)); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression level is changed, the input available so far is compressed with the old level (and may be flushed); the new level will take effect only at the next call of deflate(). Before the call of deflateParams, the stream state must be set as for a call of deflate(), since the currently available input may have to be compressed and flushed. In particular, strm->avail_out must be non-zero. deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if strm->avail_out was zero. */ ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain)); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for searching for the best matching string, and even then only by the most fanatic optimizer trying to squeeze out the last compressed bit for their specific input data. Read the deflate.c source code for the meaning of the max_lazy, good_length, nice_length, and max_chain parameters. deflateTune() can be called after deflateInit() or deflateInit2(), and returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, uLong sourceLen)); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or deflateInit2(). This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate(). */ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, int bits, int value)); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits leftover from a previous deflate stream when appending to it. As such, this function can only be used for raw deflate, and must be used before the first deflate() call after a deflateInit2() or deflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the output. deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, gz_headerp head)); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information in the provided gz_header structure are written to the gzip header (xflag is ignored -- the extra flags are set according to the compression level). The caller must assure that, if not Z_NULL, name and comment are terminated with a zero byte, and that if extra is not Z_NULL, that extra_len bytes are available there. If hcrc is true, a gzip header crc is included. Note that the current versions of the command-line version of gzip (up through version 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, the time set to zero, and os set to 255, with no extra, name, or comment fields. The gzip header is returned to the default state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, int windowBits)); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The default value is 15 if inflateInit is used instead. windowBits must be greater than or equal to the windowBits value provided to deflateInit2() while compressing, or it must be equal to 15 if deflateInit2() was not used. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. windowBits can also be -8..-15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is recommended that a check value such as an adler32 or a crc32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a crc32 instead of an adler32. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg is set to null if there is no error message. inflateInit2 does not perform any decompression apart from reading the zlib header if present: this will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unchanged.) */ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, const Bytef *dictionary, uInt dictLength)); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the adler32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called immediately after inflateInit2() or inflateReset() and before any call of inflate() to set the dictionary. The application must insure that the dictionary that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); /* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success case, the application may save the current current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data. */ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, z_streamp source)); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when randomly accessing a large stream. The first pass through the stream can periodically record the inflate state, allowing restarting inflate at those points when randomly accessing the stream. inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being NULL). msg is left unchanged in both source and destination. */ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL). */ ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, int bits, int value)); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the middle of a byte. The provided bits will be used before any bytes are used from next_in. This function should only be used with raw inflate, and should be used before the first inflate() call after inflateInit2() or inflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the input. inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, gz_headerp head)); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be no gzip header information forthcoming. Note that Z_BLOCK can be used to force inflate() to return immediately after header processing is complete and before any actual data is decompressed. The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, terminated with a zero unless the length is greater than comm_max. When any of extra, name, or comment are not Z_NULL and the respective field is not present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed. If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream. inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, unsigned char FAR *window)); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized before the call. If zalloc and zfree are Z_NULL, then the default library- derived memory allocation routines are used. windowBits is the base two logarithm of the window size, in the range 8..15. window is a caller supplied buffer of that size. Except for special applications where it is assured that deflate was used with small window sizes, windowBits must be 15 and a 32K byte window must be supplied to be able to decompress general deflate streams. See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of the paramaters are invalid, Z_MEM_ERROR if the internal state could not be allocated, or Z_VERSION_ERROR if the version of the library does not match the version of the header file. */ typedef unsigned (*in_func) OF((void *, unsigned char * *)); typedef int (*out_func) OF((void *, unsigned char *, unsigned)); ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, in_func in, void *in_desc, out_func out, void *out_desc)); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is more efficient than inflate() for file i/o applications in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. This function trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns. inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw deflate stream with each call. inflateBackEnd() is then called to free the allocated state. A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only the raw deflate stream to decompress. This is different from the normal behavior of inflate(), which expects either a zlib or gzip header and trailer around the deflate stream. inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those routines until it reads a complete deflate stream and writes out all of the uncompressed data, or until it encounters an error. The function's parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If there is no input available, in() must return zero--buf is ignored in that case--and inflateBack() will return a buffer error. inflateBack() will call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() should return zero on success, or non-zero on failure. If out() returns non-zero, inflateBack() will return with an error. Neither in() nor out() are permitted to change the contents of the window provided to inflateBackInit(), which is also the buffer that out() uses to write from. The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in(). For convenience, inflateBack() can be provided input on the first call by setting strm->next_in and strm->avail_in. If that input is exhausted, then in() will be called. Therefore strm->next_in must be initialized before calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will initially be taken from strm->next_in[0 .. strm->avail_in - 1]. The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These descriptors can be optionally used to pass any information that the caller- supplied in() and out() functions need to do their job. On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR if in() or out() returned an error, Z_DATA_ERROR if there was a format error in the deflate stream (in which case strm->msg is set to indicate the nature of the error), or Z_STREAM_ERROR if the stream was not properly initialized. In the case of Z_BUF_ERROR, an input or output error can be distinguished using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK. */ ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); /* All memory allocated by inflateBackInit() is freed. inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream state was inconsistent. */ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 1.0: size of uInt 3.2: size of uLong 5.4: size of voidpf (pointer) 7.6: size of z_off_t Compiler, assembler, and debug options: 8: DEBUG 9: ASMV or ASMINF -- use ASM code 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) Library content (indicates missing functionality): 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking deflate code when not needed) 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect and decode gzip streams (to avoid linking crc code) 18-19: 0 (reserved) Operation variations (changes in library functionality): 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 21: FASTEST -- deflate algorithm with only one, lowest compression level 22,23: 0 (reserved) The sprintf variant used by gzprintf (zero is best): 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 26: 0 = returns value, 1 = void -- 1 means inferred string length returned Remainder: 27-31: 0 (reserved) */ /* utility functions */ /* The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can easily be modified if you need special options. */ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. This function can be used to compress a whole file at once if the input file is mmap'ed. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed buffer. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the compressed buffer. This function can be used to decompress a whole file at once if the input file is mmap'ed. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. */ typedef voidp gzFile; ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); /* Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only compression as in "wb1h", or 'R' for run-length encoding as in "wb1R". (See the description of deflateInit2 for more information about the strategy parameter.) gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. gzopen returns NULL if the file could not be opened or if there was insufficient memory to allocate the (de)compression state; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); /* gzdopen() associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (in the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd), mode) closes the file descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). gzdopen returns NULL if there was insufficient memory to allocate the (de)compression state. */ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not opened for writing. */ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); /* Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number of bytes into the buffer. gzread returns the number of uncompressed bytes actually read (0 for end of file, -1 for error). */ ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written (0 in case of error). */ ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); /* Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written (0 in case of error). The number of uncompressed bytes written is limited to 4095. The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if zlib was compiled with the insecure functions sprintf() or vsprintf() because the secure snprintf() or vsnprintf() functions were not available. */ ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file condition is encountered. The string is then terminated with a null character. gzgets returns buf, or Z_NULL in case of error. */ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); /* Push one character back onto the stream to be read again later. Only one character of push-back is allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if a character has been pushed but not read yet, or if c is -1. The pushed character will be discarded if the stream is repositioned with gzseek() or gzrewind(). */ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush returns Z_OK if the flush parameter is Z_FINISH and all output could be flushed. gzflush should be called only when strictly necessary because it can degrade compression. */ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, z_off_t offset, int whence)); /* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. */ ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); /* Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream. gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ ZEXTERN int ZEXPORT gzeof OF((gzFile file)); /* Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); /* Returns 1 if file is being read directly without decompression, otherwise zero. */ ZEXTERN int ZEXPORT gzclose OF((gzFile file)); /* Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. The return value is the zlib error number (see function gzerror below). */ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. */ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); /* Clears the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ /* checksum functions */ /* These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library. */ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, z_off_t len2)); /* Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. */ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. If buf is NULL, this function returns the required initial value for the for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); /* Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and len2. */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, const char *version, int stream_size)); ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, unsigned char *window, const char *version, int stream_size)); #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, sizeof(z_stream)) #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif ZEXTERN const char * ZEXPORT zError OF((int)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); #ifdef __cplusplus } #endif #endif /* ZLIB_H */ wgd-3.1/include/wgd/zlib/inftrees.h0000644000175000001440000000450510755642347014230 00000000000000/* inftrees.h -- header to use inftrees.c * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* Structure for decoding tables. Each entry provides either the information needed to do the operation requested by the code that indexed that table entry, or it provides a pointer to another table that indexes more bits of the code. op indicates whether the entry is a pointer to another table, a literal, a length or distance, an end-of-block, or an invalid code. For a table pointer, the low four bits of op is the number of index bits of that table. For a length or distance, the low four bits of op is the number of extra bits to get after the code. bits is the number of bits in this code or part of the code to drop off of the bit buffer. val is the actual byte to output in the case of a literal, the base length or distance, or the offset from the current table to the next table. Each entry is four bytes. */ typedef struct { unsigned char op; /* operation, extra bits, table bits */ unsigned char bits; /* bits in this part of the code */ unsigned short val; /* offset in table or code value */ } code; /* op values as set by inflate_table(): 00000000 - literal 0000tttt - table link, tttt != 0 is the number of table index bits 0001eeee - length or distance, eeee is the number of extra bits 01100000 - end of block 01000000 - invalid code */ /* Maximum size of dynamic tree. The maximum found in a long but non- exhaustive search was 1444 code structures (852 for length/literals and 592 for distances, the latter actually the result of an exhaustive search). The true maximum is not known, but the value below is more than safe. */ #define ENOUGH 2048 #define MAXD 592 /* Type of code to build for inftable() */ typedef enum { CODES, LENS, DISTS } codetype; extern int inflate_table OF((codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work)); wgd-3.1/include/wgd/zlib/trees.h0000644000175000001440000002037410755642347013535 00000000000000/* header created automatically with -DGEN_TREES_H */ local const ct_data static_ltree[L_CODES+2] = { {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} }; local const ct_data static_dtree[D_CODES] = { {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} }; const uch _dist_code[DIST_CODE_LEN] = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 }; const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 }; local const int base_length[LENGTH_CODES] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0 }; local const int base_dist[D_CODES] = { 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 }; wgd-3.1/include/wgd/zlib/deflate.h0000644000175000001440000002752210755642347014021 00000000000000/* deflate.h -- internal compression state * Copyright (C) 1995-2004 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef DEFLATE_H #define DEFLATE_H #include "zutil.h" /* define NO_GZIP when compiling if you want to disable gzip header and trailer creation by deflate(). NO_GZIP would be used to avoid linking in the crc code when it is not needed. For shared libraries, gzip encoding should be left enabled. */ #ifndef NO_GZIP # define GZIP #endif /* =========================================================================== * Internal compression state. */ #define LENGTH_CODES 29 /* number of length codes, not counting the special END_BLOCK code */ #define LITERALS 256 /* number of literal bytes 0..255 */ #define L_CODES (LITERALS+1+LENGTH_CODES) /* number of Literal or Length codes, including the END_BLOCK code */ #define D_CODES 30 /* number of distance codes */ #define BL_CODES 19 /* number of codes used to transfer the bit lengths */ #define HEAP_SIZE (2*L_CODES+1) /* maximum heap size */ #define MAX_BITS 15 /* All codes must not exceed MAX_BITS bits */ #define INIT_STATE 42 #define EXTRA_STATE 69 #define NAME_STATE 73 #define COMMENT_STATE 91 #define HCRC_STATE 103 #define BUSY_STATE 113 #define FINISH_STATE 666 /* Stream status */ /* Data structure describing a single value and its code string. */ typedef struct ct_data_s { union { ush freq; /* frequency count */ ush code; /* bit string */ } fc; union { ush dad; /* father node in Huffman tree */ ush len; /* length of bit string */ } dl; } FAR ct_data; #define Freq fc.freq #define Code fc.code #define Dad dl.dad #define Len dl.len typedef struct static_tree_desc_s static_tree_desc; typedef struct tree_desc_s { ct_data *dyn_tree; /* the dynamic tree */ int max_code; /* largest code with non zero frequency */ static_tree_desc *stat_desc; /* the corresponding static tree */ } FAR tree_desc; typedef ush Pos; typedef Pos FAR Posf; typedef unsigned IPos; /* A Pos is an index in the character window. We use short instead of int to * save space in the various tables. IPos is used only for parameter passing. */ typedef struct internal_state { z_streamp strm; /* pointer back to this zlib stream */ int status; /* as the name implies */ Bytef *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ Bytef *pending_out; /* next pending byte to output to the stream */ uInt pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ gz_headerp gzhead; /* gzip header information to write */ uInt gzindex; /* where in extra, name, or comment */ Byte method; /* STORED (for zip only) or DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ /* used by deflate.c: */ uInt w_size; /* LZ77 window size (32K by default) */ uInt w_bits; /* log2(w_size) (8..16) */ uInt w_mask; /* w_size - 1 */ Bytef *window; /* Sliding window. Input bytes are read into the second half of the window, * and move to the first half later to keep a dictionary of at least wSize * bytes. With this organization, matches are limited to a distance of * wSize-MAX_MATCH bytes, but this ensures that IO is always * performed with a length multiple of the block size. Also, it limits * the window size to 64K, which is quite useful on MSDOS. * To do: use the user input buffer as sliding window. */ ulg window_size; /* Actual size of window: 2*wSize, except when the user input buffer * is directly used as sliding window. */ Posf *prev; /* Link to older string with same hash index. To limit the size of this * array to 64K, this link is maintained only for the last 32K strings. * An index in this array is thus a window index modulo 32K. */ Posf *head; /* Heads of the hash chains or NIL. */ uInt ins_h; /* hash index of string to be inserted */ uInt hash_size; /* number of elements in hash table */ uInt hash_bits; /* log2(hash_size) */ uInt hash_mask; /* hash_size-1 */ uInt hash_shift; /* Number of bits by which ins_h must be shifted at each input * step. It must be such that after MIN_MATCH steps, the oldest * byte no longer takes part in the hash key, that is: * hash_shift * MIN_MATCH >= hash_bits */ long block_start; /* Window position at the beginning of the current output block. Gets * negative when the window is moved backwards. */ uInt match_length; /* length of best match */ IPos prev_match; /* previous match */ int match_available; /* set if previous match exists */ uInt strstart; /* start of string to insert */ uInt match_start; /* start of matching string */ uInt lookahead; /* number of valid bytes ahead in window */ uInt prev_length; /* Length of the best match at previous step. Matches not greater than this * are discarded. This is used in the lazy match evaluation. */ uInt max_chain_length; /* To speed up deflation, hash chains are never searched beyond this * length. A higher limit improves compression ratio but degrades the * speed. */ uInt max_lazy_match; /* Attempt to find a better match only when the current match is strictly * smaller than this value. This mechanism is used only for compression * levels >= 4. */ # define max_insert_length max_lazy_match /* Insert new strings in the hash table only if the match length is not * greater than this length. This saves time but degrades compression. * max_insert_length is used only for compression levels <= 3. */ int level; /* compression level (1..9) */ int strategy; /* favor or force Huffman coding*/ uInt good_match; /* Use a faster search when the previous match is longer than this */ int nice_match; /* Stop searching when current match exceeds this */ /* used by trees.c: */ /* Didn't use ct_data typedef below to supress compiler warning */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ struct tree_desc_s l_desc; /* desc. for literal tree */ struct tree_desc_s d_desc; /* desc. for distance tree */ struct tree_desc_s bl_desc; /* desc. for bit length tree */ ush bl_count[MAX_BITS+1]; /* number of codes at each bit length for an optimal tree */ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ int heap_len; /* number of elements in the heap */ int heap_max; /* element of largest frequency */ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. * The same heap array is used to build all trees. */ uch depth[2*L_CODES+1]; /* Depth of each subtree used as tie breaker for trees of equal frequency */ uchf *l_buf; /* buffer for literals or lengths */ uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for * limiting lit_bufsize to 64K: * - frequencies can be kept in 16 bit counters * - if compression is not successful for the first block, all input * data is still in the window so we can still emit a stored block even * when input comes from standard input. (This can also be done for * all blocks if lit_bufsize is not greater than 32K.) * - if compression is not successful for a file smaller than 64K, we can * even emit a stored file instead of a stored block (saving 5 bytes). * This is applicable only for zip (not gzip or zlib). * - creating new Huffman trees less frequently may not provide fast * adaptation to changes in the input data statistics. (Take for * example a binary file with poorly compressible code followed by * a highly compressible string table.) Smaller buffer sizes give * fast adaptation but have of course the overhead of transmitting * trees more frequently. * - I can't count above 4 */ uInt last_lit; /* running index in l_buf */ ushf *d_buf; /* Buffer for distances. To simplify the code, d_buf and l_buf have * the same number of elements. To use different lengths, an extra flag * array would be necessary. */ ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ uInt matches; /* number of string matches in current block */ int last_eob_len; /* bit length of EOB code for last block */ #ifdef DEBUG ulg compressed_len; /* total bit length of compressed file mod 2^32 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif ush bi_buf; /* Output buffer. bits are inserted starting at the bottom (least * significant bits). */ int bi_valid; /* Number of valid bits in bi_buf. All bits above the last valid bit * are always zero. */ } FAR deflate_state; /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. */ #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) /* In order to simplify the code, particularly on 16 bit machines, match * distances are limited to MAX_DIST instead of WSIZE. */ /* in trees.c */ void _tr_init OF((deflate_state *s)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); void _tr_align OF((deflate_state *s)); void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, int eof)); #define d_code(dist) \ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) /* Mapping from a distance to a distance code. dist is the distance - 1 and * must not have side effects. _dist_code[256] and _dist_code[257] are never * used. */ #ifndef DEBUG /* Inline versions of _tr_tally for speed: */ #if defined(GEN_TREES_H) || !defined(STDC) extern uch _length_code[]; extern uch _dist_code[]; #else extern const uch _length_code[]; extern const uch _dist_code[]; #endif # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ s->d_buf[s->last_lit] = 0; \ s->l_buf[s->last_lit++] = cc; \ s->dyn_ltree[cc].Freq++; \ flush = (s->last_lit == s->lit_bufsize-1); \ } # define _tr_tally_dist(s, distance, length, flush) \ { uch len = (length); \ ush dist = (distance); \ s->d_buf[s->last_lit] = dist; \ s->l_buf[s->last_lit++] = len; \ dist--; \ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->last_lit == s->lit_bufsize-1); \ } #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ flush = _tr_tally(s, distance, length) #endif #endif /* DEFLATE_H */ wgd-3.1/include/wgd/widgets/0000777000175000001440000000000011265576315013024 500000000000000wgd-3.1/include/wgd/widgets/widgets.h0000644000175000001440000001716211077651472014565 00000000000000#ifndef _WGD_WIDGETS_ #define _WGD_WIDGETS_ #include #include #include #include #include #include #include #include #include #include #include namespace wgd { class WidgetManager; typedef doste::dvm::OID WidgetID; typedef doste::dvm::OID WidgetName; /** Clip rectangle structure for widget clipping */ struct ClipRect { int top; int left; int right; int bottom; }; /** * Represenst GUI Widgets.
* Widgets are independant of the game scene system and the multiple cameras * They are always defined in window pixel coordinates from the top left corner.
* All widgets MUST have a unique name if they are to be drawn.
* You can create widgets as children of other widgets, so they inherit the position * and visible status of their parent.
* If you do not specify width and height of a widget, that widget will be drawn from the * center of the widget rather than from the corner, and will have a size specified by its texture. * */ class WIDIMPORT Widget : public doste::Agent { friend class WidgetManager; public: OBJECT(Agent, Widget); Widget(const doste::dvm::OID &id); virtual ~Widget(); /** * Construct a widget with these parameters. * @param x X-Coordinate. * @param y Y-Coordinate. * @param w Widget width. * @param h Widget height. */ void make(int x=0, int y=0, int w=16, int h=16); /** Get the position of the top left corner of the widget */ vector2d position() { return vector2d(property(ix::x), property(ix::y)); }; /** Set the position of the top left corner of the widget */ void position(const vector2d &v) { property(ix::x, v.x); property(ix::y, v.y); }; /** Set the width of the widget */ PROPERTY_WF(int, width, ix::width); PROPERTY_RF(int, width, ix::width); PROPERTY_WF(int, height, ix::height); PROPERTY_RF(int, height, ix::height); /** The sprite that the widget uses */ PROPERTY_WF(wgd::Sprite, sprite, ix::sprite); PROPERTY_RF(wgd::Sprite, sprite, ix::sprite); /** The border of the sprite in pixels that is not stretched when drawing */ PROPERTY_W(int, border); PROPERTY_R(int, border); /** Whether the widget responds to the mouse events - needs a better name */ PROPERTY_W(bool, solid); PROPERTY_R(bool, solid); /**Z position - for sorting, a heigher z position means the widget is in front */ PROPERTY_WF(int, z, ix::z); PROPERTY_RF(int, z, ix::z); /** Whethet this widget and its children exists on screen */ PROPERTY_WF(bool, visible, ix::visible); PROPERTY_RF(bool, visible, ix::visible); /** The current frame of the widget - some widgets will override this */ PROPERTY_WF(int, frame, ix::frame); PROPERTY_RF(int, frame, ix::frame); /** Tint colour of the sprite */ PROPERTY_RF(wgd::colour, tint, ix::tint); PROPERTY_WF(wgd::colour, tint, ix::tint); /** Set the colout of the text on the button */ PROPERTY_WF(wgd::colour, textColour, "textcolour"); PROPERTY_RF(wgd::colour, textColour, "textcolour"); PROPERTY_WF(int, textX, "textx"); PROPERTY_RF(int, textX, "textx"); PROPERTY_WF(int, textY, "texty"); PROPERTY_RF(int, textY, "texty"); PROPERTY_WF(int, textWidth, "textwidth"); PROPERTY_RF(int, textWidth, "textwidth"); PROPERTY_WF(int, textHeight, "textheight"); PROPERTY_RF(int, textHeight, "textheight"); /** Set the buttons caption */ PROPERTY_WF(doste::dstring, caption, ix::caption); PROPERTY_RF(doste::dstring, caption, ix::caption); /** Set the caption font */ PROPERTY_WF(wgd::Font, font, ix::font); PROPERTY_RF(wgd::Font, font, ix::font); //Fundamental events. /*DB_GET_BOOL(clicked, ix::clicked); DB_GET_BOOL(mouseOver, ix::mouseover); DB_GET_BOOL(mouseExit, ix::mouseexit); DB_GET_OBJECT(mouseDown, ix::mousedown); DB_GET_OBJECT(mouseUp, ix::mouseup); DB_GET_OBJECT(keyDown, ix::keydown); DB_GET_OBJECT(keyUp, ix::keyup); DB_GET_BOOL(enter, ix::enter); DB_GET_BOOL(keyPressed, ix::keypressed);*/ /** * Set a custom variable of this widget in the database * @param var variable name * @param value Variable value */ void property(const doste::dvm::OID &var, const doste::dvm::OID &value) { set(var, value); }; /** * Get the value of a custom variable of this widget * @param var Variable name * @return value variable value - returns Null if not set */ doste::dvm::OID property(const doste::dvm::OID &var){ return get(var); }; /*DOSTE_BEGINEVENTS; DOSTE_EVENT(1000, changeVisible); //Visible DOSTE_EVENT(1001, changed); //width DOSTE_EVENT(1002, changed); //height DOSTE_EVENT(1003, changed); //frame DOSTE_EVENT(1004, changed); //sprite DOSTE_ENDEVENTS;*/ BEGIN_EVENTS(Agent); EVENT(evt_frame, (*this)(ix::frame)); EVENT(evt_changed, (*this)(ix::width)(doste::dvm::modifiers::Seq)(*this)(ix::height)(doste::dvm::modifiers::Seq)(*this)(ix::sprite)); EVENT(evt_text, (*this)(ix::caption)(doste::dvm::modifiers::Seq)(*this)(ix::font)); EVENT(evt_child, (*this)(ix::children)(doste::dvm::All)); //This also needs to trigger when a widget gets registered //EVENT(evt_child, _DASM({ .children $; @root modules })); END_EVENTS; //class ZCompare { // public: // bool operator()(const doste::OID& a, const doste::OID& b) const {return (int)a[ix::z] > (int)b[ix::z]; }; //}; protected: //these are called by drawall and updateall virtual void draw(const ClipRect &); virtual void update(); bool mouse(int x, int y); //clip a widget - calls glScissor(...) ClipRect clip(const ClipRect &, const ClipRect&); //there are some specific drawing functions: void drawChildren(const ClipRect &); void drawText(int ox, int oy, const char* s, wgd::Font* fnt = NULL); //draws some text at an offset void clearFrame(); //start again void addFrame(int x, int y, int w, int h, int cframe=0, int cborder=0); //adds a sprite frame to the vertex array void drawSprite(); //draws the vertex array void resizeText(); void makefocus(Widget *w); void setfocus(); void addFocus(Widget *w); //adds object to front focus list with z order restraints vector2d screenPosition() { return vector2d(get(ix::screenx), get(ix::screeny)); } //Throw an event - calls event handler void event(const doste::dvm::OID& type); //These functions are only called of this widget has focus virtual void keyDown(const doste::dvm::OID& key, bool shift){}; virtual void keyUp(const doste::dvm::OID& key, bool shift){}; //Vertex array wgd::vertex* m_vertices; unsigned char* m_indices; int m_nVertices; int m_nIndices; bool m_remake; //dimensions - depreciated float m_tw, m_th, m_tx, m_ty; std::list m_focus; static Widget *s_prevmouse; }; class WidgetManager : public doste::Agent { public: OBJECT(Agent, WidgetManager); WidgetManager(const doste::dvm::OID &o); ~WidgetManager(); void draw(); /** position offset for all widgets in this widget manager */ vector2d offset() { return vector2d((float)(int)get("ox"), (float)(int)get("oy")); }; BEGIN_EVENTS(WidgetManager); EVENT(evt_mouse, (*this)(ix::x)(doste::dvm::modifiers::Seq)((*this))(ix::y)); EVENT(evt_focus, (*this)(ix::focus)); END_EVENTS; /** Widget that currently has focus */ static doste::dvm::OID s_focus; private: static bool s_rebuild; }; }; #endif wgd-3.1/include/wgd/widgets/Makefile.am0000755000175000001440000000012311044044040014747 00000000000000pkgincludedir = $(includedir)/wgd/widgets pkginclude_HEADERS=widgets.h wviewport.h wgd-3.1/include/wgd/widgets/Makefile.in0000644000175000001440000002614511265575054015014 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = include/wgd/widgets DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(pkgincludedir)" pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER) HEADERS = $(pkginclude_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) pkgincludedir = $(includedir)/wgd/widgets ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pkginclude_HEADERS = widgets.h wviewport.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps include/wgd/widgets/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps include/wgd/widgets/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \ $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \ done uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \ rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: for dir in "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-pkgincludeHEADERS install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkgincludeHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ ctags distclean distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-pkgincludeHEADERS install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ uninstall uninstall-am uninstall-pkgincludeHEADERS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/include/wgd/widgets/wviewport.h0000644000175000001440000000201311056217230015135 00000000000000#ifndef _WGD_WVIEWPORT_ #define _WGD_WVIEWPORT_ #include #include #include #include namespace wgd { /** * WViewport is a widget that acts as a special form of RenderTarget. You * can either specify a source RenderTarget object (such as a Framebuffer) or * directly specify a Camera and Scene. Using one of the above it will draw * it to the screen in a rectangle given by the widgets position and size. */ class WViewport : public wgd::Widget { public: WViewport(const doste::dvm::OID &id); ~WViewport(); void draw(const ClipRect &); /** stuff from RenderTarget */ PROPERTY_RF(RenderTarget, source, ix::source); PROPERTY_WF(RenderTarget, source, ix::source); PROPERTY_RF(Camera, camera, ix::camera); PROPERTY_WF(Camera, camera, ix::camera); PROPERTY_RF(Scene, scene, ix::scene); PROPERTY_WF(Scene, scene, ix::scene); OBJECT(Widget, WViewport); }; }; #endif wgd-3.1/include/Makefile.am0000644000175000001440000000001411044043336012523 00000000000000SUBDIRS=wgd wgd-3.1/include/Makefile.in0000644000175000001440000003325511265575054012565 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = include DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = wgd all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps include/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps include/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-exec-am: install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic ctags \ ctags-recursive distclean distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ tags-recursive uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/INSTALL0000644000175000001440000002243210750154243010110 00000000000000Installation Instructions Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. (Caching is disabled by default to prevent problems with accidental use of stale cache files.) If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You only need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not support the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Here is a another example: /bin/bash ./configure CONFIG_SHELL=/bin/bash Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent configuration-related scripts to be executed by `/bin/bash'. `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. wgd-3.1/missing0000755000175000001440000002453310750154243010462 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2004-09-07.08 # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004 # Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Send bug reports to ." exit 0 ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit 0 ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). case "$1" in lex|yacc) # Not GNU programs, they don't have --version. ;; tar) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: wgd-3.1/src/0000777000175000001440000000000011265576313007737 500000000000000wgd-3.1/src/wgd.in0000644000175000001440000000067411233311615010756 00000000000000#!/bin/bash datadir="." #bindir="@prefix@/bin" #xaraling="/dcs/pg07/nick/xaraling/bin/xaraling" xaraling="doste" export LD_LIBRARY_PATH="@prefix@/share/wgd/modules" #export LD_LIBRARY_PATH="./src/base:./src/resources_base:./src/base_3d" #cd $bindir xtype="$1" shift if ( test "$xtype" = "debug" ); then debug="1" xtype="$1" shift fi if ( test "$debug" = "1" ); then exec "gdb" "--args" "$xaraling" -i $* else exec "$xaraling" -i $* fi wgd-3.1/src/Makefile.am0000644000175000001440000000056511236532200011676 00000000000000#bin_PROGRAMS=dloader #dloader_SOURCES=main.cpp #INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include #AM_LDFLAGS=--ldl -lxaraling loadexecdir=$(bindir) loadexec_SCRIPTS=wgd #EXTRA_DIST=$(script_DATA) #install-data-hook: # chmod "a+x" $(bindir)/wgd SUBDIRS=base collision_2d collision_3d input resources_base base_3d base_2d models sound widgets xnet heightmap ui wgd-3.1/src/models/0000777000175000001440000000000011265576313011222 500000000000000wgd-3.1/src/models/modelx.cpp0000644000175000001440000003303511077705131013127 00000000000000#include #include #include #include #include #include #include #include using namespace wgd; using namespace doste; using namespace doste::token; static const doste::token::Char<1> semi(';'); static const doste::token::Char<1> comma(','); bool ModelX::validate(File *file){ if(file->parse(Keyword("xof"))){ file->seek(5); bool valid = file->parse(Keyword("txt 0032")); if(!valid) Warning(0, "Invalid .x file"); file->seek(0, Stream::BEG); return valid; } return false; } void ModelX::load(){ std::cout << "Loading Model " << file()->filename() << "\n"; file()->open(File::READ); file()->seek(16); //main loop while(!file()->eof()){ parseJunk(); if(file()->eof()) break; if(parse(Keyword("template"))) skipBlock(); else if(parse(Keyword("Frame"))) readFrame(createBone(ix::root)); else if(parse(Keyword("Mesh"))) readMesh(Null); else if(parse(Keyword("AnimationSet"))) readAnimationSet(); else if(parse(AlphaNumericX())) skipBlock(); else Error(0, "ModelX: Some crazy error of doom"); } file()->close(); } void ModelX::skipBlock(){ startBlock(); endBlock(); } OID ModelX::startBlock(){ token::AlphaNumericX name; parse(WhiteSpace()); parseValue(name); parse(WhiteSpace()); parse(Char<1>('{')); return (name.value)? OID(name.value) : Null; } void ModelX::endBlock(){ int count=1; while(count>0 && !file()->eof()) { if(parse(Char<1>('{'))) count++; else if(parse(Char<1>('}'))) count--; else file()->seek(1); } } OID ModelX::readInline(){ AlphaNumericX s; parseJunk(); parseValue(s); parse(Block<-1>('}')); return (s.value)? OID(s.value) : Null; } void ModelX::readFrame(Bone *parent){ OID name = startBlock(); Bone *cBone; ALIGNVS float tMatrix[16] ALIGNED; //create bone cBone = createBone(name); parent->addChild(name); while(!file()->eof()){ parseJunk(); if(parse(Keyword("FrameTransformMatrix"))){ startBlock(); readMatrix(tMatrix); cBone->tMatrix(tMatrix); endBlock(); } else if(parse(Keyword("Frame"))) readFrame(cBone); else if(parse(Keyword("Mesh"))) readMesh(name); else if(parse(Char<1>('{'))) readInline(); //Mesh reference - ignore for now (and probably forever) else break; } endBlock(); } void ModelX::readMatrix(float* m){ token::Float f; for(int i=0; i<16; i++){ parseJunk(); parseValue(f); m[i] = f.value; parse(Char<1>(',')); parse(WhiteSpace()); } } vector3d ModelX::readVector(int n){ return parseVector(n, semi); } void ModelX::readMesh(const OID& boneName){ int nVertices=0; vector3d *vertices = NULL; vector3d *normals = NULL; vector2d *uvs = NULL; int nFaces=0; int *faces = NULL; int *matList = NULL; OID *materials = NULL; int *duplication = NULL; int weights = 0; MeshSkin *skin = NULL; //The actual parsing... OID name = startBlock(); nVertices = readVertices(vertices); nFaces = readFaces(faces, duplication); //sub blocks while(!file()->eof()){ parseJunk(); if(parse(Keyword("MeshNormals"))) readNormals(normals); else if(parse(Keyword("MeshTextureCoords"))) readTexCoords(uvs); else if(parse(Keyword("MeshMaterialList"))) readMaterials(nFaces, matList, materials, duplication); else if(parse(Keyword("XSkinMeshHeader"))) { weights = readSkinHeader(skin); skin = new MeshSkin[weights * nVertices]; memset(skin, 0, weights * nVertices * sizeof(MeshSkin)); }else if(parse(Keyword("SkinWeights"))) readSkin(skin, weights); else if(parse(Keyword("VertexDuplicationIndices"))) skipBlock(); else break; } //Process mesh (divide it into sub meshes per material - also fo any flipping stuff) processMesh(boneName, nFaces, faces, vertices, normals, uvs, matList, materials, weights, skin); endBlock(); } int ModelX::readVertices(vector3d *& vertices){ token::Integer<10> tint; parseJunk(); int nVertices=0; //if(!parseValue(tint)) return 0; if(!tint.parse(*file())) return 0; nVertices = (int)tint.value; parse(semi); vertices = new vector3d[nVertices]; for(int i=0; i tint; std::vector tfaces; std::vector tduplication; int nFaces, sides; int f[2] = {-1, -1}; parseJunk(); //char a = file()->peek(); //no idea //char b = file()->peek(1); if(!parseValue(tint)) return 0; nFaces = (int)tint.value; parse(semi); for(int i=0; i2) { tduplication.push_back(i); } } parse(semi); parse(comma); } parse(semi); //return data faces = new int[tfaces.size()]; memcpy(faces, &tfaces[0], tfaces.size() * sizeof(int)); //material duplication tduplication.push_back(-1); duplication = new int[tduplication.size()]; memcpy(duplication, &tduplication[0], tduplication.size() * sizeof(int)); //return number of triangles return tfaces.size() / 3; } int ModelX::readNormals(wgd::vector3d *& normals){ token::Integer<10> tint; startBlock(); parseJunk(); int nNormals=0; parseValue(tint); parse(semi); nNormals = (int)tint.value; normals = new vector3d[nNormals]; for(int i=0; i tint; startBlock(); parseJunk(); int nUVs=0; parseValue(tint); parse(semi); nUVs = (int)tint.value; uvs = new vector2d[nUVs]; for(int i=0; i tint; startBlock(); parseJunk(); int nFaces=0; int nMaterials=0; parseValue(tint); parse(semi); nMaterials = (int)tint.value; parseJunk(); parseValue(tint); parse(semi); nFaces = (int)tint.value; int index=0, dix=0; matID = new int[count]; for(int i=0; i('{'))) material[i] = readInline(); } endBlock(); return nMaterials; } OID ModelX::readMaterial(){ token::Float tfloat; vector3d v; OID name = startBlock(); //Create the material resource Material *mat = createMaterial(name); //diffuse (ambient) parseJunk(); v = readVector(4); if(mat->get(ix::diffuse)==Null) mat->diffuse(colour(v.x, v.y, v.z, v.w)); if(mat->get(ix::ambient)==Null) mat->ambient(colour(v.x/3.0f, v.y/3.0f, v.z/3.0f, 1.0)); parse(semi); //Shininess parseJunk(); parseValue(tfloat); if(mat->get(ix::shininess)==Null) { mat->shininess(tfloat.value); //Blender bug - this value is between 0-2 rather than 0-128: if(tfloat.value > 0.0 && tfloat.value < 1.0) mat->shininess(tfloat.value * 64.0f); } parse(semi); //specular parseJunk(); v = readVector(); if(mat->get(ix::specular)==Null) mat->specular(colour(v.x, v.y, v.z, 1.0)); parse(semi); //emmissive parseJunk(); v = readVector(); if(mat->get(ix::emission)==Null) mat->emission(colour(v.x, v.y, v.z, 1.0)); parse(semi); //Texture parseJunk(); if(parse(Keyword("TextureFilename"))){ startBlock(); parseJunk(); //read string (append to directory(file()->localFile(), buf); and save) Block<-1> texFile('"', '"'); parseValue(texFile); //create texture if(mat->texture()==NULL || mat->texture()->file()==NULL){ char tdir[128]; directory((const char*)file()->filename(), tdir); dstring tf(tdir); tf + texFile.value; if(mat->texture()==NULL) mat->texture(new Texture); mat->texture()->file(new LocalFile((const char*)tf)); } endBlock(); } endBlock(); return name; } int ModelX::readSkinHeader(wgd::MeshSkin *&){ startBlock(); parseJunk(); Integer<10> wpv; parseValue(wpv); endBlock(); return (int)wpv.value; } int ModelX::readSkin(wgd::MeshSkin *&skin, int weights){ Block<-1> boneName('"', '"'); Integer<10> count; Integer<10> tint; Float tfloat; startBlock(); parseJunk(); parseValue(boneName); parse(semi); Bone *bone = createBone(boneName.value); parseJunk(); parseValue(count); parse(semi); int *index = new int[(int)count.value]; for(int i=0; i<(int)count.value; i++){ parseJunk(); parseValue(tint); parse(comma); index[i] = (int)tint.value; } parse(semi); for(int i=0; i<(int)count.value; i++){ parseJunk(); parseValue(tfloat); parse(comma); for(int j=0; jsMatrix(mat); endBlock(); return (int) count.value; } void ModelX::processMesh(const OID& boneName, int nfaces, int *f, wgd::vector3d *v, wgd::vector3d *n, wgd::vector2d *uv, int *m, OID *mat, int w, MeshSkin *skin){ int offset=0; while(offset < nfaces){ //see how many faces in this material int num = 0, cmat = m[offset]; for(int i=offset; i<=nfaces; i++){ if(m[i]!=cmat || i==nfaces) { num = i-offset; break; } } //create mesh if(num>0){ //copy vertex data MeshSkin *s=0; vertex_t *vx = new vertex_t[num * 3]; if(w) s = new MeshSkin[num * 3 * w]; for(int i=0; ivertices(num * 3, vx); m->skin(w, s); //std::cout << "CMAT = " << cmat << "\n"; OID mate = mat[cmat]; m->material(mate); if(boneName!=Null) m->bone(boneName); offset += num; } } } void ModelX::readAnimationSet(){ OID name = startBlock(); //create animation set AnimationSet *set = createAnimation(name); while(!file()->eof()){ parseJunk(); if(parse(Keyword("Animation"))) readAnimation(set); else break; } endBlock(); } void ModelX::readAnimation(AnimationSet *set){ OID name = startBlock(); OID boneName; //get bone it applies to parseJunk(); if(parse(Char<1>('{'))) boneName = readInline(); if(boneName==Null){ Error(0, "ModelX: No frame defined for animation"); endBlock(); return; } int bID = createBone(boneName)->bid(); //Read Keyframes while(!file()->eof()){ parseJunk(); if(parse(Keyword("AnimationKey"))) readAnimationKey(set, bID); else break; } endBlock(); } void ModelX::readAnimationKey(AnimationSet*set, int bone){ token::Integer<10> tint; int type, keys, frame, size; vector3d v; startBlock(); //type parseJunk(); parseValue(tint); parse(semi); type = (int)tint.value; //Invalid type if(type==4){ Error(0, "ModelX: Cannot use matrix keys for animation"); endBlock(); return; } //number of keyframes parseJunk(); parseValue(tint); parse(semi); keys = (int)tint.value; for(int i=0; ikeyOrientation(bone, frame, quaternion(v.y, v.z, v.w, -v.x)); break; //Rotation Keys case 1: set->keyScale(bone, frame, v); break; //Scale keys case 2: set->keyPosition(bone, frame, v); break; //position keys } } parse(semi); endBlock(); } wgd-3.1/src/models/collision.cpp0000644000175000001440000001032511233311614013620 00000000000000//collision functions from "Real Time Collision Detection" book #include #include "collision.h" using namespace wgd; // Closest point of a triangle to a point, page 141/2 vector3d wgd::ClosectPointTriangle(const vector3d &p, const vector3d &a, const vector3d &b, const vector3d &c) { // check if P in vertex region outside A vector3d ab = b - a; vector3d ac = c - a; vector3d ap = p - a; float d1 = ab.dot(ap); float d2 = ac.dot(ap); if(d1 <= 0.0f && d2 <= 0.0f) return a; //barycentric coordinates (1, 0, 0) // check if P in vertex region outside B vector3d bp = p - b; float d3 = ab.dot(bp); float d4 = ac.dot(bp); if(d3 >= 0.0f && d4 <= d3) return b; //barycentric coordinates (0, 1, 0) //Check if P in edge region of AB, if so, return projection of P onto AB float vc = d1*d4 - d3*d2; if(vc <= 0.0f && d1 >= 0.0f && d3 <= 0.0f) { float v = d1 / (d1 - d3); return a + ab * v; //barycentric coordinates (1-v, v, 0) } // check if P in vertex region outside C vector3d cp = p - c; float d5 = ab.dot(cp); float d6 = ac.dot(cp); if(d6 >= 0.0f && d5 <= d6) return c; //barycentric coordinates (0, 0, 1) // check if P in edge region of AC, if so return projection of P onto AC float vb = d5*d2 - d1*d6; if(vb <= 0.0f && d2 >= 0.0f && d6 <= 0.0f) { float w = d2 / (d2 - d6); return a + ac * w; //barycentric coordinates (1-w, 0, w) } // check if P in edge region of BC, if so return projection of P onto BC float va = d3*d6 - d5*d4; if(va <= 0.0f && (d4-d3) >= 0.0f && (d5-d6) >= 0.0f) { float w = (d4-d3) / ((d4-d3) + (d5-d6)); return a + (c-b) * w; //barycentric coordinates (0, 1-w, w) } // P inside face region. compute Q through its barycentric coordinates (u, v, w) float denom = 1.0f / (va + vb + vc); float v = vb * denom; float w = vc * denom; return a + ab * v + ac * w; // = u*a + v*b + w*c, u = va * denom = 1.0f - v - w } // line segment intersects triangle page 191/2 (modified to return actual point) int wgd::intersectLineTriangle(const vector3d &p, const vector3d &q, const vector3d &a, const vector3d &b, const vector3d &c, vector3d &result, vector3d &normal) { float t,u,v,w; // barycentric result vector3d ab = b - a; vector3d ac = c - a; vector3d qp = p - q; // Compute triangle normal vector3d n = ab.cross(ac); //compute denominator d. if d <= 0, line is parallel to or points away from triangle float d = qp.dot(n); if(d <= 0.0f) return 0; // compute intersection t value of pq with plane of triangle vector3d ap = p - a; t = ap.dot(n); if(t <= 0.0f) return 0; //intersection before line starts if(t > d) return 0; //intersection after line ends, leave out for ray tests // compute barycentric coordinate components and test if within bounds vector3d e = qp.cross(ap); v = ac.dot(e); if(v < 0.0f || v > d) return 0; w = -ab.dot(e); if(w < 0.0f || v + w > d) return 0; // segment/ray intersects triangle. perform delayed division and // compute the last barycentric coordinate component float ood = 1.0f / d; t *= ood; v *= ood; w *= ood; u = 1.0f - v - w; // output stuff normal = n; result = a*u + b*v + c*w; return 1; } //Line segment - AABB test - page 183/4 #define EPSILON 0.00001f; int wgd::TestSegmentAABB(const wgd::vector3d &p0, const wgd::vector3d &p1, const wgd::vector3d &min, const wgd::vector3d &max) { vector3d e = max - min; //box halflength (*2 to save time) vector3d d = p1 - p0; //segment halflength (*2 to save time) vector3d m = p0 + p1 - min - max; //segment midpoint translated to origin //world coordinate as seperating axis float adx = abs(d.x); if(abs(m.x) > e.x + adx) return 0; float ady = abs(d.y); if(abs(m.y) > e.y + ady) return 0; float adz = abs(d.z); if(abs(m.z) > e.x + adz) return 0; //add epsilon to fix errors when near parallel adx+=EPSILON; ady+=EPSILON; adz+=EPSILON; //cross products of segment direction vector with coordinate axes if(abs(m.y*d.z - m.z * d.y) > e.y * adz + e.z * ady) return 0; if(abs(m.y*d.z - m.z * d.y) > e.y * adz + e.z * ady) return 0; if(abs(m.y*d.z - m.z * d.y) > e.y * adz + e.z * ady) return 0; //no seperating axis found return 1; } wgd-3.1/src/models/animationset.cpp0000644000175000001440000000756211025132561014332 00000000000000#include using namespace wgd; AnimationSet::AnimationSet(int size) : m_size(size) { // create arrays of vectors m_scale = new std::vector [ size ]; m_position = new std::vector [ size ]; m_orientation = new std::vector [ size ]; } AnimationSet::~AnimationSet() { for(int j=0; j= m_size) return; //error if(m_scale[id].size()>0 && frame <= m_scale[id].back()->frame) return; //error KeyScale *k = new KeyScale; k->frame = frame; k->scale = scale; m_scale[id].push_back(k); } void AnimationSet::keyPosition(int id, int frame, const vector3d &position) { if(id >= m_size) return; //error if(m_position[id].size()>0 && frame <= m_position[id].back()->frame) return; //error KeyPosition *k = new KeyPosition; k->frame = frame; k->position = position; m_position[id].push_back(k); } void AnimationSet::keyOrientation(int id, int frame, const quaternion &orientation) { if(id >= m_size) return; //error if(m_orientation[id].size()>0 && frame <= m_orientation[id].back()->frame) return; //error KeyOrientation *k = new KeyOrientation; k->frame = frame; k->orientation = orientation; m_orientation[id].push_back(k); } // Get frame // vector3d AnimationSet::scale(int id, float frame) const { if(m_scale[id].empty()) return vector3d(1.0, 1.0, 1.0); for(unsigned int i=0; iframe > frame){ //frame before first keyframe if(i==0) return m_scale[id][i]->scale; //linear interpolation between keyframe i-1 and keyframe i float ka = (float)m_scale[id][i-1]->frame; float kb = (float)m_scale[id][i]->frame; float pcnt = (frame - ka) / (kb - ka); return vector3d::lerp(m_scale[id][i-1]->scale, m_scale[id][i]->scale, pcnt); } } //after last keyframe return m_scale[id].back()->scale; } vector3d AnimationSet::position(int id, float frame) const { if(m_position[id].empty()) return vector3d(); for(unsigned int i=0; iframe > frame){ //frame before first keyframe if(i==0) return m_position[id][i]->position; //linear interpolation between keyframe i-1 and keyframe i float ka = (float)m_position[id][i-1]->frame; float kb = (float)m_position[id][i]->frame; float pcnt = (frame - ka) / (kb - ka); return vector3d::lerp(m_position[id][i-1]->position, m_position[id][i]->position, pcnt); } } //after last keyframe return m_position[id].back()->position; } quaternion AnimationSet::orientation(int id, float frame) const { if(m_orientation[id].empty()) return quaternion(); for(unsigned int i=0; iframe > frame){ //frame before first keyframe if(i==0) return m_orientation[id][i]->orientation; //linear interpolation between keyframe i-1 and keyframe i float ka = (float)m_orientation[id][i-1]->frame; float kb = (float)m_orientation[id][i]->frame; float pcnt = (frame - ka) / (kb - ka); return quaternion::slerp(m_orientation[id][i-1]->orientation, m_orientation[id][i]->orientation, pcnt); } } //after last keyframe return m_orientation[id].back()->orientation; } wgd-3.1/src/models/skincontroller.cpp0000644000175000001440000000566411077705131014716 00000000000000#include #include using namespace wgd; using namespace doste; SkinController::SkinController(wgd::AnimationController *c) : m_anim(c) { //place for deformed meshes to go if(m_anim->m_inst->get(ix::meshes)==Null) m_anim->m_inst->set(ix::meshes, OID::create()); //setup local memory int num = m_anim->m_model->bones(); m_offset = new vector3d[num]; //Manually aligh matrices m_finalA = new matrix[num+1]; #ifdef X86_64 m_final = (matrix*)(((unsigned long long)m_finalA + 16) & 0xFFFFFFFFFFFFFFF0); #else m_final = (matrix*)(((unsigned int)m_finalA + 16) & 0xFFFFFFF0); #endif } SkinController::~SkinController(){ delete [] m_offset; delete [] m_finalA; } bool SkinController::update(){ OID dest = m_anim->m_inst->get(ix::meshes); Mesh *mesh, *deformed; calculateFinal(); for(int i=0; im_model->meshes(); i++){ mesh = m_anim->m_model->mesh(i); if(mesh->weights()>0){ //the mesh is skinned - create/get destination mesh if(dest.get(i)==Null){ deformed = new Mesh; dest.set(i, *deformed); } else deformed = dest.get(i); if(!deformed) Error(0, "There be something wrong with deformed meshes"); else deform(deformed, mesh); } } return true; } void SkinController::calculateFinal(){ for(int i=0; im_model->bones(); i++){ matrix::fastMultiply(m_final[i], m_anim->m_transform[i], m_anim->m_model->boneID(i)->sMatrix()); m_offset[i] = m_final[i] * vector2d(); } } void SkinController::deform(wgd::Mesh* dest, wgd::Mesh *src) { //copy material dest->set(ix::material, src->material()); //Allocate and clear memory in destination mesh dest->create(src->vertices()); //local vars meshVertex *vsrc, *vdest; vector3d position, normal, tpos, tnorm; Bone *bone=0; float weight; MeshSkin *skin = src->m_skin; int tskin; int i, j; for(i=0; ivertices(); ++i){ vsrc = &src->data()[i]; vdest = &dest->data()[i]; tskin = i*src->m_weightsPerVertex; //Copy UVs memcpy(&vdest->texcoords[0].u, &vsrc->texcoords[0].u, sizeof(float)*2); //transform vertex for(j=0; jm_weightsPerVertex; ++j){ weight = skin[tskin + j].weight; if(weight){ position.fromArray(&(vsrc->position.x)); normal.fromArray(&(vsrc->normal.x)); //get transform matrix if(skin[tskin + j].bone){ bone = skin[tskin + j].bone; matrix::fastMultiply(tpos, m_final[bone->bid()], position); matrix::fastMultiply(tnorm, m_final[bone->bid()], normal); } vector3d::fastScale(tpos, tpos, weight); vdest->position.x += tpos.x; vdest->position.y += tpos.y; vdest->position.z += tpos.z; vector3d::fastScale(tnorm, (tnorm - m_offset[bone->bid()]), weight); vdest->normal.x += tnorm.x; vdest->normal.y += tnorm.y; vdest->normal.z += tnorm.z; //ToDo: Tangents } } } } wgd-3.1/src/models/imodel.cpp0000644000175000001440000001147611233311614013106 00000000000000#include #include #include #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; //Implement model loader base class IMPLEMENT_LOADER(ModelLoader); namespace wgd { OnEvent(IModel, evt_update){ //update animationcontroler bool changed; if(m_anim) changed = m_anim->update(true); if(m_morph) m_built &= !m_morph->update(); if(m_skin && changed) m_built &= !m_skin->update(); m_forceUpdate = false; } OnEvent(IModel, evt_setup){ //setup controllers if(m_anim) delete m_anim; m_anim=0; if(m_skin) delete m_skin; m_skin=0; if(m_morph) delete m_morph; m_morph=0; if((bool)get(ix::model).get("loaded")) { Model *mdl = model(); if(mdl->bones() > 1){ //create animation controler m_anim = new AnimationController(*this); //start initial animation OID startAnim = get(ix::animation); if(startAnim!=Null) { m_anim->animation(0).start(startAnim); m_anim->update(true); //force update } //check all meshes to see if we need the skincontroler for(int i=0; imeshes(); i++) { if(mdl->mesh(i)->skin() != NULL) { m_skin = new SkinController(m_anim); break; } } } if(mdl->get(ix::morphs)!=Null) { m_morph = new MorphController(this); //initialise morphs for(OID::iterator i=get(ix::meshes).begin(); i!=get(ix::meshes).end(); i++){ m_morph->changeMorph(*i, get(ix::morphs)[*i][ix::morph]); } } } } OnEvent(IModel, evt_bone) { //add dependancies to any bones OID bones = get(ix::bones); for(OID::iterator i = bones.begin(); i!=bones.end(); i++) { IBone *bone = bones.get(*i); //make object if(bone) DEPENDENCY(*bone, ix::changed); } //tell update loop that bones have changed m_forceUpdate = true; } OnEvent(IModel, evt_animation){ if(m_anim) { m_anim->animation(0).start(animation()); } } OnEvent(IModel, evt_morph){ for(OID::iterator i=get(ix::meshes).begin(); i!=get(ix::meshes).end(); i++){ addEvent(*i, get(ix::meshes).get(*i)(ix::morph)); } } IMPLEMENT_EVENTS(IModel, Instance3D); } bool IModel::handler(int i){ if(m_morph) m_morph->changeMorph(i); return false; } IModel::IModel() : Instance3D(), m_built(true), m_anim(0), m_morph(0), m_skin(0) { set(ix::type, type()); if(scale() == vector3d()) scale(1.0); registerEvents(); } IModel::IModel(Model *mdl) : Instance3D(), m_built(true), m_anim(0), m_morph(0), m_skin(0) { set(ix::type, type()); if(scale() == vector3d()) scale(1.0); registerEvents(); model(mdl); } IModel::IModel(const doste::dvm::OID &id) : Instance3D(id), m_built(true), m_anim(0), m_morph(0), m_skin(0) { if(scale() == vector3d()) scale(1.0); registerEvents(); } IModel::~IModel(){ if(m_anim) delete m_anim; if(m_morph) delete m_morph; if(m_skin) delete m_skin; ///stop if no model if((*this)[ix::model]==Null) return; } /** Get a material by name */ Material* IModel::material(const doste::dvm::OID &name){ //Look for material inside instance (for overridden textures) if(get(ix::materials)!=Null){ if(get(ix::materials)[name]!=Null){ return get(ix::materials).get(name); } } //look for the material inside the instance's model if(!model()) return NULL; return model()->material(name); } matrix IModel::boneMatrix(const OID &boneName) { if(m_anim) return localMatrix() * m_anim->boneMatrix(boneName); else return localMatrix(); } IBone* IModel::bone(const OID& boneName) { //return if bone does not exist in model if(!model()->bone(boneName)) return 0; //get IBone IBone *b = get(ix::bones)[boneName]; if(!b) { b = new IBone(); get(ix::bones)[boneName] = b; } return b; } void IModel::draw(SceneGraph &graph, Camera3D *camera){ Instance3D::draw(graph, camera); Model *mdl = model(); if(!mdl) return; //the local matrix does not take scale into account! matrix scl; scl.scale(scale()); matrix local = localMatrix() * scl; //Add all meshes to scene graph ====================== Mesh* mesh = 0; int meshes = mdl->meshes(); if(m_morph) meshes = m_morph->meshes(); for(int i=0; imesh(i); } //Send mesh to Scene graph Drawable *d = new Drawable; d->clearData = false; d->discard = true; d->data = mesh->data(); d->size = mesh->vertices(); Material *mat = material(mesh->material()); if(mat) d->surface = *mat; //mesh local transformation if(m_anim) d->transform = local * m_anim->transformMesh(mesh); else d->transform = local; graph.addSolid(d); } } wgd-3.1/src/models/collision.h0000644000175000001440000000114411233311614013264 00000000000000//collision functions from book 'Real Time Collision Detection' #ifndef _WGD_COLLISION_ #define _WGD_COLLISION_ namespace wgd { wgd::vector3d ClosectPointTriangle(const wgd::vector3d &p, const wgd::vector3d &a, const wgd::vector3d &b, const wgd::vector3d &c); int intersectLineTriangle(const wgd::vector3d &p, const wgd::vector3d &q, const wgd::vector3d &a, const wgd::vector3d &b, const wgd::vector3d &c, wgd::vector3d &result, wgd::vector3d &normal); int TestSegmentAABB(const wgd::vector3d &p0, const wgd::vector3d &p1, const wgd::vector3d &minAABB, const wgd::vector3d &maxAABB); }; #endif wgd-3.1/src/models/Makefile.am0000644000175000001440000000074611265575301013175 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_models.so libwgd_models_so_SOURCES=mesh.cpp model3ds.cpp model.cpp imodel.cpp animationcontroller.cpp animationset.cpp modelx.cpp morphcontroller.cpp skincontroller.cpp clipmap.cpp collision.cpp collision.h AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -L../base_3d -L../resources_base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base -lwgd_base3d INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/models/morphcontroller.cpp0000644000175000001440000000625311077705131015072 00000000000000#include using namespace wgd; MorphController::MorphController(wgd::Instance3D* inst) : m_meshes(0), m_inst(inst), m_time(0), m_duration(0) { m_model = inst->get(ix::model); } MorphController::~MorphController() { if(m_meshes){ delete [] m_time; delete [] m_duration; } } void MorphController::resize(int n){ //resize arrays float* ttime = new float[n]; float* tdur = new float[n]; //copy any existing data if(m_meshes){ memcpy(ttime, m_time, m_meshes * sizeof(float)); memcpy(tdur, m_duration, m_meshes * sizeof(float)); delete [] m_time; delete [] m_duration; } //set member array pointers to point to new arrays m_time = ttime; m_duration = tdur; m_meshes = n; } bool MorphController::update() { float time = (float)WGD.get(ix::time); float mtime, value; for(int i=0; iget(ix::meshes)[i][ix::morph]; if(cmorph!=Null){ //morph time mtime = time - m_time[i]; //get morph interpolation value if(m_duration[i]==0.0) value=1.0f; else value = mtime / m_duration[i]; //next morph? if(value >= 1.0f){ OID next = m_model->get(ix::morphs)[cmorph][ix::next]; if(next!=Null) m_inst->get(ix::meshes).get(i).set(ix::morph, next); value = 1.0; } //get meshes Mesh *a = (OID)m_model->get(ix::morphs)[cmorph][ix::start]; Mesh *b = (OID)m_model->get(ix::morphs)[cmorph][ix::end]; //_ASSERT(a && b); if(m_inst->get(ix::meshes).get(i)==Null) m_inst->get(ix::meshes).set(i, *new Mesh); Mesh *deformed = m_inst->get(ix::meshes).get(i); //deform mesh deform(deformed, a, b, value); } } return m_meshes>0; } void MorphController::changeMorph(int mesh, float transition) { if(mesh >= m_meshes) resize(mesh+1); OID morph = m_inst->get(ix::meshes)[mesh][ix::morph]; m_time[mesh] = (float)WGD.get(ix::time); m_duration[mesh] = m_model->get(ix::morphs)[morph][ix::time]; } void MorphController::deform(Mesh* dest, Mesh *a, Mesh* b, float pcnt) { //copy material dest->set(ix::material, a->material()); //Allocate and clear memory in destination mesh dest->create(a->vertices()); meshVertex *vdest, *va, *vb; vector3d pos, start, end; for(int i=0; ivertices(); ++i){ vdest = &dest->data()[i]; va = &a->data()[i]; vb = &b->data()[i]; //position start.fromArray(&va->position.x); end.fromArray (&vb->position.x); pos = vector3d::lerp(start, end, pcnt); memcpy(&vdest->position.x, &pos.x, 3*sizeof(float)); //Normals start.fromArray(&va->normal.x); end.fromArray (&vb->normal.x); pos = vector3d::lerp(start, end, pcnt); memcpy(&vdest->normal.x, &pos.x, 3*sizeof(float)); //Texture coordinates start.fromArray(&va->texcoords[0].u); end.fromArray (&vb->texcoords[0].u); pos = vector2d::lerp(start, end, pcnt); memcpy(&vdest->texcoords[0].u, &pos.x, 2*sizeof(float)); //Tangents start.fromArray(&va->custom.var.x); end.fromArray(&vb->custom.var.x); pos = vector3d::lerp(start, end, pcnt); memcpy(&vdest->custom.var.x, &pos.x, 3*sizeof(float)); } } wgd-3.1/src/models/model.cpp0000644000175000001440000001031711233311614012726 00000000000000#include #include #include #include #include #include #include #include using namespace doste; using namespace doste::dvm; #ifdef _MSC_VER #pragma warning(disable:4996) #endif extern "C" void MODELSIMPORT initialise(const doste::dvm::OID &base) { Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); //Model loaders wgd::Loader::regFileType(); wgd::Loader::regFileType(); } extern "C" void MODELSIMPORT finalise() { } using namespace wgd; namespace wgd { OnEvent(Model, evt_file) { if(m_loader) delete m_loader; m_loader = Loader::create(file()); } IMPLEMENT_EVENTS(Model,Agent); } Model::Model(const char* filename) : Agent(), m_nMeshes(0), m_radius(0), m_loaded(false), m_loader(NULL) { registerEvents(); file(new LocalFile(filename)); } Model::Model(doste::File *f) : Agent(), m_nMeshes(0), m_radius(0), m_loaded(false), m_loader(NULL) { registerEvents(); file(f); } Model::Model(const doste::dvm::OID &id) : Agent(id), m_nMeshes(0), m_radius(0), m_loaded(false), m_loader(NULL) { registerEvents(); } Model::~Model(){ //delete bones for(unsigned int i=0; i(file()); if(!m_loaded && m_loader) { m_loader->parent(this); m_loader->load(); m_loaded=true; set("loaded", true); } } int Model::meshes() { load(); return m_nMeshes; } Mesh *Model::mesh(int index) const { if(get(ix::meshes)[index]==Null) return NULL; return get(ix::meshes).get(index); } Bone *Model::bone(const doste::dvm::OID &name) { const OID &id = m_boneMap[name]; if(id==Null) return NULL; else return boneID((int)id); } Bone *Model::boneID(int bid) const { if(bid>=(int)m_bones.size() || bid<0) return NULL; return m_bones[bid]; } /** Get a material from teh model */ Material *Model::material(const doste::dvm::OID &mat) const{ if(get(ix::materials)[mat]==Null) return NULL; return get(ix::materials).get(mat); } AnimationSet *Model::animationSet(const doste::dvm::OID &name){ OID a = m_animationMap[name]; if(a==Null) return NULL; else return (AnimationSet*)(void*)a; } ///////// LOADER FUNCTIONS ///////// //texture directory - Model Loader char* ModelLoader::directory(dstring s, char* d) const { strcpy(d, (const char*)s); for(int i=s.size(); i>0; i--){ if(d[i]=='/' || d[i] == '\\') break; d[i]=0; } return d; } Bone *ModelLoader::createBone(const doste::dvm::OID &name){ //check if bone already exists Bone* b = m_model->bone(name); if(b) return b; //create new bone int id = m_model->m_bones.size(); m_model->m_bones.push_back(new Bone(id)); m_model->m_boneMap.add(name, id); if(m_model->get(ix::bones)==Null) m_model->set(ix::bones, OID::create()); m_model->get(ix::bones).set(id, name); return m_model->m_bones.back(); } Mesh *ModelLoader::createMesh(){ if(m_model->get(ix::meshes)==Null) m_model->set(ix::meshes, OID::create()); Mesh *m = m_model->mesh(m_meshCounter); if(m) return m; //create a mesh m = new Mesh; m_model->get(ix::meshes).set(m_meshCounter++, *m); m_model->m_nMeshes=m_meshCounter; return m; } Material *ModelLoader::createMaterial(doste::dvm::OID &name){ if(m_model->get(ix::materials)==Null) m_model->set(ix::materials, OID::create()); //Generate material name if(name==Null){ char buf[10]; sprintf(buf, "mat%d", ++m_materialCounter); name = OID(buf); } //check prior existance Material *mat = m_model->material(name); if(mat) return mat; //create new material mat = new Material(); //Material::create(); m_model->get(ix::materials).set(name, *mat); return mat; } AnimationSet *ModelLoader::createAnimation(const doste::dvm::OID &name){ AnimationSet *anim = new AnimationSet(m_model->bones()); m_model->m_animationMap.add(name, (void*)anim); return anim; } wgd-3.1/src/models/animationcontroller.cpp0000644000175000001440000002546111233311614015717 00000000000000#include #include #include #include using namespace wgd; using namespace doste; AnimationController::AnimationController(Instance3D* inst) : m_inst(inst) { m_model = inst->get(ix::model); //set up local memory int num = m_model->bones(); //Manually aligh matrices m_transformA = new matrix[num+1]; #ifdef X86_64 m_transform = (matrix*)(((unsigned long long)m_transformA + 16) & 0xFFFFFFFFFFFFFFF0); #else m_transform = (matrix*)(((unsigned int)m_transformA + 16) & 0xFFFFFFF0); #endif //default fps if(m_model->get(ix::fps)==Null) m_model->fps(30.0f); m_cscale = new vector3d[num]; m_cposition = new vector3d[num]; m_corientation = new quaternion[num]; //set up animations memset(m_blend, 0, MAX_ANIMATIONS * sizeof(Blend)); memset(m_animation, 0, MAX_ANIMATIONS * sizeof(Animation)); for(int i=0; ibones(); i++){ vector3d start = m_transform[i] * vector3d(); vector3d end = m_transform[i] * vector3d(0.0, 0.0, 1.0f); vector3d norm = m_transform[i] * vector3d(0.0, 0.2f, 0.0); IBone *ibone = m_inst->get(ix::bones)[m_model->get(ix::bones)[i]]; glBegin(GL_LINES); if(ibone && ibone->active() && ibone->get("target")!=Null){ matrix inv; matrix::fastInverse(inv, m_inst->localMatrix()); vector3d target = inv * (vector3d)ibone->get("target"); glColor3f(1.0, 0.5f, 0.0f); glVertex3f(start.x, start.y, start.z); glVertex3f(target.x, target.y, target.z); } glColor3f(0.0, 1.0f, 1.0f); glVertex3f(start.x, start.y, start.z); glVertex3f(end.x, end.y, end.z); glColor3f(0.0, 0.0, 1.0f); glVertex3f(start.x, start.y, start.z); glVertex3f(norm.x, norm.y, norm.z); glEnd(); } glColor3f(1.0f, 1.0f, 1.0f); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); } bool AnimationController::update(bool force) { //update frame and calculate matrices float time = WGD[ix::time]; float itime = WGD["itime"]; bool changed=false; for(int i=0; i0) { float t = m_animation[b].time + dt; //calculate frame if(m_animation[b].loop) { float pcnt = t / m_animation[b].length(); //normalised time pcnt -= floor(pcnt); //wrap pcnt between 0 and 1 float f = pcnt * m_blend[b].frames; //get current frame //translate this frame to animation start/end frames if(m_blend[b].start > m_blend[b].end) f = -f; m_blend[b].frame = m_blend[b].start + f; } else { //off the ends of the animation if(t<=0) m_blend[b].frame = m_blend[b].start; else if(t>=m_animation[b].length()) { m_blend[b].frame = m_blend[b].end; if(m_blend[b].next !=Null) startAnimation(b); } else { //get frame from time since start of animation float f = t / m_animation[b].length() * m_blend[b].frames; //translate this frame to animation start/end frames if(m_blend[b].start > m_blend[b].end) f = -f; m_blend[b].frame = m_blend[b].start + f; } } m_animation[b].time = t; } //calculate transition value - later //return true if something has changed return lastFrame!=m_blend[b].frame; } matrix &AnimationController::transformMesh(Mesh *mesh) { //local matrices for each mesh if not skeletally deformed return boneMatrix(mesh->bone()); } void Animation::start(const OID &name, float wt, const OID &bone, float spd) { m_animation = name; weight = wt; speed = spd; m_parent->startAnimation(m_index, bone); } void AnimationController::startAnimation(int anim, const OID &bone) { //change the current animation OID an = m_animation[anim].animation(); OID animation = m_model->get(ix::animations)[an]; //cache local animation data m_blend[anim].set = m_model->animationSet(animation[ix::animset]); m_blend[anim].next = animation[ix::next]; m_blend[anim].start = animation[ix::start]; m_blend[anim].end = animation[ix::end]; m_blend[anim].frames = fabs(m_blend[anim].end-m_blend[anim].start); m_blend[anim].frame = m_blend[anim].start; //set bone if(bone!=Null) { Bone *sbone = m_model->bone(bone); if(sbone) m_blend[anim].root = sbone->bid(); else m_blend[anim].root=0; } //change public data m_animation[anim].loop = animation[ix::loop]; m_animation[anim].m_length = m_blend[anim].frames / m_model->fps(); m_animation[anim].time = 0; } void AnimationController::transform(int bid, int mask, vector3d &position, vector3d &scale, quaternion &orientation) { //get base ?? no idea what this will do... - perhaps use frame 0 ?? scale = m_cscale[bid]; position = m_cposition[bid]; orientation = m_corientation[bid]; //loop through all blended animations for(unsigned int i=0; iscale(bid, m_blend[i].frame); scale = vector3d::lerp(scale, tscale, m_animation[i].weight); //position vector3d tposition = m_blend[i].set->position(bid, m_blend[i].frame); position = vector3d::lerp(position, tposition, m_animation[i].weight); //orientation quaternion torientation = m_blend[i].set->orientation(bid, m_blend[i].frame); orientation = quaternion::slerp(orientation, torientation, m_animation[i].weight); } } } void AnimationController::calculateBone(const OID &boneName, const matrix &parent, int mask) { //calculate matrix for each bone recursively Bone *bone = m_model->bone(boneName); IBone *ibone = m_inst->get(ix::bones)[boneName]; int bid = bone->bid(); //activate animations for(int i=0; i<9; i++) { if(m_blend[i].root==bid && m_animation[i].weight>0 && m_blend[i].set) mask |= (1<bid()]; //user defined transformation if( ibone && ibone->active() ) { matrix::fastMultiply(tmp, parent, bone->tMatrix()); matrix scale; scale.scale(m_inst->get(ix::scale)); //this should really be outside the loop const matrix &user = ibone->transform(m_inst->localMatrix() * scale, tmp); matrix::fastMultiply(combined, tmp, user); } else if(mask==0) { //use base matrix if no animations active on this bone matrix::fastMultiply(combined, parent, bone->tMatrix()); } else { //apply animations to this bone matrix rot, pos, scl; quaternion quat; //get transformatrions from animation for this bone transform(bid, mask, m_cposition[bid], m_cscale[bid], m_corientation[bid]); //create matrices scl.scale(m_cscale[bid]); pos.translate(m_cposition[bid]); m_corientation[bid].createMatrix(rot); //mash all matrices together in a big pile of numbers matrix::fastMultiply(combined, pos, scl); matrix::fastMultiply(tmp, combined, rot); matrix::fastMultiply(combined, parent, tmp); } //recursively process all child bones for(int i=0; ichildren(); i++){ calculateBone(bone->child(i), combined, mask); } //deactivate animations for(int i=0; i<9; i++) { if(m_blend[i].root==bid) mask &= ~(1<bone(boneName); if(bone) return m_transform[bone->bid()]; else return m_transform[0]; } /////// IBone stuff //////////// namespace wgd { OnEvent(IBone, evt_target) { if(get("target")!=Null) { m_target = get("target"); m_useTarget=true; set(ix::changed, dvm::Void); } else { calcPYR(); m_useTarget = false; } } OnEvent(IBone, evt_pitchyawRoll) { calcPYR(); } IMPLEMENT_EVENTS(IBone, Agent); }; IBone::IBone() { registerEvents(); } IBone::IBone(const doste::dvm::OID &id) : Agent(id), m_useTarget(false) { registerEvents(); } const matrix &IBone::transform(const matrix& p, const matrix& b){ if(m_useTarget) calcTarget(p, b); return m_matrix; } void IBone::calcPYR(){ m_matrix.rotate(orientation()); if(get(ix::scale)!=Null) { matrix scl; scl.scale(scale()); m_matrix = m_matrix * scl; } set(ix::changed, dvm::Void); } void IBone::calcTarget(const matrix &inst, const matrix &parent){ //get target in bone local coodinates matrix mat, inv; matrix::fastMultiply(mat, inst, parent); matrix::fastInverse(inv, mat); vector3d target = inv * m_target; //calculate pitch and yaw float yaw = atan2(target.x, target.z); float pitch = atan2( sqrt(target.x*target.x + target.z*target.z), target.y) - 1.5707963f; float roll = get(ix::orientation).get(ix::z); //are there limits? //this has to be done here rather than in doste as triggeting may happen at the wrong time //i may be wrong here but it can be taken out if it is a problem. vector3d vmin, vmax; bool limits = (get("max") != Null); if(limits) { vmin = minimum(); vmax = maximum(); if(pitch < vmin.x) pitch = vmin.x; else if(pitch > vmax.x) pitch = vmax.x; if(yaw < vmin.y) yaw = vmin.y; else if(yaw > vmax.y) yaw = vmax.y; if(roll < vmin.z) roll = vmin.z; else if(roll > vmax.z) roll = vmax.z; } //if speed is set, the bone must rotate smoothly at that speed float spd = speed(); if(spd>0.0) { vector3d last = orientation(); //get directions float pd = pitch - last.x; float yd = yaw - last.y; float pi = (float)PI; //wrap -> the other direction if(pd < -pi && (!limits || vmin.x < -pi)) pd = pi * 2 + pd; else if(pd > pi && (!limits || vmax.x > pi)) pd = pd - pi * 2; if(yd < -pi && (!limits || vmin.y < -PI)) yd = pi * 2 + yd; else if(yd > pi && (!limits || vmax.y > PI)) yd = yd - pi * 2; //rotate if(pd > spd) pitch = last.x + spd; else if(pd < -spd) pitch = last.x - spd; if(yd > spd) yaw = last.y + spd; else if(yd < -spd) yaw = last.y - spd; //wrap values to { -PI, PI } if(pitch < -pi) pitch += pi*2; else if(pitch > PI) pitch -= pi*2; if(yaw < -pi) yaw += pi*2; else if(yaw > pi) yaw -= pi*2; if(roll < -pi) roll += pi*2; else if(roll > pi) roll -= pi*2; } //set orientation to cause the matrix to be recalculated orientation(vector3d(pitch, yaw, roll)); } wgd-3.1/src/models/Makefile.in0000644000175000001440000003134211265575310013202 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_models.so$(EXEEXT) subdir = src/models DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_models_so_OBJECTS = mesh.$(OBJEXT) model3ds.$(OBJEXT) \ model.$(OBJEXT) imodel.$(OBJEXT) animationcontroller.$(OBJEXT) \ animationset.$(OBJEXT) modelx.$(OBJEXT) \ morphcontroller.$(OBJEXT) skincontroller.$(OBJEXT) \ clipmap.$(OBJEXT) collision.$(OBJEXT) libwgd_models_so_OBJECTS = $(am_libwgd_models_so_OBJECTS) libwgd_models_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libwgd_models_so_SOURCES) DIST_SOURCES = $(libwgd_models_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_models_so_SOURCES = mesh.cpp model3ds.cpp model.cpp imodel.cpp animationcontroller.cpp animationset.cpp modelx.cpp morphcontroller.cpp skincontroller.cpp clipmap.cpp collision.cpp collision.h AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -L../base_3d -L../resources_base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base -lwgd_base3d INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/models/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/models/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_models.so$(EXEEXT): $(libwgd_models_so_OBJECTS) $(libwgd_models_so_DEPENDENCIES) @rm -f libwgd_models.so$(EXEEXT) $(CXXLINK) $(libwgd_models_so_OBJECTS) $(libwgd_models_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/models/clipmap.cpp0000644000175000001440000003001611233311614013251 00000000000000#include #include "collision.h" #include #include using namespace wgd; namespace wgd { OnEvent(ClipMap, evt_build) { if((bool)model()->get("loaded")) build(); } OnEvent(ClipMap, evt_scale) { calcLocal(); } OnEvent(ClipMap, evt_position) { calcLocal(); } OnEvent(ClipMap, evt_orientation) { calcLocal(); } OnEvent(ClipMap, evt_cache) { m_built = false; } IMPLEMENT_EVENTS(ClipMap, doste::Agent); }; ClipMap::ClipMap(const wgd::OID &id) : Agent(id), m_built(false), m_vertex(0), m_mesh(0) { if(get(ix::scale)==Null) scale(vector3d(1.0f, 1.0f, 1.0f)); memset(m_tree.n, 0, 8 * sizeof(Node*)); //initialise tree registerEvents(); } ClipMap::ClipMap(wgd::Model* mdl, int d, bool csh) : Agent(), m_built(false), m_vertex(0), m_mesh(0) { memset(m_tree.n, 0, 8 * sizeof(Node*)); //initialise tree scale(vector3d(1.0f, 1.0f, 1.0f)); model(mdl); depth(d); cache(csh); registerEvents(); } ClipMap::~ClipMap() { if(m_vertex) delete [] m_vertex; if(m_mesh) delete [] m_mesh; } void ClipMap::calcLocal() { matrix t, r, s, x; t.translate(position()); r.rotate(orientation()); s.scale(scale()); matrix::fastMultiply(x, s, r); matrix::fastMultiply(m_localMatrix, t, x); m_built = false; //force rebuild } void ClipMap::build() { //build octree Model *mdl = model(); if(mdl) mdl->load(); if(!mdl || !(bool)mdl->loaded()) return; //cache transformed vertices if(m_vertex) delete [] m_vertex; m_vcount=0; if(cache()) { for(int i=0; imeshes(); i++) m_vcount += mdl->mesh(i)->vertices(); m_vertex = new vector3d[m_vcount]; vector3d temp; m_vcount=0; for(int i=0; imeshes(); i++) { for(int j=0; jmesh(i)->vertices(); j++) { memcpy(&temp, &mdl->mesh(i)->data()[j].position.x, 3 * sizeof(float)); matrix::fastMultiply(m_vertex[m_vcount++], m_localMatrix, temp); } } //first calculate AABB m_high = m_vertex[0]; m_low = m_vertex[0]; for(int i=0; i m_high.x) m_high.x = m_vertex[i].x; if(m_vertex[i].y > m_high.y) m_high.y = m_vertex[i].y; if(m_vertex[i].z > m_high.z) m_high.z = m_vertex[i].z; if(m_vertex[i].x < m_low.x) m_low.x = m_vertex[i].x; if(m_vertex[i].y < m_low.y) m_low.y = m_vertex[i].y; if(m_vertex[i].z < m_low.z) m_low.z = m_vertex[i].z; } } else { //cache mesh pointers m_vertex = 0; m_meshes = mdl->meshes(); if(m_mesh) delete [] m_mesh; m_mesh = new Mesh*[m_meshes]; for(int i=0; imesh(i); //calculate AABB directly from model vertices for(int i=0; idata()[0].position.x, sizeof(float) * 3); memcpy(&m_low, &m_mesh[i]->data()[0].position.x, sizeof(float) * 3); } for(int j=0; jvertices(); j++) { vector_selector<3> &v = m_mesh[i]->data()[j].position; if(v.x > m_high.x) m_high.x = v.x; if(v.y > m_high.y) m_high.y = v.y; if(v.z > m_high.z) m_high.z = v.z; if(v.x < m_low.x) m_low.x = v.x; if(v.y < m_low.y) m_low.y = v.y; if(v.z < m_low.z) m_low.z = v.z; } } //save inverse transform matrix //this wont work properly with spheres if a non-uniform scale is used //as it transforms the test input, and sphere radius is fixed matrix::fastInverse(m_inverseMatrix, m_localMatrix); } //setup octree m_depth = depth(); NodeData data; clearTree(m_tree); m_tree.centre = (m_high + m_low) / 2; m_tree.size = m_high - m_low; m_tree.depth = 0; //loop through cached vertices if(cache()) { for(int i=0; in, 0, 8 * sizeof(Node*)); //clear child pointers n.n[index]->size = s2; //node size n.n[index]->depth = n.depth + 1; //node depth n.n[index]->centre.x = n.centre.x + (index&1)? s2.x: -s2.x; //calculate centre n.n[index]->centre.y = n.centre.y + (index&2)? s2.y: -s2.y; // .. n.n[index]->centre.z = n.centre.z + (index&4)? s2.z: -s2.z; // .. } return *n.n[index]; } void ClipMap::addTree(Node &n, NodeData &data) { //calculate the octant each vertex is in int v1=0, v2=0, v3=0, straddle=0; if(m_vertex[data.polygon].x > n.centre.x) v1 |= 1; if(m_vertex[data.polygon].y > n.centre.y) v1 |= 2; if(m_vertex[data.polygon].z > n.centre.z) v1 |= 4; if(m_vertex[data.polygon+1].x > n.centre.x) v2 |= 1; if(m_vertex[data.polygon+1].y > n.centre.y) v2 |= 2; if(m_vertex[data.polygon+1].z > n.centre.z) v2 |= 4; if(m_vertex[data.polygon+2].x > n.centre.x) v3 |= 1; if(m_vertex[data.polygon+2].y > n.centre.y) v3 |= 2; if(m_vertex[data.polygon+2].z > n.centre.z) v3 |= 4; //calculate straddle value if((v1&1) != (v2&1) || (v2&1) != (v3&1)) straddle |= 1; if((v1&2) != (v2&2) || (v2&2) != (v3&2)) straddle |= 2; if((v1&4) != (v2&4) || (v2&4) != (v3&4)) straddle |= 4; //in a quadrant if(!straddle && n.depth= 3) straddle=0; //dont do this further down the tree if(straddle==1) { addTree(addNode(n, x), data); addTree(addNode(n, x-1), data); } else if(straddle==2) { addTree(addNode(n, x), data); addTree(addNode(n, x-2), data); } else if(straddle==4) { addTree(addNode(n, x), data); addTree(addNode(n, x-4), data); } else { //stick it here n.data.push_back(data); } } } //ray collision int ClipMap::test(const vector3d &pa, const vector3d &pb, vector3d &hit, vector3d &normal) { if(!m_built) build(); if(!m_built) return 0; //AABB test - need to know if it intersects, not where exactly... if(!TestSegmentAABB(pa, pb, m_low, m_high)) return 0; if(m_vcount) { /* //test with octree std::vector data; m_tests = testTree(m_tree, pa, pb, data, vector3d::distanceSquared(pa, pb)); if(data.empty()) return 0; //extract hits - return closest one for now float clen = data[0].d+1; for(unsigned int i=0; ivertices(); i+=3) { memcpy(&a.x, &m_mesh[j]->data()[i+0].position.x, sizeof(float) * 3); memcpy(&b.x, &m_mesh[j]->data()[i+1].position.x, sizeof(float) * 3); memcpy(&c.x, &m_mesh[j]->data()[i+2].position.x, sizeof(float) * 3); if( intersectLineTriangle(ta,tb, a,b,c, r,n) ) { //check if it is the closest hit float d = pa.distanceSquared(r); if(d < dist) { matrix::fastMultiply(hit, m_localMatrix, r); //hit = r; //get normal from polygon matrix::fastMultiply(normal, m_localMatrix, n); //normal = n; dist = d; } hits++; } } } m_tests = m_vcount / 3; //testing all polys return hits; } } int ClipMap::testTree(Node &n, const wgd::vector3d &a, const wgd::vector3d &b, std::vector &data, float length) { //test AABB, then call ALL its children if(!TestSegmentAABB(a, b, m_low, m_high)) return 0; //do tests on this node's data if(!n.data.empty()) { int p; vector3d r,nm; for(unsigned int i=0; i m_high.x || centre.y-radius > m_high.y || centre.z-radius > m_high.z) return 0; //temportaty collision data std::vector data; //recursively test octree if(m_vcount) { m_tests = testTree(m_tree, centre, radius, data); } else if(m_mesh) { //transform input vector3d ctr = m_inverseMatrix * centre; float rd = radius; //scale().length() * radius; //if no cache, test all meshes m_tests = 0; for(int j = 0; jvertices(); i+=3) { memcpy(&a.x, &m_mesh[j]->data()[i+0].position.x, sizeof(float) * 3); memcpy(&b.x, &m_mesh[j]->data()[i+1].position.x, sizeof(float) * 3); memcpy(&c.x, &m_mesh[j]->data()[i+2].position.x, sizeof(float) * 3); r = ClosectPointTriangle(ctr, a,b,c); //check if it within the collision radius float d = ctr.distanceSquared(r); if(d < rd*rd) { //convert back to world coordinates matrix::fastMultiply(r2, m_localMatrix, r); //insert into array in order of decreasing d data.push_back(CData(r2, (centre - r2).normalise(), d)); } } m_tests += m_mesh[j]->vertices() / 3; } } //sort list std::sort(data.begin(), data.end()); //copy data to return variables int i=0; for(std::vector::iterator iter=data.begin(); iter!=data.end(); iter++, i++) { if(i==max) return max; //stop if we are over the array size memcpy(&point[i].x, iter->p, 3 * sizeof(float)); memcpy(&normal[i].x, iter->n, 3 * sizeof(float)); } return data.size(); } int ClipMap::testTree(Node &n, const wgd::vector3d ¢re, float radius, std::vector &data) { int tests=0; //debug - count tests //chose child nodes to recurse to int index = 0, straddle=0; if(centre.x > n.centre.x) index |= 1; if(centre.y > n.centre.y) index |= 2; if(centre.z > n.centre.z) index |= 4; //are we in multiple child nodes? if(centre.x-radius <= n.centre.x && centre.x+radius > n.centre.x) straddle |= 1; if(centre.y-radius <= n.centre.y && centre.y+radius > n.centre.y) straddle |= 2; if(centre.z-radius <= n.centre.z && centre.z+radius > n.centre.z) straddle |= 4; if(straddle) { //is there a nice way of limiting the straddle testing - meh - do them all for now for(int i=0; i<8; i++) { if(n.n[i]) tests += testTree(*n.n[i], centre, radius, data); } } else { if(n.n[index]) tests += testTree(*n.n[index], centre, radius, data); } //do the actual testing if(!n.data.empty()) { vector3d a,b,c,r; for(unsigned int i=0; i #include #include #include #include #include #define MAIN3DS 0x4d4d //Main 3DS chunk, always the first chunk #define EDIT3DS 0x3d3d //Chunk whose subchunks contain objects #define EDITOBJECT 0x4000 //An object which contains vertex and polygon data #define OBJ_TRIMESH 0x4100 //The triangle mesh #define TRI_VERTEXL 0x4110 //Vertices #define TRI_FACEL1 0x4120 //triangles #define FACE_MATERIAL 0x4130 //material for above polygons #define MAPPING_COORDS 0x4140 //Texture mapping coordinates #define MATERIAL 0xAFFF //material #define MATERIAL_NAME 0xA000 //material name #define MAT_AMBIENT 0xA010 //material attributes... #define MAT_DIFFUSE 0xA020 #define MAT_SPECULAR 0xA030 #define MAT_SHININESS 0xA040 #define MAT_TEXTURE 0xa300 //Material texture file name (limited to 12 characters aparently) #define KEYFRAME 0xB000 //Beginning of KeyFrame stuff #define FRAMEINFO 0xB008 //Key frame info #define OBJECTINFO 0xB002 //Key frame object info #define NAMEHIER 0xB010 //Object name and hierarchy #define DUMMYNAME 0xB011 //Dummy object name #define PIVOTPOINT 0xB020 //Objects pivot point. #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif using namespace wgd; using namespace doste; using namespace doste::dvm; bool Model3DS::validate(doste::File *file){ unsigned short chunk_id; file->read(chunk_id); file->seek(0, File::BEG); return chunk_id==MAIN3DS; } void Model3DS::load(){ File *f = file(); f->open(File::READ); DMsg msg(DMsg::INFO); msg << "Loading 3DS model '" << (const char*)f->filename() << "'\n"; char tdir[128]; directory((const char*)f->filename(), tdir); unsigned short chunk_id; unsigned int chunk_length; unsigned short qty; unsigned short face_flags; unsigned int hier; int i; unsigned char lchar; //geometry data char name[50] = ""; char mName[50] = ""; vector3d *vertices=NULL; vector2d *texCoords=NULL; unsigned short *faces=NULL; unsigned short nFaces=0; //material data char matName[50] = ""; char texFile[50] = ""; Texture *tex = NULL; float rgb[3]; Material *mat = NULL; int meshindex = 0; char buffer[50]; while(!f->eof()){ f->read(chunk_id); f->read(chunk_length); //std::cout << "chunk " << std::hex << chunk_id << std::dec << " length " << chunk_length << "\n"; switch(chunk_id){ case KEYFRAME: break; //Beginning of KeyFrame stuff case OBJECTINFO: break; //Key frame object info case NAMEHIER: //Object name and hierarchy i = 0; do { //f->read((char*)&lchar, 1); f->read(lchar); if(lchar==32) lchar='_'; buffer[i] = lchar; i++; } while (lchar != 0 && i < 50); f->read(hier); f->read(hier); f->read(hier); //std::cout << " - Hierarchy: " << buffer << " = " << hier << std::endl; break; case MAIN3DS: break; //Main 3DS chunk, always the first chunk case MATERIAL: break; case MATERIAL_NAME: i = 0; do { f->read(lchar); if(lchar==32) lchar='_'; matName[i] = lchar; i++; } while (lchar != 0 && i < 20); if(m_model->get(ix::materials)==Null) m_model->set(ix::materials, OID::create()); if (m_model->get(ix::materials).get(matName) == Null) { mat = Material::create(); m_model->get(ix::materials).set(matName, *mat); } else { mat = m_model->get(ix::materials).get(matName); } break; case MAT_AMBIENT: //use only the last 3 bytes f->seek(chunk_length - 9); rgb[0] = (float) f->read(); rgb[1] = (float) f->read(); rgb[2] = (float) f->read(); if (mat->get(ix::ambient) == Null) mat->ambient(colour(rgb[0]/256.0f, rgb[1]/256.0f, rgb[2]/256.0f, 1.0f)); break; case MAT_DIFFUSE: //use only the last 3 bytes f->seek(chunk_length - 9); rgb[0] = (float) f->read(); rgb[1] = (float) f->read(); rgb[2] = (float) f->read(); if (mat->get(ix::diffuse) == Null) mat->diffuse(colour(rgb[0]/256.0f, rgb[1]/256.0f, rgb[2]/256.0f, 1.0f)); break; case MAT_SPECULAR: //use only the last 3 bytes f->seek(chunk_length - 9); rgb[0] = (float) f->read(); rgb[1] = (float) f->read(); rgb[2] = (float) f->read(); if (mat->get(ix::specular) == Null) mat->specular(colour(rgb[0]/256.0f, rgb[1]/256.0f, rgb[2]/256.0f, 1.0f)); break; //case MAT_SHININESS: //no idea which values to use so ill leave this for now case 0xa200: break; case MAT_TEXTURE: i = 0; do { //f->read((char*)&lchar, 1); f->read(lchar); buffer[i] = lchar; i++; } while (lchar != 0 && i < 20); sprintf(texFile, "%s%s", tdir, buffer); //wgd::cout << "Texture found: " << texFile << "\n"; tex = mat->texture(); if (tex == 0) { tex = new Texture(); mat->texture(tex); tex->file(new LocalFile(texFile)); } break; case EDIT3DS: break; //Chunk whose subchunks contain objects case EDITOBJECT: //An object which contains vertex and polygon data //Submit current mesh here - if it contains anything if(nFaces>0) { processMesh(meshindex++, mName, nFaces, faces, vertices, texCoords); texCoords = NULL; vertices = NULL; } i = 0; do { f->read(lchar); if(lchar==32) lchar='_'; name[i] = lchar; i++; } while (lchar != 0 && i < 50); break; case OBJ_TRIMESH: break;//The triangle mesh case TRI_VERTEXL: //List of vertices f->read(qty); vertices = new vector3d[qty]; for (i=0; iread(vertices[i].x); f->read(vertices[i].y); f->read(vertices[i].z); } break; case TRI_FACEL1: //List of triangle faces f->read(nFaces); faces = new unsigned short[nFaces*3]; for (i = 0; iread(faces[i]); f->read(faces[i+1]); f->read(faces[i+2]); f->read(face_flags); } break; case FACE_MATERIAL: //get material name i = 0; do { //f->read((char*)&lchar, 1); f->read(lchar); if(lchar==32) lchar='_'; mName[i] = lchar; i++; } while (lchar != 0 && i < 50); //skip the rest of this block f->seek(chunk_length - 6 - i); break; case MAPPING_COORDS: //Texture mapping coordinates f->read(qty); texCoords = new vector2d[qty]; for (i=0; iread(texCoords[i].x); f->read(texCoords[i].y); } break; default: //skip chunk f->seek(chunk_length - 6); } f->peek(); } f->close(); if(nFaces>0) processMesh(meshindex++, mName, nFaces, faces, vertices, texCoords); return; } void Model3DS::processMesh(int index, char *material, int nFaces, unsigned short *faces, vector3d *vertices, vector2d *tex) { //make vertex arrays meshVertex *vx = new meshVertex[nFaces*3]; for(int i=0; ivertices(nFaces * 3, vx); m->material(material); m->calcNormals(); m->calcTangents(); if(tex!=NULL) delete [] tex; tex=NULL; delete [] vertices; vertices=NULL; } wgd-3.1/src/models/mesh.cpp0000644000175000001440000000761311077705131012576 00000000000000#include #include #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; Mesh::Mesh() : Object(), m_weightsPerVertex(0), m_skin(NULL), m_drawable(0) { set("type",type()); } Mesh::Mesh(const OID &id) : Object(id), m_weightsPerVertex(0), m_skin(NULL), m_drawable(0) { set("type",type()); } Mesh::~Mesh(){ if(m_skin) delete [] m_skin; if(m_drawable) m_drawable->destroy(); } void Mesh::setup() { m_drawable = new Drawable; m_drawable->mode = GL_TRIANGLES; m_drawable->clearData = false; m_drawable->discard = false; } void Mesh::vertices(int nVertices, meshVertex* vx) { if(!m_drawable) setup(); m_drawable->deleteData(); m_drawable->data = vx; m_drawable->size = nVertices; } void Mesh::skin(int wpv, MeshSkin *skin){ if(m_skin) delete [] m_skin; m_weightsPerVertex = wpv; m_skin = skin; } void Mesh::create(int n){ //setup blank mesh array if(!m_drawable || m_drawable->size != n){ meshVertex *vx = new meshVertex[n]; memset(vx, 0, n * sizeof(meshVertex)); vertices(n, vx); } else { memset(m_drawable->data, 0, n * sizeof(meshVertex)); } } void Mesh::calcTangents(){ for(unsigned int i=0; isize; i+=3){ meshVertex *vx = m_drawable->data; vector3d tangent = calcTangent(vx[i], vx[i+1], vx[i+2]); for(int j=0; j<3; j++){ vx[i+j].custom.var.x = tangent.x; vx[i+j].custom.var.y = tangent.y; vx[i+j].custom.var.z = tangent.z; } } } vector3d Mesh::calcTangent(const meshVertex &vA, const meshVertex &vB, const meshVertex &vC){ vector3d vAB = vector3d(vB.position.x, vB.position.y, vB.position.z) - vector3d(vA.position.x, vA.position.y, vA.position.z); vector3d vAC = vector3d(vC.position.x, vC.position.y, vC.position.z) - vector3d(vA.position.x, vA.position.y, vA.position.z); vector3d nA = vector3d(vA.normal.x, vA.normal.y, vA.normal.z); // Components of vectors to neighboring vertices that are orthogonal to the // vertex normal vector3d vProjAB = vAB - nA * ( vector3d::dotProduct( nA, vAB )); vector3d vProjAC = vAC - nA * ( vector3d::dotProduct( nA, vAC )); // tu texture coordinate differences float duAB = vB.texcoords[0].u - vA.texcoords[0].u; float duAC = vC.texcoords[0].u - vA.texcoords[0].u; // tv texture coordinate differences float dvAB = vB.texcoords[0].v - vA.texcoords[0].v; float dvAC = vC.texcoords[0].v - vA.texcoords[0].v; if( (dvAC * duAB) > (dvAB * duAC) ){ dvAC = -dvAC; dvAB = -dvAB; } vector3d vTangent = (vProjAC * dvAB) - (vProjAB * dvAC); //vTangent.normalise(); return vTangent.normalise(); } void Mesh::calcNormals(){ for(unsigned int i=0; isize; i+=3){ meshVertex *vx = m_drawable->data; //points vector3d p1 = vector3d(vx[i ].position.x, vx[i ].position.y, vx[i ].position.z); vector3d p2 = vector3d(vx[i+1].position.x, vx[i+1].position.y, vx[i+1].position.z); vector3d p3 = vector3d(vx[i+2].position.x, vx[i+2].position.y, vx[i+2].position.z); //vectors vector3d a = p2 - p1; vector3d b = p3 - p1; //normal vector3d normal = vector3d::crossProduct(a, b); normal = normal.normalise(); //save in the three points for(int j=0; j<3; j++){ vx[i+j].normal.x = normal.x; vx[i+j].normal.y = normal.y; vx[i+j].normal.z = normal.z; } } } wgd-3.1/src/base_2d/0000777000175000001440000000000011265576313011236 500000000000000wgd-3.1/src/base_2d/sprite2d.cpp0000644000175000001440000001054611233311614013402 00000000000000#include using namespace wgd; Sprite2D::Sprite2D() : m_sprite(0), m_angle(0), m_frame(0), m_depth(0) { setup(); } Sprite2D::Sprite2D(Sprite* spr, const vector2d &pos, float s, float ang, int f) : m_sprite(spr), m_position(pos), m_angle(ang), m_frame(f), m_depth(0) { scale(s); setup(); } void Sprite2D::sprite(Sprite *spr) { m_sprite = spr; m_changed = true; } void Sprite2D::position(const vector2d &p) { m_position = p; } void Sprite2D::angle(float ang) { m_angle = ang; } void Sprite2D::scale(float s) { stretch(s, s); } void Sprite2D::depth(float d) { m_depth=d; } void Sprite2D::stretch(float sx, float sy) { //need to check for null if(!m_sprite) return; m_sprite->texture()->load(); int cols = m_sprite->columns(); int rows = m_sprite->rows(); if(cols==0) cols=1; if(rows==0) rows=1; m_size.x = m_sprite->texture()->width() / cols * sx; m_size.y = m_sprite->texture()->height() / rows * sy; m_changed = true; } void Sprite2D::size(float width, float height) { m_size.x = width; m_size.y = height; m_changed = true; } void Sprite2D::colour(const wgd::colour &c) { for(int i=0; i<4; i++) { m_drawable->data[i].colour = c; } } void Sprite2D::frame(int f) { m_frame = f; if(m_sprite) { f=-f; //for some reason, its backwards int cols = m_sprite->columns(); int rows = m_sprite->rows(); float tw = 1.0f / (float)cols; float th = 1.0f / (float)m_sprite->rows(); float tx = tw*(float)(cols-(f%cols)); float ty = th*(float)(rows-1+(f/cols)); m_drawable->data[0].texcoords[0].u = tx+tw; m_drawable->data[0].texcoords[0].v = ty; m_drawable->data[1].texcoords[0].u = tx+tw; m_drawable->data[1].texcoords[0].v = ty+th; m_drawable->data[2].texcoords[0].u = tx; m_drawable->data[2].texcoords[0].v = ty+th; m_drawable->data[3].texcoords[0].u = tx; m_drawable->data[3].texcoords[0].v = ty; } } void Sprite2D::draw(SceneGraph &graph) { graph.add(drawable()); } wgd::Drawable *Sprite2D::drawable() { if(m_changed) build(); matrix t, r; t.translate(m_position.x, m_position.y, -m_depth); r.rotate(vector3d(0.0f, 0.0f, m_angle)); m_drawable->transform = t * r; m_drawable->distance = m_depth; return m_drawable; } void Sprite2D::setup() { //create drawable m_drawable = new Drawable; m_drawable->mode = GL_QUADS; m_drawable->flags = DEPTH_TEST | DEPTH_WRITE; m_drawable->deleteData(); m_drawable->data = new SpriteVertex[4]; m_drawable->size = 4; vector3d normal(0.0, 1.0, 0.0); //normals should not do anything but ill stick them in anyway for(int i=0; i<4; i++) { m_drawable->data[i].normal = normal; m_drawable->data[i].colour = wgd::colour(1.0f, 1.0f, 1.0f); m_drawable->data[i].position = vector3d(); } build(); } void Sprite2D::build() { float w = m_size.x / 2.0f; float h = m_size.y / 2.0f; for(int i=0; i<4; i++) { m_drawable->data[i].position.x = (i<2)? w : -w; m_drawable->data[i].position.y = (i==1 || i==2)? -h : h; m_drawable->data[i].position.z = 0; } //set surface if(m_sprite && m_sprite->texture()) m_drawable->surface = *m_sprite->texture(); frame(m_frame); m_changed = false; } ////////////////////////////////////////////////////////////////// namespace wgd { OnEvent(ISprite2D, evt_size) { m_sprite.size(width(), height()); } OnEvent(ISprite2D, evt_sprite) { m_sprite.sprite(sprite()); } OnEvent(ISprite2D, evt_frame) { m_sprite.frame(frame()); } IMPLEMENT_EVENTS(ISprite2D, Instance2D); }; ISprite2D::ISprite2D(const OID &id) : Instance2D(id) { if(width()==0 && height()==0) { width(32); height(32); } registerEvents(); } ISprite2D::ISprite2D() { set(ix::type, type()); if(width()==0 && height()==0) { width(32); height(32); } registerEvents(); } ISprite2D::~ISprite2D() {} void ISprite2D::draw(SceneGraph &graph, Camera2D *camera) { m_sprite.position(position()); m_sprite.depth(depth()); m_sprite.angle(orientation()); m_sprite.draw(graph); } void ISprite2D::scale(float s) { stretch(s, s); } void ISprite2D::stretch(float sx, float sy) { Sprite *spr = sprite(); //need to check for null int cols = spr->columns(); int rows = spr->rows(); if(cols==0) cols=1; if(rows==0) rows=1; width(spr->texture()->width() / cols * sx); height(spr->texture()->height() / rows * sy); } wgd-3.1/src/base_2d/base2d.cpp0000644000175000001440000000102411233311614012775 00000000000000#include #include #include #include #include #include extern "C" void BASE2DIMPORT initialise(const doste::dvm::OID &base) { doste::Object::registerType(); doste::Object::registerType(); doste::Object::registerType(); //doste::Object::registerType(); //doste::Object::registerType(); } extern "C" void BASE2DIMPORT finalise() { } wgd-3.1/src/base_2d/Makefile.am0000644000175000001440000000053611233311614013174 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_base2d.so libwgd_base2d_so_SOURCES=base2d.cpp scene2d.cpp camera2d.cpp instance2d.cpp sprite2d.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -L../resources_base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/base_2d/Makefile.in0000644000175000001440000003042311265575054013222 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_base2d.so$(EXEEXT) subdir = src/base_2d DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_base2d_so_OBJECTS = base2d.$(OBJEXT) scene2d.$(OBJEXT) \ camera2d.$(OBJEXT) instance2d.$(OBJEXT) sprite2d.$(OBJEXT) libwgd_base2d_so_OBJECTS = $(am_libwgd_base2d_so_OBJECTS) libwgd_base2d_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_base2d_so_SOURCES) DIST_SOURCES = $(libwgd_base2d_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_base2d_so_SOURCES = base2d.cpp scene2d.cpp camera2d.cpp instance2d.cpp sprite2d.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -L../resources_base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/base_2d/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/base_2d/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_base2d.so$(EXEEXT): $(libwgd_base2d_so_OBJECTS) $(libwgd_base2d_so_DEPENDENCIES) @rm -f libwgd_base2d.so$(EXEEXT) $(CXXLINK) $(libwgd_base2d_so_OBJECTS) $(libwgd_base2d_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/base_2d/scene2d.cpp0000644000175000001440000000075211233311614013167 00000000000000#include #include #include using namespace wgd; Scene2D::Scene2D(const OID &id) : Scene(id) { } Scene2D::~Scene2D() { } void Scene2D::update() { //updates quadtree } void Scene2D::draw(Camera *cam) { Camera2D *camera = (Camera2D*)(OID)*cam; OID instances = get(ix::instances); for(Iterator i = instances.begin(); i!=instances.end(); i++) { (*i)->draw(graph(), camera); } m_graph.draw(); }wgd-3.1/src/base_2d/camera2d.cpp0000644000175000001440000000257511233311614013327 00000000000000#include using namespace wgd; Camera2D::Camera2D(const OID &id) : Camera(id) { if(zoom() == 0) zoom(1.0f); } Camera2D::~Camera2D() {} void Camera2D::bind() { double right = (double)m_width / 2.0; double left = -right; double top = (double)m_height / 2.0; double bottom = -top; //set up projection matrix glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(left, right, bottom, top, 1.0, 128.0); //set up modelview matrix glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glClear(GL_DEPTH_BUFFER_BIT); //transform modelview float r = orientation(); float s = zoom(); vector2d t = position(); glRotatef(r * 57.29578f, 0.0f, 0.0f, 1.0f); glScalef(s, -s, s); glTranslatef(-t.x, -t.y, -10.0f); glEnable(GL_DEPTH_TEST); } void Camera2D::unbind() { glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_DEPTH_TEST); } void Camera2D::move(const vector2d &v) { position(position() + v); } void Camera2D::translate(const vector2d &v) { position(position().translate(orientation(), v)); } void Camera2D::rotate(float r) { orientation(orientation() + r); } vector2d Camera2D::project(const vector2d&) { //meh - later return vector2d(); } vector2d Camera2D::unproject(const vector2d&) { return vector2d(); } wgd-3.1/src/base_2d/instance2d.cpp0000644000175000001440000000160511233311614013674 00000000000000#include using namespace wgd; Instance2D::Instance2D() : Agent() {} Instance2D::Instance2D(const OID &id) : Agent(id) {} Instance2D::~Instance2D() {} void Instance2D::draw(SceneGraph &graph, Camera2D *camera) { //? } void Instance2D::move(const vector2d &v) { position(position()+v); } void Instance2D::translate(const vector2d &v) { vector2d p = position(); float ang = orientation(); p.x += cos(ang) * v.x; p.y += sin(ang) * v.y; position(p); } vector2d Instance2D::worldPosition() { Instance2D *p = parent(); if(p) { return p->worldPosition().translate(p->worldOrientation(), position()); } return position(); } void Instance2D::rotate(float r) { orientation(orientation() + r); } float Instance2D::worldOrientation() { if(parent()) { return orientation() + parent()->worldOrientation(); } return orientation(); } wgd-3.1/src/Makefile.in0000644000175000001440000003632111265575054011726 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ #bin_PROGRAMS=dloader #dloader_SOURCES=main.cpp #INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include #AM_LDFLAGS=--ldl -lxaraling VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/wgd.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = wgd am__installdirs = "$(DESTDIR)$(loadexecdir)" loadexecSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(loadexec_SCRIPTS) depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ loadexecdir = $(bindir) loadexec_SCRIPTS = wgd #EXTRA_DIST=$(script_DATA) #install-data-hook: # chmod "a+x" $(bindir)/wgd SUBDIRS = base collision_2d collision_3d input resources_base base_3d base_2d models sound widgets xnet heightmap ui all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh wgd: $(top_builddir)/config.status $(srcdir)/wgd.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-loadexecSCRIPTS: $(loadexec_SCRIPTS) @$(NORMAL_INSTALL) test -z "$(loadexecdir)" || $(MKDIR_P) "$(DESTDIR)$(loadexecdir)" @list='$(loadexec_SCRIPTS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f $$d$$p; then \ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ echo " $(loadexecSCRIPT_INSTALL) '$$d$$p' '$(DESTDIR)$(loadexecdir)/$$f'"; \ $(loadexecSCRIPT_INSTALL) "$$d$$p" "$(DESTDIR)$(loadexecdir)/$$f"; \ else :; fi; \ done uninstall-loadexecSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(loadexec_SCRIPTS)'; for p in $$list; do \ f=`echo "$$p" | sed 's|^.*/||;$(transform)'`; \ echo " rm -f '$(DESTDIR)$(loadexecdir)/$$f'"; \ rm -f "$(DESTDIR)$(loadexecdir)/$$f"; \ done # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(SCRIPTS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(loadexecdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-exec-am: install-loadexecSCRIPTS install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-loadexecSCRIPTS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic ctags \ ctags-recursive distclean distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ install-loadexecSCRIPTS install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-loadexecSCRIPTS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/input/0000777000175000001440000000000011265576313011076 500000000000000wgd-3.1/src/input/Makefile.am0000644000175000001440000000043511101056112013023 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_input.so libwgd_input_so_SOURCES=wiimote.cpp input.cpp joystick.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -shared -lGL -lX11 -lXxf86vm -ldoste -lwgd_base -lbluetooth INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/input/joystick.cpp0000644000175000001440000002255611233311614013351 00000000000000#include #include #ifdef WIN32 #include #include #include #endif #ifdef LINUX #include #include #include #include #include #define test_bit(nr, addr) (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) #endif #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif using namespace wgd; using namespace doste; using namespace doste::dvm; int wgd::Joystick::s_numjs = 0; Joystick *wgd::Joystick::s_jsticks[MAX_JOYSTICKS]; extern doste::dvm::OID inputbase; #ifdef LINUX Joystick::Joystick(const OID &obj, int fp, const char *devname) : Object(obj), m_numbuts(0), m_numaxis(0) { m_fp = fp; if (get(ix::buttons) == Null) set(ix::buttons, OID::create()); if (get(ix::axes) == Null) set(ix::axes, OID::create()); fcntl(fp, F_SETFL, O_NONBLOCK); //Get the joystick name ioctl(m_fp, EVIOCGNAME(sizeof(m_name)), m_name); unsigned int keyBit[40]; unsigned int absBit[40]; unsigned int relBit[40]; //Uses new unified API (HID) ? Assume yes if ((ioctl(fp, EVIOCGBIT(EV_KEY, sizeof(keyBit)), keyBit) >= 0) && (ioctl(fp, EVIOCGBIT(EV_ABS, sizeof(absBit)), absBit) >= 0) && (ioctl(fp, EVIOCGBIT(EV_REL, sizeof(relBit)), relBit) >= 0)) { //joystick->hwdata->is_hid = SDL_TRUE; } for (int i=BTN_JOYSTICK; i= MAX_JOYSTICKS) return 0; return s_jsticks[num]; } float wgd::Joystick::axis(int ax) { return get(ix::axes)[ax][ix::value]; } bool wgd::Joystick::btnPressed(int btn) { return get(ix::buttons)[btn]; } void wgd::Joystick::inverted(int ax, bool invert) { get(ix::axes)[ax][ix::invert] = invert; } bool wgd::Joystick::inverted(int ax) { return get(ix::axes)[ax][ix::invert]; } void wgd::Joystick::update() { int min, max; float deadzone; float value; #ifdef LINUX int len, code; input_event events[32]; while ((len = read(m_fp, events, sizeof(events))) > 0) { len /= sizeof(events[0]); for (int i=0; i= BTN_MISC) { code -= BTN_MISC; //Button pressed / release... events[i].value get(ix::buttons)[(int)m_keymap[code]] = (events[i].value) ? true : false; } break; case EV_ABS: //Axis change, code = HAT or AXIS number //Value is new state. switch(code) { case ABS_HAT0X: case ABS_HAT0Y: case ABS_HAT1X: case ABS_HAT1Y: case ABS_HAT2X: case ABS_HAT2Y: case ABS_HAT3X: case ABS_HAT3Y: //std::cout << "Hat was changed: " << code-ABS_HAT0X << "\n"; break; default: min = get(ix::axes)[m_absmap[code]]["min"]; max = get(ix::axes)[m_absmap[code]]["max"]; deadzone = get(ix::axes)[m_absmap[code]][ix::deadzone]; //Automatic calibration: if (events[i].value < min) { min = events[i].value; get(ix::axes)[m_absmap[code]]["min"] = min; } if (events[i].value > max) { max = events[i].value; get(ix::axes)[m_absmap[code]]["max"] = max; } value = (((float)events[i].value - ((min+max) / 2.0f)) / (float)(abs(min)+abs(max))) * 2.0f; if (inverted(i)) value = -value; if (fabs(value) < deadzone) { get(ix::axes)[m_absmap[code]][ix::value] = 0.0f; } else { get(ix::axes)[m_absmap[code]][ix::value] = value; //std::cout << "Axis changed: " << (int)m_absmap[code] << "=" << events[i].value << "\n"; } break; } break; case EV_REL: //Relative Axis (Ball) break; default: break; } } } #else //First get axis positions JOYINFOEX joyinfo; joyinfo.dwSize = sizeof(joyinfo); joyinfo.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS; joyGetPosEx(m_id, &joyinfo); int pos[6]; pos[0] = joyinfo.dwXpos; pos[1] = joyinfo.dwYpos; pos[2] = joyinfo.dwZpos; pos[3] = joyinfo.dwRpos; pos[4] = joyinfo.dwUpos; pos[5] = joyinfo.dwVpos; DWORD flags[6] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, JOY_RETURNR, JOY_RETURNU, JOY_RETURNV }; //Get axis positions... for (int i=0; i 36000) set("pov", false); else set("pov", joyinfo.dwPOV / 100.0f); #endif } void wgd::Joystick::updateAll() { for (int i=0; iupdate(); } void wgd::Joystick::initialise() { if (inputbase["joysticks"] == Null) inputbase["joysticks"] = OID::create(); OID njs; #ifdef LINUX int js; unsigned int evBit[40]; unsigned int keyBit[40]; unsigned int absBit[40]; char buf[100]; for (int i=0; i #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; wgd::OID inputbase; class InputAgent : doste::Agent { public: InputAgent(const OID &obj) : Agent(obj) { registerEvents(); } ~InputAgent() {} BEGIN_EVENTS(Agent); EVENT(evt_wiimote_find, (*this)("wiimotes")("find")); EVENT(evt_update, (*this)("update")); END_EVENTS; }; OnEvent(InputAgent, evt_wiimote_find) { if(get("wiimotes")["find"] != wgd::Null) { Wiimote::find(); } } OnEvent(InputAgent, evt_update) { Wiimote::updateAll(); Joystick::updateAll(); } IMPLEMENT_EVENTS(InputAgent, Agent); extern "C" INPUTIMPORT void initialise(const doste::dvm::OID &base) { inputbase = base; doste::Object::registerType(); doste::Object::registerType(); Wiimote::initialise(); Joystick::initialise(); new InputAgent(base); } extern "C" INPUTIMPORT void finalise() { Wiimote::finalise(); Joystick::finalise(); } wgd-3.1/src/input/Makefile.in0000644000175000001440000003022611265575055013064 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_input.so$(EXEEXT) subdir = src/input DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_input_so_OBJECTS = wiimote.$(OBJEXT) input.$(OBJEXT) \ joystick.$(OBJEXT) libwgd_input_so_OBJECTS = $(am_libwgd_input_so_OBJECTS) libwgd_input_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_input_so_SOURCES) DIST_SOURCES = $(libwgd_input_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_input_so_SOURCES = wiimote.cpp input.cpp joystick.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -shared -lGL -lX11 -lXxf86vm -ldoste -lwgd_base -lbluetooth INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/input/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/input/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_input.so$(EXEEXT): $(libwgd_input_so_OBJECTS) $(libwgd_input_so_DEPENDENCIES) @rm -f libwgd_input.so$(EXEEXT) $(CXXLINK) $(libwgd_input_so_OBJECTS) $(libwgd_input_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/input/wiimote.cpp0000644000175000001440000006726511233311614013175 00000000000000#include #include #include #ifdef LINUX #include #include #endif #ifndef NO_BLUETOOTH #ifdef LINUX #include #include #include #include #endif #ifdef WIN32 #include //#include //#include #include #include #endif extern doste::dvm::OID inputbase; #ifdef _MSC_VER #pragma warning( disable : 4996 ) BOOL (WINAPI *HidD_GetAttributes) (HANDLE, PHIDD_ATTRIBUTES); VOID (WINAPI *HidD_GetHidGuid) (LPGUID); BOOL (WINAPI *HidD_GetPreparsedData)(HANDLE, PHIDP_PREPARSED_DATA *); BOOL (WINAPI *HidD_FreePreparsedData)(PHIDP_PREPARSED_DATA); NTSTATUS (WINAPI *HidP_GetCaps)(PHIDP_PREPARSED_DATA PreparsedData, PHIDP_CAPS Capabilities); #endif #endif #define WIIMOTE_DEV_CLASS_0 0x04 #define WIIMOTE_DEV_CLASS_1 0x25 #define WIIMOTE_DEV_CLASS_2 0x00 #define WIIMOTE_VID 0x057e #define WIIMOTE_PID 0x0306 #define WIIMOTE_OUTPUT_CHANNEL 0x11 #define WIIMOTE_INPUT_CHANNEL 0x13 #define SET_REPORT 0x50 #define BT_INPUT 0x01 #define BT_OUTPUT 0x02 #define PIEBY2 1.570796f using namespace wgd; int wgd::Wiimote::s_nummotes = 0; Wiimote *wgd::Wiimote::s_motes[4]; doste::dvm::OID wgd::Wiimote::BUTTON_LEFT; doste::dvm::OID wgd::Wiimote::BUTTON_RIGHT; doste::dvm::OID wgd::Wiimote::BUTTON_UP; doste::dvm::OID wgd::Wiimote::BUTTON_DOWN; doste::dvm::OID wgd::Wiimote::BUTTON_ONE; doste::dvm::OID wgd::Wiimote::BUTTON_TWO; doste::dvm::OID wgd::Wiimote::BUTTON_MINUS; doste::dvm::OID wgd::Wiimote::BUTTON_HOME; doste::dvm::OID wgd::Wiimote::BUTTON_PLUS; doste::dvm::OID wgd::Wiimote::BUTTON_A; doste::dvm::OID wgd::Wiimote::BUTTON_B; doste::dvm::OID wgd::Wiimote::BUTTON_C; doste::dvm::OID wgd::Wiimote::BUTTON_Z; struct WiiMsg { unsigned char proto; unsigned char type; unsigned char data[21]; } PACKED; struct WiiEvent { unsigned char proto; unsigned char type; unsigned char data[22]; } PACKED; struct WiiReadData { unsigned int addr; unsigned short size; } PACKED; struct WiiWriteData { unsigned int addr; unsigned char size; unsigned char data[10]; } PACKED; namespace wgd { OnEvent(Wiimote, evt_leds) { int cleds = 0; OID obj = get("leds"); for(int i=0; i<4; i++) { if((bool)obj.get(i)) cleds |= (1 << (4+i)); } if(cleds != m_leds) leds(cleds); m_leds = cleds; } OnEvent(Wiimote, evt_rumble) { if ((bool)((*this)["rumble"]) && !m_rumble) { m_rumble = true; char buf = m_leds | 0x01; send_wii(CMD_RUMBLE, &buf, 1); } else if ((bool)((*this)["rumble"]) == false && m_rumble) { m_rumble = false; char buf = m_leds & 0xF0; send_wii(CMD_RUMBLE, &buf, 1); } } OnEvent(Wiimote, evt_ir) { if (irEnabled()) { //Enable the IR sensor. char buf = 0x04 | ((m_rumble) ? 0x01 : 0x00); send_wii(CMD_IR, &buf, 1); #ifdef WIN32 Sleep(100); #else usleep(100000); #endif send_wii(CMD_IR2, &buf, 1); #ifdef WIN32 Sleep(100); #else usleep(100000); #endif //Set the IR sensitivity; unsigned char ir_sens1[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0xc0}; unsigned char ir_sens2[] = {0x40, 0x00}; buf = 0x08; write_data(MEM_IR, &buf, 1); #ifdef WIN32 Sleep(100); #else usleep(100000); #endif write_data(MEM_IR_SENSITIVITY, (char*)ir_sens1, sizeof(ir_sens1)); #ifdef WIN32 Sleep(100); #else usleep(100000); #endif write_data(MEM_IR_SENSITIVITY2, (char*)ir_sens2, sizeof(ir_sens2)); #ifdef WIN32 Sleep(100); #else usleep(100000); #endif buf = IRMODE_EXTENDED; write_data(MEM_IR_MODE, &buf, 1); std::cout << "IR ENABLED\n"; //wgd::cout << wgd::DEV << "IR Enabled...\n"; } else { //wgd::cout << wgd::DEV << "IR Disabled...\n"; //Disable the IR sensor. char buf = (m_leds & 0xF0) | ((m_rumble) ? 0x01 : 0x00); send_wii(CMD_IR, &buf, 1); send_wii(CMD_IR2, &buf, 1); } } IMPLEMENT_EVENTS(Wiimote, Agent); }; #ifdef LINUX #ifndef NO_BLUETOOTH wgd::Wiimote::Wiimote(bdaddr_t id, const doste::dvm::OID &obj) #else wgd::Wiimote::Wiimote(int id, const doste::dvm::OID &obj) #endif #endif #ifdef WIN32 #ifndef NO_BLUETOOTH wgd::Wiimote::Wiimote(HIDDevice id, const doste::dvm::OID &obj) #else wgd::Wiimote::Wiimote(int id, const doste::dvm::OID &obj) #endif #endif : Agent(obj), m_addr(id), m_nchuk(false) { if (get("leds") == Null) set("leds", OID::create()); if (get("buttons") == Null) set("buttons", OID::create()); if (get("axes") == Null) set("axes", OID::create()); for(int i=0; i<3; i++) { if (get("axes")[i] == Null) get("axes")[i] = OID::create(); if (get("axes")[i][ix::scale] == Null) get("axes")[i][ix::scale] = 1.0f; if (get("axes")[i][ix::deadzone] == Null) get("axes")[i][ix::deadzone] = 0.001f; } if (get("dots") == Null) set("dots", OID::create()); if (get("dots")[0] == Null) get("dots")[0] = OID::create(); if (get("dots")[1] == Null) get("dots")[1] = OID::create(); if (get("dots")[2] == Null) get("dots")[2] = OID::create(); if (get("dots")[3] == Null) get("dots")[3] = OID::create(); irEnabled(true); //initialise rumble m_rumble = false; connect_wii(); rumble(false); updateAll(); registerEvents(); } wgd::Wiimote::~Wiimote() { disconnect_wii(); } void wgd::Wiimote::connect_wii() { #ifndef NO_BLUETOOTH #ifdef LINUX sockaddr_l2 addr; addr.l2_family = AF_BLUETOOTH; addr.l2_bdaddr = m_addr; m_outsock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); if (m_outsock == -1) { //wgd::cout << wgd::ERR << "Could not connect to wiimote.\n"; return; } addr.l2_psm = htobs(WIIMOTE_OUTPUT_CHANNEL); if (connect(m_outsock, (sockaddr*)&addr, sizeof(addr)) < 0) { //wgd::cout << wgd::ERR << "Could not connect to wiimote.\n"; return; } m_insock = socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); if (m_insock == -1) { //wgd::cout << wgd::ERR << "Could not connect to wiimote.\n"; return; } addr.l2_psm = htobs(WIIMOTE_INPUT_CHANNEL); if (connect(m_insock, (sockaddr*)&addr, sizeof(addr)) < 0) { //wgd::cout << wgd::ERR << "Could not connect to wiimote.\n"; return; } #endif #ifdef WIN32 //start the listen thread listening=true; m_thread = (HANDLE)_beginthreadex(0, 0, listener, this, 0, &m_threadID); InitializeCriticalSection(&m_lock); //wgd::cout << wgd::DEV << "Wiimote listen thread started (" << m_threadID << ")\n"; #endif #endif //We want motion data but no expansion data. reportType(true,false); handshake_wii(); leds(LED_NONE); } void wgd::Wiimote::handshake_wii() { read_data(MEM_CALIBRATION, (char*)m_calib, 8); //WiiEvent evt; /*while (true) { poll_wii(evt); if (evt.type == REPORT_READ) { int err = evt.data[0] & 0x0F; if (err == 0x08) { wgd::cout << wgd::ERR << "Wiimote read error: Address does not exist.\n"; return; } else if (err == 0x07) { wgd::cout << wgd::ERR << "Wiimote read error: Address is write only.\n"; return; } else if (err) { wgd::cout << wgd::ERR << "Wiimote read error: unknown\n"; return; } int len = ((evt.data[0] & 0xF0) >> 4) + 1; //if (len < 8) { //wgd::cout << wgd::ERR << "Invalid wiimote calibration data.\n"; //continue; //} wgd::cout << wgd::DEV << "Reading wiimote calibration...\n"; m_calzero.x = evt.data[1]; m_calzero.y = evt.data[2]; m_calzero.z = evt.data[3]; m_calg.x = evt.data[5]; m_calg.y = evt.data[6]; m_calg.z = evt.data[7]; wgd::cout << wgd::DEV << "Zero: " << m_calzero.x << "," << m_calzero.y << "," << m_calzero.z << "\n"; wgd::cout << wgd::DEV << "G: " << m_calg.x << "," << m_calg.y << "," << m_calg.z << "\n"; break; } else { continue; } }*/ //Get calibration data... } void wgd::Wiimote::leds(unsigned char pleds) { m_leds = pleds & 0xF0; //Keep rumble on... if (m_rumble) pleds |= 0x01; send_wii(CMD_LEDS, (char*)&pleds, 1); } void wgd::Wiimote::postRequest(const WiiReadReq &req) { //Add to request queue m_requests.push_back(req); //If queue was empty then send immediately. if (m_requests.size() == 1) { WiiReadData msg; msg.addr = htonl(req.addr); msg.size = htons(req.length); send_wii(CMD_READ_DATA, (char*)&msg, sizeof(WiiReadData)); } } void wgd::Wiimote::write_data(unsigned int addr, char *data, int length) { //WiiWriteData msg; //msg.addr =htonl(addr); //msg.size = length; //memcpy(&msg.data, data, length); char msg[21] = {0}; msg[0] = ((addr & 0xff000000) >> 24) ; //Or with rumble bit. msg[1] = (addr & 0xff0000) >> 16; msg[2] = (addr & 0xff00) >> 8; msg[3] = (addr & 0xff); msg[4] = (char)length; memcpy(msg+5, data, length); //wgd::cout << "write_data: " << (int)msg[0] << " " << (int)msg[1] << " " << (int)msg[2] << " " << (int)msg[3] << "\n"; //return; send_wii(CMD_WRITE_DATA, (char*)&msg, 21); } void wgd::Wiimote::read_data(unsigned int addr, char *data, int length) { //Make a read request and post it. WiiReadReq req; req.addr = addr; req.data = data; req.length = length; postRequest(req); /*WiiEvent evt; int len; */ } void wgd::Wiimote::handleRead() { unsigned char *buf = (unsigned char*)m_requests.front().data; if (m_requests.front().addr == MEM_CALIBRATION) { //wgd::cout << wgd::DEV << "Reading wiimote calibration...\n"; m_calzero.x = buf[0]; m_calzero.y = buf[1]; m_calzero.z = buf[2]; m_calg.x = buf[4]; m_calg.y = buf[5]; m_calg.z = buf[6]; //wgd::cout << wgd::DEV << "Zero: " << m_calzero.x << "," << m_calzero.y << "," << m_calzero.z << "\n"; //wgd::cout << wgd::DEV << "G: " << m_calg.x << "," << m_calg.y << "," << m_calg.z << "\n"; } else if (m_requests.front().addr == MEM_EXT_CALIB) { //wgd::cout << wgd::DEV << "Reading wiimote nunchuck calibration...\n"; //DECRYPT for (int i=0; i<14; i++) { buf[i] = (buf[i] ^ 0x17) + 0x17; } m_nc_calzero.x = buf[0]; m_nc_calzero.y = buf[1]; m_nc_calzero.z = buf[2]; m_nc_calg.x = buf[4]; m_nc_calg.y = buf[5]; m_nc_calg.z = buf[6]; m_js_max.x = buf[8]; m_js_min.x = buf[9]; m_js_centre.x = buf[10]; m_js_max.y = buf[11]; m_js_min.y = buf[12]; m_js_centre.y = buf[13]; } } void wgd::Wiimote::gforce() { float xg = m_calg.x - m_calzero.x; float yg = m_calg.y - m_calzero.y; float zg = m_calg.z - m_calzero.z; m_gforce.x = (m_accel.x - m_calzero.x) / xg; m_gforce.y = (m_accel.y - m_calzero.y) / yg; m_gforce.z = (m_accel.z - m_calzero.z) / zg; //NUNCHUK xg = m_nc_calg.x - m_nc_calzero.x; yg = m_nc_calg.y - m_nc_calzero.y; zg = m_nc_calg.z - m_nc_calzero.z; m_nc_gforce.x = (m_nc_accel.x - m_nc_calzero.x) / xg; m_nc_gforce.y = (m_nc_accel.y - m_nc_calzero.y) / yg; m_nc_gforce.z = (m_nc_accel.z - m_nc_calzero.z) / zg; } void wgd::Wiimote::orientation() { float x,y,z; x = m_gforce.x; y = m_gforce.y; z = m_gforce.z; x -= 1.0f; x *= 5.0f; //m_orient.x = x; x *= (float)get(ix::axes)[0][ix::scale]; if((bool)get(ix::axes)[0][ix::invert]) x = -x; if(fabs(x) < (float)get(ix::axes)[0][ix::deadzone]) { get(ix::axes)[0][ix::value] = 0.0f; } else { get(ix::axes)[0][ix::value] = x; } y -= 1.0f; y *= 0.6666f; //m_orient.y = y; y *= (float)get(ix::axes)[1][ix::scale]; if((bool)get(ix::axes)[1][ix::invert]) y = -y; if(fabs(y) < (float)get(ix::axes)[1][ix::deadzone]) { get(ix::axes)[1][ix::value] = 0.0f; } else { get(ix::axes)[1][ix::value] = y; } z -= 1.0f; z *= 5.0f; //m_orient.x = x; z *= (float)get(ix::axes)[2][ix::scale]; if((bool)get(ix::axes)[2][ix::invert]) z = -z; if(fabs(z) < (float)get(ix::axes)[2][ix::deadzone]) { get(ix::axes)[2][ix::value] = 0.0f; } else { get(ix::axes)[2][ix::value] = z; } //NUNCHUK x = m_nc_gforce.x; y = m_nc_gforce.y; z = m_nc_gforce.z; x -= 1.0f; x *= 5.0f; //m_orient.x = x; x *= (float)get(ix::axes)[3][ix::scale]; if ((bool)get(ix::axes)[3][ix::invert]) x = -x; if (fabs(x) < (float)get(ix::axes)[3][ix::deadzone]) { get(ix::axes)[3][ix::value] = 0.0f; } else { get(ix::axes)[3][ix::value] = x; } y -= 1.0f; y *= 0.6666f; //m_orient.y = y; y *= (float)get(ix::axes)[4][ix::scale]; if ((bool)get(ix::axes)[4][ix::invert]) y = -y; if (fabs(y) < (float)get(ix::axes)[4][ix::deadzone]) { get(ix::axes)[4][ix::value] = 0.0f; } else { get(ix::axes)[4][ix::value] = y; } z -= 1.0f; z *= 5.0f; //m_orient.x = x; z *= (float)get(ix::axes)[5][ix::scale]; if ((bool)get(ix::axes)[5][ix::invert]) z = -z; if (fabs(z) < (float)get(ix::axes)[5][ix::deadzone]) { get(ix::axes)[5][ix::value] = 0.0f; } else { get(ix::axes)[5][ix::value] = z; } } void wgd::Wiimote::update() { WiiEvent evt; int length; char *data; //int len; short button; int err; char buf; int offs; int j; float irx,iry,minirx; int minirx_index; while (poll_wii(evt)) { switch(evt.type) { case REPORT_CTRL_STATUS: //Check for NunChuk if (evt.data[2] == 0x2) { //wgd::cout << wgd::DEV << "We have a nunchuk.\n"; buf = 0; write_data(0x04A40040, &buf, 1); m_nchuk = true; reportType(true,m_nchuk); read_data(MEM_EXT_CALIB, (char*)m_nc_calib, 14); } else { m_nchuk = false; reportType(true,m_nchuk); } break; case REPORT_READ: length = m_requests.front().length; data = m_requests.front().data; err = evt.data[0] & 0x0F; if (err == 0x08) { //wgd::cout << wgd::ERR << "Wiimote read error: Address does not exist.\n"; return; } else if (err == 0x07) { //wgd::cout << wgd::ERR << "Wiimote read error: Address is write only.\n"; return; } else if (err) { //wgd::cout << wgd::ERR << "Wiimote read error: unknown\n"; return; } //len = ((evt.data[0] & 0xF0) >> 4) + 1; //wgd::cout << "READ PACKET." << length << "\n"; memcpy(data, &evt.data[1], length); //length -= len; //data += len; //m_requests.front().length = length; //m_requests.front().data = data; //if (length == 0) { handleRead(); m_requests.pop_front(); if (m_requests.size() > 0) { WiiReadData msg; msg.addr = htonl(m_requests.front().addr); msg.size = htons(m_requests.front().length); send_wii(CMD_READ_DATA, (char*)&msg, sizeof(WiiReadData)); } //} break; //case REPORT_BTN_MOTION_EXP: //Includes IR case REPORT_BTN_MOTION_IR: //Process IR information. //Assume extended mode, but this may not be the case. j = 0; irx = 0.0; iry = 0.0; minirx = 2000.0; minirx_index = 0; for (int i=0; i<4; i++) { m_dots[i].found = false; offs = 5+(3*i); m_dots[j].found = !(evt.data[offs]==0xff && evt.data[offs+1] == 0xff && evt.data[offs+2]==0xff); if (m_dots[j].found) { m_dots[j].rawX = evt.data[offs] | ((evt.data[offs+2] >> 4) & 0x03) << 8; m_dots[j].rawY = evt.data[offs+1] | ((evt.data[offs+2] >> 6) & 0x03) << 8; m_dots[j].x = 1.0f - ((float)m_dots[j].rawX / 1016.0f); m_dots[j].y = (float)m_dots[j].rawY / 760.0f; //wgd::cout << "IR Dot: " << i << " " << m_dots[i].x << "," << m_dots[i].y << "\n"; get("dots")[j][ix::x] = m_dots[j].x; get("dots")[j][ix::y] = m_dots[j].y; if (minirx > m_dots[j].x) { minirx_index = j; minirx = m_dots[j].x; } j++; } irx += m_dots[j].x; iry += m_dots[j].y; } irx /= j; iry /= j; set("irx", m_dots[minirx_index].x); set("iry", m_dots[minirx_index].y); //wgd::cout << "EXPANSION\n"; //DECRYPT //for (int i=15; i<22; i++) { // evt.data[i] = (evt.data[i] ^ 0x17) + 0x17; //} //m_js.x = evt.data[15]; //m_js.y = evt.data[16]; //m_nc_accel.x = evt.data[17]; //m_nc_accel.y = evt.data[18]; //m_nc_accel.z = evt.data[19]; //wgd::cout << wgd::DEV << "NC ACCEL X: " << m_nc_accel.x << "\n"; //button = evt.data[20]; //if (button & NUNCHUK_BUTTON_Z) get(ix::buttons)[BUTTON_Z] = true; else get(ix::buttons)[BUTTON_Z] = false; //if (button & NUNCHUK_BUTTON_C) get(ix::buttons)[BUTTON_C] = true; else get(ix::buttons)[BUTTON_C] = false; case REPORT_BTN_MOTION: m_accel.x = evt.data[2]; m_accel.y = evt.data[3]; m_accel.z = evt.data[4]; gforce(); orientation(); //wgd::cout << wgd::DEV << "GFORCE: " << m_gforce.z << "\n"; //break; case REPORT_BTN: button = htons(*(short*)&evt.data[0]); //wgd::cout << wgd::DEV << "Wiimote button pressed: " << button << "\n"; if (button & WIIMOTE_BUTTON_TWO) get(ix::buttons)[BUTTON_TWO] = true; else get(ix::buttons)[BUTTON_TWO] = false; if (button & WIIMOTE_BUTTON_ONE) get(ix::buttons)[BUTTON_ONE] = true; else get(ix::buttons)[BUTTON_ONE] = false; if (button & WIIMOTE_BUTTON_LEFT) get(ix::buttons)[BUTTON_LEFT] = true; else get(ix::buttons)[BUTTON_LEFT] = false; if (button & WIIMOTE_BUTTON_RIGHT) get(ix::buttons)[BUTTON_RIGHT] = true; else get(ix::buttons)[BUTTON_RIGHT] = false; if (button & WIIMOTE_BUTTON_UP) get(ix::buttons)[BUTTON_UP] = true; else get(ix::buttons)[BUTTON_UP] = false; if (button & WIIMOTE_BUTTON_DOWN) get(ix::buttons)[BUTTON_DOWN] = true; else get(ix::buttons)[BUTTON_DOWN] = false; if (button & WIIMOTE_BUTTON_PLUS) get(ix::buttons)[BUTTON_PLUS] = true; else get(ix::buttons)[BUTTON_PLUS] = false; if (button & WIIMOTE_BUTTON_MINUS) get(ix::buttons)[BUTTON_MINUS] = true; else get(ix::buttons)[BUTTON_MINUS] = false; if (button & WIIMOTE_BUTTON_HOME) get(ix::buttons)[BUTTON_HOME] = true; else get(ix::buttons)[BUTTON_HOME] = false; if (button & WIIMOTE_BUTTON_A) get(ix::buttons)[BUTTON_A] = true; else get(ix::buttons)[BUTTON_A] = false; if (button & WIIMOTE_BUTTON_B) get(ix::buttons)[BUTTON_B] = true; else get(ix::buttons)[BUTTON_B] = false; break; default: break; //wgd::cout << wgd::WARN << "Unknown wiimote event (" << (int)evt.type << ")\n"; } } } void wgd::Wiimote::reportType(bool motion, bool expansion) { char buf[2]; buf[0] = 0x00; buf[1] = 0x00; if (rumble()) buf[0] |= 0x01; if (motion && expansion) buf[1] = 0x37; else if (expansion) buf[1] = 0x36; else if (motion) buf[1] = 0x33; else buf[1] = 0x30; send_wii(CMD_REPORT_TYPE, buf, 2); } bool wgd::Wiimote::poll_wii(WiiEvent &evt) { #ifndef NO_BLUETOOTH #ifdef LINUX fd_set fds; FD_ZERO(&fds); int highest = 0; //Timeout of 500 micro seconds. timeval tv; tv.tv_sec = 0; tv.tv_usec = 0; FD_SET(m_insock, &fds); highest = m_insock; select(highest+1, &fds, 0, 0, &tv); if (FD_ISSET(m_insock, &fds)) { int res = read(m_insock, (char*)&evt, sizeof(WiiEvent)); if (res == -1) { //wgd::cout << wgd::ERR << "Wiimote read error.\n"; return false; } if (res < 2) { //wgd::cout << wgd::ERR << "Wiimote disconnected.\n"; return false; } //wgd::cout << "EVT Size: " << res << "\n"; } else { return false; } #endif #ifdef WIN32 //windows gets its stuff from the thread! //DWORD wait = WaitForSingleObject(m_addr.event, 300); if(msgs.empty()) return false; EnterCriticalSection(&m_lock); //get message from queue evt.proto = msgs.front()->proto; evt.type = msgs.front()->type; memcpy(evt.data, msgs.front()->data, 22); //delete message from queue delete msgs.front(); msgs.pop(); LeaveCriticalSection(&m_lock); #endif #endif return true; } //windows listener thread #if defined(WIN32) && !defined(NO_BLUETOOTH) unsigned CALLBACK wgd::Wiimote::listener(void * param){ unsigned char report[22]; memset(report, 0, 22); DWORD result, read; Wiimote *wii = (Wiimote*) param; while(wii->listening){ //check read handle if(wii->m_addr.hRead != INVALID_HANDLE_VALUE){ result = ReadFile(wii->m_addr.hRead, report, wii->m_addr.caps.InputReportByteLength, &read, (LPOVERLAPPED)&(wii->m_addr.overlapped)); } // Wait for read to finish result = WaitForSingleObject(wii->m_addr.event, 300); ResetEvent(wii->m_addr.event); //retry if the wait was unsuccessful if (result != WAIT_OBJECT_0) continue; //convert message WiiEvent *evt = new WiiEvent;; evt->proto=0; evt->type = report[0]; memcpy(evt->data, (char*)report+1, 21); //add message to event queue EnterCriticalSection(&wii->m_lock); wii->msgs.push(evt); LeaveCriticalSection(&wii->m_lock); } return 0; } #endif void wgd::Wiimote::send_wii(unsigned char cmd, char *msg, int length) { WiiMsg m; memset((char*)&m, 0, sizeof(WiiMsg)); m.proto = SET_REPORT | BT_OUTPUT; m.type = cmd; memcpy(m.data, msg, length); #ifndef NO_BLUETOOTH #ifdef LINUX write(m_outsock, (char*)&m, length+2); //write(m_outsock, (char*)&m, 23); #endif #ifdef WIN32 //WriteFile(m_addr, (char*)&m, length+2, &written, 0); DWORD written=0; ULONG result; char report[22]; //clear report memory memset(report, 0, 22); //skip m.proto - as it results in ERROR_INVALID_PARAMETER memcpy(report, (char*)&m + 1, length+2); //check the write handle if (m_addr.hWrite != INVALID_HANDLE_VALUE){ SetLastError(0); result = WriteFile(m_addr.hWrite, report, m_addr.caps.OutputReportByteLength, &written, NULL); if (!result){ std::cout << "Write Failed [" << GetLastError() << "]\n"; } } #endif #endif } void wgd::Wiimote::disconnect_wii() { #ifndef NO_BLUETOOTH #ifdef LINUX close(m_insock); close(m_outsock); #endif #ifdef WIN32 //stop listen thread listening=false; WaitForSingleObject(m_addr.event, INFINITE); m_thread = NULL; DeleteCriticalSection(&m_lock); //close device handles CloseHandle(m_addr.hRead); CloseHandle(m_addr.hWrite); //CloseHandle(m_addr.hDevice); #endif #endif } void wgd::Wiimote::find() { //Search all bluetooth devices for WIIMOTES std::cout << "Scanning for Wiimotes...\n"; #ifndef NO_BLUETOOTH #ifdef LINUX int id = hci_get_route(0); if (id < 0) { return; } int sock = hci_open_dev(id); if (sock < 0) { return; } inquiry_info *scan_info = new inquiry_info[128]; memset(scan_info, 0, sizeof(inquiry_info)*128); int num_dev = hci_inquiry(id, 5, 128, 0, &scan_info, IREQ_CACHE_FLUSH); if (num_dev < 0) { return; } //wgd::cout << wgd::DEV << "Found " << num_dev << " bluetooth devices.\n"; s_nummotes = 0; for (int i=0; icbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); // After allocating, call again to get data result = SetupDiGetDeviceInterfaceDetail(hDevInfo, &devInfoData, detailData, length, &required, NULL); //open devce deviceHandle = CreateFile(detailData->DevicePath, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, 0, NULL); //Is this a wiimote? attributes.Size = sizeof(attributes); result = HidD_GetAttributes(deviceHandle, &attributes); if (attributes.VendorID == WIIMOTE_VID && attributes.ProductID == WIIMOTE_PID){ //wgd::cout << wgd::DEV << "Found a Wiimote!\n"; std::cout << "Found a wiimote\n"; device.hDevice = deviceHandle; //Does not work in visual studio. #ifdef _MSC_VER //break; #endif //Get the Capabilities structure for the device. PHIDP_PREPARSED_DATA preparsedData; HidD_GetPreparsedData(deviceHandle, &preparsedData); HidP_GetCaps(preparsedData, &device.caps); HidD_FreePreparsedData(preparsedData); CloseHandle(deviceHandle); //get read and write handles seperately device.hWrite = CreateFile(detailData->DevicePath, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); device.hRead = CreateFile(detailData->DevicePath, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); // Get an event object for the overlapped structure. device.event = CreateEvent (NULL, TRUE, TRUE, L""); device.overlapped.hEvent = device.event; device.overlapped.Offset = 0; device.overlapped.OffsetHigh = 0; //make sure the handles are valid bool fail=false; if(device.hRead == INVALID_HANDLE_VALUE) { doste::Error(0, "Invalid Wiimote Read Handle"); fail=true; } if(device.hWrite == INVALID_HANDLE_VALUE) { doste::Error(0, "Invalid Wiimote Write Handle"); fail=true; } if(!fail) { if(inputbase["wiimotes"][s_nummotes] == Null) { std::cout << "Null - creating\n"; inputbase["wiimotes"][s_nummotes] = OID::create(); } s_motes[s_nummotes++] = new Wiimote(device, inputbase["wiimotes"][s_nummotes]); } } else { CloseHandle(deviceHandle); } free(detailData); //next device memberIndex++; } SetupDiDestroyDeviceInfoList(hDevInfo); #ifdef _MSC_VER FreeLibrary(hiddll); #endif #endif #endif } void wgd::Wiimote::initialise() { #ifndef NO_BLUETOOTH #ifdef WIN32 WORD version = MAKEWORD(2,0); WSADATA wsadata; WSAStartup(version, &wsadata); #endif #endif BUTTON_LEFT = "left"; BUTTON_RIGHT = "right"; BUTTON_UP = "up"; BUTTON_DOWN = "down"; BUTTON_PLUS = "plus"; BUTTON_MINUS = "minus"; BUTTON_HOME = "home"; BUTTON_ONE = "one"; BUTTON_TWO = "two"; BUTTON_A = "a"; BUTTON_B = "b"; BUTTON_C = "c"; BUTTON_Z = "z"; } void wgd::Wiimote::finalise() { #ifndef NO_BLUETOOTH #ifdef WIN32 WSACleanup(); #endif #endif } void wgd::Wiimote::updateAll() { for (int i=0; iupdate(); } } wgd-3.1/src/base_3d/0000777000175000001440000000000011265576313011237 500000000000000wgd-3.1/src/base_3d/instance3d.cpp0000644000175000001440000000157011233311614013677 00000000000000#include namespace wgd { OnEvent(Instance3D, evt_orientation) { m_update=true; } OnEvent(Instance3D, evt_position) { m_update=true; } IMPLEMENT_EVENTS(Instance3D, Agent); }; wgd::Instance3D::Instance3D() : Agent(), m_update(true) { registerEvents(); } wgd::Instance3D::Instance3D(const doste::dvm::OID &id) : Agent(id), m_update(true) { registerEvents(); } void wgd::Instance3D::draw(SceneGraph &graph, Camera3D *camera) { } const wgd::matrix &wgd::Instance3D::localMatrix() { //recalculate matrix if stuff has changed since last call if(m_update) { m_update=false; m_quat.createRotation(orientation()); matrix t, r; t.translate(position()); m_quat.createMatrix(r); matrix::fastMultiply(m_localMatrix, t, r); } return m_localMatrix; } void wgd::Instance3D::localMatrix(const wgd::matrix& m) { m_localMatrix = m; m_update = false; } wgd-3.1/src/base_3d/base3d.cpp0000644000175000001440000000116111233311614013001 00000000000000#include #include #include #include #include #include #include #include extern "C" void BASE3DIMPORT initialise(const doste::dvm::OID &base) { doste::Object::registerType(); doste::Object::registerType(); doste::Object::registerType(); doste::Object::registerType(); doste::Object::registerType(); doste::Object::registerType(); } extern "C" void BASE3DIMPORT finalise() { } wgd-3.1/src/base_3d/iprimitive.cpp0000644000175000001440000001673211233311614014033 00000000000000 #include #ifdef WIN32 #include #endif #include #include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #endif using namespace wgd; using namespace doste; using namespace doste::dvm; wgd::IPrimitive3D::IPrimitive3D() : Instance3D(){ set(ix::type, type()); if (get(ix::width) == Null) width(1.0); if (get(ix::height) == Null) height(1.0); if (get(ix::depth) == Null) depth(1.0); if (get(ix::primitive) == Null) primitive(ix::cube); } wgd::IPrimitive3D::IPrimitive3D(const doste::dvm::OID &inst) : Instance3D(inst){ if (get(ix::width) == Null) width(1.0); if (get(ix::height) == Null) height(1.0); if (get(ix::depth) == Null) depth(1.0); if (get(ix::primitive) == Null) primitive(ix::cube); } void wgd::IPrimitive3D::size(float w, float h, float d){ width(w); height(h); depth(d); } void wgd::IPrimitive3D::draw(SceneGraph &graph, Camera3D *camera) { Instance3D::draw(graph, camera); localMatrix().apply(); Material *mat = material(); if (mat != 0) mat->bind(); //test for shader - to add tangent only //Shader *s = Shader::current(); //if(s!=NULL && !s->tangents()) s=NULL; Shader *s = 0; if (primitive() == OID("cube")) { float w2 = width()/2.0f; float h2 = height()/2.0f; float d2 = depth()/2.0f; glBegin(GL_QUADS); glNormal3f(0.0, 0.0, -1.0); if(s) s->setVariable("tangent", -1.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f(-w2, -h2, -d2); glTexCoord2f(1.0f, 1.0f); glVertex3f(-w2, h2, -d2); glTexCoord2f(0.0f, 1.0f); glVertex3f( w2, h2, -d2); glTexCoord2f(0.0f, 0.0f); glVertex3f( w2, -h2, -d2); if(s) s->setVariable("tangent", 1.0, 0.0, 0.0); glNormal3f(0.0, 0.0, 1.0); glTexCoord2f(1.0f, 0.0f); glVertex3f( w2, -h2, d2); glTexCoord2f(1.0f, 1.0f); glVertex3f( w2, h2, d2); glTexCoord2f(0.0f, 1.0f); glVertex3f(-w2, h2, d2); glTexCoord2f(0.0f, 0.0f); glVertex3f(-w2, -h2, d2); if(s) s->setVariable("tangent", 0.0, 0.0, -1.0); glNormal3f(1.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f( w2, -h2, -d2); glTexCoord2f(1.0f, 1.0f); glVertex3f( w2, h2, -d2); glTexCoord2f(0.0f, 1.0f); glVertex3f( w2, h2, d2); glTexCoord2f(0.0f, 0.0f); glVertex3f( w2, -h2, d2); if(s) s->setVariable("tangent", 0.0, 0.0, 1.0); glNormal3f(-1.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f( -w2, -h2, d2); glTexCoord2f(1.0f, 1.0f); glVertex3f( -w2, h2, d2); glTexCoord2f(0.0f, 1.0f); glVertex3f( -w2, h2, -d2); glTexCoord2f(0.0f, 0.0f); glVertex3f( -w2, -h2, -d2); glNormal3f(0.0, 1.0, 0.0); if(s) s->setVariable("tangent", 1.0, 0.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f( w2, h2, d2); glTexCoord2f(1.0f, 1.0f); glVertex3f( w2, h2, -d2); glTexCoord2f(0.0f, 1.0f); glVertex3f( -w2, h2, -d2); glTexCoord2f(0.0f, 0.0f); glVertex3f( -w2, h2, d2); glNormal3f(0.0, -1.0, 0.0); glTexCoord2f(1.0f, 0.0f); glVertex3f( w2, -h2, -d2); glTexCoord2f(1.0f, 1.0f); glVertex3f( w2, -h2, d2); glTexCoord2f(0.0f, 1.0f); glVertex3f(-w2, -h2, d2); glTexCoord2f(0.0f, 0.0f); glVertex3f(-w2, -h2, -d2); glEnd(); } if (primitive() == OID("sphere")) { float r=radius(); //calculate radius from MIN(width,height,depth) if not set if(r==0.0){ r=width()/2.0f; if(height()/2.0=0; i--){ glTexCoord2f((float)i/nSides, 1-1/(nSlices+1)); glNormal3f(ring2[i].x/r, ring2[i].y/r, ring2[i].z/r); glVertex3f(ring2[i].x, ring2[i].y, ring2[i].z); } glTexCoord2f(0.0, 1.0); glNormal3f(ring2[nSides-1].x/r, ring2[nSides-1].y/r, ring2[nSides-1].z/r); glVertex3f(ring2[nSides-1].x, ring2[nSides-1].y, ring2[nSides-1].z); glEnd(); delete [] ring1; delete [] ring2; } if (primitive() == OID("cylinder")) { float rx = width()/2; float rz = depth()/2; float ht = height()/2; if(sides()<3) sides(3); //minimum 3 sides int nSlices = sides(); vector3d *ring = new vector3d[nSlices]; float step = 2*wgd::PI / nSlices; for(int i=0; i=0; i--){ glTexCoord2f(ring[i].x / (rx*2), ring[i].z / (rz*2)); glVertex3f(ring[i].x, ht, ring[i].z); } glEnd(); delete [] ring; } if (mat != 0) mat->unbind(); //glPopMatrix(); localMatrix().unapply(); } wgd-3.1/src/base_3d/sprite3d.cpp0000644000175000001440000001233011233311614013375 00000000000000#include #include using namespace wgd; Sprite3D::Sprite3D() : m_drawable(0), m_width(1.0f), m_height(1.0f), m_sprite(0), m_frame(0), m_mode(0) {} Sprite3D::Sprite3D(Sprite* sprite, const vector3d &position, const quaternion &orientation, float width, float height, int frame) : m_drawable(0), m_width(width), m_height(height), m_sprite(sprite), m_frame(frame), m_position(position), m_orientation(orientation), m_mode(2) {} Sprite3D::Sprite3D(Sprite* sprite, const vector3d &position, float width, float height, int frame, float angle) : m_drawable(0), m_width(width), m_height(height), m_sprite(sprite), m_frame(frame), m_position(position), m_angle(angle), m_mode(0) {} Sprite3D::Sprite3D(Sprite* sprite, const vector3d &position, const vector3d &direction, float width, float height, int frame) : m_drawable(0), m_width(width), m_height(height), m_sprite(sprite), m_frame(frame), m_position(position), m_direction(direction), m_mode(1) {} Sprite3D::~Sprite3D() { if(m_drawable) { if(!m_drawable->queued) { m_drawable->deleteData(); delete m_drawable; } else m_drawable->discard = true; } } DrawableBase *Sprite3D::draw(SceneGraph &graph, Camera3D *camera) { return graph.addAlpha(drawable(camera)); } wgd::Drawable *Sprite3D::drawable(Camera3D* cam) { if(!m_drawable) setup(); switch(m_mode) { case 0: if(cam) makeOrientated(cam); break; case 1: if(cam) makeAligned(cam); break; case 2: makeAbsolute(); break; //absolute doesn't change with the camera } if(m_sprite) m_drawable->surface = m_sprite->get(ix::texture); else m_drawable->surface = Null; //set distance if(cam) m_drawable->distance = cam->position().distanceSquared(m_position); return m_drawable; } void Sprite3D::sprite(Sprite* spr) { m_sprite = spr; setFrame(m_frame); } void Sprite3D::size(float width, float height) { m_width = width; m_height = height; } void Sprite3D::position(const vector3d &v) { m_position = v; } void Sprite3D::direction(const vector3d &v) { m_direction = v.normalise(); m_mode = 1; } void Sprite3D::orientation(const quaternion &v) { m_orientation = v; m_mode=2; } void Sprite3D::angle(float ang) { m_angle = ang; m_mode=0; } void Sprite3D::colour(const wgd::colour &c) { if(!m_drawable) setup(); for(int i=0; i<4; i++) m_drawable->data[i].colour = c; } void Sprite3D::setup() { // set up drawable (4 vertices, GL_QUADS, etc) m_drawable = new Drawable; m_drawable->data = new SpriteVertex[4]; //initialise normals for(int i=0; i<4; i++) { m_drawable->data[i].normal.x = 0.0f; m_drawable->data[i].normal.y = 0.0f; m_drawable->data[i].normal.z = 1.0f; m_drawable->data[i].colour.r = 1.0f; m_drawable->data[i].colour.g = 1.0f; m_drawable->data[i].colour.b = 1.0f; m_drawable->data[i].colour.a = 1.0f; } m_drawable->size = 4; m_drawable->discard = false; m_drawable->mode = GL_QUADS; m_drawable->flags = (DrawFlags)(DEPTH_TEST + DEPTH_WRITE); setFrame(m_frame); } void Sprite3D::setFrame(int f) { if(m_sprite && m_drawable) { f=-f; //for some reason, its backwards int cols = m_sprite->columns(); int rows = m_sprite->rows(); float tw = 1.0f / (float)cols; float th = 1.0f / (float)m_sprite->rows(); float tx = tw*(float)(cols-(f%cols)); float ty = th*(float)(rows-1+(f/cols)); m_drawable->data[0].texcoords[0].u = tx+tw; m_drawable->data[0].texcoords[0].v = ty; m_drawable->data[1].texcoords[0].u = tx+tw; m_drawable->data[1].texcoords[0].v = ty+th; m_drawable->data[2].texcoords[0].u = tx; m_drawable->data[2].texcoords[0].v = ty+th; m_drawable->data[3].texcoords[0].u = tx; m_drawable->data[3].texcoords[0].v = ty; m_frame=f; } } void Sprite3D::drawSprite() { float w = m_width / 2; float h = m_height / 2; for(int i=0; i<4; i++) { m_drawable->data[i].position.x = (i<2)? w : -w; m_drawable->data[i].position.y = (i==1 || i==2)? h : -h; m_drawable->data[i].position.z = 0; } } void Sprite3D::makeOrientated(Camera3D* cam) { //transformation matrix matrix mat, mat2; cam->quaternion().createMatrix(mat); mat2.translate(m_position); matrix::fastMultiply(m_drawable->transform, mat2, mat); //sprite as usual drawSprite(); } void Sprite3D::makeAligned(Camera3D *cam) { //sprite more complicated, or crazy matrix stuff. vector3d c2 = m_position - cam->position() + cam->direction(); vector3d tangent = c2.cross(m_direction).normalise(); vector3d normal = tangent.cross(m_direction).normalise(); //construct matrix from these vectors - may have got it the wrong way round... matrix mat, mat2; mat.m[0][0] = tangent.x; mat.m[0][1] = tangent.y; mat.m[0][2] = tangent.z; mat.m[1][0] = m_direction.x; mat.m[1][1] = m_direction.y; mat.m[1][2] = m_direction.z; mat.m[2][0] = normal.x; mat.m[2][1] = normal.y; mat.m[2][2] = normal.z; mat2.translate(m_position); matrix::fastMultiply(m_drawable->transform, mat2, mat); //sprite as usual drawSprite(); } void Sprite3D::makeAbsolute() { matrix mat, mat2; m_orientation.createMatrix(mat); mat2.translate(m_position); matrix::fastMultiply(m_drawable->transform, mat2, mat); //sprite as usual drawSprite(); } wgd-3.1/src/base_3d/scene3d.cpp0000644000175000001440000001525311233311614013173 00000000000000#include #include #include #include #include #include #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; //Events namespace wgd { OnEvent(Scene3D, evt_add){ //instance added //add(value); //Iterate over all and add. //clear(); m_doclear = true; //OID inst = get("instances"); //for (OID::iterator i=inst.begin(); i!=inst.end(); i++) { // add(inst.get(*i)); //} //m_built=true; //build(); } IMPLEMENT_EVENTS(Scene3D, Scene); }; Scene3D::Scene3D(const doste::dvm::OID &id) : Scene(id), m_built(false), m_doclear(false) { registerEvents(); } Scene3D::~Scene3D(){ clear(); } void Scene3D::build(){ if(m_built) return; //wgd::cout << wgd::DEV << "Building Scene3D " << getID() << "\n"; //std::cout << "Building Scene3D\n"; //create root node Node *newNode = new Node; newNode->key = 1; newNode->hasChild = 0; m_octree[1] = newNode; //getID()[ix::instances].SetTriggerable(this); //Set up trigger to add objects when modified //Can i just do this? - [if i need to set triggerable for child objects here, need to split it up] Iterator iter; iter.recursive(true); for(iter=get(ix::instances).begin(); iter!=get(ix::instances).end(); iter++){ //begin has been redefined by OID?? need to do something about that. add(*iter); } m_built=true; } void Scene3D::clear(){ m_doclear = false; if(!m_built) return; //std::cout << "Clear Scene3D\n"; for(std::map::iterator i=m_octree.begin(); i!=m_octree.end(); i++){ //delete instances for(std::list::iterator j = i->second->instances.begin(); j!=i->second->instances.end(); j++){ //delete *j; } i->second->instances.clear(); } m_octree.clear(); m_location.clear(); //Clear lights for(unsigned int i=0; iisa(ix::light)){ m_lights.push_back(inst); return; } //Add 3D object to octree if(inst->isa(ix::instance3D)){ insert(m_octree[1], inst, inst->boundingBoxLow(), inst->boundingBoxHigh()); return; } } wgd::uint Scene3D::morton(const vector3d &v){ //create a morton key from a point in 3d space //fractions float fx=0.5, fy=0.5, fz = 0.5; if(width()!=0) fx = (v.x + width()/2) / width(); if(height()!=0) fy = (v.y + height()/2) / height(); if(depth()!=0) fz = (v.z + depth()/2) / depth(); //convert to fixed point number [0.0000000000] uint x = (uint) (( fx)*0x400); uint y = (uint) (( fy)*0x400); uint z = (uint) (( fz)*0x400); //create Morton key x = (x | (x<<16)) & 0xff0000ff; x = (x | (x<< 8)) & 0x0300f00f; x = (x | (x<< 4)) & 0x030c30c3; x = (x | (x<< 2)) & 0x09249249; y = (y | (y<<16)) & 0xff0000ff; y = (y | (y<< 8)) & 0x0300f00f; y = (y | (y<< 4)) & 0x030c30c3; y = (y | (y<< 2)) & 0x09249249; z = (z | (z<<16)) & 0xff0000ff; z = (z | (z<< 8)) & 0x0300f00f; z = (z | (z<< 4)) & 0x030c30c3; z = (z | (z<< 2)) & 0x09249249; //add sentinel bit and combine key uint key =(1<<30) + (z<<2) + (y<<1) + x; return key; } wgd::uint Scene3D::truncate(int depth, uint key){ //get key depth int cdepth = calcDepth(key); uint k = key; if(cdepth > depth) k = key >> ((cdepth-depth) * 3); return k; } int Scene3D::calcDepth(uint key){ int d=1; uint tmp = key; while(tmp > 1){ tmp = tmp >> 3; d++; } return d; } wgd::uint Scene3D::insert(Node* n, Instance3D* inst, const vector3d &low, const vector3d &high, int d){ int index=0; bool straddle=false; uint key=0; //Calculate which octant the instance is in if(low.xcentre.x && high.x>=n->centre.x && width()!=0 || low.ycentre.y && high.y>=n->centre.y && height()!=0|| low.zcentre.z && high.z>=n->centre.z && depth()!=0 ){ straddle=true; } else { if(low.x >= n->centre.x && width() !=0) index |= 1; if(low.y >= n->centre.y && height()!=0) index |= 2; if(low.z >= n->centre.z && depth() !=0) index |= 4; } if(!straddle && d<=levels()){ //add to child key = (n->key << 3) | index; //check if child exists if(!(n->hasChild & (1<key = key; newNode->hasChild = 0; //update this node n->hasChild |= (1<centre.x = n->centre.x + (index&1? rx: -rx); newNode->centre.y = n->centre.y + (index&2? ry: -ry); newNode->centre.z = n->centre.z + (index&4? rz: -rz); //Create new node m_octree[key] = newNode; } //recurse to child insert(m_octree[key], inst, low, high, d+1); } else { //straddling, or at the bottom of the tree - add here n->instances.push_front(inst); key = n->key; //save the key in instance location map so the instance knows where it is in the tree m_location[inst] = key; } return key; } wgd::uint Scene3D::remove(Instance3D *inst){ //get the node if(m_location.find(inst)==m_location.end()) return 0; uint key = m_location[inst]; //remove instance pointer m_octree[key]->instances.remove(inst); return key; } void Scene3D::draw(Camera *cam){ //HACK: rebuild the scene if it has changed if (m_doclear) clear(); //Build the scene graph if not already done if(!m_built) build(); //Hack of doom. Camera3D *camera = (Camera3D*)(OID)*cam; //draw the skybox stuff glDisable(GL_LIGHTING); //HACK vector3d pos = camera->position(); glTranslatef(pos.x, pos.y, pos.z); m_skyboxes.draw(); glClear(GL_DEPTH_BUFFER_BIT); glTranslatef(-pos.x, -pos.y, -pos.z); glEnable(GL_LIGHTING); //HACK //Insanely simple draw function - from octree for(std::map::iterator i=m_octree.begin(); i!=m_octree.end(); i++){ for(std::list::iterator j = i->second->instances.begin(); j!=i->second->instances.end(); j++){ //dont draw if visible is false if( (*j)->get(ix::visible) != OID(false) ) { //TODO: automatic scaling for large and distant objects. if ((bool)(*j)->get("skybox")) { (*j)->draw(m_skyboxes, camera); } else { (*j)->draw(m_graph, camera); } } } } m_graph.draw(); Render::end(); //depricated } wgd-3.1/src/base_3d/Makefile.am0000644000175000001440000000064711233311614013200 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_base3d.so libwgd_base3d_so_SOURCES=base3d.cpp scene3d.cpp camera3d.cpp instance3d.cpp iline.cpp iprimitive.cpp render.cpp frustum.cpp sprite3d.cpp isprite3d.cpp text3d.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -L../resources_base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/base_3d/Makefile.in0000644000175000001440000003071711265575054013231 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_base3d.so$(EXEEXT) subdir = src/base_3d DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_base3d_so_OBJECTS = base3d.$(OBJEXT) scene3d.$(OBJEXT) \ camera3d.$(OBJEXT) instance3d.$(OBJEXT) iline.$(OBJEXT) \ iprimitive.$(OBJEXT) render.$(OBJEXT) frustum.$(OBJEXT) \ sprite3d.$(OBJEXT) isprite3d.$(OBJEXT) text3d.$(OBJEXT) libwgd_base3d_so_OBJECTS = $(am_libwgd_base3d_so_OBJECTS) libwgd_base3d_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_base3d_so_SOURCES) DIST_SOURCES = $(libwgd_base3d_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_base3d_so_SOURCES = base3d.cpp scene3d.cpp camera3d.cpp instance3d.cpp iline.cpp iprimitive.cpp render.cpp frustum.cpp sprite3d.cpp isprite3d.cpp text3d.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -L../resources_base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/base_3d/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/base_3d/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_base3d.so$(EXEEXT): $(libwgd_base3d_so_OBJECTS) $(libwgd_base3d_so_DEPENDENCIES) @rm -f libwgd_base3d.so$(EXEEXT) $(CXXLINK) $(libwgd_base3d_so_OBJECTS) $(libwgd_base3d_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/base_3d/isprite3d.cpp0000644000175000001440000000256311233311614013555 00000000000000#include #include namespace wgd { OnEvent(ISprite3D, evt_sprite) { m_sprite.sprite(sprite()); } OnEvent(ISprite3D, evt_frame) { m_sprite.frame(frame()); } OnEvent(ISprite3D, evt_size) { m_sprite.size(width(), height()); } OnEvent(ISprite3D, evt_colour) { m_sprite.colour(colour()); } IMPLEMENT_EVENTS(ISprite3D, Instance3D); }; using namespace wgd; ISprite3D::ISprite3D() : Instance3D() { registerEvents(); set(ix::type, type()); if(mode()==Null) mode("point"); if(get(ix::width)==Null) { width(1.0f); height(1.0f); } m_start = WGD.get(ix::time); } ISprite3D::ISprite3D(const OID &id) : Instance3D(id) { registerEvents(); if(mode()==Null) mode("point"); if(get(ix::width)==Null) { width(1.0f); height(1.0f); } m_start = WGD.get(ix::time); } ISprite3D::~ISprite3D() {} void ISprite3D::draw(SceneGraph &graph, Camera3D *camera) { m_sprite.position(position()); if(mode()==OID("aligned")) { m_sprite.direction(direction()); } else if(mode() == OID("absolute")) { wgd::quaternion quat; quat.createRotation(orientation()); m_sprite.orientation(quat); } else { m_sprite.angle(orientation().z); } m_sprite.draw(graph, camera); } void ISprite3D::frame(int f) { if(fps() != 0.0) { float time = WGD.get(ix::time); m_start = time - f * fps(); } set(ix::frame, f); } wgd-3.1/src/base_3d/iline.cpp0000644000175000001440000000112611233311614012741 00000000000000#include using namespace wgd; using namespace doste; using namespace doste::dvm; ILine3D::ILine3D(const OID &obj) : Instance3D(obj) { } ILine3D::~ILine3D() { } void ILine3D::draw(SceneGraph &graph, Camera3D *camera) { wgd::colour c = colour(); vector3d p1 = point1(); vector3d p2 = point2(); //Disable lighting glDisable(GL_LIGHTING); glLineWidth((float)width()); glBegin(GL_LINES); glColor4f(c.r, c.g, c.b, c.a); glVertex3f(p1.x,p1.y,p1.z); glVertex3f(p2.x,p2.y,p2.z); glEnd(); glColor4f(1.0f,1.0f,1.0f,1.0f); //Re-enable lighting glEnable(GL_LIGHTING); } wgd-3.1/src/base_3d/camera3d.cpp0000644000175000001440000000731511233311614013326 00000000000000#include #include #include #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; //Events namespace wgd { OnEvent(Camera3D, evt_orientation){ m_quat.createRotation(orientation()); m_quat = m_quat.conjugate(); } IMPLEMENT_EVENTS(Camera3D, Camera); }; Camera3D::Camera3D(const doste::dvm::OID &id) : Camera(id) { //some defaults if(get(ix::near)==Null) nearclip(1.0f); if(get("far")==Null) farclip(128.0f); if(get(ix::fov)==Null) fov(60.0f); registerEvents(); } Camera3D::~Camera3D(){} void Camera3D::bind(){ float aspect = (float)m_width / m_height; float vfovY = fov() / aspect; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); if (get("frustum") == Null) { gluPerspective(vfovY, aspect, nearclip(), farclip()); } else { OID frust = get("frustum"); glFrustum(frust.get("left"), frust.get("right"), frust.get("bottom"), frust.get("top"), nearclip(), farclip()); } //create view frustum for culling m_frustum.create(this); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glClear(GL_DEPTH_BUFFER_BIT); //Transform ModelView //rotate float matrix[16]; m_quat.createMatrix(matrix); glMultMatrixf(matrix); //SKYBOX GOES HERE. //translate vector3d pos = position(); glTranslatef(-pos.x, -pos.y, -pos.z); glEnable(GL_DEPTH_TEST); } void Camera3D::unbind(){ glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glDisable(GL_DEPTH_TEST); } void Camera3D::move(const vector3d &v){ position(position() + v); } void Camera3D::translate(const vector3d &v){ position(position().translate(m_quat, v)); } const Quaternion Camera3D::quaternion() const{ return m_quat.conjugate(); } void Camera3D::quaternion(const Quaternion &q){ m_quat = q.conjugate(); } void Camera3D::rotate(const vector3d &r){ orientation(orientation() + r); } void Camera3D::lookat(const vector3d &target) { vector3d direction = (target-position()).normalise(); //calculate pitch and yaw float yaw = -atan2(direction.z, direction.x) - (float)wgd::PI/2.0f; float dist = sqrt(direction.x*direction.x + direction.z*direction.z); float pitch = atan2(direction.y, dist); float roll = get(ix::roll); orientation(vector3d(pitch, yaw, roll)); } vector3d Camera3D::project(const vector3d &w) { double proj[16], mdl[16]; int vp[4] = {0, 0, m_width, m_height }; projectionMatrix(proj); modelViewMatrix(mdl); double rx, ry, rz; gluUnProject(w.x, w.y, w.z, mdl, proj, vp, &rx, &ry, &rz); return vector3d((float)rx, m_height - (float)ry, (float)rz); } vector3d Camera3D::unProject(const vector3d &s) { double proj[16], mdl[16]; int vp[4] = {0, 0, m_width, m_height }; projectionMatrix(proj); modelViewMatrix(mdl); double rx, ry, rz; gluUnProject(s.x, m_height - s.y, s.z, mdl, proj, vp, &rx, &ry, &rz); return vector3d((float)rx, (float)ry, (float)rz); } void Camera3D::projectionMatrix(double *m) { float aspect = (float)m_width / m_height; double fovy = degToRad(fov()) / aspect; double f = 1.0 / tan( fovy / 2.0 ); //cotangent(fovy/2); double far = farclip(); double near = nearclip(); memset(m, 0, 16 * sizeof(double)); m[0] = f / aspect; m[5] = f; m[10] = (far + near) / (near - far); m[11] = -1.0; m[14] = (2 * far * near) / (near - far); } void Camera3D::modelViewMatrix(double *m) { matrix mat, tm, rm; tm.translate(-position()); m_quat.createMatrix(rm); matrix::fastMultiply(mat, rm, tm); //convert to doubles float gl[16]; mat.toOpenGL(gl); for(int i=0; i<16; i++) m[i] = gl[i]; } wgd-3.1/src/base_3d/text3d.cpp0000644000175000001440000001003611233311614013054 00000000000000#include #include #ifdef _MSC_VER #pragma warning ( disable : 4996 ) #endif using namespace wgd; Text3D::Text3D() : m_drawable(0), m_angle(0), m_scale(1.0f), m_align(CENTRE), m_colour(0,0,0), m_text(0), m_font(0) { setup(); } Text3D::Text3D(const char* t, Font* font, const vector3d &position, float scale, TextAlign align, float angle) : m_drawable(0), m_position(position), m_angle(angle), m_scale(scale), m_align(align), m_colour(0,0,0), m_text(0), m_font(font) { text(t); setup(); } Text3D::~Text3D() { if(m_text) delete [] m_text; if(m_drawable) m_drawable->destroy(); } DrawableBase *Text3D::draw(SceneGraph &graph, Camera3D *camera) { return graph.addAlpha(drawable(camera)); } wgd::Drawable *Text3D::drawable(Camera3D* cam) { if(m_changed) build(); //change matrix matrix rcam, p, s, r; cam->quaternion().createMatrix(rcam); p.translate(m_position); s.scale(m_scale, m_scale, m_scale); r.rotate(0, 0, m_angle); m_drawable->transform = p * rcam * r * s; return m_drawable; } void Text3D::text(const char* t) { if(m_text) delete [] m_text; m_text = strdup(t); m_changed = true; } void Text3D::colour(const wgd::colour& c) { m_colour = c; } void Text3D::setup() { m_drawable = new Drawable; m_drawable->mode = GL_QUADS; m_drawable->flags = DEPTH_TEST | DEPTH_WRITE | ALPHA_TEST; } void Text3D::build() { if(!m_text || !m_font) return; m_font->build(); m_drawable->surface = *m_font->texture(); m_drawable->deleteData(); SpriteVertex v; float tx, ty, tw, th; //source float texw = (float)m_font->texture()->width(); float texh = (float)m_font->texture()->height(); float x=0, y=0; vector3d normal(0.0f, 0.0f, 1.0f); int chr = -1; while(m_text[++chr]) { tx = (float)m_font->CharX(m_text[chr]) / texw; ty = (float)m_font->CharY(m_text[chr]) / texh; tw = (float)m_font->CharWidth(m_text[chr]) / texw; th = (float)m_font->CharHeight(m_text[chr]) / texh; v.colour = m_colour; v.position = vector3d(x, y, 0.0f); v.normal = normal; v.texcoords[0].u = tx; v.texcoords[0].v = ty; m_drawable->add(v); v.colour = m_colour; v.position = vector3d(x, y-fabs(th), 0.0f); v.normal = normal; v.texcoords[0].u = tx; v.texcoords[0].v = ty+th; m_drawable->add(v); x += tw; v.colour = m_colour; v.position = vector3d(x, y-fabs(th), 0.0f); v.normal = normal; v.texcoords[0].u = tx+tw; v.texcoords[0].v = ty+th; m_drawable->add(v); v.colour = m_colour; v.position = vector3d(x, y, 0.0f); v.normal = normal; v.texcoords[0].u = tx+tw; v.texcoords[0].v = ty; m_drawable->add(v); } //adjust position with alignment; if(m_align != LEFT) { float delta; if(m_align==CENTRE) delta=x/2.0f; else delta = x; for(unsigned int i=0; isize; i++) { m_drawable->data[i].position.x -= delta; } } } //////////////////////////////////////////// //instane stuff IText3D::IText3D(const wgd::OID &id) : Instance3D(id) { registerEvents(); } IText3D::IText3D() : Instance3D() { registerEvents(); } void IText3D::draw(SceneGraph &graph, Camera3D *cam) { m_text.draw(graph, cam); } void IText3D::align(TextAlign align) { switch(align) { case LEFT: set("align", ix::left); break; case RIGHT: set("align", ix::right); break; case CENTRE: set("align", OID("centre")); break; } } TextAlign IText3D::align() { OID a = get("align"); if(a==ix::left) return LEFT; if(a==ix::right) return RIGHT; return CENTRE; } namespace wgd { OnEvent(IText3D, evt_text) { m_text.text((const char*)text()); } OnEvent(IText3D, evt_scale) { if(scale()) m_text.scale(scale()); } OnEvent(IText3D, evt_angle) { m_text.angle(angle()); } OnEvent(IText3D, evt_align) { m_text.align(align()); } OnEvent(IText3D, evt_colour) { m_text.colour(colour()); } OnEvent(IText3D, evt_font) { m_text.font(font()); } OnEvent(IText3D, evt_position) { m_text.position(position()); } IMPLEMENT_EVENTS(IText3D, Instance3D); }; wgd-3.1/src/base_3d/render.cpp0000644000175000001440000000324611027212123013121 00000000000000#include #include #ifdef WIN32 #include #endif #include using namespace wgd; Camera3D *Render::s_cam3d = 0; Camera2D *Render::s_cam2d = 0; void Render::begin(Camera3D *cam) { s_cam2d = 0; s_cam3d = cam; } void Render::end() { s_cam2d = 0; s_cam3d = 0; } void Render::transform(const matrix &mat) { #ifdef _MSC_VER __declspec(align(16)) float mat2[16]; #else float mat2[16] __attribute__((aligned(16))); #endif mat.toOpenGL(mat2); glPushMatrix(); glMultMatrixf(mat2); } void Render::untransform() { glPopMatrix(); } void Render::sprite(Sprite *spr, int frame, const vector3d &pos) { if (s_cam3d == 0) return; sprite(spr,frame,pos,s_cam3d->quaternion()); } void Render::sprite(Sprite *spr, int frame, const vector3d &pos, const quaternion &quat) { float mat[16]; quat.createMatrix(mat); glPushMatrix(); glTranslatef(pos.x,pos.y,pos.z); glMultMatrixf(mat); sprite(spr, frame); glPopMatrix(); } void Render::sprite(Sprite *spr, int frame) { int cols = spr->columns(); float tw = 1.0f / (float)cols; float th = 1.0f / (float)spr->rows(); float tx = tw*(float)(frame%cols); float ty = th*(float)(frame/cols); Texture *tex = spr->texture(); if (tex == 0) return; tex->bind(); glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); glBegin(GL_QUADS); //Calculate texture coords from sprite info. glTexCoord2f(tx, ty); glVertex3f(-0.5f, 0.5f, 0.0); glTexCoord2f(tx+tw, ty); glVertex3f(0.5f, 0.5f, 0.0); glTexCoord2f(tx+tw, ty+th); glVertex3f(0.5f, -0.5f, 0.0); glTexCoord2f(tx, ty+th); glVertex3f(-0.5f, -0.5f, 0.0); glEnd(); glEnable(GL_CULL_FACE); glEnable(GL_LIGHTING); tex->unbind(); } wgd-3.1/src/base_3d/frustum.cpp0000644000175000001440000000657611071454426013375 00000000000000#include #include #include #include using namespace wgd; void Frustum::create(Camera3D *c) { // Get camera up, forward and left vectors vector3d zero; vector3d up = zero.translate(c->quaternion().conjugate(), vector3d(0.0, 1.0, 0.0)); vector3d forward = zero.translate(c->quaternion().conjugate(), vector3d(0.0, 0.0, -1.0)); vector3d left = zero.translate(c->quaternion().conjugate(), vector3d(-1.0, 0.0, 0.0)); vector3d position = c->position(); // Get camera perspective float a = degToRad(c->fovY() / 2.0f); float b = degToRad(c->fov() / 2.0f); // Get the plane normals matrix rotate; rotate.rotateAxis(left, -a); plane[0].normal = rotate * up * -1; // TOP rotate.rotateAxis(left, a); plane[1].normal = rotate * up; // BOTTOM rotate.rotateAxis(up, -b); plane[2].normal = rotate * left; // RIGHT rotate.rotateAxis(up, b); plane[3].normal = rotate * left * -1; // LEFT plane[4].normal = forward; // NEAR plane[5].normal = forward * -1; // FAR // Next calculate the plane offsets from the normals and the eye position. plane[0].d = -position.dot( plane[0].normal ); plane[1].d = -position.dot( plane[1].normal ); plane[2].d = -position.dot( plane[2].normal ); plane[3].d = -position.dot( plane[3].normal ); plane[4].d = -position.dot( plane[4].normal ); // for far, need the point on the far plane vector3d farPt = position + (forward * c->farclip()); plane[5].d = -farPt.dot( plane[5].normal ); } // Frustum Tests // int Frustum::inside(const vector3d &point, int flags) const { // Test each clip plane for (int i=0; i<6; i++) { //ignore if already inside this plane if(!(flags & (2<= 0); } int Frustum::inside(const Plane &plane, const vector3d &min, const vector3d &max) const { // Assemble accept / reject points based on the plane slope vector3d accept, reject; accept.x = (plane.normal.x > 0)? min.x: max.x; accept.y = (plane.normal.y > 0)? min.y: max.y; accept.z = (plane.normal.z > 0)? min.z: max.z; reject.x = (plane.normal.x > 0)? max.x: min.x; reject.y = (plane.normal.y > 0)? max.y: min.y; reject.z = (plane.normal.z > 0)? max.z: min.z; // If reject point is outside the clipping plane if(!inside(plane, reject)) return 0; // If accept point is inside the clipping plane if(inside(plane, accept)) return 1; // Otherwise intersected return 2; } wgd-3.1/src/sound/0000777000175000001440000000000011265576313011067 500000000000000wgd-3.1/src/sound/Makefile.am0000644000175000001440000000000210757502253013024 00000000000000 wgd-3.1/src/sound/Makefile.in0000644000175000001440000002023211265575055013051 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = src/sound DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/sound/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/sound/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/collision_3d/0000777000175000001440000000000011265576313012320 500000000000000wgd-3.1/src/collision_3d/Makefile.am0000644000175000001440000000000210757502050014250 00000000000000 wgd-3.1/src/collision_3d/Makefile.in0000644000175000001440000002025711265575054014310 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = src/collision_3d DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/collision_3d/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/collision_3d/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/ui/0000777000175000001440000000000011265576314010355 500000000000000wgd-3.1/src/ui/syntax.h0000775000175000001440000000133511236552535011774 00000000000000#ifndef _SYNTAX_ #define _SYNTAX_ #include enum Token {TLP='(', RP=')', LS='{', RS='}', LC='[', RC=']', COMMENT='#', LO='<', RO='>', ASSIGN='=', STRING='"', CHARSTART='\'', OIDSEP=':', END=';', TERM=0, OBJECT='O', SEP=',', CMD='%', IVAR='@'}; class Syntax : public QSyntaxHighlighter { public: Syntax(QTextDocument *textEdit); ~Syntax(); void highlightBlock ( const QString & text ); QTextCharFormat font_normal; QTextCharFormat font_comment; QTextCharFormat font_string; QTextCharFormat font_command; QTextCharFormat font_number; QTextCharFormat font_object; QTextCharFormat font_oid; QTextCharFormat font_char; QTextCharFormat font_op; QTextCharFormat font_ivar; }; #endif wgd-3.1/src/ui/Makefile.am0000644000175000001440000000054511265576310012325 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_ui.so libwgd_ui_so_SOURCES=ui.cpp syntax.cpp moc_inputwindow.cpp inputwindow.cpp syntax.h inputwindow.h AM_CPPFLAGS=-fPIC -I/usr/include/QtCore -I/usr/include/QtGui AM_LDFLAGS=-L../base -shared -lGL -lX11 -lXxf86vm -ldoste -lQtGui -lQtCore INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/ui/inputwindow.cpp0000644000175000001440000000271311237007271013355 00000000000000#include #include "inputwindow.h" #include "syntax.h" #include #include #include #include using namespace doste; using namespace doste::dvm; IWindow::IWindow() { QWidget *central = new QWidget; setCentralWidget(central); QHBoxLayout *buttonLayout = new QHBoxLayout; m_input = new QTextEdit(); m_submit = new QPushButton("Input"); m_submit->setFixedSize(100,25); m_output = new QTextEdit(); buttonLayout->addWidget(m_submit); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(m_input); mainLayout->addLayout(buttonLayout); //mainLayout->addWidget(m_output); central->setLayout(mainLayout); Syntax *syn = new Syntax(m_input->document()); resize(640,480); show(); connect(m_submit, SIGNAL(clicked()), this, SLOT(submit())); } IWindow::~IWindow() { } void IWindow::submit() { OID dasm = doste::dvm::root["notations"]["dasm"]; char *ibuf = m_input->toPlainText().toLocal8Bit().data(); std::cout << ibuf << "\n"; char *pbuf = new char[1000]; ((DASM*)dasm)->execute(ibuf,root); OID res = dasm.get("result"); if (!res.isReserved() && res.get(Size) != Null && res.get(0).isChar()) { dstring(res).toString(pbuf,1000); std::cout << " \"" << pbuf << "\"\n"; //m_output->document()->setPlainText(m_output->document()->toPlainText().append(pbuf)); } else { res.toString(pbuf, 1000); std::cout << " " << pbuf << "\n"; } m_input->clear(); delete [] pbuf; } wgd-3.1/src/ui/inputwindow.h0000644000175000001440000000041011236552146013017 00000000000000#include #include #include class IWindow : public QMainWindow { Q_OBJECT public: IWindow(); ~IWindow(); private: QTextEdit *m_input; QPushButton *m_submit; QTextEdit *m_output; public slots: void submit(); }; wgd-3.1/src/ui/Makefile.in0000644000175000001440000003061311265576314012341 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_ui.so$(EXEEXT) subdir = src/ui DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_ui_so_OBJECTS = ui.$(OBJEXT) syntax.$(OBJEXT) \ moc_inputwindow.$(OBJEXT) inputwindow.$(OBJEXT) libwgd_ui_so_OBJECTS = $(am_libwgd_ui_so_OBJECTS) libwgd_ui_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libwgd_ui_so_SOURCES) DIST_SOURCES = $(libwgd_ui_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_ui_so_SOURCES = ui.cpp syntax.cpp moc_inputwindow.cpp inputwindow.cpp syntax.h inputwindow.h AM_CPPFLAGS = -fPIC -I/usr/include/QtCore -I/usr/include/QtGui AM_LDFLAGS = -L../base -shared -lGL -lX11 -lXxf86vm -ldoste -lQtGui -lQtCore INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/ui/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/ui/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_ui.so$(EXEEXT): $(libwgd_ui_so_OBJECTS) $(libwgd_ui_so_DEPENDENCIES) @rm -f libwgd_ui.so$(EXEEXT) $(CXXLINK) $(libwgd_ui_so_OBJECTS) $(libwgd_ui_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/ui/ui.cpp0000644000175000001440000000064711236546111011407 00000000000000#include #include #include "inputwindow.h" using namespace doste; using namespace doste::dvm; QApplication *qtapp=0; int argc = 0; extern "C" void initialise(const doste::dvm::OID &base) { qtapp = new QApplication(argc,0); IWindow *input = new IWindow(); } extern "C" void update() { if (qtapp) qtapp->processEvents(); } extern "C" void finalise() { delete qtapp; } wgd-3.1/src/ui/moc_inputwindow.cpp0000644000175000001440000000373011236550055014215 00000000000000/* ** Meta object code from reading C++ file 'inputwindow.h' ** ** Created ** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2) ** ** WARNING! All changes made in this file will be lost! **/ #include "inputwindow.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'inputwindow.h' doesn't include ." #elif Q_MOC_OUTPUT_REVISION != 61 #error "This file was generated using the moc from 4.5.2. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_IWindow[] = { // content: 2, // revision 0, // classname 0, 0, // classinfo 1, 12, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors // slots: signature, parameters, type, tag, flags 9, 8, 8, 8, 0x0a, 0 // eod }; static const char qt_meta_stringdata_IWindow[] = { "IWindow\0\0submit()\0" }; const QMetaObject IWindow::staticMetaObject = { { &QMainWindow::staticMetaObject, qt_meta_stringdata_IWindow, qt_meta_data_IWindow, 0 } }; const QMetaObject *IWindow::metaObject() const { return &staticMetaObject; } void *IWindow::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_IWindow)) return static_cast(const_cast< IWindow*>(this)); return QMainWindow::qt_metacast(_clname); } int IWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: submit(); break; default: ; } _id -= 1; } return _id; } QT_END_MOC_NAMESPACE wgd-3.1/src/ui/syntax.cpp0000775000175000001440000001213411236553231012320 00000000000000#include "syntax.h" #include Syntax::Syntax(QTextDocument *textEdit) : QSyntaxHighlighter(textEdit) { font_command.setFont(QFont("Courier New", 10, QFont::Bold)); font_object.setFont(font_command.font()); font_comment.setFont(QFont("Courier New", 10)); font_normal.setFont(font_comment.font()); font_oid.setFont(font_object.font()); font_string.setFont(font_normal.font()); font_number.setFont(font_normal.font()); font_char.setFont(font_number.font()); font_op.setFont(font_command.font()); font_ivar.setFont(font_command.font()); font_command.setForeground(QColor("black")); font_object.setForeground(QColor(38,140,223)); font_comment.setForeground(QColor("darkgreen")); font_normal.setForeground(QColor("black")); font_oid.setForeground(QColor("red")); font_string.setForeground(QColor("red")); font_number.setForeground(QColor("blue")); font_char.setForeground(QColor("pink")); font_op.setForeground(QColor("black")); font_ivar.setForeground(QColor("pink")); } Syntax::~Syntax() { } void Syntax::highlightBlock ( const QString & text ) { unsigned int pos = 0; unsigned int beg = 0; bool istring; unsigned int i; char buffer[100]; while (pos < text.length()) { //Remove all white space from the buffer, reguardless of whether its in peek mode. while ((pos < text.length()) && (text[pos] == ' ' || text[pos] == '\n' || text[pos] == '\r' || text[pos] == '\t')) { pos++; } if (pos == text.length()) return; switch (text[pos].toAscii()) { case COMMENT: beg = pos; pos++; while (text[pos] != '\n' && text[pos] != (char)0) { //Remove comment until new line pos++; if (pos == text.length()) break; } setFormat(beg, pos-beg, font_comment); break; case CMD: beg = pos; pos++; i = 0; while ((pos < text.length()) && text[pos] != ' ' && text[pos] != '\t' && text[pos] != (char)0) { buffer[i] = text[pos].toAscii(); pos++; i++; if (pos == text.length()) break; } buffer[i] = 0; if (strcmp(buffer, "include") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "list") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "debug") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "query") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "using") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "def") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "print") == 0) setFormat(beg, pos-beg, font_command); else if (strcmp(buffer, "hide") == 0) setFormat(beg, pos-beg, font_command); else setFormat(beg, pos-beg, font_normal); break; case IVAR: beg = pos; pos++; i = 0; while ((pos < text.length()) && text[pos] != ' ' && text[pos] != '\t' && text[pos] != (char)0) { buffer[i] = text[pos].toAscii(); pos++; if (pos == text.length()) break; i++; } buffer[i] = 0; setFormat(beg, pos-beg, font_ivar); break; case TERM: break; case TLP: case RP: case LO: case RO: case RS: case LS: pos++; break; case LC: beg = pos; pos++; break; case RC: pos++; setFormat(beg, pos-beg, font_oid); break; case ASSIGN: pos++; break; case SEP: pos++; break; case END: pos++; break; default: beg = pos; i = 0; istring = false; while (pos < text.length() && (istring || (text[pos] != ' ' && text[pos] != '\t' && text[pos] != (char)0 && text[pos] != '\n' && text[pos] != '(' && text[pos] != ')' && text[pos] != ';' && text[pos] != ',' && text[pos] != '<' && text[pos] != '>'))) { if (text[pos] == '"') istring = !istring; buffer[i] = text[pos].toAscii(); pos++; i++; } buffer[i] = 0; if (strcmp(buffer, "this") == 0) setFormat(beg, pos-beg, font_object); else if (strcmp(buffer, "true") == 0) setFormat(beg, pos-beg, font_object); else if (strcmp(buffer, "false") == 0) setFormat(beg, pos-beg, font_object); else if (strcmp(buffer, "null") == 0) setFormat(beg, pos-beg, font_object); else if (strcmp(buffer, "is") == 0) setFormat(beg, pos-beg, font_op); else if (strcmp(buffer, "$") == 0) setFormat(beg, pos-beg, font_object); else { //Check for numbers, characters and strings if (buffer[0] == '"') setFormat(beg, pos-beg, font_string); else if (buffer[0] == '0' || buffer[0] == '1' || buffer[0] == '2' || buffer[0] == '3' || buffer[0] == '4' || buffer[0] == '5' || buffer[0] == '6' || buffer[0] == '7' || buffer[0] == '8' || buffer[0] == '9' || buffer[0] == '-') setFormat(beg, pos-beg, font_number); else if (buffer[0] == '\'') setFormat(beg, pos-beg, font_char); else setFormat(beg, pos-beg, font_normal); } break; } } } wgd-3.1/src/collision_2d/0000777000175000001440000000000011265576313012317 500000000000000wgd-3.1/src/collision_2d/Makefile.am0000644000175000001440000000000210757502042014250 00000000000000 wgd-3.1/src/collision_2d/Makefile.in0000644000175000001440000002025711265575054014307 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = src/collision_2d DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/collision_2d/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/collision_2d/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/xnet/0000777000175000001440000000000011265576313010715 500000000000000wgd-3.1/src/xnet/xnet.h0000644000175000001440000000042211013000343011726 00000000000000#ifndef _DOSTE_XNET_ #define _DOSTE_XNET_ #ifdef WIN32 #if BUILD_XNET_DLL # define XNETIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define XNETIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ #else #define XNETIMPORT #endif #endif wgd-3.1/src/xnet/xnetprotocol.h0000644000175000001440000001165511027176747013555 00000000000000#ifndef _doste_XNETPROTOCOL_H_ #define _doste_XNETPROTOCOL_H_ #include #include "xnet.h" #include #include #include #define MAX_RESULTS 10 #define MAX_INDEXES 10000 #include "xnetconnection.h" class XNetCallback { public: virtual ~XNetCallback() {} virtual void event(doste::dvm::Event &evt) {} virtual void script(const char *s) {}; virtual void result(const char *r) {}; virtual void error(const char *err) {}; }; struct XNet_Local { XNet_Header h; doste::dvm::OID local; } __attribute__ ((packed)); struct XNet_Share { XNet_Header h; doste::dvm::OID share; } __attribute__ ((packed)); struct XNet_Login { XNet_Header h; char username[20]; char password[20]; } __attribute__ ((packed)); struct XNet_SmallEvent { XNet_Header h; unsigned char id; unsigned char type; doste::dvm::OID dest; doste::dvm::OID p1; } __attribute__ ((packed)); struct XNet_Event { XNet_Header h; unsigned char id; unsigned char type; doste::dvm::OID dest; doste::dvm::OID p1, p2, p3, p4; } __attribute__ ((packed)); struct XNet_Result { XNet_Header h; int id; doste::dvm::OID result; } __attribute__ ((packed)); struct XNet_Block { XNet_Header h; int id; int size; //Might include type information. //Followed by 'size' OIDs. } __attribute__ ((packed)); struct XNet_ILookup { XNet_Header h; doste::dvm::OID index; } __attribute__ ((packed)); struct XNet_IValue { XNet_Header h; int id; char value[40]; } __attribute__ ((packed)); class XNETIMPORT XNetProtocol { public: XNetProtocol(XNetConnection *conn); virtual ~XNetProtocol(); XNetConnection *connection() const { return m_conn; }; //Allow for callbacks to overload default behaviour. void callback(XNetCallback *cb, int flags) { m_cb = cb; m_cbflags = flags; }; XNetCallback *callback() const { return m_cb; }; int callbackFlags() const { return m_cbflags; }; void begin(); void local(const doste::dvm::OID &base); void share(const doste::dvm::OID &share); void login(const char *user, const char *passwd); int event(doste::dvm::Event &evt, int flags); //void script(const char *d); //void results(bool v); //void errors(bool v); void result(int id, const doste::dvm::OID &res); void ilookup(const doste::dvm::OID &index); void ivalue(int id, const char *value); void end(); bool wait(int id) { return m_results[id].waiting; }; doste::dvm::OID getResult(int id) { doste::dvm::OID res = m_results[id].res; m_results[id].avail = true; return res; }; virtual void data(const char *d, int length); doste::dvm::OID lookup(const doste::dvm::OID &index); static const int EFLAG_WAITRESULT = 0x0001; static const int CBFLAG_RESULT = 0x01; static const int CBFLAG_ERROR = 0x02; static const int CBFLAG_EVENT = 0x03; static const int CBFLAG_SCRIPT = 0x04; static const unsigned char MSG_LOCAL = 0x01; static const unsigned char MSG_SHARE = 0x02; static const unsigned char MSG_LOGIN = 0x03; static const unsigned char MSG_SMALLEVT = 0x04; static const unsigned char MSG_EVENT = 0x05; static const unsigned char MSG_RESULT = 0x06; static const unsigned char MSG_BLOCK = 0x07; static const unsigned char MSG_ILOOKUP = 0x08; static const unsigned char MSG_IVALUE = 0x09; private: XNetConnection *m_conn; //std::string m_data; XNetCallback *m_cb; int m_cbflags; /*class XMLTag { public: XMLTag(const char *name, XMLTag *parent=0) : m_parent(parent), m_name(name) {}; ~XMLTag(); const char *name() const { return m_name.data(); }; std::string &attribute(const char *name) { return m_attribs[name]; }; void addAttribute(const char *name, const char *value) { m_attribs[name] = value; }; void appendContent(const char *content) { m_content += content; }; const char *content() const { return m_content.data(); }; void addChild(XMLTag *tag) { m_children.push_back(tag); }; int numChildren() const { return m_children.size(); }; XMLTag *child (int c) { return m_children[c]; }; XMLTag *parent() const { return m_parent; }; private: XMLTag *m_parent; std::string m_content; std::string m_name; std::vector m_children; //Something for attributes. std::map m_attribs; };*/ //XMLTag *m_root; //XMLTag *m_current; int m_datasize; char m_data[1000]; doste::dvm::OID m_this; struct ResultEntries { bool waiting; bool avail; doste::dvm::OID res; }; ResultEntries m_results[MAX_RESULTS]; int onLocal(const char *buf); int onEvent(const char *buf); //void onScript(char *buf); int onLogin(const char *buf); int onResult(const char *buf); //void onError(char *buf); int onShare(const char *buf); int onBlock(const char *buf); int onSmallEvent(const char *buf); int onILookup(const char *buf); int onIValue(const char *buf); //Cache stuff. //int parseTag(const char *buf); //int parseAttributes(const char *d); //int countWS(const char *d); //void executeTree(); //void deleteTree(); int m_indexes[MAX_INDEXES]; //NOTE: Max of 10000 indexes!!! }; #endif wgd-3.1/src/xnet/Makefile.am0000644000175000001440000000047611044046031012654 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libxnet.so libxnet_so_SOURCES=xnetconnection.cpp xnet.cpp xnethandler.cpp xnetmanager.cpp xnetprotocol.cpp xnetconnection.h xnet.h xnethandler.h xnetprotocol.h AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../doste -shared INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/xnet/xnet.cpp0000644000175000001440000000227011026706237012307 00000000000000#include "xnethandler.h" #include "xnetconnection.h" #include "xnet.h" #include using namespace doste; using namespace doste::dvm; OID xnetbase; class XNetAgent : public Agent { public: XNetAgent(const OID &obj) : Agent(obj) { registerEvents(); } ~XNetAgent() {} BEGIN_EVENTS(Agent); EVENT(evt_listen, (*this)("listen")); EVENT(evt_connection, (*this)("connections")(All)); //EVENT(evt_update, root("time")); END_EVENTS; }; OnEvent(XNetAgent, evt_listen) { if ((bool)get("listen") == true) { XNetConnection::listen(*this); } else { //If already listening. //XNetConnection::stop(); } } OnEvent(XNetAgent, evt_connection) { OID conns = get("connections"); for (OID::iterator i=conns.begin(); i!=conns.end(); i++) { (XNetConnection*)conns.get(*i); } } //OnEvent(XNetAgent, evt_update) { // XNetConnection::update(); //} IMPLEMENT_EVENTS(XNetAgent, Agent); XNetAgent *myagent; extern "C" void XNETIMPORT initialise(const OID &base) { xnetbase = base; Object::registerType(); myagent = new XNetAgent(base); } extern "C" void XNETIMPORT update() { XNetConnection::update(); } extern "C" void XNETIMPORT finalise() { //delete myagent; } wgd-3.1/src/xnet/Makefile.in0000644000175000001440000003056211265575055012706 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libxnet.so$(EXEEXT) subdir = src/xnet DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libxnet_so_OBJECTS = xnetconnection.$(OBJEXT) xnet.$(OBJEXT) \ xnethandler.$(OBJEXT) xnetmanager.$(OBJEXT) \ xnetprotocol.$(OBJEXT) libxnet_so_OBJECTS = $(am_libxnet_so_OBJECTS) libxnet_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libxnet_so_SOURCES) DIST_SOURCES = $(libxnet_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libxnet_so_SOURCES = xnetconnection.cpp xnet.cpp xnethandler.cpp xnetmanager.cpp xnetprotocol.cpp xnetconnection.h xnet.h xnethandler.h xnetprotocol.h AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../doste -shared INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/xnet/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/xnet/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libxnet.so$(EXEEXT): $(libxnet_so_OBJECTS) $(libxnet_so_DEPENDENCIES) @rm -f libxnet.so$(EXEEXT) $(CXXLINK) $(libxnet_so_OBJECTS) $(libxnet_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/xnet/xnetprotocol.cpp0000644000175000001440000002076311072477120014075 00000000000000#include "xnetprotocol.h" #include "xnetconnection.h" #include #include #include #include #include #undef ERROR using namespace doste; using namespace doste::dvm; /*struct EvtTypeToString { int type; const char *name; };*/ /*EvtTypeToString cnvtype[] = { {Event::SET, "SET"}, {Event::GET, "GET"}, {Event::ADDDEP, "ADDDEP"}, //{Event::ADDDEP_AGENT, "ADDDEP_AGENT"}, {Event::NOTIFY, "NOTIFY"}, {Event::DEFINE, "DEFINE"}, {Event::DEFINE_FUNC, "DEFINE_FUNC"}, {Event::GET_KEYS, "GET_KEYS"}, {0,0} };*/ XNetProtocol::XNetProtocol(XNetConnection *conn) : m_conn(conn), m_datasize(0) { m_this = Void; for (int i=0; i tag //m_data += "\n"; m_datasize = 0; } void XNetProtocol::end() { //Generate tag and send to net connection //m_data += "\n"; m_conn->send(m_data, m_datasize); m_datasize = 0; //m_data.clear(); } void XNetProtocol::local(const OID &base) { XNet_Local *l = (XNet_Local*)&m_data[m_datasize]; l->h.id = MSG_LOCAL; l->h.size = sizeof(XNet_Local); l->local = base; m_datasize += sizeof(XNet_Local); } void XNetProtocol::ilookup(const OID &index) { //std::cout << "ilookup\n"; XNet_ILookup *l = (XNet_ILookup*)&m_data[m_datasize]; l->h.id = MSG_ILOOKUP; l->h.size = sizeof(XNet_ILookup); l->index = index; m_datasize += sizeof(XNet_ILookup); } void XNetProtocol::ivalue(int id, const char *value) { XNet_IValue *l = (XNet_IValue*)&m_data[m_datasize]; l->h.id = MSG_IVALUE; l->h.size = sizeof(XNet_IValue); l->id = id; strcpy(l->value, value); m_datasize += sizeof(XNet_IValue); } void XNetProtocol::share(const OID &s) { XNet_Share *l = (XNet_Share*)&m_data[m_datasize]; l->h.id = MSG_SHARE; l->h.size = sizeof(XNet_Share); l->share = s; m_datasize += sizeof(XNet_Share); } void XNetProtocol::result(int id, const OID &res) { //std::cout << "result\n"; if (res.isBuffer()) { XNet_Block *b = (XNet_Block*)&m_data[m_datasize]; b->h.id = MSG_BLOCK; b->id = id; Buffer *buf = Buffer::lookup(res); b->size = buf->count(); b->h.size = sizeof(XNet_Block) + buf->count()*sizeof(OID); //std::cout << "block size= " << b->size << "\n"; //DMsg msg(DMsg::DEBUG); OID *element = (OID*)(b+1); for (int i=0; isize; i++) { element[i] = buf->get(i); //msg << " sending element " << element[i] << "\n"; } Buffer::free(res); m_datasize += sizeof(XNet_Block) + (sizeof(OID) * b->size); } else { XNet_Result *r = (XNet_Result*)&m_data[m_datasize]; r->h.id = MSG_RESULT; r->h.size = sizeof(XNet_Result); r->id = id; r->result = res; m_datasize += sizeof(XNet_Result); } } int XNetProtocol::event(Event &evt, int flags) { //Convert to event tags //DMsg msg(DMsg::INFO); //msg << "send event: " << evt.type() << " " << evt.dest() << "(" << evt.param<0>() << ")\n"; unsigned char id=0xFF; if (flags & EFLAG_WAITRESULT) { for (id=0; idh.id = MSG_EVENT; e->h.size = sizeof(XNet_Event); e->id = id; e->type = evt.type(); e->dest = evt.dest(); e->p1 = evt.param<0>(); e->p2 = evt.param<1>(); e->p3 = evt.param<2>(); e->p4 = evt.param<3>(); m_datasize += sizeof(XNet_Event); return id; } void XNetProtocol::login(const char *user, const char *passwd) { //std::cout << "login\n"; XNet_Login *l = (XNet_Login*)&m_data[m_datasize]; l->h.id = MSG_LOGIN; l->h.size = sizeof(XNet_Login); strcpy(l->username, user); strcpy(l->password, passwd); m_datasize += sizeof(XNet_Login); } void printhex(const char *d, int count) { std::cout << std::hex; for (int i=0; iid) { case MSG_LOCAL: i += onLocal(d); break; case MSG_LOGIN: i += onLogin(d); break; case MSG_SHARE: i += onShare(d); break; case MSG_EVENT: i += onEvent(d); break; case MSG_SMALLEVT: i += onEvent(d); break; case MSG_RESULT: i += onResult(d); break; case MSG_BLOCK: i += onBlock(d); break; case MSG_ILOOKUP: i += onILookup(d); break; case MSG_IVALUE: i += onIValue(d); break; default: err << "XNetProtocol: I received a message that appears to be corrupt. " << length-i << "\n"; printhex(d, 20); //i++; return; } d = od + i; } } int XNetProtocol::onILookup(const char *buf) { XNet_ILookup *l = (XNet_ILookup*)buf; char buf2[50]; l->index.toString(buf2, 50); //std::cout << "Lookup: " << buf2 << "\n"; begin(); ivalue(l->index.d(), buf2); end(); return sizeof(XNet_ILookup); } int XNetProtocol::onIValue(const char *buf) { //std::cout << "IVALUE\n"; XNet_IValue *l = (XNet_IValue*)buf; m_indexes[l->id] = OID(l->value).d(); return sizeof(XNet_IValue); } int XNetProtocol::onLocal(const char *buf) { //m_conn->handler(OID(tag->content())); XNet_Local *l = (XNet_Local*)buf; m_conn->xhandler(l->local); return sizeof(XNet_Local); } int XNetProtocol::onShare(const char *buf) { //connection()->set("share", OID(tag->content())); XNet_Share *l = (XNet_Share*)buf; connection()->set("share", l->share); return sizeof(XNet_Share); } int XNetProtocol::onEvent(const char *buf) { XNet_Event *e = (XNet_Event*)buf; Event *evt = new Event(); int id = e->id; evt->dest(e->dest); evt->type(e->type); //DMsg msg(DMsg::DEBUG); //msg << "Event: type=" << (int)e->type << " dest=" << e->dest << " p1=" << e->p1 << "\n"; //std::cout << "Event type=" << (int)e->type << " id=" << (int)e->id << "\n"; evt->param<0>(e->p1); evt->param<1>(e->p2); evt->param<2>(e->p3); evt->param<3>(e->p4); //Now do index lookups if (evt->param<0>().isName()) evt->param<0>(lookup(evt->param<0>())); if (evt->param<1>().isName()) evt->param<1>(lookup(evt->param<1>())); if (evt->param<2>().isName()) evt->param<2>(lookup(evt->param<2>())); if (evt->param<3>().isName()) evt->param<3>(lookup(evt->param<3>())); //std::cout << "onEvent: " << id << "\n"; if (id != 0xFF) { //Blocking evt->send(); //std::cout << "Sending result: " << id << "\n"; begin(); result(id, evt->result()); end(); delete evt; } else { evt->send(Event::FLAG_FREE); } return sizeof(XNet_Event); } extern OID xnetbase; int XNetProtocol::onLogin(const char *buf) { //extract username and password and compare with the database. XNet_Login *l = (XNet_Login*)buf; DString pwd((OID)(xnetbase["users"][l->username]["password"])); char buf2[100]; pwd.toString(buf2,100); if (strcmp(buf2, l->password) == 0) { //Login was successful std::cout << "Successful Login: " << l->username << "\n"; m_this = xnetbase["users"][l->username]; } else { std::cout << "Invalid login: " << l->username << "\n"; } begin(); local(OID::local()); share(m_this); end(); return sizeof(XNet_Login); } int XNetProtocol::onResult(const char *buf) { XNet_Result *r = (XNet_Result*)buf; //std::cout << "Received result: " << r->id << "\n"; m_results[r->id].res = r->result; m_results[r->id].waiting = false; if (m_results[r->id].res.isName()) m_results[r->id].res = lookup(m_results[r->id].res); return sizeof(XNet_Result); } int XNetProtocol::onBlock(const char *buf) { XNet_Block *b = (XNet_Block*)buf; //std::cout << "onblock\n"; m_results[b->id].res = Buffer::create(B_OID, b->size); Buffer *buf2 = Buffer::lookup(m_results[b->id].res); //DMsg msg(DMsg::DEBUG); OID *element = (OID*)(b+1); //The network buffer is reused by lookup. int size = b->size; int id = b->id; for (int i=0; iseti(i, element[i]); //msg << " element = " << element[i] << "\n"; } m_results[id].waiting = false; return sizeof(XNet_Block) + (size * sizeof(OID)); } OID XNetProtocol::lookup(const OID &index) { //DMsg msg(DMsg::DEBUG); //msg << "Lookup: " << index << "\n"; if (m_indexes[index.d()] != -1) { return OID(0,5,0,m_indexes[index.d()]); } else { begin(); ilookup(index); end(); while (m_indexes[index.d()] == -1) connection()->update(); return OID(0,5,0,m_indexes[index.d()]); } } wgd-3.1/src/xnet/xnethandler.h0000644000175000001440000000332411027176747013323 00000000000000#ifndef _doste_XNETHANDLER_H_ #define _doste_XNETHANDLER_H_ #include #include #include #include class XNetConnection; class XNetHandler : public doste::dvm::Handler { public: XNetHandler(XNetConnection *conn, const doste::dvm::OID &base); ~XNetHandler(); bool handle(doste::dvm::Event &evt); struct OIDPair { friend inline bool operator==(const OIDPair &p1, const OIDPair &p2); doste::dvm::OID object; doste::dvm::OID key; }; private: struct Object { doste::dvm::OID object; doste::Vector keys; Object *next; }; struct Attribute { doste::dvm::OID value; doste::List deps; }; struct Mapping { doste::dvm::OID object; doste::dvm::OID key; Attribute *attrib; Mapping *next; }; Object *getObject(const doste::dvm::OID &o); void addObject(const doste::dvm::OID &o, const doste::dvm::OID &buf); Attribute *getAttrib(const doste::dvm::OID &o, const doste::dvm::OID &k); void addAttrib(const doste::dvm::OID &o, const doste::dvm::OID &k, const doste::dvm::OID &value); static const unsigned int ATTRIB_HASH_SIZE = 2000; static const unsigned int OBJECT_HASH_SIZE = 200; Mapping *m_hash[ATTRIB_HASH_SIZE]; doste::Vector m_attribs; static int hashOIDS(const doste::dvm::OID &o, const doste::dvm::OID &k) { return (o.d()+k.d()) % ATTRIB_HASH_SIZE; }; static int hashOID(const doste::dvm::OID &o) { return o.d() % OBJECT_HASH_SIZE; }; //Hash of objects Object *m_objs[OBJECT_HASH_SIZE]; XNetConnection *m_conn; }; bool operator==(const XNetHandler::OIDPair &p1, const XNetHandler::OIDPair &p2) { return (p1.object == p2.object && p1.key == p2.key); } #endif wgd-3.1/src/xnet/xnetmanager.cpp0000644000175000001440000000000210765136617013641 00000000000000 wgd-3.1/src/xnet/xnetconnection.h0000644000175000001440000000530211027176747014043 00000000000000#ifndef _doste_XNETCONNECTION_H_ #define _doste_XNETCONNECTION_H_ #include #include #include "xnet.h" #ifndef WIN32 #include #include #include #include #include #include #include #endif #ifdef WIN32 #include #include typedef int socklen_t; #define MSG_WAITALL 0 #endif class XNetProtocol; class XNetHandler; struct XNet_Header { unsigned char id; //Message type unsigned short size; } __attribute__ ((packed)); class XNetConnection : public doste::Agent { public: OBJECT(Agent, XNetConnection); XNetConnection(const doste::dvm::OID &o); XNetConnection(const doste::dvm::OID &o, int sck); ~XNetConnection(); PROPERTY_RF(bool, connect, "connect"); PROPERTY_WF(bool, connect, "connect"); PROPERTY_RF(doste::dstring, address, "address"); PROPERTY_WF(doste::dstring, address, "address"); PROPERTY_RF(int, port, "port"); PROPERTY_WF(int, port, "port"); PROPERTY_RF(doste::dvm::OID, local, "local"); PROPERTY_RF(doste::dstring, username, "username"); PROPERTY_WF(doste::dstring, username, "username"); PROPERTY_RF(doste::dstring, password, "password"); PROPERTY_WF(doste::dstring, password, "password"); BEGIN_EVENTS(Agent); EVENT(evt_connect, (*this)("connect")); END_EVENTS; //const doste::dvm::OID &local() { return m_local; }; void send(const char *data, int length); XNetProtocol *protocol() const { return m_proto; }; bool ssDependency() { return true; }; XNetHandler *xhandler() const { return m_handler; }; void xhandler(const doste::dvm::OID &base); static XNetConnection *lookup(const doste::dvm::OID &o); static void listen(const doste::dvm::OID &base); static void stop(); static void update(); static const int MAX_CONNECTIONS = 10; private: bool _connect(const char *addr, int port); void _disconnect(); int sock() { return m_socket; }; bool data(); //Process XML input data. void error(); //Urrr... probably disconnected. int m_socket; char m_addr[15]; doste::dvm::OID m_local; XNetProtocol *m_proto; int m_bufsize; int m_bpos; char *m_buffer; XNetHandler *m_handler; //#ifndef WIN32 //static void *listen_thread(void*); //#else //static DWORD listen_thread(void*); //#endif static bool acceptConnections(); static int setDescriptors(); static bool initServer(short port); static XNetConnection *s_conns[MAX_CONNECTIONS]; static doste::dvm::OID s_base; //#ifndef WIN32 //static pthread_t s_thread; //#else //static HANDLE s_thread; //#endif static bool s_running; static bool s_server; static int s_sd; static fd_set s_fdread; static fd_set s_fderror; static sockaddr_in s_localAddr; }; #endif wgd-3.1/src/xnet/xnethandler.cpp0000644000175000001440000001651711236564021013652 00000000000000#include "xnethandler.h" #include "xnetconnection.h" #include "xnetprotocol.h" #include #include #include using namespace doste; using namespace doste::dvm; //Supports 4 billion network connection objects! XNetHandler::XNetHandler(XNetConnection *conn, const OID &base) : Handler(OID(base.a(),base.b(),0,0), OID(base.a(),base.b(),0xFFFFFFFF,0xFFFFFFFF)) { m_conn = conn; std::cout << "Making handler\n"; map(OID::local() + OID(0,0,16,0), OID::local()+OID(0,0,16,1)); for (int i=0; iobject == o) { return cur; } cur = cur->next; } return 0; } void XNetHandler::addObject(const OID &o, const OID &buf) { int hash = hashOID(o); Object *obj = new Object; obj->object = o; Buffer *buffer = Buffer::lookup(buf); if (buffer == 0) { delete obj; return; } for (int i=0; icount(); i++) { obj->keys.add(buffer->get(i)); } obj->next = m_objs[hash]; m_objs[hash] = obj; //OID k2 = k; //if (k2.isName()) k2 = m_conn->protocol()->lookup(k2); //Add dependency /*Event *evt = new Event(Event::ADDDEP, o); evt->param<0>(k); evt->param<1>(OID::local() + OID(0,0,16,0)); evt->param<2>(m_attribs.size()-1); //evt->send(Event::FLAG_FREE); m_conn->protocol()->begin(); m_conn->protocol()->event(*evt, 0); m_conn->protocol()->end(); delete evt;*/ } XNetHandler::Attribute *XNetHandler::getAttrib(const OID &o, const OID &k) { int hash = hashOIDS(o,k); Mapping *cur = m_hash[hash]; while (cur != 0) { if (cur->object == o && cur->key == k) { return cur->attrib; } cur = cur->next; } return 0; } void XNetHandler::addAttrib(const OID &o, const OID &k, const OID &value) { int hash = hashOIDS(o,k); //Make a new attribute; Attribute *a = new Attribute; Mapping *m = new Mapping; a->value = value; m->object = o; m->key = k; m->attrib = a; m->next = m_hash[hash]; m_hash[hash] = m; m_attribs.add(a); //OID k2 = k; //if (k2.isName()) k2 = m_conn->protocol()->lookup(k2); //Add dependency Event *evt = new Event(Event::ADDDEP, o); evt->param<0>(k); evt->param<1>(OID::local() + OID(0,0,16,0)); evt->param<2>(m_attribs.size()-1); //evt->send(Event::FLAG_FREE); m_conn->protocol()->begin(); m_conn->protocol()->event(*evt, 0); m_conn->protocol()->end(); delete evt; } bool XNetHandler::handle(Event &evt) { //Implement caching here also... std::cout << "HANDLE XNET EVENT\n"; if (evt.dest() == OID::local()+OID(0,0,16,0)) { //std::cout << "CACHE notify\n"; //Okay, we have been updated. Attribute *a = m_attribs[(int)evt.param<0>()]; a->value = evt.param<3>(); //Or go get it. //Loop through the list of dependents and generate notify messages. Event *evt2; for (List::iterator i=a->deps.begin(); i!=a->deps.end(); i++) { a->deps.unique(*i); evt2 = new Event(Event::NOTIFY, (*i).object); evt2->param<0>((*i).key); evt2->param<1>(evt.dest()); evt2->param<2>(evt.param<0>()); evt2->param<3>(a->value); evt2->send(Event::FLAG_FREE); } a->deps.clear(); //Add dependency evt2 = new Event(Event::ADDDEP, evt.param<1>()); evt2->param<0>(evt.param<2>()); evt2->param<1>(evt.dest()); evt2->param<2>(evt.param<0>()); //if (evt.param<2>().isName()) evt.param<2>(m_conn->protocol()->lookup(evt.param<2>())); //evt2->send(Event::FLAG_FREE); m_conn->protocol()->begin(); m_conn->protocol()->event(*evt2, 0); m_conn->protocol()->end(); delete evt2; } else { if (evt.type() == Event::ADDDEP) { //std::cout << "CACHE adddep\n"; //Add to local dependency list Attribute *a = getAttrib(evt.dest(),evt.param<0>()); if (a == 0) { addAttrib(evt.dest(),evt.param<0>(), Null); a = getAttrib(evt.dest(),evt.param<0>()); } OIDPair pair; pair.object = evt.param<1>(); pair.key = evt.param<2>(); a->deps.addBack(pair); } else if (evt.type() == Event::GET) { Attribute *a = getAttrib(evt.dest(), evt.param<0>()); if (a == 0) { //std::cout << "CACHE get, slow\n"; m_conn->protocol()->begin(); int id = m_conn->protocol()->event(evt, XNetProtocol::EFLAG_WAITRESULT); m_conn->protocol()->end(); while (m_conn->protocol()->wait(id)) { //Processor::processRemaining(); XNetConnection::update(); } evt.result(m_conn->protocol()->getResult(id)); addAttrib(evt.dest(), evt.param<0>(), evt.result()); } else { //std::cout << "CACHE get, fast\n"; evt.result(a->value); } } else if (evt.type() == Event::GET_KEYS) { Object *o = getObject(evt.dest()); if (o == 0) { //std::cout << "CACHE get, slow\n"; m_conn->protocol()->begin(); int id = m_conn->protocol()->event(evt, XNetProtocol::EFLAG_WAITRESULT); m_conn->protocol()->end(); while (m_conn->protocol()->wait(id)) { //Processor::processRemaining(); XNetConnection::update(); } evt.result(m_conn->protocol()->getResult(id)); addObject(evt.dest(), evt.result()); } else { //std::cout << "CACHE get, fast\n"; evt.result(Buffer::create(o->keys.data(), o->keys.size())); } } else { //std::cout << "CACHE other\n"; m_conn->protocol()->begin(); int id = m_conn->protocol()->event(evt, 0); m_conn->protocol()->end(); //Block for result if needed. /*if (evt.type() == Event::GET_KEYS) { while (m_conn->protocol()->wait(id)) { //std::cout << "waiting on " << id << "\n"; //Processor::processRemaining(); XNetConnection::update(); } evt.result(m_conn->protocol()->getResult(id)); }*/ } } return true; /*m_conn->protocol()->begin(); int id = m_conn->protocol()->event(evt, (evt.type() == Event::GET || evt.type() == Event::GET_KEYS) ? XNetProtocol::EFLAG_WAITRESULT : 0); m_conn->protocol()->end(); //Block for result if needed. if (evt.type() == Event::GET || evt.type() == Event::GET_KEYS) { while (m_conn->protocol()->wait(id)) { //Processor::processInstant(); XNetConnection::update(); } evt.result(m_conn->protocol()->getResult(id)); } return true;*/ //Use a true local object for cache data, re-route the event. //Filter events and use or modify the local cache. //Pass all other events to the relevant XNetConnection. //bool conncb = false; /*XNetConnection *conn = XNetConnection::lookup(evt.dest()); switch (evt.type()) { //route to local cache object and pass to network also. case Event::SET: evt.dest(conn->local()); Handler::route(evt); conn->sendEvent(evt); return true; case Event::NOTIFY: case Event::ADDDEP: case Event::DEFINE: case Event::DEFINE_FUNC: case Event::DEFINE_AGENT: if (conn->ssDependency()) { evt.dest(conn->local()); Handler::route(evt); } else { conn->sendEvent(evt); } return true; case Event::GET: case Event::GET_KEYS: evt.dest(conn->local()); Handler::route(evt); //if (evt.result() == Null) { // conn->sendEvent(evt, conncb); //Must wait for result. // while (!conncb) { //Should only do current queue, no queue change. // Processor::process(); // } //} return true; default: return false; }*/ //return true; } wgd-3.1/src/xnet/xnetconnection.cpp0000644000175000001440000002532411265575474014410 00000000000000#include "xnetconnection.h" #include "xnetprotocol.h" #include "xnethandler.h" #include #include #ifndef WIN32 #include #include #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #endif #undef ERROR using namespace doste; using namespace doste::dvm; XNetConnection *XNetConnection::s_conns[MAX_CONNECTIONS] = {0}; OID XNetConnection::s_base; //#ifndef WIN32 //pthread_t XNetConnection::s_thread; //#else //HANDLE XNetConnection::s_thread; //#endif bool XNetConnection::s_running = false; bool XNetConnection::s_server = false; int XNetConnection::s_sd; fd_set XNetConnection::s_fdread; fd_set XNetConnection::s_fderror; sockaddr_in XNetConnection::s_localAddr; OnEvent(XNetConnection, evt_connect) { //DMsg dbg(DMsg::DEBUG); //dbg << "evt_connected: " << get("address") << ", " << get("port") << ", " << get("connect") << "\n"; if (XNetConnection::connect()) { if (m_socket >= 0) { //#ifdef LINUX //fcntl(m_socket, F_SETFL, O_NONBLOCK); //#endif //Send handshake data. //protocol()->begin(); //protocol()->local(OID::local()); //protocol()->end(); } else { if (!_connect(address(),port())) { DMsg err(DMsg::ERROR); err << "XNetConnection: Failed to connect to '" << (const char*)address() << ":" << port() << "'\n"; return; } protocol()->begin(); protocol()->login(username(), password()); protocol()->end(); } } else { //Disconnect #ifndef WIN32 close(m_socket); #else closesocket(m_socket); #endif m_socket = -1; } } IMPLEMENT_EVENTS(XNetConnection, Agent); XNetConnection::XNetConnection(const OID &o) : Agent(o) { m_local = o; m_socket = -1; m_bpos = 0; m_handler = 0; m_bufsize = 10000; m_buffer = new char[10000]; std::cout << "NEW LOCAL CONNECTION\n"; m_proto = new XNetProtocol(this); registerEvents(); } XNetConnection::XNetConnection(const OID &o, int sck) : Agent(o) { m_local = o; m_socket = sck; m_bpos = 0; m_handler = 0; m_bufsize = 10000; m_buffer = new char[10000]; std::cout << "NEW REMOTE CONNECTION\n"; //#ifdef LINUX //fcntl(m_socket, F_SETFL, O_NONBLOCK); //#endif m_proto = new XNetProtocol(this); connect(true); registerEvents(); } XNetConnection::~XNetConnection() { #ifndef WIN32 close(m_socket); #else closesocket(m_socket); #endif delete m_buffer; delete m_proto; if (m_handler != 0) delete m_handler; } XNetConnection *XNetConnection::lookup(const OID &o) { for (int i=0; ilocal() == o) { return s_conns[i]; } } return 0; } void XNetConnection::xhandler(const OID &base) { m_handler = new XNetHandler(this, base); } void XNetConnection::stop() { s_running = false; for (int i=0; isock()); #else if (s_conns[i]) closesocket(s_conns[i]->sock()); #endif } //#ifndef WIN32 //pthread_join(s_thread, 0); //#else //#endif for (int i=0; im_socket = csock; //Save the ip address #ifdef WIN32 strcpy(newcon->m_addr, inet_ntoa(remoteAddr.sin_addr)); #else strcpy(newcon->m_addr, inet_ntoa(remoteAddr.sin_addr)); #endif return true; } int XNetConnection::setDescriptors() { //Reset all file descriptors FD_ZERO(&s_fdread); FD_ZERO(&s_fderror); int n = 0; //Set file descriptor for the listening socket. if (s_server) { FD_SET(s_sd, &s_fdread); FD_SET(s_sd, &s_fderror); n = s_sd; } //Set the file descriptors for each client for (int i=0; isock() != INVALID_SOCKET) { #else if (s_conns[i] && s_conns[i]->sock() >= 0) { #endif if (s_conns[i]->sock() > n) { n = s_conns[i]->sock(); } FD_SET(s_conns[i]->sock(), &s_fdread); FD_SET(s_conns[i]->sock(), &s_fderror); } } return n; } //#ifndef WIN32 //void *XNetConnection::listen_thread(void *p) { //#else //DWORD XNetConnection::listen_thread(void *p) { //#endif void XNetConnection::update() { timeval block; int n; int selres = 1; //std::cout << "Thread Started\n"; if (!s_running) return; while (true) { n = setDescriptors(); //Wait for a network event or timeout in 3 seconds block.tv_sec = 0; block.tv_usec = 0; selres = select(n+1, &s_fdread, 0, &s_fderror, &block); //Exit loop if connection termination requested. //if (!s_running) { // break; //} //Some kind of error occured, it is usually possible to recover from this. if (selres <= 0) { //DMsg msg(DMsg::WARNING); //msg << "XNet: Select error.\n"; return; } //If connection request is waiting if (s_server) { if (FD_ISSET(s_sd, &s_fdread)) { if (!acceptConnections()) { return; } } } //Also check each clients socket to see if any messages or errors are waiting for (int i=0; isock() != INVALID_SOCKET) { #else if (s_conns[i] && s_conns[i]->sock() >= 0) { #endif //If message received from this client then deal with it if (FD_ISSET(s_conns[i]->sock(), &s_fdread)) { s_conns[i]->data(); //An error occured with this client. } else if (FD_ISSET(s_conns[i]->sock(), &s_fderror)) { s_conns[i]->error(); } } } } return; } void XNetConnection::send(const char *data, int length) { if (::send(m_socket, data, length,0) != length) { DMsg msg(DMsg::WARNING); msg << "A message did not send properly\n"; } } bool XNetConnection::data() { //Read data from socket int rc = 1; XNet_Header *header = (XNet_Header*)m_buffer; //Read header //Read expected number of bytes... //If there is more then read again. //while (rc > 0) { rc = recv(m_socket, m_buffer, sizeof(XNet_Header), 0); if (rc != sizeof(XNet_Header)) { //break; rc = -1; } rc = recv(m_socket, m_buffer+sizeof(XNet_Header), header->size - sizeof(XNet_Header), 0); if (rc != header->size - sizeof(XNet_Header)) { //break; rc = -1; } m_proto->data(m_buffer, header->size); //} if (rc <= 0) { std::cout << "XNet: Disconnected.\n"; #ifndef WIN32 close(m_socket); #else closesocket(m_socket); #endif m_socket = INVALID_SOCKET; return false; } //Did we disconnect. //if (rc != 0 && rc != SOCKET_ERROR) { //while (rc > 0) { // rc = recv(m_socket, &m_buffer[m_bpos], m_bufsize-1-m_bpos, 0); // //Send to protocol for processing // m_bpos += rc; // m_buffer[m_bpos] = 0; //} /*if (count == 0) { std::cout << "XNet: Disconnected.\n"; #ifndef WIN32 close(m_socket); #else closesocket(m_socket); #endif m_socket = INVALID_SOCKET; return false;*/ //}// else { // m_proto->data(m_buffer, m_bpos); //} return true; } void XNetConnection::error() { } bool XNetConnection::_connect(const char *addr, int port) { int rc; sockaddr_in destAddr; //DMsg dbg(DMsg::DEBUG); //dbg << "XnetConnection: Connecting to '" << addr << ":" << port << "'\n"; #ifdef WIN32 WSAData wsaData; if (WSAStartup(MAKEWORD(1,1), &wsaData) != 0) { //ERROR return false; } #endif //We want a TCP socket m_socket = socket(AF_INET, SOCK_STREAM, 0); if (m_socket == INVALID_SOCKET) { return false; } #ifdef WIN32 HOSTENT *host = gethostbyname(addr); #else hostent *host = gethostbyname(addr); #endif destAddr.sin_family = AF_INET; destAddr.sin_addr.s_addr = ((in_addr *)(host->h_addr))->s_addr; destAddr.sin_port = htons(port); rc = ::connect(m_socket, (struct sockaddr*)&destAddr, sizeof(destAddr)); if (rc == SOCKET_ERROR) { #ifndef WIN32 close(m_socket); #else closesocket(m_socket); #endif return false; } int freeclient = -1; //Find a free client slot and allocated it for (int i=0; ibegin(); protocol()->local(OID::local()); protocol()->end(); return true; } wgd-3.1/src/heightmap/0000777000175000001440000000000011265576313011705 500000000000000wgd-3.1/src/heightmap/Makefile.am0000644000175000001440000000054711027200203013635 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_heightmap.so libwgd_heightmap_so_SOURCES=heightmap.cpp iheightmap.cpp hmimagesource.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -L../resources_base -L../base_3d -shared -lGL -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base -lwgd_base3d INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/heightmap/hmimagesource.cpp0000644000175000001440000001017411233311614015142 00000000000000#include using namespace wgd; using namespace doste; using namespace doste::dvm; HMImageSource::HMImageSource(doste::File* heights) : HeightmapSource(), m_image(0), m_default(0) { m_valid = true; file(heights); } HMImageSource::HMImageSource(const OID &o) : HeightmapSource(o), m_image(0), m_default(0) { m_valid = true; } HMImageSource::~HMImageSource() { if (m_image != 0) delete m_image; if (m_default != 0) delete m_default; } void HMImageSource::begin() { //buffer variable m_repeat = repeat(); if (m_image == 0 && m_valid) { buildImage(); } if (m_default == 0 && !m_repeat) { buildDefault(); } } void HMImageSource::end() { } HMRegion *HMImageSource::region(int x, int y) { if(m_repeat) return m_image; else if (x == 0 && y == 0 && m_image != 0) return m_image; else return m_default; } void HMImageSource::buildDefault() { if (regionSize() == 0) { regionSize(128); } HMData data; data.size = (regionSize()+1) * (regionSize()+1); data.heights = new float[data.size]; data.nMat = 0; data.materials = 0; data.material = get(ix::material); for (int i=0; i(file()); if (l == 0) { m_valid = false; Error(0, "HMImageSource must have a valid texture file"); return; } if (!l->load()) { m_valid = false; return; } if (l->width() != l->height()) { Error(0, "A heightmap image must be square."); m_valid = false; return; } if (countBits(l->width()) != 1) { Error(0, "A heightmap image must be a power of 2."); m_valid = false; return; } //Now have an array of bytes... HMData data; regionSize(l->width()); data.size = (regionSize()+1) * (regionSize()+1); int size2 = regionSize() * regionSize(); int j = 0; data.heights = new float[data.size]; data.material = get(ix::material); // int index; int bpp = (l->format() == RGBA) ? 4 : 3; for (int i=0; idata()[i*bpp]); //Leave a gap for extra row if((i % regionSize()) == (regionSize()-1)) j++; } //test - smoothing to reduce artefacts int rs = regionSize() + 1; for(int i=0; i0) h+= data.heights[i-1 + k*rs]; else h+=h2; if(i0) h+= data.heights[i + (k-1)*rs]; else h+=h2; if(k temp; int i=0; OID matid; OID mats = get(ix::materials); if (mats != Null) { while (true) { matid = mats.get(i++); if (matid == Null) break; temp.push_back(matid); } data.nMat = temp.size(); data.materials = new Material*[temp.size()]; for (i=0; i> i) & 1; } return count; } float HMImageSource::convertData(char *data) { //For now assume r component only return (float)(unsigned char)data[0] / 128.0f; } wgd-3.1/src/heightmap/Makefile.in0000644000175000001440000003045211265575054013673 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_heightmap.so$(EXEEXT) subdir = src/heightmap DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_heightmap_so_OBJECTS = heightmap.$(OBJEXT) \ iheightmap.$(OBJEXT) hmimagesource.$(OBJEXT) libwgd_heightmap_so_OBJECTS = $(am_libwgd_heightmap_so_OBJECTS) libwgd_heightmap_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_heightmap_so_SOURCES) DIST_SOURCES = $(libwgd_heightmap_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_heightmap_so_SOURCES = heightmap.cpp iheightmap.cpp hmimagesource.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -L../resources_base -L../base_3d -shared -lGL -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base -lwgd_base3d INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/heightmap/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/heightmap/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_heightmap.so$(EXEEXT): $(libwgd_heightmap_so_OBJECTS) $(libwgd_heightmap_so_DEPENDENCIES) @rm -f libwgd_heightmap.so$(EXEEXT) $(CXXLINK) $(libwgd_heightmap_so_OBJECTS) $(libwgd_heightmap_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/heightmap/heightmap.cpp0000644000175000001440000004616011233311614014264 00000000000000#include #include #include #include #include #ifdef LINUX template T max(T a, T b) { return (a>b) ? a : b; } #endif using namespace wgd; //Code for the height map regions HMRegion::HMRegion(HMData *data, HMPadding *padding, int size) : m_VBO(0), m_patchSize(0), m_tree(0), m_patches(0), m_spatCoord(0) { //create vertex array m_size = size; m_vertices = new vertex[data->size]; for(int i=0; isize; i++){ m_vertices[i].x = (float) (i % (size+1)); m_vertices[i].y = data->heights[i]; m_vertices[i].z = (float) (i / (size+1)); //regionwide texture coordinates m_vertices[i].u = m_vertices[i].x / size; m_vertices[i].v = m_vertices[i].z / size; } delete [] data->heights; calculateNormals( padding ); //Save textures m_baseMaterial = data->material; m_splatMaterial = data->materials; m_splatCount = data->nMat; //build VBO if (Extensions::hasVBO()) { WGDglGenBuffersARB( 1, &m_VBO); WGDglBindBufferARB( GL_ARRAY_BUFFER_ARB, m_VBO ); WGDglBufferDataARB( GL_ARRAY_BUFFER_ARB, data->size * sizeof(vertex), m_vertices, GL_STATIC_DRAW_ARB ); WGDglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0); } } HMRegion::~HMRegion(){ int count = m_size/m_patchSize; for(int i=0; i0){ int nVertices = (m_size+1)*(m_size+1); m_spatCoord = new GLTexCoord[nVertices]; for(int i=0; im_size) x=m_size; if(y>m_size) y=m_size; int loc = x + y*(m_size+1); return m_vertices[loc].y; } vector3d HMRegion::normal(int x, int y) const { int loc = x + y*(m_size+1); return vector3d(&m_vertices[loc].nx); } int HMRegion::nodeCount(int patchSize){ int i=1, count=1; int size = m_size; while(size > patchSize) { i <<= 2; //multiply by 4 for each level count += i; size >>= 1; //divide by 2 for next level } return count; } int HMRegion::levels(int patchSize){ int i=0; while(patchSize > 0) { i++; patchSize >>= 1; } return i; } float HMRegion::calcError(int patchSize, int x, int y, int level){ int step = 1<left) v1 = vector3d(-1.0, padding->left[i / width], 0.0); v2 = vector3d(-1.0, m_vertices[i+1].y, 0.0); } else if(i % width >= m_size) { v1 = vector3d(-1.0, m_vertices[i-1].y, 0.0); if(padding && padding->right) v2 = vector3d( 1.0, padding->right[i / width], 0.0); } else { v1 = vector3d(-1.0, m_vertices[i-1].y, 0.0); v2 = vector3d( 1.0, m_vertices[i+1].y, 0.0); } //up and down if(i / width == 0) { if(padding && padding->top) v3 = vector3d(0.0, padding->top[i % width], -1.0); v4 = vector3d(0.0, m_vertices[i+width].y, 1.0); } else if(i / width >= m_size) { v3 = vector3d(0.0, m_vertices[i-width].y, -1.0); if(padding && padding->bottom) v4 = vector3d(0.0, padding->bottom[i % width], 1.0); } else { v3 = vector3d(0.0, m_vertices[i-width].y, -1.0); v4 = vector3d(0.0, m_vertices[i+width].y, 1.0); } //calculate four normals vector3d n1, n2, n3, n4; n1 = vector3d::crossProduct(v1-v, v2-v); n2 = vector3d::crossProduct(v2-v, v3-v); n3 = vector3d::crossProduct(v3-v, v4-v); n4 = vector3d::crossProduct(v4-v, v1-v); //clear data if a vertex is undefined if(n1.y>=0.0){ n1.x=0; n1.y=0; n1.z=0; } if(n2.y>=0.0){ n2.x=0; n2.y=0; n2.z=0; } if(n3.y>=0.0){ n3.x=0; n3.y=0; n3.z=0; } if(n4.y>=0.0){ n4.x=0; n4.y=0; n4.z=0; } //get average normal v = (n1+n2+n3+n4).normalise(); m_vertices[i].nx = -v.x; m_vertices[i].ny = -v.y; m_vertices[i].nz = -v.z; //Tangents are relatively simple (may be backwards) vector3d tangent = vector3d::crossProduct(vector3d(0.0, 0.0, 1.0), v) ; m_vertices[i].tx = tangent.x; m_vertices[i].ty = tangent.y; m_vertices[i].tz = tangent.z; } } vector2d HMRegion::calcBoxR(int node, int x, int y, int size){ vector2d box, tmp; // x = min, y = max; int halfSize = size >> 1; if(size > m_patchSize){ //recurse through quadtree if not a leaf node to get higher level boxes box = calcBoxR((node << 2) + 1, x, y + halfSize, halfSize); //bottom left tmp = calcBoxR((node << 2) + 2, x+halfSize, y + halfSize, halfSize); //bottom right if(tmp.xbox.y) box.y=tmp.y; tmp = calcBoxR((node << 2) + 3, x, y, halfSize); //top left if(tmp.xbox.y) box.y=tmp.y; tmp = calcBoxR((node << 2) + 4, x+halfSize, y, halfSize); //top right if(tmp.xbox.y) box.y=tmp.y; } else { //Calculate min and max from vertex data box.x = box.y = height(x, y); for(int i=0; i<=size; i++){ for(int j=0; j<=size; j++){ float h = height(x+i, y+j); if(hbox.y) box.y = h; } } //save node index in this patch patch(x / size, y / size)->node = node; } m_tree[node].min = box.x; m_tree[node].max = box.y; return box; } void HMRegion::clip(Camera3D *cam, const vector3d &scale, const vector3d &pos, int rx, int ry){ m_rx = rx; m_ry = ry; m_scale = scale; m_pos = pos; clipR(cam, 0, 0, 0, m_size, 0x7e); } void HMRegion::clipR(Camera3D *cam, int node, int x, int y, int size, int parent){ //Do clipping tests here int flags = m_tree[node].clipFlags; //int lastFlags = flags; - for stopping if no change - causes problems //if parent was all in, so are its children if(parent & 0x1) flags = 0x7f; //if parent all out, so are children else if(parent==0) flags = 0; //if parent intersects, need to retest else { vector3d low, high; low.x = (m_rx*m_size + x) * m_scale.x; low.y = m_tree[node].min * m_scale.y; low.z = (m_ry*m_size + y) * m_scale.z; high.x = (m_rx*m_size + x + size) * m_scale.x; high.y = m_tree[node].max * m_scale.y; high.z = (m_ry*m_size + y + size) * m_scale.z; flags = cam->insideFrustum(low+m_pos, high+m_pos); } //save flags m_tree[node].clipFlags = flags; //stop here if node is all out if(flags==0) return; //we can also stop if all in and no change //if(flags==lastFlags && (flags & 0x1)) return; //recurse through quadtree if not a leaf node int halfSize = size >> 1; if(size > m_patchSize){ clipR(cam, (node << 2) + 1, x, y + halfSize, halfSize, flags); //bottom left clipR(cam, (node << 2) + 2, x+halfSize, y + halfSize, halfSize, flags); //bottom right clipR(cam, (node << 2) + 3, x, y, halfSize, flags); //top left clipR(cam, (node << 2) + 4, x+halfSize, y, halfSize, flags); //top right } } void HMRegion::setLevels(Camera3D *cam, const wgd::vector3d &scale, float errorMetric){ m_errorMetric = errorMetric; m_scale = scale; m_camFar = cam->farclip(); m_camPos = cam->position(); setLevelsR(0, 0, 0, m_size); } void HMRegion::setLevelsR(int node, int x, int y, int size){ if(m_tree[node].clipFlags==0) return; int halfSize = size >> 1; //calculate distance from camera (of the node centre) vector3d centre; centre.x = (m_rx*m_size + x + halfSize) * m_scale.x; centre.y = ((m_tree[node].min + m_tree[node].max) / 2) * m_scale.y; centre.z = (m_ry*m_size + y + halfSize) * m_scale.z; m_tree[node].distance = m_camPos.distance(centre); if(size > m_patchSize){ //recurse through quadtree if not a leaf node setLevelsR((node << 2) + 1, x, y + halfSize, halfSize); //bottom left setLevelsR((node << 2) + 2, x+halfSize, y + halfSize, halfSize); //bottom right setLevelsR((node << 2) + 3, x, y, halfSize); //top left setLevelsR((node << 2) + 4, x+halfSize, y, halfSize); //top right } else { //get patch at this leaf node Patch *p = patch(x / m_patchSize, y / m_patchSize); //initialise mip level int level = m_levels-1; //calculate mip level from the log of the distance from the camera float farclip = m_camFar * 0.8f; float dist = m_tree[node].distance; int distanceScale = (m_patchSize * (int)(farclip - dist)) / (int)farclip; while(distanceScale>0){ level--; distanceScale >>= 1; } //calculate mip level from the screen distortion error metric //use this if it allows a higher mip level dist *= m_errorMetric; for(int i=m_levels-1; i>=0; i--) { if(p->error[i] * m_scale.y <= dist){ if(i>level) level = i; break; } } //Set the new level if(level<0) level=0; if(level!=p->level){ p->level=level; p->changed = true; } } } // Height and normals of a point // float HMRegion::height(float x, float y) const { int lx = (int)floor(x); int lz = (int)floor(y); //fractions float dx = x - lx; float dz = y - lz; //four spot heights float h1 = height(lx, lz); float h2 = height(lx, lz+1); float h3 = height(lx+1, lz); float h4 = height(lx+1, lz+1); //heights on z plane h1 = h1 + (h2-h1) * dz; h2 = h3 + (h4-h3) * dz; //final point plus heightmap position return h1 + (h2-h1) * dx; } vector3d HMRegion::normal(float x, float y) const { int lx = (int)floor(x); int lz = (int)floor(y); //fractions float dx = x - lx; float dz = y - lz; //four vertex normals vector3d n1 = normal(lx, lz); vector3d n2 = normal(lx, lz+1); vector3d n3 = normal(lx+1, lz); vector3d n4 = normal(lx+1, lz+1); ///normals on z plane n1 = n1 + (n2-n1) * dz; n2 = n3 + (n4-n3) * dz; //final normal return n1 + (n2-n1) * dx; } bool HMRegion::intersect(vector3d& point, const wgd::vector3d &start, const wgd::vector3d &end) { /*//draw full line glDisable(GL_LIGHTING); glDisable(GL_TEXTURE_2D); glColor3f(0.0, 1.0, 0.0); glBegin(GL_LINES); glVertex3f(start.x, start.y, start.z); glVertex3f(end.x, end.y, end.z); glColor3f(0.0, 0.8f, 0.8f); glEnd();//*/ bool r = intersectPatches(point, start, end); //glColor3f(1.0, 1.0, 1.0); //glEnable(GL_LIGHTING); return r; } bool HMRegion::intersectPatches(wgd::vector3d &point, const wgd::vector3d &start, const wgd::vector3d &end) { //re-written version - to try and fix a problem! vector3d d = end - start; //direction vector3d a, b; //per-test start and end points vector3d inc; //increment int patchCount = m_size / m_patchSize; //The algorithm is different depending on line orientation if (fabs(d.x) < fabs(d.z)) { //major axis: Z =========================== inc.x = d.x / d.z; inc.y = d.y / d.z; inc.z = 1.0; if(d.z < 0) inc = inc * -1; //adjust for start position if(inc.z < 0) a = start - inc * ( ceil(start.z / m_patchSize) * m_patchSize - start.z ); else a = start - inc * ( start.z - floor(start.z / m_patchSize) * m_patchSize ); inc = inc * (float)m_patchSize; int limit = (int)( d.length() / inc.length() + 1 ); for(int i=0; i0) pz--; //dont go off the edge if(px >= patchCount) px = patchCount-1; if(pz >= patchCount) pz = patchCount-1; //get the node of this patch int n = patch(px, pz)->node; int n2 = n; //may need to also use adjacent node x+-1 if(inc.x>0) { if(px < patchCount-1 && a.x - px*m_patchSize > m_patchSize-inc.x) n2 = patch(px+1, pz)->node; } else { if(px > 0 && px*m_patchSize - a.x > inc.x) n2 = patch(px-1, pz)->node; } //outer limits of patches n and n2 float min = (m_tree[n].min < m_tree[n2].min)? m_tree[n].min : m_tree[n2].min; float max = (m_tree[n].max > m_tree[n2].max)? m_tree[n].max : m_tree[n2].max; /*/more debug lines glBegin(GL_LINES); glVertex3f(a.x, max, a.z); glVertex3f(a.x, min, a.z); glVertex3f(b.x, max, b.z); glVertex3f(b.x, min, b.z); // glVertex3f(a.x, max, a.z); glVertex3f(b.x, max, b.z); glEnd();//*/ //test with geometry if inside patch bounds if(!(a.y > max && b.y > max) && !(a.y < min && b.y < min)) { if(i==0 && intersectPolygons(point, start, b)) return true; else if(intersectPolygons(point, a, b)) return true; } //next test a = b; } } else { //Major axis: X ========================================= inc.x = 1.0; inc.y = d.y / d.x; inc.z = d.z / d.x; if (d.x < 0) inc = inc * -1; //adjust for start position if(inc.x < 0) a = start - inc * ( ceil(start.x / m_patchSize) * m_patchSize - start.x ); else a = start - inc * ( start.x - floor(start.x / m_patchSize) * m_patchSize ); inc = inc * (float)m_patchSize; int limit = (int)( d.length() / inc.length() + 1 ); for(int i=0; i0) px--; //dont go off the edge if(px >= patchCount) px = patchCount-1; if(pz >= patchCount) pz = patchCount-1; //patch node int n = patch(px, pz)->node; int n2 = n; //may need to also use adjacent node x+-1 if(inc.z>0) { if(pz < patchCount-1 && a.z - pz*m_patchSize > m_patchSize-inc.z) n2 = patch(px, pz+1)->node; } else { if(pz > 0 && pz*m_patchSize-a.z > inc.z) n2 = patch(px, pz-1)->node; } //outer limits of patches n and n2 float min = (m_tree[n].min < m_tree[n2].min)? m_tree[n].min : m_tree[n2].min; float max = (m_tree[n].max > m_tree[n2].max)? m_tree[n].max : m_tree[n2].max; /*/more debug lines glBegin(GL_LINES); glVertex3f(a.x, max, a.z); glVertex3f(a.x, min, a.z); glVertex3f(b.x, max, b.z); glVertex3f(b.x, min, b.z); // glVertex3f(a.x, max, a.z); glVertex3f(b.x, max, b.z); glEnd();//*/ //test with geometry if inside patch bounds if(!(a.y > max && b.y > max) && !(a.y < min && b.y < min)) { if(i==0 && intersectPolygons(point, start, b)) return true; else if(intersectPolygons(point, a, b)) return true; } //next test a = b; } } //no intersection return false; } bool HMRegion::intersectPolygons(wgd::vector3d &point, const wgd::vector3d &start, const wgd::vector3d &end) { /*//DEBUG: Draw the line segment glColor3f(1.0, 1.0, 0.0); glLineWidth(2.0f); glBegin(GL_LINES); glVertex3f(start.x, start.y, start.z); glVertex3f(end.x, end.y, end.z); glEnd(); glLineWidth(1.0f); //*/ //Temporary information vector3d d = end - start; vector3d p = start; vector3d inc; //Is the start point above or below the heightmap? if(start.x < 0 || start.x >= m_size || start.z < 0 || start.z >= m_size) { //std::cout << "Invalid test\n"; return false; } bool above = height(start.x, start.z) >= start.y; //Get increment in each dimension if (fabs(d.x) < fabs(d.z)) { inc.x = d.x / d.z; inc.y = d.y / d.z; inc.z = 1.0; if(d.z < 0) inc = inc * -1; //find the first edge if(p.z != floor(p.z)){ if(inc.z > 0) p += inc * (ceil(p.z) - p.z); else p+= inc * (p.z - floor(p.z)); } } else { inc.x = 1.0; inc.y = d.y / d.x; inc.z = d.z / d.x; if (d.x < 0) inc = inc * -1; //find the first edge if(p.x != floor(p.x)){ if(inc.x > 0) p += inc * (ceil(p.x) - p.x); else p+= inc * (p.x - floor(p.x)); } } //number of steps until the end of the line segment int limit = (int)( d.length() / inc.length() + 2 ); //Trace along the ray while(limit-- > 0) { //make sure the point is inside the region (it should be) if(p.x < 0 || p.x >= m_size || p.z < 0 || p.z >= m_size) { //std::cout << "Test outside region\n"; } else { //Stop if the intersection is between this point and the last one! if((height(p.x, p.z) >= p.y) != above) break; } //next test position p += inc; } //if we reached the end of the segment if(limit<0) return false; //get the actual intersection point float h1 = (p.y-inc.y) - height(p.x-inc.x, p.z-inc.z); float h2 = height(p.x, p.z) - p.y; point = p - inc * (1 / (1 + h1/h2)); return true; } wgd-3.1/src/heightmap/iheightmap.cpp0000644000175000001440000004325611233311614014440 00000000000000#include #include #include #include #include #include using namespace doste; extern "C" void HEIGHTMAPIMPORT initialise(const doste::dvm::OID &base) { Object::registerType(); Object::registerType(); Object::registerType(); } extern "C" void HEIGHTMAPIMPORT finalise() { } using namespace wgd; IHeightmap::IHeightmap(HeightmapSource* src) : Instance3D(), m_regionSize(0) { set(ix::type, type()); if(get(ix::scale)==Null) scale(1.0f); if(get("splatscale")==Null) splatScale(8.0f); if(get("fade")==Null) fade(3.0f * patchSize()); source(src); } IHeightmap::IHeightmap(const OID& id) : Instance3D(id), m_regionSize(0) { if(get(ix::scale)==Null) scale(1.0f); if(get("splatscale")==Null) splatScale(8.0f); if(get("fade")==Null) fade(3.0f * patchSize()); } IHeightmap::~IHeightmap(){} void IHeightmap::errorMetric(float fovY, int viewHeight){ float halfFov; float vlod = lod(); if(vlod<=0) vlod = 4.0f; if(fovY >= 180.0f) fovY = 179.99f; else if(fovY < 0.0) fovY = 0.0; halfFov = fovY * (float)PI / 360.0f; m_errorMetric = (float)(tan(halfFov) / (float)viewHeight) * vlod; } void IHeightmap::draw(SceneGraph &graph, Camera3D *camera) { //update fps WGD[ix::widgets][ix::root][ix::children][ix::height][ix::children]["fps"]["draw"].set(dvm::Void); //begin heightmap operations m_source = source(); m_source->begin(); //info m_polys = 0; m_maxError = 0.0; m_count=0; //local data for this draw loop m_regionSize = m_source->regionSize(); m_patchSize = patchSize(); if(m_patchSize==0) m_patchSize = 16; m_patches = m_regionSize / m_patchSize; m_splatScale = splatScale(); errorMetric(camera->fov(), camera->height()); m_farClip = camera->farclip(); m_fade = fade(); m_scale = scale(); if(wireframe()) glPolygonMode(GL_FRONT, GL_LINE); //Setup gl client state glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnable(GL_NORMALIZE); //draw infinite regions vector3d ctr = camera->position() / m_scale; int rx = (int)floor(ctr.x / m_regionSize); //the region containing the camera int ry = (int)floor(ctr.z / m_regionSize); int visx = (int)ceil(m_farClip / (m_regionSize * m_scale.x)); //maximum number of visible patches in any direction int visz = (int)ceil(m_farClip / (m_regionSize * m_scale.z)); //draw regions for(int i=rx-visx; i<=rx+visx; i++) { for(int j=ry-visz; j<=ry+visz; j++) { drawRegion(camera, i, j); } } glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); if(wireframe()) glPolygonMode(GL_FRONT, GL_FILL); //end heightmap operations m_source->end(); //output info OID l = WGD[ix::widgets][ix::root][ix::children][ix::height][ix::children]["label"][ix::caption].get(); l.set(8, m_polys); l.set(22, m_maxError * m_scale.y); l.set(35, m_count); l.set(37, m_patches * m_patches * 9); } void IHeightmap::drawRegion(Camera3D *camera, int rx, int ry) { //Will asynchronously load the region if it is not in memory HMRegion *region = source()->region(rx, ry); if(!region) return; //setup patches region->setup(m_patchSize, m_splatScale); vector3d pos = position(); //clip patches (HMRegion) region->clip(camera, m_scale, pos, rx, ry); //exit here if region is completely off sreen if(region->node(0).clipFlags==0) return; //set mip levels (HMRegion) region->setLevels(camera, m_scale, m_errorMetric); //draw patches (IHeightmap) glPushMatrix(); glTranslatef(pos.x, pos.y, pos.z); glScalef(m_scale.x, m_scale.y, m_scale.z); glTranslatef((float)rx * m_regionSize, 0.0, (float)ry * m_regionSize); //Set up pointers if(region->vbo()) { WGDglBindBufferARB( GL_ARRAY_BUFFER_ARB, region->vbo() ); glVertexPointer( 3, GL_FLOAT, sizeof(vertex), (void*) 0); glNormalPointer( GL_FLOAT, sizeof(vertex), (void*) (3 * sizeof(float))); glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (void*) (6 * sizeof(float))); WGDglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 ); } else { float *p = ®ion->vertices()[0].x; //p is 0 if using VBO glVertexPointer(3, GL_FLOAT, sizeof(vertex), p); glNormalPointer( GL_FLOAT, sizeof(vertex), p+3); glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), p+6); } //recursively draw all visible patches with base material Material *mbase = region->baseMaterial(); if(mbase) mbase->bind(); drawPatchR(region, rx, ry, 0, 0, 0, m_regionSize); if(mbase) mbase->unbind(); //Set up openGL for texture splatting if(m_fade > 0.0) { WGDglClientActiveTextureARB(GL_TEXTURE1_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(GLTexCoord), region->splatCoord()); //recursively draw any texture splatting for(int i=0; isplatCount(); i++) { drawSplatR(region, i, rx, ry, 0, 0, 0, m_regionSize); region->splatMaterial(i)->unbind(); } //restore openGL stuff glDisableClientState(GL_TEXTURE_COORD_ARRAY); WGDglClientActiveTextureARB(GL_TEXTURE0_ARB); } /*/Debug output to test ray intersection vector3d p; bool hit=false; if(rx==0 && ry==0){ if((bool)WGD[ix::input][ix::keyboard][ix::keys]['o'].get()) { vs = camera->position(); ve = vs + vector3d().translate(camera->quaternion().conjugate(), vector3d(0.0, 0.0, -512.0)); } hit = intersect(p, vs, ve); }//*/// glPopMatrix(); //if(hit && get("sprite")!=Null) Render::sprite(get("sprite"), 0, p); } //get a patch using absolute patch coordinates (from any region) wgd::Patch *IHeightmap::patch(int x, int y) { //ger region of patch int rx = (int)floor((float)x / m_patches); int ry = (int)floor((float)y / m_patches); //This should load the region asynchronously if not already loaded HMRegion *region = m_source->region(rx, ry); region->setup(m_patchSize, m_splatScale); //get patch int px = x - rx * m_patches; int py = y - ry * m_patches; return region->patch(px, py); } unsigned int IHeightmap::glue(Patch *p, int x, int y){ int l[4]; //do null checking here if patch can return null l[0] = patch(x, y-1)->level; //top glue l[1] = patch(x, y+1)->level; //bottom glue l[2] = patch(x-1, y)->level; //left glue l[3] = patch(x+1, y)->level; //right glue unsigned int g = 0; if(p->level < l[0]) g |= l[0]; if(p->level < l[1]) g |= l[1]<<8; if(p->level < l[2]) g |= l[2]<<16; if(p->level < l[3]) g |= l[3]<<24; return g; } void IHeightmap::drawPatchR(HMRegion *region, int rx, int ry, int node, int x, int y, int size){ if(region->node(node).clipFlags==0) return; if(size > m_patchSize){ //recurse through quadtree if not a leaf node int halfSize = size >> 1; drawPatchR(region, rx, ry, (node << 2) + 1, x, y + halfSize, halfSize); //bottom left drawPatchR(region, rx, ry, (node << 2) + 2, x+halfSize, y + halfSize, halfSize); //bottom right drawPatchR(region, rx, ry, (node << 2) + 3, x, y, halfSize); //top left drawPatchR(region, rx, ry, (node << 2) + 4, x+halfSize, y, halfSize); //top right } else { //get the patch object int px = x / m_patchSize; int py = y / m_patchSize; Patch *p = region->patch(px, py); //See if glue has changed unsigned int g = glue(p, px + rx*m_patches, py + ry*m_patches); //rebuld patch if nesesary if(p->glue != g || p->changed) buildPatch(p, g); m_polys += p->nIndices / 3; m_maxError = max( p->error[p->level], m_maxError ); //Draw patch glDrawElements(GL_TRIANGLES, p->nIndices, GL_UNSIGNED_INT, p->indices); m_count++; } } void IHeightmap::drawSplatR(HMRegion *region, int splat, int rx, int ry, int node, int x, int y, int size){ if(region->node(node).clipFlags==0) return; //work out splat based on distance float d = region->node(node).distance; float scl = vector2d(m_scale.x, m_scale.z).length(); if(d - size*scl > m_fade) return; if(size > m_patchSize){ //recurse through quadtree if not a leaf node int halfSize = size >> 1; drawSplatR(region, splat, rx, ry, (node << 2) + 1, x, y + halfSize, halfSize); //bottom left drawSplatR(region, splat, rx, ry, (node << 2) + 2, x+halfSize, y + halfSize, halfSize); //bottom right drawSplatR(region, splat, rx, ry, (node << 2) + 3, x, y, halfSize); //top left drawSplatR(region, splat, rx, ry, (node << 2) + 4, x+halfSize, y, halfSize); //top right } else { //get the patch object int px = x / m_patchSize; int py = y / m_patchSize; Patch *p = region->patch(px, py); //drawing the splat texture region->splatMaterial(splat)->bind(); //aplha fro some nice fadey stuff float a = 1.0; //float c12 = m_farClip / 12, c8 = m_farClip / 8; //if(d > c12) a = 1.0f - (d-c12) / (c8-c12); float sfade = m_fade / 2; //fade start if(d > sfade) a = 1.0f - (d-sfade) / (m_fade - sfade); //fade amount GLfloat mat[4] = { 1.0, 1.0, 1.0, a }; //apply fade glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); //draw heightmap patch glDrawElements(GL_TRIANGLES, p->nIndices, GL_UNSIGNED_INT, p->indices); } } void IHeightmap::buildPatch(Patch *p, unsigned int g){ int step = 0x1 << p->level; p->nIndices = 0; p->changed = false; p->glue = g; if(!g){ //no glue - create entire patch with triangle strips for (int i = 0; i < m_patchSize; i+=step){ acrossStrip(p, i*(m_regionSize+1), m_patchSize, step); } } else { //draw central block using triangle strips for (int i = step; i < m_patchSize-step; i += step){ acrossStrip(p, i*(m_regionSize+1) + step, m_patchSize - 2*step, step); } //fill in borders with glue //top glue int tg = (g>>0) & 0xff; topGlue(p, (tg>0? tg: p->level)); //bottom glue int bg = (g>>8) & 0xff; bottomGlue(p, (bg>0? bg: p->level)); //left glue int lg = (g>>16) & 0xff; leftGlue(p, (lg>0? lg: p->level)); //Right glue int rg = (g>>24) & 0xff; rightGlue(p, (rg>0? rg: p->level)); } } void IHeightmap::acrossStrip(Patch *p, int start, int length, int step){ int &k = p->nIndices; int offset = p->offset; for(int i = start; i < start+length; i += step) { p->indices[k ] = offset + i; p->indices[k+1] = offset + i + (m_regionSize+1) * step; p->indices[k+2] = offset + i + step; //get the starting region p->indices[k+3] = offset + i + (m_regionSize+1) * step + step; p->indices[k+4] = p->indices[k+2]; p->indices[k+5] = p->indices[k+1]; k += 6; } } void IHeightmap::leftGlue(Patch *p, int nextLevel) { int &k = p->nIndices; int offset = p->offset; int min = 0x1 << p->level; int max = 0x1 << nextLevel; int p0=min, p1=2*min; for(int i=max; i<=m_patchSize; i+=max){ p->indices[k++] = offset + min + p0*(m_regionSize+1); p->indices[k++] = offset + (i-max)*(m_regionSize+1); p->indices[k++] = offset + i*(m_regionSize+1); for(; p0<(i) && p0<(m_patchSize-min); p1+=min){ p->indices[k++] = offset + i*(m_regionSize+1); p->indices[k++] = offset + min + p1*(m_regionSize+1); p->indices[k++] = offset + min + p0*(m_regionSize+1); p0=p1; } } } void IHeightmap::rightGlue (Patch *p, int nextLevel){ int &k = p->nIndices; int offset = p->offset; int min = 0x1 << p->level; int max = 0x1 << nextLevel; int p0=min, p1=2*min;//, n=0; for(int i=0; iindices[k++] = offset + m_patchSize + i*(m_regionSize+1); p->indices[k++] = offset + m_patchSize - min + p0*(m_regionSize+1); p->indices[k++] = offset + m_patchSize - min + p1*(m_regionSize+1); p0=p1; } p->indices[k++] = offset + m_patchSize + i*(m_regionSize+1); p->indices[k++] = offset + m_patchSize - min + p0*(m_regionSize+1); p->indices[k++] = offset + m_patchSize + (i+max)*(m_regionSize+1); } } void IHeightmap::topGlue(Patch *p, int nextLevel){ int &k = p->nIndices; int offset = p->offset; int min = 0x1 << p->level; int max = 0x1 << nextLevel; int p0=min, p1=2*min;//, n=0; for(int i=max; i<=m_patchSize; i+=max){ p->indices[k++] = offset + min*(m_regionSize+1)+p0; p->indices[k++] = offset + i; p->indices[k++] = offset + i-max; for(; p0<(i) && p0<(m_patchSize-min); p1+=min){ p->indices[k++] = offset + i; p->indices[k++] = offset + min*(m_regionSize+1)+p0; p->indices[k++] = offset + min*(m_regionSize+1)+p1; p0=p1; } } } void IHeightmap::bottomGlue (Patch *p, int nextLevel){ int &k = p->nIndices; int offset = p->offset; int min = 0x1 << p->level; int max = 0x1 << nextLevel; int p0=min, p1=2*min; int patchsq = m_patchSize*m_regionSize; for(int i=0; iindices[k++] = offset + patchsq + m_patchSize + i; p->indices[k++] = offset + (m_patchSize-min)*(m_regionSize+1)+p1; p->indices[k++] = offset + (m_patchSize-min)*(m_regionSize+1)+p0; p0=p1; } p->indices[k++] = offset + (m_patchSize-min)*(m_regionSize+1)+p0; p->indices[k++] = offset + patchsq + m_patchSize + i; p->indices[k++] = offset + patchsq + m_patchSize + i+max; } } float IHeightmap::height(const wgd::vector3d &v){ //in case local data has not been initialised yet if(!m_regionSize) m_regionSize = source()->regionSize(); //adjust for scale and offset vector3d pos = (v - position()) / scale(); //get the region int rx = (int)floor(pos.x / m_regionSize); int ry = (int)floor(pos.z / m_regionSize); HMRegion *r = source()->region(rx, ry); //Invalid region if(!r) return 0; //Get point in region coordinates pos.x -= rx * m_regionSize; pos.z -= ry * m_regionSize; //get spot height float h = r->height(pos.x, pos.z); //redo scale and offset h = h * scale().y + position().y; return h; } float IHeightmap::height(float x, float z) { return height(vector3d(x, 0.0, z)); } vector3d IHeightmap::normal(const wgd::vector3d &v){ //in case local data has not been initialised yet if(!m_regionSize) m_regionSize = source()->regionSize(); //adjust for scale and offset vector3d pos = (v - position()) / scale(); //get the region int rx = (int)floor(pos.x / m_regionSize); int ry = (int)floor(pos.z / m_regionSize); HMRegion *r = source()->region(rx, ry); //Invalid region - return zero value if(!r) return vector3d(); //Get point in region coordinates pos.x -= rx * m_regionSize; pos.z -= ry * m_regionSize; //get spot normal vector3d n = r->normal(pos.x, pos.z); return (n * scale()).normalise(); } bool IHeightmap::intersect(wgd::vector3d &result, const wgd::vector3d &start, const wgd::vector3d &end) { //in case local data has not been initialised yet //if(!m_regionSize) { m_scale = scale(); m_source = source(); m_regionSize = m_source->regionSize(); //} //work out which regions the line intersects then clip the line //to each region to test them individually //adjust for scale and offset vector3d tstart = (start - position()) / m_scale; vector3d tend = (end - position()) / m_scale; vector3d direction = (tend - tstart).normalise(); vector3d point = tstart; vector3d hit; //result temporary //get the ending region int ex = (int)floor(tend.x / m_regionSize); int ez = (int)floor(tend.z / m_regionSize); tend.x -= ex * m_regionSize; tend.z -= ez * m_regionSize; int rx, rz; //loop until we get to the ending region int count=0; do { //get current region rx = (int)floor(tstart.x / m_regionSize); rz = (int)floor(tstart.z / m_regionSize); //std::cout << "Testing region: (" << rx << ", " << rz << ")\n"; //translate to region coordinates vector3d rstart, rend; rstart.x = tstart.x - rx * m_regionSize; rstart.y = tstart.y; rstart.z = tstart.z - rz * m_regionSize; //get distance to edge of region float dx, dz; if(direction.x > 0) dx = fabs((m_regionSize - rstart.x) / direction.x); else if(direction.x < 0) dx = fabs(rstart.x / direction.x); else dx = 999999; if(direction.z > 0) dz = fabs((m_regionSize - rstart.z) / direction.z); else if(direction.z < 0) dz = fabs(rstart.z / direction.z); else dz = 999999; //end point if(rx==ex && rz==ez) rend = tend; else rend = rstart + direction * (dxregion(rx, rz); //Invalid region - return no intersection if(!r) return false; //test to see if the line segment is inside region bounding box to do the region intersect test HMRegion::HMNode &node = r->node(0); if(!(rstart.y > node.max && rend.y > node.max) && !(rstart.y < node.min && rend.y < node.min)) { if(r->intersect(hit, rstart, rend)) { //convert back to world coordinates hit.x += rx*m_regionSize; hit.z += rz*m_regionSize; result = hit * m_scale + position(); return true; } } //next start point - hopefully it will be in the next region... tstart += direction * ((dx 3) break; } while(rx!=ex || rz!=ez); //no intersection return false; } bool IHeightmap::ray(wgd::vector3d &result, const wgd::vector3d &point, const wgd::vector3d &direction) { //create a really long line segment - may be able to do this better return intersect(result, point, point + direction*5000); } wgd-3.1/src/base/0000777000175000001440000000000011265576313010651 500000000000000wgd-3.1/src/base/mouse.cpp0000644000175000001440000001250111233311615012403 00000000000000#include #include #include #include //If uses DMX //#include #define PIXELS_PER_SEC 3000.0f using namespace wgd; using namespace doste; using namespace doste::dvm; Button Mouse::BTN_LEFT; Button Mouse::BTN_RIGHT; Button Mouse::BTN_MIDDLE; int Mouse::s_wheel = 0; int Mouse::lastX; int Mouse::lastY; bool Mouse::s_vis = true; Mouse::Mouse(const OID &o) : Agent(o) { registerEvents(); if((*this)[ix::visible] == Null) set(ix::visible, true); if ((*this)[ix::buttons] == Null) { set(ix::buttons, OID::create()); } if ((*this)[ix::axes] == Null) { set(ix::axes, OID::create()); } if ((*this)[ix::axes][0] == Null) { (*this)[ix::axes][0] = OID::create(); } if ((*this)[ix::axes][1] == Null) { (*this)[ix::axes][1] = OID::create(); } BTN_LEFT = "left"; BTN_RIGHT = "right"; BTN_MIDDLE = "middle"; reset(); } Mouse::~Mouse() { } namespace wgd { OnEvent(Mouse, evt_cursor) { reset(); } OnEvent(Mouse, evt_visible) { reset(); } OnEvent(Mouse, evt_position) { int newX = x(); int newY = y(); if(lastX!=newX || lastY!=newY) { position(newX, newY); } } IMPLEMENT_EVENTS(Mouse, Agent); }; wgd::vector2d Mouse::position() { return vector2d(get(ix::x), get(ix::y)); } void Mouse::position(const wgd::vector2d &p) { position((int)p.x, (int)p.y); } void Mouse::position(int cx, int cy) { lastX = cx; lastY = cy; #ifdef WIN32 RECT rect; rect.top = 0; rect.left = 0; rect.right = 100; rect.bottom=100; if (!wgd::window->fullScreen()) { AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, false); } cx = (int)wgd::window->get(ix::x) + cx - rect.left; cy = (int)wgd::window->get(ix::y) + cy - rect.top; SetCursorPos(cx, cy); #elif LINUX XWarpPointer(wgd::window->getXDisplay(), 0, wgd::window->getXWindow(), 0, 0, 0, 0, cx, cy); #endif } void Mouse::reset() { #ifdef WIN32 if ((get(ix::cursor) == Null) && (visible())) { if(!s_vis) ShowCursor(true); s_vis = true; } else { if(s_vis) ShowCursor(false); s_vis=false; } #endif #ifdef LINUX Pixmap bm_no; Colormap cmap; Cursor no_ptr; XColor black, dummy; static char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0}; cmap = DefaultColormap(wgd::window->getXDisplay(), wgd::window->getXScreen()); XAllocNamedColor(wgd::window->getXDisplay(), cmap, "black", &black, &dummy); bm_no = XCreateBitmapFromData(wgd::window->getXDisplay(), wgd::window->getXWindow(), bm_no_data, 8, 8); no_ptr = XCreatePixmapCursor(wgd::window->getXDisplay(), bm_no, bm_no, &black, &black, 0, 0); if ((get(ix::cursor) == Null) && (visible())) XUndefineCursor(wgd::window->getXDisplay(), wgd::window->getXWindow()); else XDefineCursor(wgd::window->getXDisplay(), wgd::window->getXWindow(), no_ptr); XFreeCursor(wgd::window->getXDisplay(), no_ptr); if (bm_no != None) XFreePixmap(wgd::window->getXDisplay(), bm_no); XFreeColors(wgd::window->getXDisplay(), cmap, &black.pixel, 1, 0); #endif } void Mouse::btnDown(int btn) { switch(btn) { case 1: (*this)[ix::buttons][BTN_LEFT] = true; break; case 2: (*this)[ix::buttons][BTN_MIDDLE] = true; break; case 3: (*this)[ix::buttons][BTN_RIGHT] = true; break; // Linux treats button 4 as scroll wheel up and button 5 as scroll wheel down #ifdef LINUX case 4: wheel(-1); break; case 5: wheel(1); break; #else case 4: break; case 5: break; #endif case 6: break; default: break; } } void Mouse::btnUp(int btn) { switch(btn) { case 1: (*this)[ix::buttons][BTN_LEFT] = false; break; case 2: (*this)[ix::buttons][BTN_MIDDLE] = false; break; case 3: (*this)[ix::buttons][BTN_RIGHT] = false; break; case 4: break; case 5: break; case 6: break; default: break; } } int Mouse::bNo(const Button&b) const { if(b.isInt()) return b; if(b == BTN_LEFT) return 1; if(b == BTN_MIDDLE) return 2; if(b == BTN_RIGHT) return 3; return 0; } void Mouse::update() { //mouse wheel set(ix::deltaz, s_wheel); s_wheel=0; int newX, newY; #ifdef WIN32 POINT pnt; GetCursorPos(&pnt); RECT rect; rect.top = 0; rect.left = 0; rect.right = 100; rect.bottom=100; if (!wgd::window->fullScreen()) { AdjustWindowRect(&rect, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, false); } //update window position int wx = window->get(ix::x); int wy = window->get(ix::y); RECT wpos; GetWindowRect(window->getHWND(), &wpos); if(wx != wpos.left) window->set(ix::x, (int)wpos.left); if(wy != wpos.top) window->set(ix::y, (int)wpos.top); //calculate mouse position relative to the window newX = pnt.x + rect.left - wpos.left; newY = pnt.y + rect.top - wpos.top; #endif #ifdef LINUX Window wroot, wchild; int rx,ry; unsigned int mask; XQueryPointer( wgd::window->getXDisplay(), wgd::window->getXWindow(), &wroot, //Root Window &wchild,//Child Window &rx, //Root X &ry, //Root Y &newX, //Window X -- newX set here &newY, //Window Y -- newY set here &mask); //Mask #endif set(ix::deltax, newX - lastX, true); set(ix::deltay, newY - lastY); if (grab()) { position(lastX, lastY); } else { lastX = newX; lastY = newY; set(ix::x, lastX, true); set(ix::y, lastY); } //record last button states m_last[1] = pressed(BTN_LEFT); m_last[2] = pressed(BTN_MIDDLE); m_last[3] = pressed(BTN_RIGHT); bool moved = newX - lastX != 0 || newY - lastY != 0; for(int i=1; i<=3; i++) m_moved[i] = (m_last[i] && (moved || m_moved[i])); } wgd-3.1/src/base/window.cpp0000644000175000001440000003657211056217230012601 00000000000000/* * WGD Library * * Authors: * Date: 16/9/2007 * */ #include #include #include #include #include #include #ifdef WIN32 #include #endif #include #include #ifdef LINUX #include int attriblistAA4[] = { GLX_DEPTH_SIZE, 32, GLX_DOUBLEBUFFER, GLX_RGBA, GLX_SAMPLE_BUFFERS_ARB, GL_TRUE, GLX_SAMPLES_ARB, 4 , None }; int attriblistAA2[] = { GLX_DEPTH_SIZE, 32, GLX_DOUBLEBUFFER, GLX_RGBA, GLX_SAMPLE_BUFFERS_ARB, GL_TRUE, GLX_SAMPLES_ARB, 2 , None }; int attriblist[] = { GLX_DEPTH_SIZE, 32, GLX_DOUBLEBUFFER, GLX_RGBA, None }; #endif #ifdef WIN32 typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #define WGL_DRAW_TO_WINDOW_ARB 0x2001 #define WGL_ACCELERATION_ARB 0x2003 #define WGL_SUPPORT_OPENGL_ARB 0x2010 #define WGL_FULL_ACCELERATION_ARB 0x2027 #define WGL_COLOR_BITS_ARB 0x2014 #define WGL_ALPHA_BITS_ARB 0x201B #define WGL_STENCIL_BITS_ARB 0x2023 #define WGL_DEPTH_BITS_ARB 0x2022 #define WGL_DOUBLE_BUFFER_ARB 0x2011 #define WGL_SAMPLE_BUFFERS_ARB 0x2041 #define WGL_SAMPLES_ARB 0x2042 #endif #include #ifdef _MSC_VER #pragma warning(disable:4996) #endif using namespace wgd; using namespace doste; using namespace doste::dvm; #ifdef WIN32 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ //Use clicked window close button if (message == WM_CLOSE) { PostQuitMessage(0); } return DefWindowProc(hwnd, message, wParam, lParam); } #endif #undef True #undef False namespace wgd { OnEvent(GameWindow, evt_position) { } OnEvent(GameWindow, evt_size) { //cache window height m_height = get(ix::height); if (!m_init) { make(); return; }; //#ifdef LINUX //XResizeWindow(m_display, m_window, width(), height()); //#endif doste::Object::destroyAll(); wgd::window = ((OID)WGD["window"]); wgd::keyboard = ((OID)WGD["input"]["keyboard"]); wgd::mouse = ((OID)WGD["input"]["mouse"]); } OnEvent(GameWindow, evt_title) { if (!m_init) return; dstring ti(get(ix::title)); #ifdef LINUX XStoreName(m_display,m_window,ti); #endif #ifdef WIN32 SetWindowTextA(m_hWnd, ti); #endif } OnEvent(GameWindow, evt_draw) { //if (value == True) { //std::cout << "draw\n"; //draw(); //set("begindraw", false); //glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); //glLoadIdentity(); //} } IMPLEMENT_EVENTS(GameWindow, Agent); }; void wgd::GameWindow::make() { if (m_init == false) { #ifdef WIN32 //Default is to centre the window on the screen. DEVMODE dmod; EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dmod); if ((*this)["x"] == Null) { set("x", (int)((dmod.dmPelsWidth/2) - (width()/2))); } if ((*this)["y"] == Null) { set("y", (int)((dmod.dmPelsHeight/2) - (height()/2))); } #endif } #ifdef LINUX m_display = XOpenDisplay(0); if (m_display == 0) { //std::cerr << "Cannot open X11 display\n"; Error(0, "Cannot open X11 display"); return; } if (Processor::numProcessors() > 1) XLockDisplay(m_display); m_screen = DefaultScreen(m_display); //Get video modes XF86VidModeModeInfo **modes; int modeNum; int bestMode=0; if (fullScreen()) { XF86VidModeGetAllModeLines(m_display, m_screen, &modeNum, &modes); //Save desktop mode m_deskMode = *modes[0]; //Find the mode we want. for (int i=0; ihdisplay == width()) && (modes[i]->vdisplay == height())) { bestMode = i; } } } attriblistAA4[1] = depthBuffer(); attriblistAA2[1] = depthBuffer(); attriblist[1] = depthBuffer(); m_visual = 0; if ((int)get("sampling") == 4) m_visual = glXChooseVisual(m_display, m_screen, attriblistAA4); if (m_visual == 0 || get("sampling") == Null || (int)get("sampling") == 2) m_visual = glXChooseVisual(m_display, m_screen, attriblistAA2); if (m_visual == 0) m_visual = glXChooseVisual(m_display, m_screen, attriblist); if (m_visual == 0) { Error(0, dstring("You seem to be making an invalid window:") + "\n width = " + width() + "\n height = " + height() + "\n colourdepth = " + colourDepth() + "\n depthbuffer = " + depthBuffer() + "\n fullscreen = " + fullScreen()); return; } //Here we attempt to create a direct rendering opengl context (needed for shaders...). m_context = glXCreateContext(m_display, m_visual, 0, GL_TRUE); m_colormap = XCreateColormap(m_display, RootWindow(m_display, m_visual->screen), m_visual->visual, AllocNone); m_swa.colormap = m_colormap; m_swa.border_pixel = 0; m_swa.event_mask = ExposureMask | StructureNotifyMask | KeyReleaseMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask; if (fullScreen()) { XF86VidModeSwitchToMode(m_display, m_screen, modes[bestMode]); XF86VidModeSetViewPort(m_display, m_screen, 0, 0); m_swa.override_redirect = true; XFree(modes); } m_window = XCreateWindow( m_display, RootWindow(m_display,m_visual->screen), (fullScreen()) ? 0 : (int)get("x"), (fullScreen()) ? 0 : (int)get("y"), width(), height(), 0, m_visual->depth, InputOutput, m_visual->visual, CWBorderPixel|CWColormap|CWEventMask | ((fullScreen()) ? CWOverrideRedirect : 0), &m_swa); //Set the windows title XStoreName(m_display, m_window, title()); //Put window on the display. XMapWindow(m_display, m_window); if (fullScreen()) { XWarpPointer(m_display, None, m_window, 0, 0, 0, 0, 0, 0); XGrabKeyboard(m_display, m_window, true, GrabModeAsync, GrabModeAsync, CurrentTime); XGrabPointer(m_display, m_window, true, ButtonPressMask, GrabModeAsync, GrabModeAsync, m_window, None, CurrentTime); } m_makecontext = true; if (Processor::numProcessors() > 1) XUnlockDisplay(m_display); #endif #ifdef WIN32 WNDCLASS wc; m_hInst = GetModuleHandle(NULL); //Convert name and title to unicode wchar_t *wClassName = new wchar_t[4]; mbstowcs(wClassName, "wgd", 4); if(get(ix::title)==Null) set(ix::title, dstring("WGD-Lib v3")); int tLen = get(ix::title).get(ix::size); dstring title(get(ix::title)); wchar_t *wTitle = new wchar_t[tLen+1]; mbstowcs(wTitle, (const char*)title, tLen+1); if (m_init == false) { //register window class wc.style = CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = m_hInst;//GetCurrentProcess(); wc.hIcon = LoadIcon(m_hInst, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = (LPCWSTR)wClassName; RegisterClass(&wc); } if (fullScreen()) { DEVMODE screensettings; memset(&screensettings, 0, sizeof(screensettings)); screensettings.dmSize = sizeof(screensettings); screensettings.dmPelsWidth = width(); screensettings.dmPelsHeight = height(); screensettings.dmBitsPerPel = 24; //colourDepth(); screensettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; if (ChangeDisplaySettings(&screensettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { fullScreen(false); //wgd::cout << wgd::ERR << "Unable to change to fullscreen.\n"; } } RECT crect; crect.top = (int)get("y"); crect.left = (int)get("x"); crect.right = crect.left + width(); crect.bottom = crect.top + height(); if (!fullScreen()) { AdjustWindowRect(&crect, WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, false); } //Mouse::titleSize((int)get("y") - crect.top); m_hWnd = CreateWindow( (LPCWSTR)wClassName, (LPCWSTR)wTitle, ((fullScreen()) ? 0 : WS_CAPTION) | WS_POPUPWINDOW | WS_VISIBLE, ((fullScreen()) ? 0 : (int)get("x")), ((fullScreen()) ? 0 : (int)get("y")), crect.right-crect.left, crect.bottom-crect.top, NULL, NULL, m_hInst, NULL); m_hDC = GetDC(m_hWnd); //Set pixel format for the DC PIXELFORMATDESCRIPTOR pfd; ZeroMemory(&pfd, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = colourDepth(); pfd.cDepthBits = depthBuffer(); pfd.iLayerType = PFD_MAIN_PLANE; //if (m_hasmultisample) // SetPixelFormat(m_hDC, m_pixformat, &pfd); //else SetPixelFormat(m_hDC, ChoosePixelFormat(m_hDC, &pfd), &pfd); m_makecontext = true; #endif draw(); m_init = true; } void wgd::GameWindow::finaliseInternal() { #ifdef LINUX XLockDisplay(m_display); if (fullScreen()) { XF86VidModeSwitchToMode(m_display, m_screen, &m_deskMode); XF86VidModeSetViewPort(m_display, m_screen, 0, 0); } glXDestroyContext(m_display, m_context); XDestroyWindow(m_display,m_window); XCloseDisplay(m_display); #endif #ifdef WIN32 if (fullScreen()) { ChangeDisplaySettings(NULL, 0); } wglMakeCurrent(NULL, NULL); wglDeleteContext(m_hRC); ReleaseDC(m_hWnd, m_hDC); DestroyWindow(m_hWnd); //UnregisterClass("wgd", s_hInst); //s_hInst=NULL; #endif } /*void wgd::GameWindow::title(const char * ti) { dstring ti2(ti); WGD[ix::window].set(ix::title, ti2); } const char *wgd::GameWindow::title() { dstring ti(WGD[ix::window][ix::title]); return (char*)ti; }*/ void wgd::GameWindow::resolution(int width,int height) { set(ix::width, width); set(ix::height, height); } //void wgd::GameWindow::icon(const char*) { //} /*void wgd::GameWindow::clearColour(const Colour &c) { if (WGD[ix::window][ix::clearcolour] == Null) WGD[ix::window].set(ix::clearcolour, wgd::DB::createObject()); WGD[ix::window][ix::clearcolour].set(ix::r, c.r()); WGD[ix::window][ix::clearcolour].set(ix::g, c.g()); WGD[ix::window][ix::clearcolour].set(ix::b, c.b()); }*/ //Colour wgd::GameWindow::clearColour() { // return wgd::Colour(WGD[ix::window][ix::clearcolour][ix::r], WGD[ix::window][ix::clearcolour][ix::g], WGD[ix::window][ix::clearcolour][ix::b]); //} void wgd::GameWindow::position(int x,int y) { set(ix::x, x); set(ix::y, y); } void wgd::GameWindow::draw() { if (m_makecontext) { m_makecontext = false; #ifdef LINUX //We only ever have one context, so make it current. glXMakeCurrent(m_display, m_window, m_context); #endif #ifdef WIN32 //create render context (RC) m_hRC = wglCreateContext(m_hDC); if(!wglMakeCurrent(m_hDC, m_hRC)){ Error(0, "wgdMakeCurrent failed to work and gave the error " + (int)GetLastError()); return; } if (m_init == false) { //Check for multisample support. PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); int pixelFormat = 0; bool valid = false; UINT numFormats = 0; float fAttributes[] = {0,0}; if (wglChoosePixelFormatARB!=0) { // These Attributes Are The Bits We Want To Test For In Our Sample // Everything Is Pretty Standard, The Only One We Want To // Really Focus On Is The SAMPLE BUFFERS ARB And WGL SAMPLES // These Two Are Going To Do The Main Testing For Whether Or Not // We Support Multisampling On This Hardware int iAttributes[] = { WGL_DRAW_TO_WINDOW_ARB,GL_TRUE, WGL_SUPPORT_OPENGL_ARB,GL_TRUE, WGL_ACCELERATION_ARB,WGL_FULL_ACCELERATION_ARB, WGL_COLOR_BITS_ARB,24, WGL_ALPHA_BITS_ARB,8, WGL_DEPTH_BITS_ARB,16, WGL_STENCIL_BITS_ARB,0, WGL_DOUBLE_BUFFER_ARB,GL_TRUE, WGL_SAMPLE_BUFFERS_ARB,GL_TRUE, WGL_SAMPLES_ARB, 4 , // Check For 4x Multisampling 0,0}; //iAttributes[11] = depthBuffer(); //if ((int)WGD["fseffects"]["sample"] == 4) // // First We Check To See If We Can Get A Pixel Format For 4 Samples // valid = (wglChoosePixelFormatARB(s_hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats)) ? true : false; // Our Pixel Format With 4 Samples Failed, Test For 2 Samples //if (!valid || WGD["fseffects"]["sample"] == Null || (int)WGD["fseffects"]["sample"] == 2) { // iAttributes[19] = 2; // valid = (wglChoosePixelFormatARB(s_hDC,iAttributes,fAttributes,1,&pixelFormat,&numFormats)) ? true : false; //} } if (valid && numFormats >= 1) { finaliseInternal(); m_hasmultisample = true; m_init = true; m_pixformat = pixelFormat; //GameWindow::initialise(); return; } } #endif glClearColor( 0.0, 0.0, 0.0, 0.5f); glClear(GL_COLOR_BUFFER_BIT); glClearDepth(1.0f); // Depth buffer setup //glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); // Enables depth testing glDepthFunc(GL_LEQUAL); // The type of depth testing to do glCullFace(GL_BACK); //back face culling glEnable(GL_CULL_FACE); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really nice perspective calculations glEnable(GL_BLEND); // Enable alpha blending of textures glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); int glerr; if ((glerr = glGetError()) != 0) { Error(0, "An OpenGL error occured: " + glerr); } } //if (FSEffects::motionBlur() > 0.000001) { // wgd::cout << "MOTION\n"; // glAccum(GL_ACCUM, 1.f/5); // glAccum(GL_RETURN, 1.f); //} #ifdef LINUX glXSwapBuffers(m_display, m_window); #endif #ifdef WIN32 SwapBuffers(m_hDC); #endif glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glLoadIdentity(); } void wgd::GameWindow::defaults() { if ((*this)["width"] == Null) set("width", 800); if ((*this)["height"] == Null) set("height", 600); if ((*this)["colourdepth"] == Null) set("colourdepth", 32); if ((*this)["depthbuffer"] == Null) set("depthbuffer", 16); if ((*this)["title"] == Null) set("title", DString("WGD Default Title")); } wgd::GameWindow::GameWindow(const OID &o) : Agent(o), m_init(false), m_makecontext(false) { #ifdef LINUX if (Processor::numProcessors() > 1) XInitThreads(); #endif //Set defaults. defaults(); registerEvents(); //make(); } wgd::GameWindow::~GameWindow() { finaliseInternal(); } /*void wgd::GameWindow::evtClearCol(DOSTE_HANDLER) { glClearColor( (float)WGD[ix::window][ix::clearcolour][ix::r], (float)WGD[ix::window][ix::clearcolour][ix::g], (float)WGD[ix::window][ix::clearcolour][ix::b], 0.5f); }*/ /*void wgd::GameWindow::evtResolution(DOSTE_HANDLER) { if (s_hasinit) { if (validRes()) { if ((int)id == 3 && (bool)value == false) { #ifdef LINUX XF86VidModeSwitchToMode(s_display, s_screen, &s_deskMode); XF86VidModeSetViewPort(s_display, s_screen, 0, 0); #else ChangeDisplaySettings(NULL, 0); #endif } Resource::destroyAll(); finaliseInternal(); initialise(); //Lighting::initialise(); Shader::current(0); Lighting::reset(); Mouse::reset(); FSEffects::reset(); } else { wgd::cout << wgd::WARN << "Invalid resolution " << width() << "x" << height() << "\n"; } } }*/ /*bool wgd::GameWindow::validRes() { int w = width(); int h = height(); int c = colourDepth(); if (c != 16 && c != 32) return false; for (int i=0; i<100; i++) { if (WGD[ix::window][ix::resolutions][i] == Null) break; if ((int)WGD[ix::window][ix::resolutions][i][ix::width] == w && (int)WGD[ix::window][ix::resolutions][i][ix::height] == h) return true; } return false; }*/ /*void wgd::GameWindow::evtTitle(DOSTE_HANDLER) { if (s_hasinit) { dstring ti(value); #ifdef LINUX XStoreName(s_display,s_window,(char*)ti); #endif #ifdef WIN32 SetWindowTextA(s_hWnd, (char*)ti); #endif } }*/ wgd-3.1/src/base/Makefile.am0000644000175000001440000000044211027212730012603 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_base.so libwgd_base_so_SOURCES=base.cpp window.cpp index.cpp extensions.cpp input.cpp mouse.cpp matrix.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=--shared -lGL -lX11 -lXxf86vm -ldoste INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/base/matrix.cpp0000644000175000001440000000621411233311615012563 00000000000000#include using namespace wgd; bool matrix::fastInverse(matrix & dest, const matrix& src){ // 6*8+2*6 = 60 multiplications // 2*1 = 2 divisions float r0[2][2], r1[2][2], r2[2][2], r3[2][2]; float a, det, invDet; // r0 = m0.Inverse(); det = src.m[0][0] * src.m[1][1] - src.m[0][1] * src.m[1][0]; if ( fabs( det ) < 1e-14 ) { return false; } invDet = 1.0f / det; r0[0][0] = src.m[1][1] * invDet; r0[0][1] = - src.m[0][1] * invDet; r0[1][0] = - src.m[1][0] * invDet; r0[1][1] = src.m[0][0] * invDet; // r1 = r0 * m1; r1[0][0] = r0[0][0] * src.m[0][2] + r0[0][1] * src.m[1][2]; r1[0][1] = r0[0][0] * src.m[0][3] + r0[0][1] * src.m[1][3]; r1[1][0] = r0[1][0] * src.m[0][2] + r0[1][1] * src.m[1][2]; r1[1][1] = r0[1][0] * src.m[0][3] + r0[1][1] * src.m[1][3]; // r2 = m2 * r1; r2[0][0] = src.m[2][0] * r1[0][0] + src.m[2][1] * r1[1][0]; r2[0][1] = src.m[2][0] * r1[0][1] + src.m[2][1] * r1[1][1]; r2[1][0] = src.m[3][0] * r1[0][0] + src.m[3][1] * r1[1][0]; r2[1][1] = src.m[3][0] * r1[0][1] + src.m[3][1] * r1[1][1]; // r3 = r2 - m3; r3[0][0] = r2[0][0] - src.m[2][2]; r3[0][1] = r2[0][1] - src.m[2][3]; r3[1][0] = r2[1][0] - src.m[3][2]; r3[1][1] = r2[1][1] - src.m[3][3]; // r3.InverseSelf(); det = r3[0][0] * r3[1][1] - r3[0][1] * r3[1][0]; if ( fabs( det ) < 1e-14 ) { return false; } invDet = 1.0f / det; a = r3[0][0]; r3[0][0] = r3[1][1] * invDet; r3[0][1] = - r3[0][1] * invDet; r3[1][0] = - r3[1][0] * invDet; r3[1][1] = a * invDet; // r2 = m2 * r0; r2[0][0] = src.m[2][0] * r0[0][0] + src.m[2][1] * r0[1][0]; r2[0][1] = src.m[2][0] * r0[0][1] + src.m[2][1] * r0[1][1]; r2[1][0] = src.m[3][0] * r0[0][0] + src.m[3][1] * r0[1][0]; r2[1][1] = src.m[3][0] * r0[0][1] + src.m[3][1] * r0[1][1]; // FILL DESTINATION MATRIX // // m2 = r3 * r2; dest.m[2][0] = r3[0][0] * r2[0][0] + r3[0][1] * r2[1][0]; dest.m[2][1] = r3[0][0] * r2[0][1] + r3[0][1] * r2[1][1]; dest.m[3][0] = r3[1][0] * r2[0][0] + r3[1][1] * r2[1][0]; dest.m[3][1] = r3[1][0] * r2[0][1] + r3[1][1] * r2[1][1]; // m0 = r0 - r1 * m2; dest.m[0][0] = r0[0][0] - r1[0][0] * dest.m[2][0] - r1[0][1] * dest.m[3][0]; dest.m[0][1] = r0[0][1] - r1[0][0] * dest.m[2][1] - r1[0][1] * dest.m[3][1]; dest.m[1][0] = r0[1][0] - r1[1][0] * dest.m[2][0] - r1[1][1] * dest.m[3][0]; dest.m[1][1] = r0[1][1] - r1[1][0] * dest.m[2][1] - r1[1][1] * dest.m[3][1]; // m1 = r1 * r3; dest.m[0][2] = r1[0][0] * r3[0][0] + r1[0][1] * r3[1][0]; dest.m[0][3] = r1[0][0] * r3[0][1] + r1[0][1] * r3[1][1]; dest.m[1][2] = r1[1][0] * r3[0][0] + r1[1][1] * r3[1][0]; dest.m[1][3] = r1[1][0] * r3[0][1] + r1[1][1] * r3[1][1]; // m3 = -r3; dest.m[2][2] = -r3[0][0]; dest.m[2][3] = -r3[0][1]; dest.m[3][2] = -r3[1][0]; dest.m[3][3] = -r3[1][1]; return true; } matrix::matrix(const vector3d &tangent, const vector3d &binormal, const vector3d &normal) { m[0][0] = tangent.x; m[0][1] = tangent.y; m[0][2] = tangent.z; m[0][3] = 0; m[1][0] = binormal.x; m[1][1] = binormal.y; m[1][2] = binormal.z; m[1][3] = 0; m[2][0] = normal.x; m[2][1] = normal.y; m[2][2] = normal.z; m[2][3] = 0; m[3][0] = 0; m[3][1] = 0; m[3][2] = 0; m[3][3] = 1.0f; } wgd-3.1/src/base/extensions.cpp0000644000175000001440000004421611026705647013476 00000000000000#include #include #ifdef WIN32 #include #endif #include #include #include using namespace wgd; using namespace doste; bool Extensions::s_multitex = false; bool Extensions::s_texcompress = false; bool Extensions::s_shaders = false; bool Extensions::s_sse = false; bool Extensions::s_mmx = false; bool Extensions::s_framebuf = false; bool Extensions::s_halffloat = false; bool Extensions::s_multisample = false; bool Extensions::s_vbo = false; bool Extensions::s_colorbuf = false; BASEIMPORT PFNGLACTIVETEXTUREARBPROC WGDglActiveTextureARB = 0; BASEIMPORT PFNGLMULTITEXCOORD2FARBPROC WGDglMultiTexCoord2fARB = 0; BASEIMPORT PFNGLCLIENTACTIVETEXTUREARBPROC WGDglClientActiveTextureARB = 0; //#endif //#ifndef HAVE_GLCOMPRESSTEXTURE BASEIMPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC WGDglCompressedTexImage3DARB = 0; BASEIMPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC WGDglCompressedTexImage2DARB = 0; BASEIMPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC WGDglCompressedTexImage1DARB = 0; BASEIMPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC WGDglCompressedTexSubImage3DARB = 0; BASEIMPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC WGDglCompressedTexSubImage2DARB = 0; BASEIMPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC WGDglCompressedTexSubImage1DARB = 0; BASEIMPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC WGDglGetCompressedTexImageARB = 0; BASEIMPORT PFNGLCREATESHADERPROC WGDglCreateShader = 0; BASEIMPORT PFNGLSHADERSOURCEPROC WGDglShaderSource = 0; BASEIMPORT PFNGLCOMPILESHADERPROC WGDglCompileShader = 0; BASEIMPORT PFNGLCREATEPROGRAMPROC WGDglCreateProgram = 0; BASEIMPORT PFNGLATTACHSHADERPROC WGDglAttachShader = 0; BASEIMPORT PFNGLLINKPROGRAMPROC WGDglLinkProgram = 0; BASEIMPORT PFNGLGETPROGRAMIVPROC WGDglGetProgramiv = 0; BASEIMPORT PFNGLGETSHADERIVPROC WGDglGetShaderiv = 0; BASEIMPORT PFNGLGETPROGRAMINFOLOGPROC WGDglGetProgramInfoLog = 0; BASEIMPORT PFNGLGETSHADERINFOLOGPROC WGDglGetShaderInfoLog = 0; BASEIMPORT PFNGLISPROGRAMPROC WGDglIsProgram = 0; BASEIMPORT PFNGLGETUNIFORMLOCATIONPROC WGDglGetUniformLocation = 0; BASEIMPORT PFNGLGETATTRIBLOCATIONPROC WGDglGetAttribLocation = 0; BASEIMPORT PFNGLUSEPROGRAMPROC WGDglUseProgram = 0; BASEIMPORT PFNGLUNIFORM1FVPROC WGDglUniform1fv = 0; BASEIMPORT PFNGLUNIFORM1FPROC WGDglUniform1f = 0; BASEIMPORT PFNGLUNIFORM2FPROC WGDglUniform2f = 0; BASEIMPORT PFNGLUNIFORM3FPROC WGDglUniform3f = 0; BASEIMPORT PFNGLUNIFORM4FPROC WGDglUniform4f = 0; BASEIMPORT PFNGLUNIFORM1IVPROC WGDglUniform1iv = 0; BASEIMPORT PFNGLUNIFORM1IPROC WGDglUniform1i = 0; BASEIMPORT PFNGLVERTEXATTRIB1FVPROC WGDglVertexAttrib1fv = 0; BASEIMPORT PFNGLVERTEXATTRIB1FPROC WGDglVertexAttrib1f = 0; BASEIMPORT PFNGLVERTEXATTRIB2FPROC WGDglVertexAttrib2f = 0; BASEIMPORT PFNGLVERTEXATTRIB3FPROC WGDglVertexAttrib3f = 0; BASEIMPORT PFNGLVERTEXATTRIB4FPROC WGDglVertexAttrib4f = 0; BASEIMPORT PFNGLBINDATTRIBLOCATIONPROC WGDglBindAttribLocation = 0; BASEIMPORT PFNGLENABLEVERTEXATTRIBARRAYPROC WGDglEnableVertexAttribArray = 0; BASEIMPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC WGDglDisableVertexAttribArray = 0; BASEIMPORT PFNGLVERTEXATTRIBPOINTERPROC WGDglVertexAttribPointer = 0; BASEIMPORT PFNGLDELETESHADERPROC WGDglDeleteShader = 0; BASEIMPORT PFNGLDELETEPROGRAMPROC WGDglDeleteProgram = 0; BASEIMPORT PFNGLPOINTPARAMETERFVPROC WGDglPointParameterfv = 0; BASEIMPORT PFNGLPOINTPARAMETERFPROC WGDglPointParameterf = 0; BASEIMPORT PFNGLGENBUFFERSARBPROC WGDglGenBuffersARB = 0; // VBO Name Generation Procedure BASEIMPORT PFNGLBINDBUFFERARBPROC WGDglBindBufferARB = 0; // VBO Bind Procedure BASEIMPORT PFNGLBUFFERDATAARBPROC WGDglBufferDataARB = 0; // VBO Data Loading Procedure BASEIMPORT PFNGLDELETEBUFFERSARBPROC WGDglDeleteBuffersARB = 0; // VBO Deletion Procedure BASEIMPORT PFNGLGENRENDERBUFFERSEXTPROC WGDglGenRenderbuffersEXT = 0; BASEIMPORT PFNGLBINDFRAMEBUFFEREXTPROC WGDglBindFramebufferEXT = 0; BASEIMPORT PFNGLBINDRENDERBUFFEREXTPROC WGDglBindRenderbufferEXT = 0; BASEIMPORT PFNGLDELETEFRAMEBUFFERSEXTPROC WGDglDeleteFramebuffersEXT = 0; BASEIMPORT PFNGLDELETERENDERBUFFERSEXTPROC WGDglDeleteRenderbuffersEXT = 0; BASEIMPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC WGDglFramebufferRenderbufferEXT = 0; BASEIMPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC WGDglFramebufferTexture2DEXT = 0; BASEIMPORT PFNGLGENFRAMEBUFFERSEXTPROC WGDglGenFramebuffersEXT = 0; BASEIMPORT PFNGLRENDERBUFFERSTORAGEEXTPROC WGDglRenderbufferStorageEXT = 0; BASEIMPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC WGDglCheckFramebufferStatusEXT = 0; BASEIMPORT PFNGLCLAMPCOLORARBPROC WGDglClampColorARB=0; void Extensions::initialise() { char *ext = (char*)glGetString(GL_EXTENSIONS); if (ext == 0) return; if (strstr(ext, "GL_ARB_texture_compression")) s_texcompress = true; if (strstr(ext, "GL_ARB_multitexture")) s_multitex = true; if (strstr(ext, "GL_EXT_framebuffer_object")) s_framebuf = true; if (strstr(ext, "GL_ARB_half_float_pixel")) s_halffloat = true; if (strstr(ext, "GL_ARB_multisample")) s_multisample = true; if (strstr(ext, "GL_ARB_vertex_shader")) s_shaders = true; if (strstr(ext, "GL_ARB_vertex_buffer_object")) s_vbo = true; if (strstr(ext, "GL_ARB_color_buffer_float")) s_colorbuf = true; SCpuidRegs regs; getCpuid(1,regs); s_sse = (regs.edx & 0x01000000) ? true : false; //Do we have SSE instructions s_mmx = (regs.edx & 0x00400000) ? true : false; //Do we have MMX instructions if (s_shaders) Info(0,"We have shaders"); if (s_framebuf) Info(0,"We have framebuffers"); if (s_halffloat) Info(0,"We have half-float"); //Multi-texturing #ifdef WIN32 WGDglActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB"); WGDglMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB"); WGDglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB"); #endif /* Get the OpenGL ARB extention function pointers if they exist */ #ifdef LINUX //#ifndef HAVE_GLMULTITEXTURE WGDglActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)glXGetProcAddress((const GLubyte*)"glActiveTextureARB"); WGDglMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)glXGetProcAddress((const GLubyte*)"glMultiTexCoord2fARB"); WGDglClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)glXGetProcAddress((const GLubyte*)"glClientActiveTextureARB"); //#endif #endif //Texture Compression #ifdef WIN32 /* ARB_texture_compression */ //glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)wglGetProcAddress("glCompressedTexImage3DARB"); WGDglCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)wglGetProcAddress("glCompressedTexImage2DARB"); //glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)wglGetProcAddress("glCompressedTexImage1DARB"); //glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)wglGetProcAddress("glCompressedTexSubImage3DARB"); //glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)wglGetProcAddress("glCompressedTexSubImage2DARB"); //glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)wglGetProcAddress("glCompressedTexSubImage1DARB"); WGDglGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)wglGetProcAddress("glGetCompressedTexImageARB"); #endif #ifdef LINUX //#ifndef HAVE_GLCOMPRESSTEXTURE /* ARB_texture_compression */ //glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)wglGetProcAddress("glCompressedTexImage3DARB"); WGDglCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)glXGetProcAddress((const GLubyte*)"glCompressedTexImage2DARB"); //glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)wglGetProcAddress("glCompressedTexImage1DARB"); //glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)wglGetProcAddress("glCompressedTexSubImage3DARB"); //glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)wglGetProcAddress("glCompressedTexSubImage2DARB"); //glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)wglGetProcAddress("glCompressedTexSubImage1DARB"); WGDglGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)glXGetProcAddress((const GLubyte*)"glGetCompressedTexImageARB"); //#endif #endif //Shader #ifdef WIN32 WGDglCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress("glCreateShader"); WGDglShaderSource = (PFNGLSHADERSOURCEPROC) wglGetProcAddress("glShaderSource"); WGDglCompileShader = (PFNGLCOMPILESHADERPROC) wglGetProcAddress("glCompileShader"); WGDglCreateProgram = (PFNGLCREATEPROGRAMPROC) wglGetProcAddress("glCreateProgram"); WGDglAttachShader = (PFNGLATTACHSHADERPROC) wglGetProcAddress("glAttachShader"); WGDglLinkProgram = (PFNGLLINKPROGRAMPROC) wglGetProcAddress("glLinkProgram"); WGDglGetProgramiv = (PFNGLGETPROGRAMIVPROC) wglGetProcAddress("glGetProgramiv"); WGDglGetShaderiv = (PFNGLGETSHADERIVPROC) wglGetProcAddress("glGetShaderiv"); WGDglIsProgram = (PFNGLISPROGRAMPROC) wglGetProcAddress("glIsProgram"); WGDglGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) wglGetProcAddress("glGetProgramInfoLog"); WGDglGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) wglGetProcAddress("glGetShaderInfoLog"); WGDglGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) wglGetProcAddress("glGetUniformLocation"); WGDglGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) wglGetProcAddress("glGetAttribLocation"); WGDglUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress("glUseProgram"); WGDglUniform1fv = (PFNGLUNIFORM1FVPROC) wglGetProcAddress("glUniform1fv"); WGDglUniform1f = (PFNGLUNIFORM1FPROC) wglGetProcAddress("glUniform1f"); WGDglUniform2f = (PFNGLUNIFORM2FPROC) wglGetProcAddress("glUniform2f"); WGDglUniform3f = (PFNGLUNIFORM3FPROC) wglGetProcAddress("glUniform3f"); WGDglUniform4f = (PFNGLUNIFORM4FPROC) wglGetProcAddress("glUniform4f"); WGDglUniform1iv = (PFNGLUNIFORM1IVPROC) wglGetProcAddress("glUniform1iv"); WGDglUniform1i = (PFNGLUNIFORM1IPROC) wglGetProcAddress("glUniform1i"); WGDglVertexAttrib1fv= (PFNGLVERTEXATTRIB1FVPROC) wglGetProcAddress("glVertexAttrib1fv"); WGDglVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) wglGetProcAddress("glVertexAttrib1f"); WGDglVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) wglGetProcAddress("glVertexAttrib2f"); WGDglVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) wglGetProcAddress("glVertexAttrib3f"); WGDglVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) wglGetProcAddress("glVertexAttrib4f"); WGDglBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) wglGetProcAddress("glBindAttribLocation"); WGDglEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress("glEnableVertexAttribArray"); WGDglDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress("glDisableVertexAttribArray"); WGDglVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) wglGetProcAddress("glVertexAttribPointer"); WGDglDeleteShader = (PFNGLDELETESHADERPROC) wglGetProcAddress("glDeleteShader"); WGDglDeleteProgram = (PFNGLDELETEPROGRAMPROC) wglGetProcAddress("glDeleteProgram"); #endif #ifdef LINUX WGDglCreateShader = (PFNGLCREATESHADERPROC) glXGetProcAddress((unsigned char*)"glCreateShader"); WGDglShaderSource = (PFNGLSHADERSOURCEPROC) glXGetProcAddress((unsigned char*)"glShaderSource"); WGDglCompileShader = (PFNGLCOMPILESHADERPROC) glXGetProcAddress((unsigned char*)"glCompileShader"); if (WGDglCreateShader == 0) { s_shaders = false; } WGDglCreateProgram = (PFNGLCREATEPROGRAMPROC) glXGetProcAddress((unsigned char*)"glCreateProgram"); WGDglAttachShader = (PFNGLATTACHSHADERPROC) glXGetProcAddress((unsigned char*)"glAttachShader"); WGDglLinkProgram = (PFNGLLINKPROGRAMPROC) glXGetProcAddress((unsigned char*)"glLinkProgram"); WGDglGetProgramiv = (PFNGLGETPROGRAMIVPROC) glXGetProcAddress((unsigned char*)"glGetProgramiv"); WGDglGetShaderiv = (PFNGLGETSHADERIVPROC) glXGetProcAddress((unsigned char*)"glGetShaderiv"); WGDglIsProgram = (PFNGLISPROGRAMPROC) glXGetProcAddress((unsigned char*)"glIsProgram"); WGDglGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) glXGetProcAddress((unsigned char*)"glGetProgramInfoLog"); WGDglGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) glXGetProcAddress((unsigned char*)"glGetShaderInfoLog"); WGDglGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) glXGetProcAddress((unsigned char*)"glGetUniformLocation"); WGDglGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) glXGetProcAddress((unsigned char*)"glGetAttribLocation"); WGDglUseProgram = (PFNGLUSEPROGRAMPROC) glXGetProcAddress((unsigned char*)"glUseProgram"); WGDglUniform1fv = (PFNGLUNIFORM1FVPROC) glXGetProcAddress((unsigned char*)"glUniform1fv"); WGDglUniform1f = (PFNGLUNIFORM1FPROC) glXGetProcAddress((unsigned char*)"glUniform1f"); WGDglUniform2f = (PFNGLUNIFORM2FPROC) glXGetProcAddress((unsigned char*)"glUniform2f"); WGDglUniform3f = (PFNGLUNIFORM3FPROC) glXGetProcAddress((unsigned char*)"glUniform3f"); WGDglUniform4f = (PFNGLUNIFORM4FPROC) glXGetProcAddress((unsigned char*)"glUniform4f"); WGDglUniform1iv = (PFNGLUNIFORM1IVPROC) glXGetProcAddress((unsigned char*)"glUniform1iv"); WGDglUniform1i = (PFNGLUNIFORM1IPROC) glXGetProcAddress((unsigned char*)"glUniform1i"); WGDglVertexAttrib1fv= (PFNGLVERTEXATTRIB1FVPROC) glXGetProcAddress((unsigned char*)"glVertexAttrib1fv"); WGDglVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) glXGetProcAddress((unsigned char*)"glVertexAttrib1f"); WGDglVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) glXGetProcAddress((unsigned char*)"glVertexAttrib2f"); WGDglVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) glXGetProcAddress((unsigned char*)"glVertexAttrib3f"); WGDglVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) glXGetProcAddress((unsigned char*)"glVertexAttrib4f"); WGDglBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) glXGetProcAddress((unsigned char*)"glBindAttribLocation"); WGDglEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) glXGetProcAddress((unsigned char*)"glEnableVertexAttribArray"); WGDglDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)glXGetProcAddress((unsigned char*)"glDisableVertexAttribArray"); WGDglVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) glXGetProcAddress((unsigned char*)"glVertexAttribPointer"); WGDglDeleteShader = (PFNGLDELETESHADERPROC) glXGetProcAddress((unsigned char*)"glDeleteShader"); WGDglDeleteProgram = (PFNGLDELETEPROGRAMPROC) glXGetProcAddress((unsigned char*)"glDeleteProgram"); #endif //Point Sprites #ifdef LINUX WGDglPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)glXGetProcAddress((unsigned char*)"glPointParameterfv"); WGDglPointParameterf = (PFNGLPOINTPARAMETERFPROC)glXGetProcAddress((unsigned char*)"glPointParameterf"); #endif #ifdef WIN32 WGDglPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)wglGetProcAddress("glPointParameterfv"); WGDglPointParameterf = (PFNGLPOINTPARAMETERFPROC)wglGetProcAddress("glPointParameterf"); #endif //VBOs #ifdef LINUX WGDglGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glXGetProcAddress((unsigned char*)"glGenBuffersARB"); WGDglBindBufferARB = (PFNGLBINDBUFFERARBPROC)glXGetProcAddress((unsigned char*)"glBindBufferARB"); WGDglBufferDataARB = (PFNGLBUFFERDATAARBPROC)glXGetProcAddress((unsigned char*)"glBufferDataARB"); WGDglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)glXGetProcAddress((unsigned char*)"glDeleteBuffersARB"); #endif #ifdef WIN32 WGDglGenBuffersARB = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB"); WGDglBindBufferARB = (PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB"); WGDglBufferDataARB = (PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB"); WGDglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB"); #endif //FBOs #ifdef LINUX WGDglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) glXGetProcAddress((unsigned char*)"glGenRenderbuffersEXT"); WGDglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) glXGetProcAddress((unsigned char*)"glBindFramebufferEXT"); WGDglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) glXGetProcAddress((unsigned char*)"glBindRenderbufferEXT"); WGDglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) glXGetProcAddress((unsigned char*)"glDeleteFramebuffersEXT"); WGDglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) glXGetProcAddress((unsigned char*)"glDeleteRenderbuffersEXT"); WGDglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) glXGetProcAddress((unsigned char*)"glFramebufferRenderbufferEXT"); WGDglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) glXGetProcAddress((unsigned char*)"glFramebufferTexture2DEXT"); WGDglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) glXGetProcAddress((unsigned char*)"glGenFramebuffersEXT"); WGDglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) glXGetProcAddress((unsigned char*)"glRenderbufferStorageEXT"); WGDglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) glXGetProcAddress((unsigned char*)"glCheckFramebufferStatusEXT"); WGDglClampColorARB = (PFNGLCLAMPCOLORARBPROC) glXGetProcAddress((unsigned char*)"glClampColorARB"); #endif #ifdef WIN32 WGDglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) wglGetProcAddress("glGenRenderbuffersEXT"); WGDglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) wglGetProcAddress("glBindFramebufferEXT"); WGDglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) wglGetProcAddress("glBindRenderbufferEXT"); WGDglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) wglGetProcAddress("glDeleteFramebuffersEXT"); WGDglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) wglGetProcAddress("glDeleteRenderbuffersEXT"); WGDglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT"); WGDglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) wglGetProcAddress("glFramebufferTexture2DEXT"); WGDglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenFramebuffersEXT"); WGDglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) wglGetProcAddress("glRenderbufferStorageEXT"); WGDglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) wglGetProcAddress("glCheckFramebufferStatusEXT"); WGDglClampColorARB = (PFNGLCLAMPCOLORARBPROC) wglGetProcAddress("glClampColorARB"); #endif } void Extensions::finalise() { } bool Extensions::isinstring(char *str, const char *search) { return false; } wgd-3.1/src/base/input.cpp0000644000175000001440000002151511233311615012417 00000000000000#include #include #include #include #include #include #ifdef LINUX #include #include #endif #include using namespace doste; using namespace doste::dvm; using namespace wgd; wgd::Key wgd::Keyboard::KEY_LEFT; wgd::Key wgd::Keyboard::KEY_UP; wgd::Key wgd::Keyboard::KEY_RIGHT; wgd::Key wgd::Keyboard::KEY_DOWN; wgd::Key wgd::Keyboard::KEY_RETURN; wgd::Key wgd::Keyboard::KEY_ENTER; wgd::Key wgd::Keyboard::KEY_SPACE; wgd::Key wgd::Keyboard::KEY_CTRL; wgd::Key wgd::Keyboard::KEY_SHIFT; wgd::Key wgd::Keyboard::KEY_RCTRL; wgd::Key wgd::Keyboard::KEY_RSHIFT; wgd::Key wgd::Keyboard::KEY_ALT; wgd::Key wgd::Keyboard::KEY_ALTGR; wgd::Key wgd::Keyboard::KEY_DEL; wgd::Key wgd::Keyboard::KEY_BKSPACE; wgd::Key wgd::Keyboard::KEY_END; wgd::Key wgd::Keyboard::KEY_PGDOWN; wgd::Key wgd::Keyboard::KEY_PGUP; wgd::Key wgd::Keyboard::KEY_HOME; wgd::Key wgd::Keyboard::KEY_INSERT; wgd::Key wgd::Keyboard::KEY_PAUSE; wgd::Key wgd::Keyboard::KEY_TAB; wgd::Key wgd::Keyboard::KEY_ESCAPE; wgd::Key wgd::Keyboard::KEY_F1; wgd::Key wgd::Keyboard::KEY_F2; wgd::Key wgd::Keyboard::KEY_F3; wgd::Key wgd::Keyboard::KEY_F4; wgd::Key wgd::Keyboard::KEY_F5; wgd::Key wgd::Keyboard::KEY_F6; wgd::Key wgd::Keyboard::KEY_F7; wgd::Key wgd::Keyboard::KEY_F8; wgd::Key wgd::Keyboard::KEY_F9; wgd::Key wgd::Keyboard::KEY_F10; wgd::Key wgd::Keyboard::KEY_F11; wgd::Key wgd::Keyboard::KEY_F12; wgd::Keyboard::Keyboard(const OID &o) : doste::Agent(o) { KEY_LEFT = "left"; KEY_RIGHT = "right"; KEY_UP = "up"; KEY_DOWN = "down"; KEY_ESCAPE = "escape"; KEY_RETURN = "return"; KEY_ENTER = "enter"; KEY_SPACE = ' '; KEY_CTRL = "ctrl"; KEY_RCTRL = "rctrl"; KEY_SHIFT = "shift"; KEY_RSHIFT = "rshift"; KEY_ALT = "alt"; KEY_ALTGR = "altgr"; KEY_DEL = "delete"; KEY_BKSPACE = "bkspace"; KEY_END = "end"; KEY_PGUP = "pgup"; KEY_PGDOWN = "pgdown"; KEY_HOME = "home"; KEY_INSERT = "insert"; KEY_PAUSE = "pause"; KEY_TAB = "tab"; KEY_F1 = "F1"; KEY_F2 = "F2"; KEY_F3 = "F3"; KEY_F4 = "F4"; KEY_F5 = "F5"; KEY_F6 = "F6"; KEY_F7 = "F7"; KEY_F8 = "F8"; KEY_F9 = "F9"; KEY_F10 = "F10"; KEY_F11 = "F11"; KEY_F12 = "F12"; } wgd::Keyboard::~Keyboard() { } void wgd::Keyboard::keyPress(char key) { wgd::Key rkey = convert(key); get("keys")[rkey].set(true); char c = ascii(rkey, (bool)((OID)keys()[KEY_SHIFT]) | (bool)((OID)keys()[KEY_RSHIFT])); if (c != 0) { set("ascii", c); set("key", rkey); set("press", Void); set("pressed", true); set("pressed", false); } m_pressed[rkey] = true; } void wgd::Keyboard::keyRelease(char key) { wgd::Key rkey = convert(key); (*this)["keys"][rkey].set(false); } char wgd::Keyboard::ascii(const wgd::Key &key, bool shift){ //non-character OIDs convert to '@' //if((char)key == '@'){ if(key == KEY_RETURN) return '\n'; if(key == KEY_TAB) return '\t'; if(key == KEY_BKSPACE) return 8; //} else { char ckey = (char)key; if(shift){ switch(ckey){ case '`': return '?'; case '1': return '!'; case '2': return '"'; case '3': return '?'; case '4': return '$'; case '5': return '%'; case '6': return '^'; case '7': return '&'; case '8': return '*'; case '9': return '('; case '0': return ')'; case '-': return '_'; case '=': return '+'; case '[': return '{'; case ']': return '}'; case ';': return ':'; case '\'': return '@'; case '#': return '~'; case '\\': return '|'; case ',': return '<'; case '.': return '>'; case '/': return '?'; default: if(ckey >= 97 && ckey <= 122) return ckey-32; } } if(ckey >= 32 && ckey <= 126) return ckey; //} return 0; } wgd::Key wgd::Keyboard::convert(char key) { wgd::Key rkey; #ifdef WIN32 switch (key) { case 27: rkey = KEY_ESCAPE; break; case -90: rkey = KEY_UP; break; case -91: rkey = KEY_LEFT; break; case -88: rkey = KEY_DOWN; break; case -89: rkey = KEY_RIGHT; break; case 13: rkey = KEY_RETURN; break; case 8: rkey = KEY_BKSPACE; break; case 32: rkey = KEY_SPACE; break; case 17: rkey = KEY_CTRL; break; case -111: rkey = KEY_RCTRL; break; case 16: rkey = KEY_SHIFT; break; //case ??: rkey = KEY_ALT; break; //umm - alt does not print out? case -110: rkey = KEY_ALTGR; break; case -83: rkey = KEY_INSERT; break; case -82: rkey = KEY_DEL; break; case -92: rkey = KEY_HOME; break; case -93: rkey = KEY_END; break; case -95: rkey = KEY_PGUP; break; case -94: rkey = KEY_PGDOWN; break; case 19: rkey = KEY_PAUSE; break; case 9: rkey = KEY_TAB; break; case 112: rkey = KEY_F1; break; case 113: rkey = KEY_F2; break; case 114: rkey = KEY_F3; break; case 115: rkey = KEY_F4; break; case 116: rkey = KEY_F5; break; case 117: rkey = KEY_F6; break; case 118: rkey = KEY_F7; break; case 119: rkey = KEY_F8; break; case 120: rkey = KEY_F9; break; case 121: rkey = KEY_F10; break; case 122: rkey = KEY_F11; break; case 123: rkey = KEY_F12; break; //more mappings case -33: rkey = '`'; break; case -67: rkey = '-'; break; case -69: rkey = '='; break; case -37: rkey = '['; break; case -35: rkey = ']'; break; case -70: rkey = ';'; break; case -64: rkey = '\''; break; case -34: rkey = '#'; break; case -36: rkey = '\\'; break; case -68: rkey = ','; break; case -66: rkey = '.'; break; case -65: rkey = '/'; break; default: if ((int)key >= 65 && (int)key <= 90) rkey = (char)((int)key+32); else rkey = key; break; } return rkey; #endif #ifdef LINUX KeySym keysym = XKeycodeToKeysym(wgd::window->getXDisplay(), key, 0); switch (keysym) { case XK_Left: return KEY_LEFT; case XK_Up: return KEY_UP; case XK_Right: return KEY_RIGHT; case XK_Down: return KEY_DOWN; case XK_Return: return KEY_RETURN; case XK_Escape: return KEY_ESCAPE; case XK_BackSpace: return KEY_BKSPACE; case XK_Tab: return KEY_TAB; case XK_Delete: return KEY_DEL; case XK_Pause: return KEY_PAUSE; case XK_Home: return KEY_HOME; case XK_Page_Up: return KEY_PGUP; case XK_Page_Down: return KEY_PGDOWN; case XK_End: return KEY_END; case XK_Insert: return KEY_INSERT; case XK_KP_Enter: return KEY_ENTER; case XK_F1: return KEY_F1; case XK_F2: return KEY_F2; case XK_F3: return KEY_F3; case XK_F4: return KEY_F4; case XK_F5: return KEY_F5; case XK_F6: return KEY_F6; case XK_F7: return KEY_F7; case XK_F8: return KEY_F8; case XK_F9: return KEY_F9; case XK_F10: return KEY_F10; case XK_F11: return KEY_F11; case XK_F12: return KEY_F12; case XK_Shift_L: return KEY_SHIFT; case XK_Shift_R: return KEY_RSHIFT; case XK_Control_L: return KEY_CTRL; case XK_Control_R: return KEY_RCTRL; case XK_Alt_L: return KEY_ALT; case XK_Alt_R: return KEY_ALTGR; // Is this correct? default: return (char)keysym; } #endif } wgd::Input::Input(const OID &o) : Agent(o) { registerEvents(); } wgd::Input::~Input() { } void wgd::Input::update() { mouse->update(); keyboard->update(); #ifdef LINUX XEvent event; XKeyEvent *keyevent; XButtonEvent *buttonevent; //if (Processor::numProcessors() > 1) XLockDisplay(wgd::window->getXDisplay()); while (XPending(wgd::window->getXDisplay())) { XNextEvent(wgd::window->getXDisplay(), &event); switch (event.type) { case ClientMessage: if (*XGetAtomName(wgd::window->getXDisplay(), event.xclient.message_type) == *"WM_PROTOCOLS") { doste::dvm::root.set("running", false); } break; case KeyRelease: keyevent = (XKeyEvent*)&event; wgd::keyboard->keyRelease((char)keyevent->keycode); break; case KeyPress: keyevent = (XKeyEvent*)&event; wgd::keyboard->keyPress((char)keyevent->keycode); break; case ButtonPress: buttonevent = (XButtonEvent*)&event; wgd::mouse->btnDown(buttonevent->button); break; case ButtonRelease: buttonevent = (XButtonEvent*)&event; wgd::mouse->btnUp(buttonevent->button); break; default: break; } } //if (Processor::numProcessors() > 1) XUnlockDisplay(wgd::window->getXDisplay()); #else MSG msg; while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch (msg.message) { case WM_QUIT: root["running"] = false; break; case WM_KEYDOWN: wgd::keyboard->keyPress((char)(msg.wParam + (((msg.lParam >> 24) * 0x1) << 7))); break; case WM_KEYUP: wgd::keyboard->keyRelease((char)(msg.wParam + (((msg.lParam >> 24) * 0x1) << 7))); break; case WM_LBUTTONDOWN: wgd::mouse->btnDown(1); break; case WM_LBUTTONUP: wgd::mouse->btnUp(1); break; case WM_MBUTTONDOWN: wgd::mouse->btnDown(2); break; case WM_MBUTTONUP: wgd::mouse->btnUp(2); break; case WM_RBUTTONDOWN: wgd::mouse->btnDown(3); break; case WM_RBUTTONUP: wgd::mouse->btnUp(3); break; case WM_MOUSEWHEEL: //wgd::mouse->set(ix::deltaz, GET_WHEEL_DELTA_WPARAM(msg.wParam)); wgd::mouse->wheel(GET_WHEEL_DELTA_WPARAM(msg.wParam) / WHEEL_DELTA); break; default: TranslateMessage(&msg); DispatchMessage(&msg); } } #endif } wgd-3.1/src/base/Makefile.in0000644000175000001440000003032211265575054012633 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_base.so$(EXEEXT) subdir = src/base DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_base_so_OBJECTS = base.$(OBJEXT) window.$(OBJEXT) \ index.$(OBJEXT) extensions.$(OBJEXT) input.$(OBJEXT) \ mouse.$(OBJEXT) matrix.$(OBJEXT) libwgd_base_so_OBJECTS = $(am_libwgd_base_so_OBJECTS) libwgd_base_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_base_so_SOURCES) DIST_SOURCES = $(libwgd_base_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_base_so_SOURCES = base.cpp window.cpp index.cpp extensions.cpp input.cpp mouse.cpp matrix.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = --shared -lGL -lX11 -lXxf86vm -ldoste INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/base/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/base/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_base.so$(EXEEXT): $(libwgd_base_so_OBJECTS) $(libwgd_base_so_DEPENDENCIES) @rm -f libwgd_base.so$(EXEEXT) $(CXXLINK) $(libwgd_base_so_OBJECTS) $(libwgd_base_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/base/base.cpp0000644000175000001440000000241511233311615012170 00000000000000#include #include #include #include #include #include #include #include using namespace doste; using namespace doste::dvm; void createIndices(); namespace wgd { BASEIMPORT GameWindow* window; BASEIMPORT Keyboard* keyboard; BASEIMPORT Mouse* mouse; BASEIMPORT wgd::OID WGD; }; //somewhere to define this... char* wgd::vertex_tangent::name = "tangent"; extern "C" void BASEIMPORT initialise(const OID &base) { createIndices(); wgd::WGD = base; Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); // Suggestion: set these in the GameWindow/Keyboard/Mouse constructor. // Rationale: so that their location in the database isn't hardcoded //if (base["window"] == doste::Null) base["window"] = doste::OID::create(); wgd::window = ((OID)base["window"]); wgd::keyboard = ((OID)base["input"]["keyboard"]); wgd::mouse = ((OID)base["input"]["mouse"]); wgd::Extensions::initialise(); } extern "C" void BASEIMPORT update() { wgd::Input::update(); wgd::window->draw(); } extern "C" void BASEIMPORT finalise() { wgd::Extensions::finalise(); } wgd-3.1/src/base/index.cpp0000644000175000001440000002731511077651472012411 00000000000000#include using namespace wgd::ix; namespace wgd { namespace ix { doste::dvm::OID BASEIMPORT position; doste::dvm::OID BASEIMPORT orientation; doste::dvm::OID BASEIMPORT direction; doste::dvm::OID BASEIMPORT changed; doste::dvm::OID BASEIMPORT material; doste::dvm::OID BASEIMPORT materials; doste::dvm::OID BASEIMPORT model; doste::dvm::OID BASEIMPORT models; doste::dvm::OID BASEIMPORT animationset; doste::dvm::OID BASEIMPORT animations; doste::dvm::OID BASEIMPORT animated; doste::dvm::OID BASEIMPORT animation; doste::dvm::OID BASEIMPORT transformed; doste::dvm::OID BASEIMPORT transition; doste::dvm::OID BASEIMPORT meshes; doste::dvm::OID BASEIMPORT morphs; doste::dvm::OID BASEIMPORT morph; doste::dvm::OID BASEIMPORT root; doste::dvm::OID BASEIMPORT bones; doste::dvm::OID BASEIMPORT animset; doste::dvm::OID BASEIMPORT start; doste::dvm::OID BASEIMPORT end; doste::dvm::OID BASEIMPORT fps; doste::dvm::OID BASEIMPORT loop; doste::dvm::OID BASEIMPORT next; doste::dvm::OID BASEIMPORT solid; doste::dvm::OID BASEIMPORT mode; doste::dvm::OID BASEIMPORT debug; doste::dvm::OID BASEIMPORT x; doste::dvm::OID BASEIMPORT y; doste::dvm::OID BASEIMPORT z; doste::dvm::OID BASEIMPORT w; doste::dvm::OID BASEIMPORT r; doste::dvm::OID BASEIMPORT g; doste::dvm::OID BASEIMPORT b; doste::dvm::OID BASEIMPORT a; doste::dvm::OID BASEIMPORT sx; doste::dvm::OID BASEIMPORT sy; doste::dvm::OID BASEIMPORT sz; doste::dvm::OID BASEIMPORT pitch; doste::dvm::OID BASEIMPORT yaw; doste::dvm::OID BASEIMPORT roll; doste::dvm::OID BASEIMPORT console; doste::dvm::OID BASEIMPORT lines; doste::dvm::OID BASEIMPORT visible; doste::dvm::OID BASEIMPORT showdebug; doste::dvm::OID BASEIMPORT font; doste::dvm::OID BASEIMPORT bgcolour; doste::dvm::OID BASEIMPORT text; doste::dvm::OID BASEIMPORT ambient; doste::dvm::OID BASEIMPORT specular; doste::dvm::OID BASEIMPORT diffuse; doste::dvm::OID BASEIMPORT emission; doste::dvm::OID BASEIMPORT directional; doste::dvm::OID BASEIMPORT linear; doste::dvm::OID BASEIMPORT quadratic; doste::dvm::OID BASEIMPORT enabled; doste::dvm::OID BASEIMPORT lights; doste::dvm::OID BASEIMPORT size; doste::dvm::OID BASEIMPORT name; doste::dvm::OID BASEIMPORT bold; doste::dvm::OID BASEIMPORT fonts; doste::dvm::OID BASEIMPORT shininess; doste::dvm::OID BASEIMPORT shader; doste::dvm::OID BASEIMPORT texture; doste::dvm::OID BASEIMPORT textures; doste::dvm::OID BASEIMPORT clamp; doste::dvm::OID BASEIMPORT filename; doste::dvm::OID BASEIMPORT mipmap; doste::dvm::OID BASEIMPORT objects; doste::dvm::OID BASEIMPORT world; doste::dvm::OID BASEIMPORT positionvar; doste::dvm::OID BASEIMPORT rate; doste::dvm::OID BASEIMPORT life; doste::dvm::OID BASEIMPORT particles; doste::dvm::OID BASEIMPORT primitive; doste::dvm::OID BASEIMPORT primitives; doste::dvm::OID BASEIMPORT width; doste::dvm::OID BASEIMPORT height; doste::dvm::OID BASEIMPORT depth; doste::dvm::OID BASEIMPORT radius; doste::dvm::OID BASEIMPORT playing; doste::dvm::OID BASEIMPORT attenuation; doste::dvm::OID BASEIMPORT volume; doste::dvm::OID BASEIMPORT sounds; doste::dvm::OID BASEIMPORT sound; doste::dvm::OID BASEIMPORT velocity; doste::dvm::OID BASEIMPORT sprite; doste::dvm::OID BASEIMPORT sprites; doste::dvm::OID BASEIMPORT frame; doste::dvm::OID BASEIMPORT music; doste::dvm::OID BASEIMPORT number; doste::dvm::OID BASEIMPORT velocityvar; doste::dvm::OID BASEIMPORT growth; doste::dvm::OID BASEIMPORT growthvar; doste::dvm::OID BASEIMPORT endsize; doste::dvm::OID BASEIMPORT endsizevar; doste::dvm::OID BASEIMPORT startsize; doste::dvm::OID BASEIMPORT startsizevar; doste::dvm::OID BASEIMPORT lifevar; doste::dvm::OID BASEIMPORT fade; doste::dvm::OID BASEIMPORT fadevar; doste::dvm::OID BASEIMPORT startcolour; doste::dvm::OID BASEIMPORT startcolourvar; doste::dvm::OID BASEIMPORT endcolour; doste::dvm::OID BASEIMPORT endcolourvar; doste::dvm::OID BASEIMPORT acceleration; doste::dvm::OID BASEIMPORT accelerationvar; doste::dvm::OID BASEIMPORT resources; doste::dvm::OID BASEIMPORT vert; doste::dvm::OID BASEIMPORT frag; doste::dvm::OID BASEIMPORT shaders; doste::dvm::OID BASEIMPORT left; doste::dvm::OID BASEIMPORT right; doste::dvm::OID BASEIMPORT top; doste::dvm::OID BASEIMPORT bottom; doste::dvm::OID BASEIMPORT front; doste::dvm::OID BASEIMPORT back; doste::dvm::OID BASEIMPORT skybox; doste::dvm::OID BASEIMPORT skyboxes; doste::dvm::OID BASEIMPORT cur; doste::dvm::OID BASEIMPORT frames; doste::dvm::OID BASEIMPORT columns; doste::dvm::OID BASEIMPORT rows; doste::dvm::OID BASEIMPORT billboard; doste::dvm::OID BASEIMPORT distance; doste::dvm::OID BASEIMPORT atmosphere; doste::dvm::OID BASEIMPORT density; doste::dvm::OID BASEIMPORT camera; doste::dvm::OID BASEIMPORT fov; doste::dvm::OID BASEIMPORT far; doste::dvm::OID BASEIMPORT near; doste::dvm::OID BASEIMPORT zoom; doste::dvm::OID BASEIMPORT running; doste::dvm::OID BASEIMPORT flipped; doste::dvm::OID BASEIMPORT keyboard; doste::dvm::OID BASEIMPORT keys; doste::dvm::OID BASEIMPORT commands; doste::dvm::OID BASEIMPORT lighting; doste::dvm::OID BASEIMPORT smooth; doste::dvm::OID BASEIMPORT mouse; doste::dvm::OID BASEIMPORT deltax; doste::dvm::OID BASEIMPORT deltay; doste::dvm::OID BASEIMPORT buttons; doste::dvm::OID BASEIMPORT cursor; doste::dvm::OID BASEIMPORT colour; doste::dvm::OID BASEIMPORT window; doste::dvm::OID BASEIMPORT cube; doste::dvm::OID BASEIMPORT deltaz; doste::dvm::OID BASEIMPORT game; doste::dvm::OID BASEIMPORT scene; doste::dvm::OID BASEIMPORT levels; doste::dvm::OID BASEIMPORT instances; doste::dvm::OID BASEIMPORT instance2D; doste::dvm::OID BASEIMPORT instance3D; doste::dvm::OID BASEIMPORT resolutions; doste::dvm::OID BASEIMPORT clearcolour; doste::dvm::OID BASEIMPORT colourdepth; doste::dvm::OID BASEIMPORT depthbuffer; doste::dvm::OID BASEIMPORT title; doste::dvm::OID BASEIMPORT fullscreen; doste::dvm::OID BASEIMPORT movespeed; doste::dvm::OID BASEIMPORT paused; doste::dvm::OID BASEIMPORT blending; doste::dvm::OID BASEIMPORT resistance; doste::dvm::OID BASEIMPORT resistancevar; doste::dvm::OID BASEIMPORT axes; doste::dvm::OID BASEIMPORT compress; doste::dvm::OID BASEIMPORT controls; doste::dvm::OID BASEIMPORT scale; doste::dvm::OID BASEIMPORT value; doste::dvm::OID BASEIMPORT deadzone; doste::dvm::OID BASEIMPORT invert; doste::dvm::OID BASEIMPORT keep; doste::dvm::OID BASEIMPORT flipv; doste::dvm::OID BASEIMPORT fliph; doste::dvm::OID BASEIMPORT tint; doste::dvm::OID BASEIMPORT layer; doste::dvm::OID BASEIMPORT widgets; doste::dvm::OID BASEIMPORT caption; doste::dvm::OID BASEIMPORT grab; doste::dvm::OID BASEIMPORT focus; doste::dvm::OID BASEIMPORT parent; doste::dvm::OID BASEIMPORT screenx; doste::dvm::OID BASEIMPORT screeny; doste::dvm::OID BASEIMPORT volumes; doste::dvm::OID BASEIMPORT children; doste::dvm::OID BASEIMPORT light; doste::dvm::OID BASEIMPORT type; doste::dvm::OID BASEIMPORT glowfilename; doste::dvm::OID BASEIMPORT glowmax; doste::dvm::OID BASEIMPORT reload; doste::dvm::OID BASEIMPORT variables; doste::dvm::OID BASEIMPORT input; doste::dvm::OID BASEIMPORT source; doste::dvm::OID BASEIMPORT location; doste::dvm::OID BASEIMPORT time; }; }; void createIndices(){ position = "position"; orientation = "orientation"; direction = "direction"; changed = "changed"; material = "material"; materials = "materials" ; model = "model"; models = "models"; animationset = "animationset"; animations = "animations"; animated = "animated"; animation = "animation" ; transformed = "transformed"; transition = "transition"; meshes = "meshes"; morphs = "morphs"; morph = "morph"; root = "root"; bones = "bones"; animset = "animset"; start = "start"; end = "end"; fps = "fps"; loop = "loop"; next = "next"; solid = "solid"; mode = "mode"; debug = "debug"; x = "x"; y = "y"; z = "z"; w = "w"; r = "r"; g = "g"; b = "b"; a = "a"; sx = "sx"; sy = "sy"; sz = "sz"; pitch = "pitch"; yaw = "yaw"; roll = "roll"; console = "console"; lines = "lines"; ambient = "ambient"; specular = "specular"; diffuse = "diffuse"; emission = "emission"; directional = "directional"; linear = "linear"; quadratic = "quadratic"; enabled = "enabled"; lights = "lights"; visible = "visible"; showdebug = "showdebug"; font = "font"; bgcolour = "bgcolour"; text = "text"; size = "size"; name = "name"; bold = "bold"; fonts = "fonts"; shininess = "shininess"; shader = "shader"; texture = "texture"; textures = "textures"; clamp = "clamp"; filename = "filename"; mipmap = "mipmap"; objects = "objects"; world = "world"; positionvar = "positionvar"; rate = "rate"; life = "life"; particles = "particles"; primitive = "primitive"; primitives = "primitives"; width = "width"; height = "height"; depth = "depth"; radius = "radius"; attenuation = "attenuation"; volume = "volume"; sounds = "sounds"; playing = "playing"; sound = "sound"; velocity = "velocity"; sprite = "sprite"; sprites = "sprites"; frame = "frame"; music = "music"; number = "number"; velocityvar = "velocityvar"; growth = "growth"; growthvar = "growthvar"; endsize = "endsize"; endsizevar = "endsizevar"; startsize = "startsize"; startsizevar = "startsizevar"; lifevar = "lifevar"; fade = "fade"; fadevar = "fadevar"; startcolour = "startcolour"; startcolourvar = "startcolourvar"; endcolour = "endcolour"; endcolourvar = "endcolourvar"; acceleration = "acceleration"; accelerationvar = "accelerationvar"; resources = "resources"; vert = "vert"; frag = "frag"; shaders = "shaders"; wgd::ix::left = "left"; wgd::ix::right = "right"; top = "top"; bottom = "bottom"; front = "front"; back = "back"; skybox = "skybox"; skyboxes = "skyboxes"; cur = "cur"; frames = "frames"; columns = "columns"; rows = "rows"; billboard = "billboard"; wgd::ix::distance = "distance"; atmosphere = "atmosphere"; density = "density"; camera = "camera"; fov = "fov"; far = "far"; near = "near"; zoom = "zoom"; running = "running"; flipped = "flipped"; keyboard = "keyboard"; keys = "keys"; commands = "commands"; lighting = "lighting"; smooth = "smooth"; mouse = "mouse"; deltax = "deltax"; deltay = "deltay"; buttons = "buttons"; cursor = "cursor"; colour = "colour"; window = "window"; cube = "cube"; deltaz = "deltaz"; game = "game"; scene = "scene"; levels = "levels"; instances = "instances"; instance2D = "Instance2D"; instance3D = "Instance3D"; resolutions = "resolutions"; clearcolour = "clearcolour"; colourdepth = "colourdepth"; depthbuffer = "depthbuffer"; title = "title"; fullscreen = "fullscreen"; movespeed = "movespeed"; paused = "paused"; blending = "blending"; resistance = "resistance"; resistancevar = "resistancevar"; axes = "axes"; compress = "compress"; controls = "controls"; scale = "scale"; value = "value"; deadzone = "deadzone"; invert = "invert"; keep = "keep"; flipv = "flipv"; fliph = "fliph"; tint = "tint"; layer = "layer"; widgets = "widgets"; caption = "caption"; grab = "grab"; focus = "focus"; parent = "parent"; screenx = "screenx"; screeny = "screeny"; volumes = "volumes"; children = "children"; type = "type"; light = "light"; glowfilename = "glowfilename"; glowmax = "glowmax"; reload = "reload"; variables = "variables"; input = "input"; source = "source"; location = "location"; wgd::ix::time = "time"; } wgd-3.1/src/resources_base/0000777000175000001440000000000011265576313012743 500000000000000wgd-3.1/src/resources_base/texture.cpp0000644000175000001440000002371611233311614015056 00000000000000 #ifdef WIN32 #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef LINUX #include #include //#include "../config.h" #endif #ifdef _MSC_VER #pragma warning(disable:4996) #endif using namespace doste; using namespace doste::dvm; using namespace wgd; int wgd::Texture::s_bind = 0; int wgd::Texture::s_maxtex = 1; int wgd::Texture::s_maxmem = 0x8000000; //128Mb int wgd::Texture::s_curmem = 0; Texture *wgd::Texture::s_curtex = 0; IMPLEMENT_LOADER(TextureLoader); void wgd::Texture::initialise() { glGetIntegerv(GL_MAX_TEXTURE_UNITS, &s_maxtex); Loader::regFileType(); Loader::regFileType(); Loader::regFileType(); } void wgd::Texture::finalise() { } namespace wgd { OnEvent(Texture, evt_reload) { if (m_loaded & !m_failed) { m_loaded = false; m_failed = false; m_loading = false; if (!keep()) { glDeleteTextures(1, &m_glid); } else { if (m_data != 0) { delete [] m_data; m_data=0; } } } } IMPLEMENT_EVENTS(Texture,Agent); }; wgd::Texture::Texture() : m_data(0), m_loading(false), m_loaded(false), m_failed(false), m_bound(-1) { //Default to using texture compression compress(true); set(Type, type()); registerEvents(); } wgd::Texture::Texture(int w, int h, TextureFormat format, bool clmp) : m_data(0), m_loading(false), m_loaded(false), m_failed(false), m_bound(-1) { set(Type, type()); registerEvents(); width(w); height(h); clamp(clmp); make(format); } wgd::Texture::Texture(doste::File *f) : m_data(0), m_loading(false), m_loaded(false), m_failed(false), m_bound(-1) { //Default to using texture compression compress(true); set(Type, type()); registerEvents(); //set texture file file(f); } wgd::Texture::Texture(const char* filename) : m_data(0), m_loading(false), m_loaded(false), m_failed(false), m_bound(-1) { //Default to using texture compression compress(true); set(Type, type()); registerEvents(); //set texture file file(new LocalFile(filename)); } wgd::Texture::Texture(const OID &res) : Agent(res), m_data(0), m_loading(false), m_loaded(false), m_failed(false), m_bound(-1) { //Default to using texture compression if (get(ix::compress) == Null) { compress(true); } registerEvents(); } bool wgd::Texture::make(TextureFormat format) { TextureLoader *l = new CustomTexture(); l->data(0); l->width(width()); l->height(height()); //l->alpha(true); //l->hdr(hdr()); l->format(format); //m_cdepth = 32; //Load this texture into OpenGL. m_loaded = true; return buildTexture(l); }; void wgd::Texture::load() { if (m_loaded || m_loading) return; File *f = file(); if (f == 0) return; Info(Info::LOADING, "Loading texture " + f->filename()); TextureLoader *l = Loader::create(f); if (l == 0) return; if (!l->load()) return; m_loading = true; buildTexture(l); delete l; m_loaded = true; m_loading = false; } bool wgd::Texture::makeHDR() { /*//First save current texture pointers. unsigned char *difdata = m_data; int difw = m_width; int difh = m_height; int difd = m_cdepth; //Load glow texture. doste::dstring fname(get(ix::glowfilename)); std::cout << "Loading glow texture '" << (const char*)fname << "'\n"; if (!loadFromFile(fname)) { std::cout << "Failed to load glow texture '" << (const char*)fname << "'\n"; return false; } //Process to generate float texture data. unsigned char *gdata = m_data; //int gwidth = m_width; //int gheight = m_height; int gdepth = m_cdepth; float sfactor = glowMax(); //Allocate float data float *fdata = new float[difw*difh*4]; int j=0; int k=0; for (int i=0; i> 3); k += (gdepth >> 3); } delete [] gdata; delete [] difdata; m_data = (unsigned char*)fdata; m_width = difw; m_height = difh; m_cdepth = 32; m_ishdr = true;*/ return true; } void wgd::Texture::bind(int num) { //either cannot bind or already bound. if (m_failed || (s_curtex == this)) return; //DMsg msg; //msg << "Binding " << *this << " to " << num << "\n"; //Load if not already loaded from file. if (!m_loaded) load(); //Select the correct texture unit. activate(num); //Textures must be enabled and bound glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, m_glid); s_bind = num; m_bound = num; s_curtex = this; } void wgd::Texture::unbind() { //Nothing is bound so return. if (m_bound == -1) return; //DMsg msg; //msg << "Unbinding " << *this << " to " << m_bound << "\n"; //Select correct texture unit. activate(m_bound); //Disable OpenGL textures for this texture unit. glDisable(GL_TEXTURE_2D); m_bound = -1; s_curtex = 0; } void wgd::Texture::activate(int num) { //Check to see that its a valid texture unit. if (num >= s_maxtex) { Error(0, "Exceeding maximum supported texture units."); return; } //If not already using the correct texture unit then switch it. if (s_bind != num) { WGDglActiveTextureARB(GL_TEXTURE0_ARB+num); s_bind = num; } } #undef True bool wgd::Texture::buildTexture(TextureLoader *loader) { //Update the database values for width and height. if (get(ix::width) == Null) set(ix::width, loader->width()); if (get(ix::width) == Null) set(ix::height, loader->height()); m_width = loader->width(); m_height = loader->height(); m_format = loader->format(); //If we are not keeping the texture in system memory then //Send to video memory via OpenGL texture objects. if (!keep()) { //Create one texture object glGenTextures(1, &m_glid); //Not alignment at end of each row, packed pixel array. glPixelStorei (GL_UNPACK_ALIGNMENT, 1); //Select this new texture object glBindTexture(GL_TEXTURE_2D, m_glid); //Set the texture parameters. Clamp is used for skybox etc... if (clamp()) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // If the u,v coordinates overflow the range 0,1 the image is repeated glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } else { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // If the u,v coordinates overflow the range 0,1 the image is repeated glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } if (!nearest()) { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } else { glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } FormatMap map; lookupFormat(map, m_format); //Check that this is a valid texture resolution. int mwidth; glTexImage2D(GL_PROXY_TEXTURE_2D, 0, map.internal, loader->width(), loader->height(), 0, map.format, map.type, NULL); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, (GLint*)&mwidth); if (mwidth == 0) { m_failed = true; Error(0, dstring("Unsupported texture resolution (") + loader->width() + "x" + loader->height() + ")."); return false; } //Use GLU to build mimaps if required. Otherwise use standard OpenGL if (mipmap()) { gluBuild2DMipmaps(GL_TEXTURE_2D, map.internal, loader->width(), loader->height(), map.format, map.type, loader->data()); } else { glTexImage2D(GL_TEXTURE_2D, 0, map.internal, loader->width(), loader->height(), 0, map.format, map.type, loader->data()); } }; //s_curmem += m_width*m_height*(m_cdepth >> 3); //std::cout << "Texture memory usage: " << ((float)s_curmem/(1024.0*1024.0)) << "Mb\n"; return true; } bool Texture::lookupFormat(FormatMap &map, TextureFormat format) { switch (format) { case RGBA: map.internal = (Extensions::hasTextureCompression() && compress()) ? GL_COMPRESSED_RGBA_ARB : GL_RGBA; map.type = GL_UNSIGNED_BYTE; map.format = GL_RGBA; map.colourformat = RGBA_CHAR; break; case RGB: map.internal = (Extensions::hasTextureCompression() && compress()) ? GL_COMPRESSED_RGB_ARB : GL_RGB; map.type = GL_UNSIGNED_BYTE; map.format = GL_RGB; map.colourformat = RGB_CHAR; break; case RGBA_HDR: map.internal = GL_RGBA16F_ARB; map.type = GL_HALF_FLOAT_ARB; map.format = GL_RGBA; map.colourformat = RGBA_FLOAT; break; // case RGB_HDR: map.internal = GL_RGB16F_ARB; // map.type = GL_HALF_FLOAT_ARB; // map.format = GL_RGB; // map.colourformat = RGB_FLOAT; // break; // case DEPTH_16: map.internal = GL_DEPTH_COMPONENT16; // map.type = GL_UNSIGNED_BYTE; // map.format = GL_DEPTH_COMPONENT; // map.colourformat = RG_CHAR; // break; case DEPTH_24: map.internal = GL_DEPTH_COMPONENT24; map.type = GL_UNSIGNED_BYTE; map.format = GL_DEPTH_COMPONENT; map.colourformat = RGB_CHAR; break; case DEPTH_32: map.internal = GL_DEPTH_COMPONENT32; map.type = GL_UNSIGNED_BYTE; map.format = GL_DEPTH_COMPONENT; map.colourformat = RGBA_CHAR; break; case ALPHA: map.internal = GL_ALPHA; map.type = GL_UNSIGNED_BYTE; map.format = GL_ALPHA; map.colourformat = R_CHAR; break; case LUMINANCE: map.internal = GL_LUMINANCE; map.type = GL_UNSIGNED_BYTE; map.format = GL_LUMINANCE; map.colourformat = R_CHAR; break; default: return false; } return true; } wgd::Texture::~Texture() { //Should check first that it was loaded? if (m_loaded && !keep()) { glDeleteTextures(1, &m_glid); } else { if (m_data != 0) { delete [] m_data; } } set(ix::width, Null); set(ix::height, Null); //s_curmem -= m_width*m_height*(m_cdepth>>3); } wgd-3.1/src/resources_base/shader.cpp0000644000175000001440000002520411233311614014616 00000000000000#include #include #include #include #include #ifdef WIN32 #include #define GLAPIENTRY APIENTRY #endif #ifdef LINUX #include #endif #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif typedef char GLchar; using namespace wgd; using namespace doste; using namespace doste::dvm; bool Shader::s_available = true; Shader *Shader::s_current=NULL; namespace wgd { OnEvent(Shader, evt_reload) { if (s_available && m_ready) { if(m_vertexShader) WGDglDeleteShader(m_vertexShader); if(m_fragmentShader) WGDglDeleteShader(m_fragmentShader); if(m_program) WGDglDeleteProgram(m_program); } m_loaded = false; m_ready = false; } IMPLEMENT_EVENTS(Shader, Agent); }; Shader::Shader() : m_ready(false), m_loaded(false), m_tangents(false) { m_vars = OID::create(); registerEvents(); } Shader::Shader(doste::File &v, doste::File &f) : m_ready(false), m_loaded(false), m_tangents(false) { vert(v); frag(f); m_vars = OID::create(); registerEvents(); } Shader::Shader(const char* v, const char* f) : m_ready(false), m_loaded(false), m_tangents(false) { vert(new LocalFile(v)); frag(new LocalFile(f)); m_vars = OID::create(); registerEvents(); } Shader::Shader(const OID &res) : Agent(res), m_ready(false), m_loaded(false), m_tangents(false) { m_vars = OID::create(); registerEvents(); } Shader::~Shader(){ if (s_available) { if(m_vertexShader) WGDglDeleteShader(m_vertexShader); if(m_fragmentShader) WGDglDeleteShader(m_fragmentShader); if(m_program) WGDglDeleteProgram(m_program); } } void Shader::current(Shader *s) { s_current = s; } Shader *Shader::current() { return s_current; } void Shader::initialise() { //are shaders supported? s_available=(WGDglCreateShader!=0 && Extensions::hasShaders()); } void Shader::enabled(bool v) { } bool Shader::enabled() { return true; } bool Shader::load(){ //if(!s_available) wgd::cout << wgd::WARN << "Shaders not supported!\n"; if (!enabled()) { m_ready = false; return false; } return loadShader(); } bool Shader::loadShader(){ if(!s_available) return false; char *vsBuffer, *fsBuffer; //Read files Info(Info::LOADING, "Loading vertex shader " + vert()->filename()); vsBuffer = readFile(vert()); if(vsBuffer==NULL){ Error(0, "Vertex shader " + vert()->filename() + " failed to load\n"); return false; } Info(Info::LOADING, "Loading fragment shader " + frag()->filename()); fsBuffer = readFile(frag()); if(fsBuffer==NULL){ Error(0, "Fragment shader " + frag()->filename() + " failed to load\n"); return false; } //compile the shader bool r = make(vsBuffer, fsBuffer); if(vsBuffer!=NULL) delete [] vsBuffer; if(fsBuffer!=NULL) delete [] fsBuffer; return r; } bool Shader::make(const char *vert, const char *frag){ if(!s_available) return false; if (WGDglCreateShader == 0) return false; m_loaded=true; //Set up shaders const char * vs = vert; const char * fs = frag; m_vertexShader = WGDglCreateShader(GL_VERTEX_SHADER); m_fragmentShader = WGDglCreateShader(GL_FRAGMENT_SHADER); WGDglShaderSource(m_vertexShader, 1, &vs, NULL); WGDglShaderSource(m_fragmentShader, 1, &fs, NULL); //compile shaders WGDglCompileShader(m_vertexShader); WGDglCompileShader(m_fragmentShader); //detect any compile errors if(logInfo(m_vertexShader, "Vertex shader")<0){ Error(0, "The vertex shader failed to compile"); return false; } if(logInfo(m_fragmentShader, "Fragment shader")<0){ Error(0, "The fragment shader failed to compile"); return false; } //Create the shader program m_program = WGDglCreateProgram(); WGDglAttachShader(m_program, m_vertexShader); WGDglAttachShader(m_program, m_fragmentShader); WGDglLinkProgram(m_program); //test error? //GLenum err = glGetError(); //if(err!=0) cout << wgd::ERR << "Shader : " << err << "\n"; int r = logInfo(m_program, "Shader Program"); if(r<0) { if (r==-3) Error(0, "The shader is too large to run on your hardware"); else Error(0, "The shaders failed to link"); return false; } //bad things may happen if(m_program==0) return false; if(m_vertexShader==0) return false; if(m_fragmentShader==0) return false; //See if the shader uses the 'tangent' attribute variable GLint loc = WGDglGetAttribLocation(m_program, "tangent"); if(loc>=0){ m_tangents=true; //if(Shader::debug()) wgd::cout << wgd::DEV << "Detected 'tangent' variable at " << loc << "\n"; //WGDglBindAttribLocation(m_program, loc, "tangent"); //does this fix it? m_vars.set("tangent", (void*)(new ShaderVar(2, loc))); } //yay - the shader works! m_ready=true; return true; } char *Shader::readFile(File *f){ if (f == 0 || !f->open(File::READ)) { return 0; } char *content = new char[f->size()+1]; int count = f->read(content, f->size()); content[count] = 0; f->close(); return content; } int Shader::logInfo(GLuint s, const char *name){ int infologLength = 0; int charsWritten = 0; char *infoLog; int r=0; //get length of shader info log if(s==m_program) WGDglGetProgramiv(s, GL_INFO_LOG_LENGTH, &infologLength); else WGDglGetShaderiv(s, GL_INFO_LOG_LENGTH, &infologLength); //output the log if it exists if (infologLength > 0){ //length 1 = success if(infologLength==1){ //if(s==m_program && Shader::debug()) cout << DEV << name << ": OK\n"; return r; } infoLog = (char *)malloc(infologLength); if(s==m_program) WGDglGetProgramInfoLog(s, infologLength, &charsWritten, infoLog); else WGDglGetShaderInfoLog(s, infologLength, &charsWritten, infoLog); //if(Shader::debug()) wgd::cout << wgd::DEV << name << ": " << infoLog << "\n"; //Debug(0, dstring(name) + ": " + infoLog); std::cout << name << ": " << infoLog << "\n"; //If the shader is too large to run in hardware if(strstr(infoLog, "software")) r = -3; //any linker errors if(strstr(infoLog, "Error")) r = -2; //compile errors if(strstr(infoLog, "ERROR")) r = -1; delete [] infoLog; } return r; } GLint Shader::addVariable(const char *name){ if(!m_ready) return -1; //look in uniform, then attribute to find tha variable //and store the variable location for future reference GLint loc=0; //uniform... loc = WGDglGetUniformLocation(m_program, name); if(loc>=0){ //if(Shader::debug()) wgd::cout << wgd::DBG << "Uniform Variable '" << name << "' at " << loc << "\n"; m_vars.set(name, (void*)(new ShaderVar(1, loc))); return loc; } else{ //look in varying variables loc = WGDglGetAttribLocation(m_program, name); //wgd::cout << wgd::DEV << "program " << m_program << " '" << name << "' = " << loc << "\n"; if(loc>=0){ m_vars.set(name, (void*)(new ShaderVar(2, loc))); //if(Shader::debug()) wgd::cout << wgd::DBG << "Varying Variable '" << name << "' at " << loc << "\n"; return loc; } else{ //cant find the variable //wgd::cout << wgd::WARN << "Variable '" << name << "' does not exist " << glGetError() << "\n"; } } return -1; } //set variables here Shader::ShaderVar *Shader::getVar(const char *name){ ShaderVar *v = (ShaderVar*)(void*)m_vars[name]; if(v==NULL){ //attempt to find it! addVariable(name); v = (ShaderVar*)(void*)m_vars[name]; } return v; } void Shader::setVariable(const char *name, float v1){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform1f(v->location, v1); if(v->type==2) WGDglVertexAttrib1f(v->location, v1); } //GLenum err = glGetError(); //if(err!=0) cout << wgd::ERR << "Shader : " << err << "\n"; } void Shader::setVariable(const char *name, float v1, float v2){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform2f(v->location, v1, v2); if(v->type==2) WGDglVertexAttrib2f(v->location, v1, v2); } } void Shader::setVariable(const char *name, float v1, float v2, float v3){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform3f(v->location, v1, v2, v3); if(v->type==2) WGDglVertexAttrib3f(v->location, v1, v2, v3); } } void Shader::setVariable(const char *name, float v1, float v2, float v3, float v4){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform4f(v->location, v1, v2, v3, v4); if(v->type==2) WGDglVertexAttrib4f(v->location, v1, v2, v3, v4); } } void Shader::setVariable(const char *name, const wgd::vector3d &vec3){ if(!m_ready) return; setVariable(name, vec3.x, vec3.y, vec3.z); } void Shader::setVariable(const char *name, int v1){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform1i(v->location, v1); //if(v->type==2) wgd::cout << wgd::WARN << "Cant have integer Attribute variables.\n"; } } void Shader::setVariable(const char *name, int size, int* data){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform1iv(v->location, size, data); //if(v->type==2) wgd::cout << wgd::WARN << "Cant have integer Attribute variables.\n"; } } void Shader::setVariable(const char *name, int size, float* data){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ if(v->type==1) WGDglUniform1fv(v->location, size, data); //if(v->type==2) wgd::cout << wgd::WARN << "Attribute arrays not implemented.\n"; } } //Attribute Arrays void Shader::enableAttribArray(const char *name){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL && v->type==2) WGDglEnableVertexAttribArray(v->location); } void Shader::disableAttribArray(const char *name){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL && v->type==2) WGDglDisableVertexAttribArray(v->location); } void Shader::attribPointer(const char *name, GLint size, GLenum type, GLboolean normalised, GLsizei stride, const void *pointer){ if(!m_ready) return; ShaderVar *v = getVar(name); if(v!=NULL){ WGDglVertexAttribPointer(v->location, size, type, normalised, stride, pointer); } } void Shader::bind(){ if (!Shader::enabled()) { return; } if(!m_ready) { //load and compile shader if not already tried if(s_available && !m_loaded) load(); } if (m_ready) { WGDglUseProgram(m_program); //set current shader for outside reference s_current = this; } } void Shader::unbind(){ if(s_available && enabled()){ if (WGDglUseProgram != 0) WGDglUseProgram(0); } //no shaders bound. s_current=NULL; } wgd-3.1/src/resources_base/texturepng.cpp0000644000175000001440000001072411072476667015603 00000000000000#include #include #include #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; //Custom read handler for PNG library so that it uses our File object. void PNGAPI png_WGD_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; if(png_ptr == NULL) return; doste::File *pngfile = (doste::File*)png_ptr->io_ptr; check = (png_size_t)pngfile->read((char*)data, length); if (check != length) png_error(png_ptr, "Read Error"); } bool TexturePNG::load() { png_byte magic[8]; png_structp png_ptr; png_infop info_ptr; int bit_depth, color_type; //File fp; png_bytep *row_pointers = NULL; unsigned int i; char *mdata; unsigned int mwidth; unsigned int mheight; int mcdepth; File *f = file(); f->open(File::READ); /* read magic number */ //fread (magic, 1, sizeof (magic), fp); f->read(magic); /* check for valid magic number */ if (!png_check_sig (magic, sizeof (magic))) { std::cout << "Invalid PNG image\n"; f->close(); return false; } /* create a png read struct */ png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!png_ptr) { f->close(); return false; } /* create a png info struct */ info_ptr = png_create_info_struct (png_ptr); if (!info_ptr) { png_destroy_read_struct (&png_ptr, NULL, NULL); f->close(); return false; } /* create our OpenGL texture object */ //texinfo = (gl_texture_t *)malloc (sizeof (gl_texture_t)); /* initialize the setjmp for returning properly after a libpng error occured */ if (setjmp (png_jmpbuf (png_ptr))) { png_destroy_read_struct (&png_ptr, &info_ptr, NULL); if (row_pointers) free (row_pointers); f->close(); return false; } /* setup libpng for using standard C fread() function with our FILE pointer */ //THIS LINE IS BROKEN!!!!!! png_set_read_fn(png_ptr, 0, png_WGD_read_data); png_init_io (png_ptr, (FILE*)f); /* tell libpng that we have already read the magic number */ png_set_sig_bytes (png_ptr, sizeof (magic)); /* read png info */ png_read_info (png_ptr, info_ptr); /* get some usefull information from header */ mcdepth = png_get_bit_depth (png_ptr, info_ptr); color_type = png_get_color_type (png_ptr, info_ptr); /* convert index color images to RGB images */ if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb (png_ptr); /* convert 1-2-4 bits grayscale images to 8 bits grayscale. */ bit_depth = 32; if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_gray_1_2_4_to_8 (png_ptr); if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_tRNS_to_alpha (png_ptr); if (bit_depth == 16) png_set_strip_16 (png_ptr); else if (bit_depth < 8) png_set_packing (png_ptr); /* update info structure to apply transformations */ png_read_update_info (png_ptr, info_ptr); /* retrieve updated information */ png_get_IHDR (png_ptr, info_ptr, (png_uint_32*)(&mwidth), (png_uint_32*)(&mheight), &mcdepth, &color_type, NULL, NULL, NULL); /* get image format and components per pixel */ int iFormat=0; switch (color_type) { case PNG_COLOR_TYPE_GRAY: iFormat = 1; break; case PNG_COLOR_TYPE_GRAY_ALPHA: iFormat = 2; break; case PNG_COLOR_TYPE_RGB: iFormat = 3; mcdepth = 24; break; case PNG_COLOR_TYPE_RGB_ALPHA: iFormat = 4; mcdepth = 32; break; default: /* Badness */ break; } /* we can now allocate memory for storing pixel data */ mdata = (char*)malloc (sizeof (GLubyte) * mwidth * mheight * iFormat); /* setup a pointer array. Each one points at the begening of a row. */ row_pointers = (png_bytep *)malloc (sizeof (png_bytep) * mheight); for (i = 0; i < mheight; ++i) { row_pointers[i] = (png_bytep)(mdata + ((mheight - (i + 1)) * mwidth * iFormat)); } /* read pixel data using row pointers */ png_read_image (png_ptr, row_pointers); /* finish decompression and release memory */ png_read_end (png_ptr, info_ptr); png_destroy_read_struct (&png_ptr, &info_ptr, NULL); /* we don't need row pointers anymore */ free (row_pointers); f->close(); data((unsigned char*)mdata); width(mwidth); height(mheight); format((mcdepth==32) ? RGBA : RGB); return true; } bool TexturePNG::validate(File *f) { png_byte magic[8]; /* read magic number */ f->read(magic); f->seek(0, File::BEG); /* check for valid magic number */ if (!png_check_sig (magic, sizeof (magic))) { return false; } else { return true; } } wgd-3.1/src/resources_base/texturebmp.cpp0000644000175000001440000000426311027230475015557 00000000000000#include #include using namespace wgd; using namespace doste; using namespace doste::dvm; struct BitmapHeader { /**** BMP file info structure ****/ unsigned int biSize; /* Size of info header */ int biWidth; /* Width of image */ int biHeight; /* Height of image */ unsigned short biPlanes; /* Number of color planes */ unsigned short biBitCount; /* Number of bits per pixel */ unsigned int biCompression; /* Type of compression to use */ unsigned int biSizeImage; /* Size of image data */ int biXPelsPerMeter; /* X pixels per meter */ int biYPelsPerMeter; /* Y pixels per meter */ unsigned int biClrUsed; /* Number of colors used */ unsigned int biClrImportant; /* Number of important colors */ char *data; }; bool TextureBMP::validate(File *f) { unsigned short check; f->read(check); f->seek(0, File::BEG); return (check == 0x4D42); } bool TextureBMP::load() { char temp; long i; BitmapHeader infoheader; file()->open(File::READ); //Get the width file()->seek(18); file()->read(infoheader.biWidth); //Get the height file()->read(infoheader.biHeight); file()->read(infoheader.biPlanes); if (infoheader.biPlanes != 1) { file()->close(); std::cout << "Bitmap must have only 1 plane\n"; return false; } // read the bpp file()->read(infoheader.biBitCount); if (infoheader.biBitCount != 24) { file()->close(); std::cout << "Bitmap does not have 24bit colour\n"; return false; } file()->seek(24); // read the data. infoheader.data = new char[infoheader.biWidth * infoheader.biHeight * 3]; if ((i = file()->read(infoheader.data, infoheader.biWidth * infoheader.biHeight * 3)) != infoheader.biWidth*infoheader.biHeight*3) { std::cout << "Cannot read image data for texture\n"; file()->close(); return false; } // reverse all of the colors. (bgr -> rgb) for (i=0; i<(infoheader.biWidth * infoheader.biHeight * 3); i+=3) { temp = infoheader.data[i]; infoheader.data[i] = infoheader.data[i+2]; infoheader.data[i+2] = temp; } //Store the relevant data data((unsigned char*)infoheader.data); width(infoheader.biWidth); height(infoheader.biHeight); format(RGB); file()->close(); return true; } wgd-3.1/src/resources_base/material.cpp0000644000175000001440000001236411233311614015151 00000000000000/* * WGD Library * * Authors: * Date: 17/9/2007 * */ #include #include #include //#include using namespace doste; using namespace doste::dvm; using namespace wgd; Material *Material::s_current = 0; wgd::OID Material::BLEND_NORMAL; wgd::OID Material::BLEND_MULTIPLY; wgd::OID Material::BLEND_ADD; wgd::OID Material::BLEND_NONE; wgd::OID Material::BLEND_ONE; void wgd::Material::initialise() { BLEND_NORMAL = "normal"; BLEND_ADD = "add"; BLEND_NONE = "none"; BLEND_MULTIPLY = "multiply"; BLEND_ONE = "one"; } void wgd::Material::finalise() { } wgd::Material::Material() : Agent() { set("type", type()); } wgd::Material::Material(File* file) : Agent() { set(Type, type()); Texture *tex = new Texture(); tex->file(file); set(ix::texture, tex); } wgd::Material::Material(const colour &colour) : Agent() { set(Type, type()); diffuse(colour); } wgd::Material::Material(const OID &res) : Agent(res) { } wgd::Material::~Material() { } void wgd::Material::variable(const char *name, const wgd::OID &v) { if (get(ix::variables) == Null) { set(ix::variables, wgd::OID::create()); } get(ix::variables).set(name, v); } wgd::OID wgd::Material::variable(const char *name) { return get(ix::variables)[name]; } void wgd::Material::bind() { if (s_current != this) { GLfloat mat[4]; colour c = specular(); c.toArray(mat); glMaterialfv(GL_FRONT, GL_SPECULAR, mat); c = diffuse(); //if diffuse is null, use white (rather than transparent) if(get(ix::diffuse)==Null) { c.r=1.0; c.g=1.0; c.b=1.0; c.a=1.0; } //if (Lighting::enabled() == false) { // glColor4f(c.r,c.g,c.b,c.a); //} //std::cout << "Colours: " << c.r << " " << c.g << " " << c.b << " " << c.a << "\n"; c.toArray(mat); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); c = ambient(); c.toArray(mat); glMaterialfv(GL_FRONT, GL_AMBIENT, mat); mat[0] = shininess(); glMaterialfv(GL_FRONT, GL_SHININESS, mat); c = emission(); c.toArray(mat); glMaterialfv(GL_FRONT, GL_EMISSION, mat); s_current = this; Texture *tex; //if (get(ix::textures) != Null) { for (int i=0; ibind(i); } //} else { // if (get(ix::texture) != Null) { // tex = texture(); // if(tex!=NULL) // tex->bind(); // } //} if (get(ix::shader) != Null) { Shader *shade = shader(); shade->bind(); if (Shader::current() == shade) { //Set shader variables. OID vars = get(ix::variables); OID val; char sbuf[50]; if (vars != Null) { for (OID::iterator i=vars.begin(); i!=vars.end(); i++) { (*i).toString(sbuf, 50); val = vars[*i]; if (val.isDouble()) shade->setVariable(sbuf, (float)val); if (val.isLongLong()) shade->setVariable(sbuf, (int)val); //also need arrays /*if (val.isObject()) { //val is an array of n values //either need to send them individually, or //create an array and send them all at once strcat(sbuf, "[0]"); //get number of values int n=0; for(n=0; val[n]!=Null; n++); //floats or ints? if (val[0].IsFloat()){ float *array = new float[n]; for(int i=0; isetVariable(sbuf, n, array); delete [] array; //cout << "Array " << sbuf << " = "; //for(int i=0; isetVariable(sbuf, n, array); delete [] array; } }*/ } } } } OID blnd = blending(); if (blnd == BLEND_MULTIPLY) { glBlendFunc (GL_DST_COLOR, GL_ZERO); } else if (blnd == BLEND_ONE) { glBlendFunc(GL_ONE, GL_ONE); } else if (blnd == BLEND_ADD) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); } else { //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } //} else { // glBlendFunc(GL_SRC_ALPHA, GL_ZERO); //} } } void wgd::Material::unbind() { Texture *tex; //if (get(ix::textures) != Null) { for (int i=Texture::maxTextureUnits()-1; i>=0; i--) { tex = texture(i); if (tex == 0) continue; tex->unbind(); } //} else { // if (get(ix::texture) != Null) { // tex = texture(); // if (tex != 0) // tex->unbind(); // } //} if (get(ix::shader) != Null) { Shader *shade = shader(); shade->unbind(); } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //reset diffuse GLfloat mat[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; glMaterialfv(GL_FRONT, GL_DIFFUSE, mat); if(s_current==this) s_current=NULL; } void wgd::Material::texture(int num, Texture *tex) { if (get(ix::textures) == Null) { if (num == 0) { set(ix::texture, *tex); } else { set(ix::textures, OID::create()); get(ix::textures).set(0, get(ix::texture)); get(ix::textures).set(num, *tex); } } else { get(ix::textures).set(num, *tex); } } Texture *wgd::Material::texture(int num) { if (get(ix::textures) == Null) { if (num == 0 ) { return (Texture*)get(ix::texture); } else { return 0; } } else { return (Texture*)(get(ix::textures).get(num)); } } wgd-3.1/src/resources_base/sprite.cpp0000644000175000001440000000166111233311614014657 00000000000000/* * ÌÇÐÄTV Game Design Library */ #include using namespace doste; using namespace doste::dvm; wgd::Sprite::Sprite() : Agent() { setup(); } wgd::Sprite::Sprite(const char* filename) { texture(new Texture(new LocalFile(filename))); setup(); } wgd::Sprite::Sprite(File *file) : Agent() { texture(new Texture(file)); setup(); } wgd::Sprite::Sprite(const OID &res) : Agent(res) { setup(); } void wgd::Sprite::setup() { //Initialise defaults if (columns() == 0) columns(1); //One column if (rows() == 0) rows(1); //One row if (frames() == 0) frames(1); //One frame if (get(ix::texture) != Null) { //If there is a texture texture()->load(); //Load from file to get width/height data if (width() == 0) { width(texture()->width()); } if (height() == 0) { height(texture()->height()); } } } wgd::Sprite::~Sprite() { } void wgd::Sprite::initialise() { } void wgd::Sprite::finalise() { } wgd-3.1/src/resources_base/Makefile.am0000644000175000001440000000147411233311614014703 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_resources_base.so libwgd_resources_base_so_SOURCES=resources_base.cpp texture.cpp sprite.cpp ./png/png.cpp ./png/pngerror.cpp ./png/pnggccrd.cpp ./png/pngget.cpp ./png/pngmem.cpp ./png/pngpread.cpp ./png/pngread.cpp ./png/pngrio.cpp ./png/pngrtran.cpp ./png/pngrutil.cpp ./png/pngset.cpp ./png/pngtrans.cpp ./zlib/adler32.cpp ./zlib/crc32.cpp ./zlib/deflate.cpp ./zlib/infback.cpp ./zlib/inffast.cpp ./zlib/inflate.cpp ./zlib/inftrees.cpp ./zlib/trees.cpp ./zlib/uncompr.cpp ./zlib/zutil.cpp font.cpp material.cpp shader.cpp rendertarget.cpp texturepng.cpp texturetga.cpp texturebmp.cpp scenegraph.cpp spritefont.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/resources_base/resources_base.cpp0000644000175000001440000000132411233311614016351 00000000000000#include #include #include #include #include #include #include #include #include using namespace doste; using namespace doste::dvm; extern "C" void RESIMPORT initialise(const OID &base) { Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); Object::registerType(); wgd::Texture::initialise(); wgd::Material::initialise(); } extern "C" void RESIMPORT finalise() { } wgd-3.1/src/resources_base/scenegraph.cpp0000644000175000001440000001145411233311614015471 00000000000000//I'll stick this in base3d for now, but it really needs to be used by scene2d and scene3d. #include #include #include #include using namespace wgd; DrawStatus DrawableBase::status; bool SceneGraph::draw() { DrawableBase::begin(); //sort lists std::sort(m_solid.begin(), m_solid.end(), DrawableBase::compare); std::sort(m_alpha.begin(), m_alpha.end(), DrawableBase::compare); //draw lists for(std::vector::iterator i= m_solid.begin(); i!=m_solid.end(); i++) { (*i)->draw(); //delete data (*i)->queued--; if((*i)->clearData) (*i)->deleteData(); if((*i)->discard) delete *i; } for(std::vector::iterator i=m_alpha.begin(); i!=m_alpha.end(); i++) { (*i)->draw(); //delete data (*i)->queued--; if((*i)->clearData) (*i)->deleteData(); if((*i)->discard) delete *i; } //clear lists m_solid.clear(); m_alpha.clear(); DrawableBase::end(); return true; } DrawableBase* SceneGraph::add(DrawableBase *d) { //detect if there is any alpha (d->material/texture (from surface) + vertex colour ) return addSolid(d); } DrawableBase* SceneGraph::addSolid(DrawableBase *d) { m_solid.push_back(d); d->queued++; return d; } DrawableBase* SceneGraph::addAlpha(DrawableBase *d) { m_alpha.push_back(d); d->queued++; return d; } // Some drawable functions // DrawStatus::DrawStatus() : active(false), normals(0), colours(0), texcoords(0), material(0), texture(0), shader(0) {} void DrawStatus::begin() { glEnableClientState(GL_VERTEX_ARRAY); //All drawables need this glAlphaFunc(GL_GREATER, 0.5); active = true; //drawstatus is on flags = 7; //defaults for stuff normals = false; colours = false; texcoords = 0; surface = Null; glEnable(GL_NORMALIZE); } void DrawStatus::end() { setState(0, 0, 0); glDisableClientState(GL_VERTEX_ARRAY); setFlags(7); setSurface(Null); active = false; } void DrawStatus::setState(bool n, bool c, unsigned int tx) { //Normal array if(n && !normals) glEnableClientState (GL_NORMAL_ARRAY); if(!n && normals) glDisableClientState(GL_NORMAL_ARRAY); normals = n; //Colour array if(c && !colours) glEnableClientState (GL_COLOR_ARRAY); if(!c && colours) glDisableClientState(GL_COLOR_ARRAY); colours = c; //enable texture arrays unsigned int i; for(i=0; i0) WGDglClientActiveTextureARB(GL_TEXTURE0_ARB+i); if(i=texcoords) glEnableClientState(GL_TEXTURE_COORD_ARRAY); if(i>=tx) glDisableClientState(GL_TEXTURE_COORD_ARRAY); } if(i>0) WGDglClientActiveTextureARB(GL_TEXTURE0_ARB); texcoords = tx; } void DrawStatus::setSurface(const OID& surf) { if(surf==surface) return; //No change //unbind any existing stuff if(material) material->unbind(); if(texture) texture->unbind(); //disable any previous shader stuff if(last) last->disableCustom(shader); //bind new surfce shader = 0; material = 0; texture = 0; if(surf!=Null) { //warn user if they haven't dereferenced their material/texture pointers if(surf.isPointer()) { std::cout << "Warning: Pointer found for drawable surface\n"; return; } if(surf.get(ix::type) == OID("Material")) { material = surf; shader = material->shader(); material->bind(); } else if(surf.get(ix::type) == OID("Texture")) { texture = surf; texture->bind(); } } //store new surface surface = surf; } void DrawStatus::setFlags(unsigned char f) { //Lighting if((f & LIGHTING) && !(flags & LIGHTING)) glEnable(GL_LIGHTING); if(!(f & LIGHTING) && (flags & LIGHTING)) glDisable(GL_LIGHTING); //Depth Test if((f & DEPTH_TEST) && !(flags & DEPTH_TEST)) glEnable(GL_DEPTH_TEST); if(!(f & DEPTH_TEST) && (flags & DEPTH_TEST)) glDisable(GL_DEPTH_TEST); //Depth mask (write) if((f & DEPTH_WRITE) && !(flags & DEPTH_WRITE)) glDepthMask(1); if(!(f & DEPTH_WRITE) && (flags & DEPTH_WRITE)) glDepthMask(0); //Alpha testing if((f & ALPHA_TEST) && !(flags & ALPHA_TEST)) glEnable(GL_ALPHA_TEST); if(!(f & ALPHA_TEST) && (flags & ALPHA_TEST)) glDisable(GL_ALPHA_TEST); //Wireframe if((f & WIREFRAME) && !(flags & WIREFRAME)) glPolygonMode(GL_FRONT, GL_LINE); if(!(f & WIREFRAME) && (flags & WIREFRAME)) glPolygonMode(GL_FRONT, GL_FILL); //Double sided polygons if((f & DOUBLE_SIDED) && !(flags & DOUBLE_SIDED)) glDisable(GL_CULL_FACE); if(!(f & DOUBLE_SIDED) && (flags & DOUBLE_SIDED)) glEnable(GL_CULL_FACE); flags = f; } void DrawStatus::reset() { setState(0,0,0); glDisableClientState(GL_VERTEX_ARRAY); setSurface(Null); flags = (DrawFlags)7; glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glDepthMask(true); glDisable(GL_ALPHA_TEST); glPolygonMode(GL_FRONT, GL_FILL); active = false; } wgd-3.1/src/resources_base/Makefile.in0000644000175000001440000005776711265575055014754 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_resources_base.so$(EXEEXT) subdir = src/resources_base DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_resources_base_so_OBJECTS = resources_base.$(OBJEXT) \ texture.$(OBJEXT) sprite.$(OBJEXT) png.$(OBJEXT) \ pngerror.$(OBJEXT) pnggccrd.$(OBJEXT) pngget.$(OBJEXT) \ pngmem.$(OBJEXT) pngpread.$(OBJEXT) pngread.$(OBJEXT) \ pngrio.$(OBJEXT) pngrtran.$(OBJEXT) pngrutil.$(OBJEXT) \ pngset.$(OBJEXT) pngtrans.$(OBJEXT) adler32.$(OBJEXT) \ crc32.$(OBJEXT) deflate.$(OBJEXT) infback.$(OBJEXT) \ inffast.$(OBJEXT) inflate.$(OBJEXT) inftrees.$(OBJEXT) \ trees.$(OBJEXT) uncompr.$(OBJEXT) zutil.$(OBJEXT) \ font.$(OBJEXT) material.$(OBJEXT) shader.$(OBJEXT) \ rendertarget.$(OBJEXT) texturepng.$(OBJEXT) \ texturetga.$(OBJEXT) texturebmp.$(OBJEXT) scenegraph.$(OBJEXT) \ spritefont.$(OBJEXT) libwgd_resources_base_so_OBJECTS = \ $(am_libwgd_resources_base_so_OBJECTS) libwgd_resources_base_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_resources_base_so_SOURCES) DIST_SOURCES = $(libwgd_resources_base_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_resources_base_so_SOURCES = resources_base.cpp texture.cpp sprite.cpp ./png/png.cpp ./png/pngerror.cpp ./png/pnggccrd.cpp ./png/pngget.cpp ./png/pngmem.cpp ./png/pngpread.cpp ./png/pngread.cpp ./png/pngrio.cpp ./png/pngrtran.cpp ./png/pngrutil.cpp ./png/pngset.cpp ./png/pngtrans.cpp ./zlib/adler32.cpp ./zlib/crc32.cpp ./zlib/deflate.cpp ./zlib/infback.cpp ./zlib/inffast.cpp ./zlib/inflate.cpp ./zlib/inftrees.cpp ./zlib/trees.cpp ./zlib/uncompr.cpp ./zlib/zutil.cpp font.cpp material.cpp shader.cpp rendertarget.cpp texturepng.cpp texturetga.cpp texturebmp.cpp scenegraph.cpp spritefont.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -shared -lGL -lGLU -lX11 -lXxf86vm -ldoste -lwgd_base INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/resources_base/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/resources_base/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_resources_base.so$(EXEEXT): $(libwgd_resources_base_so_OBJECTS) $(libwgd_resources_base_so_DEPENDENCIES) @rm -f libwgd_resources_base.so$(EXEEXT) $(CXXLINK) $(libwgd_resources_base_so_OBJECTS) $(libwgd_resources_base_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` png.o: ./png/png.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o png.o `test -f './png/png.cpp' || echo '$(srcdir)/'`./png/png.cpp png.obj: ./png/png.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o png.obj `if test -f './png/png.cpp'; then $(CYGPATH_W) './png/png.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/png.cpp'; fi` pngerror.o: ./png/pngerror.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngerror.o `test -f './png/pngerror.cpp' || echo '$(srcdir)/'`./png/pngerror.cpp pngerror.obj: ./png/pngerror.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngerror.obj `if test -f './png/pngerror.cpp'; then $(CYGPATH_W) './png/pngerror.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngerror.cpp'; fi` pnggccrd.o: ./png/pnggccrd.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pnggccrd.o `test -f './png/pnggccrd.cpp' || echo '$(srcdir)/'`./png/pnggccrd.cpp pnggccrd.obj: ./png/pnggccrd.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pnggccrd.obj `if test -f './png/pnggccrd.cpp'; then $(CYGPATH_W) './png/pnggccrd.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pnggccrd.cpp'; fi` pngget.o: ./png/pngget.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngget.o `test -f './png/pngget.cpp' || echo '$(srcdir)/'`./png/pngget.cpp pngget.obj: ./png/pngget.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngget.obj `if test -f './png/pngget.cpp'; then $(CYGPATH_W) './png/pngget.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngget.cpp'; fi` pngmem.o: ./png/pngmem.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngmem.o `test -f './png/pngmem.cpp' || echo '$(srcdir)/'`./png/pngmem.cpp pngmem.obj: ./png/pngmem.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngmem.obj `if test -f './png/pngmem.cpp'; then $(CYGPATH_W) './png/pngmem.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngmem.cpp'; fi` pngpread.o: ./png/pngpread.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngpread.o `test -f './png/pngpread.cpp' || echo '$(srcdir)/'`./png/pngpread.cpp pngpread.obj: ./png/pngpread.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngpread.obj `if test -f './png/pngpread.cpp'; then $(CYGPATH_W) './png/pngpread.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngpread.cpp'; fi` pngread.o: ./png/pngread.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngread.o `test -f './png/pngread.cpp' || echo '$(srcdir)/'`./png/pngread.cpp pngread.obj: ./png/pngread.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngread.obj `if test -f './png/pngread.cpp'; then $(CYGPATH_W) './png/pngread.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngread.cpp'; fi` pngrio.o: ./png/pngrio.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngrio.o `test -f './png/pngrio.cpp' || echo '$(srcdir)/'`./png/pngrio.cpp pngrio.obj: ./png/pngrio.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngrio.obj `if test -f './png/pngrio.cpp'; then $(CYGPATH_W) './png/pngrio.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngrio.cpp'; fi` pngrtran.o: ./png/pngrtran.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngrtran.o `test -f './png/pngrtran.cpp' || echo '$(srcdir)/'`./png/pngrtran.cpp pngrtran.obj: ./png/pngrtran.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngrtran.obj `if test -f './png/pngrtran.cpp'; then $(CYGPATH_W) './png/pngrtran.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngrtran.cpp'; fi` pngrutil.o: ./png/pngrutil.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngrutil.o `test -f './png/pngrutil.cpp' || echo '$(srcdir)/'`./png/pngrutil.cpp pngrutil.obj: ./png/pngrutil.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngrutil.obj `if test -f './png/pngrutil.cpp'; then $(CYGPATH_W) './png/pngrutil.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngrutil.cpp'; fi` pngset.o: ./png/pngset.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngset.o `test -f './png/pngset.cpp' || echo '$(srcdir)/'`./png/pngset.cpp pngset.obj: ./png/pngset.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngset.obj `if test -f './png/pngset.cpp'; then $(CYGPATH_W) './png/pngset.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngset.cpp'; fi` pngtrans.o: ./png/pngtrans.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngtrans.o `test -f './png/pngtrans.cpp' || echo '$(srcdir)/'`./png/pngtrans.cpp pngtrans.obj: ./png/pngtrans.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pngtrans.obj `if test -f './png/pngtrans.cpp'; then $(CYGPATH_W) './png/pngtrans.cpp'; else $(CYGPATH_W) '$(srcdir)/./png/pngtrans.cpp'; fi` adler32.o: ./zlib/adler32.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o adler32.o `test -f './zlib/adler32.cpp' || echo '$(srcdir)/'`./zlib/adler32.cpp adler32.obj: ./zlib/adler32.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o adler32.obj `if test -f './zlib/adler32.cpp'; then $(CYGPATH_W) './zlib/adler32.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/adler32.cpp'; fi` crc32.o: ./zlib/crc32.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o crc32.o `test -f './zlib/crc32.cpp' || echo '$(srcdir)/'`./zlib/crc32.cpp crc32.obj: ./zlib/crc32.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o crc32.obj `if test -f './zlib/crc32.cpp'; then $(CYGPATH_W) './zlib/crc32.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/crc32.cpp'; fi` deflate.o: ./zlib/deflate.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o deflate.o `test -f './zlib/deflate.cpp' || echo '$(srcdir)/'`./zlib/deflate.cpp deflate.obj: ./zlib/deflate.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o deflate.obj `if test -f './zlib/deflate.cpp'; then $(CYGPATH_W) './zlib/deflate.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/deflate.cpp'; fi` infback.o: ./zlib/infback.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o infback.o `test -f './zlib/infback.cpp' || echo '$(srcdir)/'`./zlib/infback.cpp infback.obj: ./zlib/infback.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o infback.obj `if test -f './zlib/infback.cpp'; then $(CYGPATH_W) './zlib/infback.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/infback.cpp'; fi` inffast.o: ./zlib/inffast.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o inffast.o `test -f './zlib/inffast.cpp' || echo '$(srcdir)/'`./zlib/inffast.cpp inffast.obj: ./zlib/inffast.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o inffast.obj `if test -f './zlib/inffast.cpp'; then $(CYGPATH_W) './zlib/inffast.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/inffast.cpp'; fi` inflate.o: ./zlib/inflate.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o inflate.o `test -f './zlib/inflate.cpp' || echo '$(srcdir)/'`./zlib/inflate.cpp inflate.obj: ./zlib/inflate.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o inflate.obj `if test -f './zlib/inflate.cpp'; then $(CYGPATH_W) './zlib/inflate.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/inflate.cpp'; fi` inftrees.o: ./zlib/inftrees.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o inftrees.o `test -f './zlib/inftrees.cpp' || echo '$(srcdir)/'`./zlib/inftrees.cpp inftrees.obj: ./zlib/inftrees.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o inftrees.obj `if test -f './zlib/inftrees.cpp'; then $(CYGPATH_W) './zlib/inftrees.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/inftrees.cpp'; fi` trees.o: ./zlib/trees.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trees.o `test -f './zlib/trees.cpp' || echo '$(srcdir)/'`./zlib/trees.cpp trees.obj: ./zlib/trees.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o trees.obj `if test -f './zlib/trees.cpp'; then $(CYGPATH_W) './zlib/trees.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/trees.cpp'; fi` uncompr.o: ./zlib/uncompr.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncompr.o `test -f './zlib/uncompr.cpp' || echo '$(srcdir)/'`./zlib/uncompr.cpp uncompr.obj: ./zlib/uncompr.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o uncompr.obj `if test -f './zlib/uncompr.cpp'; then $(CYGPATH_W) './zlib/uncompr.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/uncompr.cpp'; fi` zutil.o: ./zlib/zutil.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zutil.o `test -f './zlib/zutil.cpp' || echo '$(srcdir)/'`./zlib/zutil.cpp zutil.obj: ./zlib/zutil.cpp $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zutil.obj `if test -f './zlib/zutil.cpp'; then $(CYGPATH_W) './zlib/zutil.cpp'; else $(CYGPATH_W) '$(srcdir)/./zlib/zutil.cpp'; fi` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/resources_base/spritefont.cpp0000644000175000001440000000207711233311614015550 00000000000000#include namespace wgd { OnEvent(SpriteFont, evt_build) { buildFont(); } IMPLEMENT_EVENTS(SpriteFont, Font); }; using namespace wgd; using namespace doste; SpriteFont::SpriteFont() { registerEvents(); } SpriteFont::SpriteFont(const OID &id) : Font(id) { registerEvents(); } SpriteFont::SpriteFont(Sprite *spr) { sprite(spr); registerEvents(); } SpriteFont::~SpriteFont() {} void SpriteFont::buildFont() { Sprite *spr = sprite(); dstring s = characters(); char str[128]; s.toString(str, 128); if(!spr || s.size()==0) return; memset(m_cdata, 0, 128 * sizeof(CData)); int tw = spr->texture()->width(); int th = spr->texture()->height(); int rows = spr->rows(); int cols = spr->columns(); for(int i=0; itexture()); }wgd-3.1/src/resources_base/png/0000777000175000001440000000000011265576313013527 500000000000000wgd-3.1/src/resources_base/png/pngget.cpp0000644000175000001440000006036110757754260015445 00000000000000 /* pngget.c - retrieval of values from info struct * * Last changed in libpng 1.2.15 January 5, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL #include #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) png_uint_32 PNGAPI png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->valid & flag); else return(0); } png_uint_32 PNGAPI png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->rowbytes); else return(0); } #if defined(PNG_INFO_IMAGE_SUPPORTED) png_bytepp PNGAPI png_get_rows(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->row_pointers); else return(0); } #endif #ifdef PNG_EASY_ACCESS_SUPPORTED /* easy access to info, added in libpng-0.99 */ png_uint_32 PNGAPI png_get_image_width(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->width; } return (0); } png_uint_32 PNGAPI png_get_image_height(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->height; } return (0); } png_byte PNGAPI png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->bit_depth; } return (0); } png_byte PNGAPI png_get_color_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->color_type; } return (0); } png_byte PNGAPI png_get_filter_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->filter_type; } return (0); } png_byte PNGAPI png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->interlace_type; } return (0); } png_byte PNGAPI png_get_compression_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) { return info_ptr->compression_type; } return (0); } png_uint_32 PNGAPI png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->x_pixels_per_unit); } #else return (0); #endif return (0); } png_uint_32 PNGAPI png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); else return (info_ptr->y_pixels_per_unit); } #else return (0); #endif return (0); } png_uint_32 PNGAPI png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) return (0); else return (info_ptr->x_pixels_per_unit); } #else return (0); #endif return (0); } #ifdef PNG_FLOATING_POINT_SUPPORTED float PNGAPI png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); if (info_ptr->x_pixels_per_unit == 0) return ((float)0.0); else return ((float)((float)info_ptr->y_pixels_per_unit /(float)info_ptr->x_pixels_per_unit)); } #else return (0.0); #endif return ((float)0.0); } #endif png_int_32 PNGAPI png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); else return (info_ptr->x_offset); } #else return (0); #endif return (0); } png_int_32 PNGAPI png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); else return (info_ptr->y_offset); } #else return (0); #endif return (0); } png_int_32 PNGAPI png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); else return (info_ptr->x_offset); } #else return (0); #endif return (0); } png_int_32 PNGAPI png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); else return (info_ptr->y_offset); } #else return (0); #endif return (0); } #if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED) png_uint_32 PNGAPI png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr) *.0254 +.5)); } png_uint_32 PNGAPI png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr) *.0254 +.5)); } png_uint_32 PNGAPI png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr) { return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr) *.0254 +.5)); } float PNGAPI png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr) { return ((float)png_get_x_offset_microns(png_ptr, info_ptr) *.00003937); } float PNGAPI png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr) { return ((float)png_get_y_offset_microns(png_ptr, info_ptr) *.00003937); } #if defined(PNG_pHYs_SUPPORTED) png_uint_32 PNGAPI png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { png_debug1(1, "in %s retrieval function\n", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; if(*unit_type == 1) { if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); } } } return (retval); } #endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ /* png_get_channels really belongs in here, too, but it's been around longer */ #endif /* PNG_EASY_ACCESS_SUPPORTED */ png_byte PNGAPI png_get_channels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->channels); else return (0); } png_bytep PNGAPI png_get_signature(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->signature); else return (NULL); } #if defined(PNG_bKGD_SUPPORTED) png_uint_32 PNGAPI png_get_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p *background) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) && background != NULL) { png_debug1(1, "in %s retrieval function\n", "bKGD"); *background = &(info_ptr->background); return (PNG_INFO_bKGD); } return (0); } #endif #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_cHRM(png_structp png_ptr, png_infop info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { png_debug1(1, "in %s retrieval function\n", "cHRM"); if (white_x != NULL) *white_x = (double)info_ptr->x_white; if (white_y != NULL) *white_y = (double)info_ptr->y_white; if (red_x != NULL) *red_x = (double)info_ptr->x_red; if (red_y != NULL) *red_y = (double)info_ptr->y_red; if (green_x != NULL) *green_x = (double)info_ptr->x_green; if (green_y != NULL) *green_y = (double)info_ptr->y_green; if (blue_x != NULL) *blue_x = (double)info_ptr->x_blue; if (blue_y != NULL) *blue_y = (double)info_ptr->y_blue; return (PNG_INFO_cHRM); } return (0); } #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, png_fixed_point *blue_x, png_fixed_point *blue_y) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { png_debug1(1, "in %s retrieval function\n", "cHRM"); if (white_x != NULL) *white_x = info_ptr->int_x_white; if (white_y != NULL) *white_y = info_ptr->int_y_white; if (red_x != NULL) *red_x = info_ptr->int_x_red; if (red_y != NULL) *red_y = info_ptr->int_y_red; if (green_x != NULL) *green_x = info_ptr->int_x_green; if (green_y != NULL) *green_y = info_ptr->int_y_green; if (blue_x != NULL) *blue_x = info_ptr->int_x_blue; if (blue_y != NULL) *blue_y = info_ptr->int_y_blue; return (PNG_INFO_cHRM); } return (0); } #endif #endif #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && file_gamma != NULL) { png_debug1(1, "in %s retrieval function\n", "gAMA"); *file_gamma = (double)info_ptr->gamma; return (PNG_INFO_gAMA); } return (0); } #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point *int_file_gamma) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && int_file_gamma != NULL) { png_debug1(1, "in %s retrieval function\n", "gAMA"); *int_file_gamma = info_ptr->int_gamma; return (PNG_INFO_gAMA); } return (0); } #endif #endif #if defined(PNG_sRGB_SUPPORTED) png_uint_32 PNGAPI png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) && file_srgb_intent != NULL) { png_debug1(1, "in %s retrieval function\n", "sRGB"); *file_srgb_intent = (int)info_ptr->srgb_intent; return (PNG_INFO_sRGB); } return (0); } #endif #if defined(PNG_iCCP_SUPPORTED) png_uint_32 PNGAPI png_get_iCCP(png_structp png_ptr, png_infop info_ptr, png_charpp name, int *compression_type, png_charpp profile, png_uint_32 *proflen) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) && name != NULL && profile != NULL && proflen != NULL) { png_debug1(1, "in %s retrieval function\n", "iCCP"); *name = info_ptr->iccp_name; *profile = info_ptr->iccp_profile; /* compression_type is a dummy so the API won't have to change if we introduce multiple compression types later. */ *proflen = (int)info_ptr->iccp_proflen; *compression_type = (int)info_ptr->iccp_compression; return (PNG_INFO_iCCP); } return (0); } #endif #if defined(PNG_sPLT_SUPPORTED) png_uint_32 PNGAPI png_get_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tpp spalettes) { if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) { *spalettes = info_ptr->splt_palettes; return ((png_uint_32)info_ptr->splt_palettes_num); } return (0); } #endif #if defined(PNG_hIST_SUPPORTED) png_uint_32 PNGAPI png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) && hist != NULL) { png_debug1(1, "in %s retrieval function\n", "hIST"); *hist = info_ptr->hist; return (PNG_INFO_hIST); } return (0); } #endif png_uint_32 PNGAPI png_get_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_type, int *compression_type, int *filter_type) { if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && bit_depth != NULL && color_type != NULL) { png_debug1(1, "in %s retrieval function\n", "IHDR"); *width = info_ptr->width; *height = info_ptr->height; *bit_depth = info_ptr->bit_depth; if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) png_error(png_ptr, "Invalid bit depth"); *color_type = info_ptr->color_type; if (info_ptr->color_type > 6) png_error(png_ptr, "Invalid color type"); if (compression_type != NULL) *compression_type = info_ptr->compression_type; if (filter_type != NULL) *filter_type = info_ptr->filter_type; if (interlace_type != NULL) *interlace_type = info_ptr->interlace_type; /* check for potential overflow of rowbytes */ //if (*width == 0 || *width > PNG_UINT_31_MAX) // png_error(png_ptr, "Invalid image width"); //if (*height == 0 || *height > PNG_UINT_31_MAX) // png_error(png_ptr, "Invalid image height"); //if (info_ptr->width > (PNG_UINT_32_MAX // >> 3) /* 8-byte RGBA pixels */ // - 64 /* bigrowbuf hack */ // - 1 /* filter byte */ // - 7*8 /* rounding of width to multiple of 8 pixels */ // - 8) /* extra max_pixel_depth pad */ //{ // png_warning(png_ptr, // "Width too large for libpng to process image data."); //} return (1); } return (0); } #if defined(PNG_oFFs_SUPPORTED) png_uint_32 PNGAPI png_get_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) && offset_x != NULL && offset_y != NULL && unit_type != NULL) { png_debug1(1, "in %s retrieval function\n", "oFFs"); *offset_x = info_ptr->x_offset; *offset_y = info_ptr->y_offset; *unit_type = (int)info_ptr->offset_unit_type; return (PNG_INFO_oFFs); } return (0); } #endif #if defined(PNG_pCAL_SUPPORTED) png_uint_32 PNGAPI png_get_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && nparams != NULL && units != NULL && params != NULL) { png_debug1(1, "in %s retrieval function\n", "pCAL"); *purpose = info_ptr->pcal_purpose; *X0 = info_ptr->pcal_X0; *X1 = info_ptr->pcal_X1; *type = (int)info_ptr->pcal_type; *nparams = (int)info_ptr->pcal_nparams; *units = info_ptr->pcal_units; *params = info_ptr->pcal_params; return (PNG_INFO_pCAL); } return (0); } #endif #if defined(PNG_sCAL_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED png_uint_32 PNGAPI png_get_sCAL(png_structp png_ptr, png_infop info_ptr, int *unit, double *width, double *height) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) { *unit = info_ptr->scal_unit; *width = info_ptr->scal_pixel_width; *height = info_ptr->scal_pixel_height; return (PNG_INFO_sCAL); } return(0); } #else #ifdef PNG_FIXED_POINT_SUPPORTED png_uint_32 PNGAPI png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, int *unit, png_charpp width, png_charpp height) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) { *unit = info_ptr->scal_unit; *width = info_ptr->scal_s_width; *height = info_ptr->scal_s_height; return (PNG_INFO_sCAL); } return(0); } #endif #endif #endif #if defined(PNG_pHYs_SUPPORTED) png_uint_32 PNGAPI png_get_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { png_debug1(1, "in %s retrieval function\n", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; } } return (retval); } #endif png_uint_32 PNGAPI png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) && palette != NULL) { png_debug1(1, "in %s retrieval function\n", "PLTE"); *palette = info_ptr->palette; *num_palette = info_ptr->num_palette; png_debug1(3, "num_palette = %d\n", *num_palette); return (PNG_INFO_PLTE); } return (0); } #if defined(PNG_sBIT_SUPPORTED) png_uint_32 PNGAPI png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) && sig_bit != NULL) { png_debug1(1, "in %s retrieval function\n", "sBIT"); *sig_bit = &(info_ptr->sig_bit); return (PNG_INFO_sBIT); } return (0); } #endif #if defined(PNG_TEXT_SUPPORTED) png_uint_32 PNGAPI png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, int *num_text) { if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) { png_debug1(1, "in %s retrieval function\n", (png_ptr->chunk_name[0] == '\0' ? "text" : (png_const_charp)png_ptr->chunk_name)); if (text_ptr != NULL) *text_ptr = info_ptr->text; if (num_text != NULL) *num_text = info_ptr->num_text; return ((png_uint_32)info_ptr->num_text); } if (num_text != NULL) *num_text = 0; return(0); } #endif #if defined(PNG_tIME_SUPPORTED) png_uint_32 PNGAPI png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) && mod_time != NULL) { png_debug1(1, "in %s retrieval function\n", "tIME"); *mod_time = &(info_ptr->mod_time); return (PNG_INFO_tIME); } return (0); } #endif #if defined(PNG_tRNS_SUPPORTED) png_uint_32 PNGAPI png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values) { png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { png_debug1(1, "in %s retrieval function\n", "tRNS"); if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (trans != NULL) { *trans = info_ptr->trans; retval |= PNG_INFO_tRNS; } if (trans_values != NULL) *trans_values = &(info_ptr->trans_values); } else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ { if (trans_values != NULL) { *trans_values = &(info_ptr->trans_values); retval |= PNG_INFO_tRNS; } if(trans != NULL) *trans = NULL; } if(num_trans != NULL) { *num_trans = info_ptr->num_trans; retval |= PNG_INFO_tRNS; } } return (retval); } #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) png_uint_32 PNGAPI png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkpp unknowns) { if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) { *unknowns = info_ptr->unknown_chunks; return ((png_uint_32)info_ptr->unknown_chunks_num); } return (0); } #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) png_byte PNGAPI png_get_rgb_to_gray_status (png_structp png_ptr) { return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0); } #endif #if defined(PNG_USER_CHUNKS_SUPPORTED) png_voidp PNGAPI png_get_user_chunk_ptr(png_structp png_ptr) { return (png_ptr? png_ptr->user_chunk_ptr : NULL); } #endif #ifdef PNG_WRITE_SUPPORTED png_uint_32 PNGAPI png_get_compression_buffer_size(png_structp png_ptr) { return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L); } #endif #ifdef PNG_ASSEMBLER_CODE_SUPPORTED #ifndef PNG_1_0_X /* this function was added to libpng 1.2.0 and should exist by default */ png_uint_32 PNGAPI png_get_asm_flags (png_structp png_ptr) { /* obsolete, to be removed from libpng-1.4.0 */ return (png_ptr? 0L: 0L); } /* this function was added to libpng 1.2.0 and should exist by default */ png_uint_32 PNGAPI png_get_asm_flagmask (int flag_select) { /* obsolete, to be removed from libpng-1.4.0 */ flag_select=flag_select; return 0L; } /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ /* this function was added to libpng 1.2.0 */ png_uint_32 PNGAPI png_get_mmx_flagmask (int flag_select, int *compilerID) { /* obsolete, to be removed from libpng-1.4.0 */ flag_select=flag_select; *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ return 0L; } /* this function was added to libpng 1.2.0 */ png_byte PNGAPI png_get_mmx_bitdepth_threshold (png_structp png_ptr) { /* obsolete, to be removed from libpng-1.4.0 */ return (png_ptr? 0: 0); } /* this function was added to libpng 1.2.0 */ png_uint_32 PNGAPI png_get_mmx_rowbytes_threshold (png_structp png_ptr) { /* obsolete, to be removed from libpng-1.4.0 */ return (png_ptr? 0L: 0L); } #endif /* ?PNG_1_0_X */ #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED /* these functions were added to libpng 1.2.6 */ png_uint_32 PNGAPI png_get_user_width_max (png_structp png_ptr) { return (png_ptr? png_ptr->user_width_max : 0); } png_uint_32 PNGAPI png_get_user_height_max (png_structp png_ptr) { return (png_ptr? png_ptr->user_height_max : 0); } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ wgd-3.1/src/resources_base/png/pngpread.cpp0000644000175000001440000013326411001137472015743 00000000000000 /* pngpread.c - read a png file in push mode * * Last changed in libpng 1.2.20 September 8, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* push model modes */ #define PNG_READ_SIG_MODE 0 #define PNG_READ_CHUNK_MODE 1 #define PNG_READ_IDAT_MODE 2 #define PNG_SKIP_MODE 3 #define PNG_READ_tEXt_MODE 4 #define PNG_READ_zTXt_MODE 5 #define PNG_READ_DONE_MODE 6 #define PNG_READ_iTXt_MODE 7 #define PNG_ERROR_MODE 8 void PNGAPI png_process_data(png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size) { if(png_ptr == NULL) return; png_push_restore_buffer(png_ptr, buffer, buffer_size); while (png_ptr->buffer_size) { png_process_some_data(png_ptr, info_ptr); } } /* What we do with the incoming data depends on what we were previously * doing before we ran out of data... */ void /* PRIVATE */ png_process_some_data(png_structp png_ptr, png_infop info_ptr) { if(png_ptr == NULL) return; switch (png_ptr->process_mode) { case PNG_READ_SIG_MODE: { png_push_read_sig(png_ptr, info_ptr); break; } case PNG_READ_CHUNK_MODE: { png_push_read_chunk(png_ptr, info_ptr); break; } case PNG_READ_IDAT_MODE: { png_push_read_IDAT(png_ptr); break; } #if defined(PNG_READ_tEXt_SUPPORTED) case PNG_READ_tEXt_MODE: { png_push_read_tEXt(png_ptr, info_ptr); break; } #endif #if defined(PNG_READ_zTXt_SUPPORTED) case PNG_READ_zTXt_MODE: { png_push_read_zTXt(png_ptr, info_ptr); break; } #endif #if defined(PNG_READ_iTXt_SUPPORTED) case PNG_READ_iTXt_MODE: { png_push_read_iTXt(png_ptr, info_ptr); break; } #endif case PNG_SKIP_MODE: { png_push_crc_finish(png_ptr); break; } default: { png_ptr->buffer_size = 0; break; } } } /* Read any remaining signature bytes from the stream and compare them with * the correct PNG signature. It is possible that this routine is called * with bytes already read from the signature, either because they have been * checked by the calling application, or because of multiple calls to this * routine. */ void /* PRIVATE */ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) { png_size_t num_checked = png_ptr->sig_bytes, num_to_check = 8 - num_checked; if (png_ptr->buffer_size < num_to_check) { num_to_check = png_ptr->buffer_size; } png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { if (num_checked < 4 && png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) png_error(png_ptr, "Not a PNG file"); else png_error(png_ptr, "PNG file corrupted by ASCII conversion"); } else { if (png_ptr->sig_bytes >= 8) { png_ptr->process_mode = PNG_READ_CHUNK_MODE; } } } void /* PRIVATE */ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IHDR; PNG_CONST PNG_IDAT; PNG_CONST PNG_IEND; PNG_CONST PNG_PLTE; #if defined(PNG_READ_bKGD_SUPPORTED) PNG_CONST PNG_bKGD; #endif #if defined(PNG_READ_cHRM_SUPPORTED) PNG_CONST PNG_cHRM; #endif #if defined(PNG_READ_gAMA_SUPPORTED) PNG_CONST PNG_gAMA; #endif #if defined(PNG_READ_hIST_SUPPORTED) PNG_CONST PNG_hIST; #endif #if defined(PNG_READ_iCCP_SUPPORTED) PNG_CONST PNG_iCCP; #endif #if defined(PNG_READ_iTXt_SUPPORTED) PNG_CONST PNG_iTXt; #endif #if defined(PNG_READ_oFFs_SUPPORTED) PNG_CONST PNG_oFFs; #endif #if defined(PNG_READ_pCAL_SUPPORTED) PNG_CONST PNG_pCAL; #endif #if defined(PNG_READ_pHYs_SUPPORTED) PNG_CONST PNG_pHYs; #endif #if defined(PNG_READ_sBIT_SUPPORTED) PNG_CONST PNG_sBIT; #endif #if defined(PNG_READ_sCAL_SUPPORTED) PNG_CONST PNG_sCAL; #endif #if defined(PNG_READ_sRGB_SUPPORTED) PNG_CONST PNG_sRGB; #endif #if defined(PNG_READ_sPLT_SUPPORTED) PNG_CONST PNG_sPLT; #endif #if defined(PNG_READ_tEXt_SUPPORTED) PNG_CONST PNG_tEXt; #endif #if defined(PNG_READ_tIME_SUPPORTED) PNG_CONST PNG_tIME; #endif #if defined(PNG_READ_tRNS_SUPPORTED) PNG_CONST PNG_tRNS; #endif #if defined(PNG_READ_zTXt_SUPPORTED) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ /* First we make sure we have enough data for the 4 byte chunk name * and the 4 byte chunk length before proceeding with decoding the * chunk data. To fully decode each of these chunks, we also make * sure we have enough data in the buffer for the 4 byte CRC at the * end of every chunk (except IDAT, which is handled separately). */ if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) { png_byte chunk_length[4]; if (png_ptr->buffer_size < 8) { png_push_save_buffer(png_ptr); return; } png_push_fill_buffer(png_ptr, chunk_length, 4); png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) if(png_ptr->mode & PNG_AFTER_IDAT) png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); } else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); png_ptr->process_mode = PNG_READ_DONE_MODE; png_push_have_end(png_ptr, info_ptr); } #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) png_ptr->mode |= PNG_HAVE_IDAT; png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && !(png_ptr->mode & PNG_HAVE_PLTE)) png_error(png_ptr, "Missing PLTE before IDAT"); } } #endif else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); } else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) { /* If we reach an IDAT chunk, this means we have read all of the * header chunks, and we can start reading the image (or if this * is called after the image has been read - we have an error). */ if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && !(png_ptr->mode & PNG_HAVE_PLTE)) png_error(png_ptr, "Missing PLTE before IDAT"); if (png_ptr->mode & PNG_HAVE_IDAT) { if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) if (png_ptr->push_length == 0) return; if (png_ptr->mode & PNG_AFTER_IDAT) png_error(png_ptr, "Too many IDAT's found"); } png_ptr->idat_size = png_ptr->push_length; png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->process_mode = PNG_READ_IDAT_MODE; png_push_have_info(png_ptr, info_ptr); png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; png_ptr->zstream.next_out = png_ptr->row_buf; return; } #if defined(PNG_READ_gAMA_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_sBIT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_cHRM_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_sRGB_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_iCCP_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_sPLT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_tRNS_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_bKGD_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_hIST_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_pHYs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_oFFs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_pCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_sCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_tIME_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_tEXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_zTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); } #endif #if defined(PNG_READ_iTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); } #endif else { if (png_ptr->push_length + 4 > png_ptr->buffer_size) { png_push_save_buffer(png_ptr); return; } png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); } png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; } void /* PRIVATE */ png_push_crc_skip(png_structp png_ptr, png_uint_32 skip) { png_ptr->process_mode = PNG_SKIP_MODE; png_ptr->skip_length = skip; } void /* PRIVATE */ png_push_crc_finish(png_structp png_ptr) { if (png_ptr->skip_length && png_ptr->save_buffer_size) { png_size_t save_size; if (png_ptr->skip_length < (png_uint_32)png_ptr->save_buffer_size) save_size = (png_size_t)png_ptr->skip_length; else save_size = png_ptr->save_buffer_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); png_ptr->skip_length -= save_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } if (png_ptr->skip_length && png_ptr->current_buffer_size) { png_size_t save_size; if (png_ptr->skip_length < (png_uint_32)png_ptr->current_buffer_size) save_size = (png_size_t)png_ptr->skip_length; else save_size = png_ptr->current_buffer_size; png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); png_ptr->skip_length -= save_size; png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; } if (!png_ptr->skip_length) { if (png_ptr->buffer_size < 4) { png_push_save_buffer(png_ptr); return; } png_crc_finish(png_ptr, 0); png_ptr->process_mode = PNG_READ_CHUNK_MODE; } } void PNGAPI png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) { png_bytep ptr; if(png_ptr == NULL) return; ptr = buffer; if (png_ptr->save_buffer_size) { png_size_t save_size; if (length < png_ptr->save_buffer_size) save_size = length; else save_size = png_ptr->save_buffer_size; png_memcpy(ptr, png_ptr->save_buffer_ptr, save_size); length -= save_size; ptr += save_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } if (length && png_ptr->current_buffer_size) { png_size_t save_size; if (length < png_ptr->current_buffer_size) save_size = length; else save_size = png_ptr->current_buffer_size; png_memcpy(ptr, png_ptr->current_buffer_ptr, save_size); png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; } } void /* PRIVATE */ png_push_save_buffer(png_structp png_ptr) { if (png_ptr->save_buffer_size) { if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) { png_size_t i,istop; png_bytep sp; png_bytep dp; istop = png_ptr->save_buffer_size; for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; i < istop; i++, sp++, dp++) { *dp = *sp; } } } if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > png_ptr->save_buffer_max) { png_size_t new_max; png_bytep old_buffer; if (png_ptr->save_buffer_size > PNG_SIZE_MAX - (png_ptr->current_buffer_size + 256)) { png_error(png_ptr, "Potential overflow of save_buffer"); } new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; old_buffer = png_ptr->save_buffer; png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, (png_uint_32)new_max); png_memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); png_free(png_ptr, old_buffer); png_ptr->save_buffer_max = new_max; } if (png_ptr->current_buffer_size) { png_memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); png_ptr->save_buffer_size += png_ptr->current_buffer_size; png_ptr->current_buffer_size = 0; } png_ptr->save_buffer_ptr = png_ptr->save_buffer; png_ptr->buffer_size = 0; } void /* PRIVATE */ png_push_restore_buffer(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length) { png_ptr->current_buffer = buffer; png_ptr->current_buffer_size = buffer_length; png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; png_ptr->current_buffer_ptr = png_ptr->current_buffer; } void /* PRIVATE */ png_push_read_IDAT(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IDAT; #endif if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER)) { png_byte chunk_length[4]; if (png_ptr->buffer_size < 8) { png_push_save_buffer(png_ptr); return; } png_push_fill_buffer(png_ptr, chunk_length, 4); png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) { png_ptr->process_mode = PNG_READ_CHUNK_MODE; if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) png_error(png_ptr, "Not enough compressed data"); return; } png_ptr->idat_size = png_ptr->push_length; } if (png_ptr->idat_size && png_ptr->save_buffer_size) { png_size_t save_size; if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) { save_size = (png_size_t)png_ptr->idat_size; /* check for overflow */ if((png_uint_32)save_size != png_ptr->idat_size) png_error(png_ptr, "save_size overflowed in pngpread"); } else save_size = png_ptr->save_buffer_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); png_ptr->idat_size -= save_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; png_ptr->save_buffer_ptr += save_size; } if (png_ptr->idat_size && png_ptr->current_buffer_size) { png_size_t save_size; if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) { save_size = (png_size_t)png_ptr->idat_size; /* check for overflow */ if((png_uint_32)save_size != png_ptr->idat_size) png_error(png_ptr, "save_size overflowed in pngpread"); } else save_size = png_ptr->current_buffer_size; png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); png_ptr->idat_size -= save_size; png_ptr->buffer_size -= save_size; png_ptr->current_buffer_size -= save_size; png_ptr->current_buffer_ptr += save_size; } if (!png_ptr->idat_size) { if (png_ptr->buffer_size < 4) { png_push_save_buffer(png_ptr); return; } png_crc_finish(png_ptr, 0); png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; png_ptr->mode |= PNG_AFTER_IDAT; } } void /* PRIVATE */ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_size_t buffer_length) { int ret; if ((png_ptr->flags & PNG_FLAG_ZLIB_FINISHED) && buffer_length) png_error(png_ptr, "Extra compression data"); png_ptr->zstream.next_in = buffer; png_ptr->zstream.avail_in = (uInt)buffer_length; for(;;) { ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); if (ret != Z_OK) { if (ret == Z_STREAM_END) { if (png_ptr->zstream.avail_in) png_error(png_ptr, "Extra compressed data"); if (!(png_ptr->zstream.avail_out)) { png_push_process_row(png_ptr); } png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } else if (ret == Z_BUF_ERROR) break; else png_error(png_ptr, "Decompression Error"); } if (!(png_ptr->zstream.avail_out)) { if (( #if defined(PNG_READ_INTERLACING_SUPPORTED) png_ptr->interlaced && png_ptr->pass > 6) || (!png_ptr->interlaced && #endif png_ptr->row_number == png_ptr->num_rows)) { if (png_ptr->zstream.avail_in) png_warning(png_ptr, "Too much data in IDAT chunks"); png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } png_push_process_row(png_ptr); png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; png_ptr->zstream.next_out = png_ptr->row_buf; } else break; } } void /* PRIVATE */ png_push_process_row(png_structp png_ptr) { png_ptr->row_info.color_type = png_ptr->color_type; png_ptr->row_info.width = png_ptr->iwidth; png_ptr->row_info.channels = png_ptr->channels; png_ptr->row_info.bit_depth = png_ptr->bit_depth; png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); png_read_filter_row(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->prev_row + 1, (int)(png_ptr->row_buf[0])); png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1); if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) png_do_read_transformations(png_ptr); #if defined(PNG_READ_INTERLACING_SUPPORTED) /* blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) /* old interface (pre-1.0.9): png_do_read_interlace(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); */ png_do_read_interlace(png_ptr); switch (png_ptr->pass) { case 0: { int i; for (i = 0; i < 8 && png_ptr->pass == 0; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ } if (png_ptr->pass == 2) /* pass 1 might be empty */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } if (png_ptr->pass == 4 && png_ptr->height <= 4) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } if (png_ptr->pass == 6 && png_ptr->height <= 4) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } break; } case 1: { int i; for (i = 0; i < 8 && png_ptr->pass == 1; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 2) /* skip top 4 generated rows */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } break; } case 2: { int i; for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 4) /* pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } break; } case 3: { int i; for (i = 0; i < 4 && png_ptr->pass == 3; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 4) /* skip top two generated rows */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } break; } case 4: { int i; for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 6) /* pass 5 might be empty */ { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } break; } case 5: { int i; for (i = 0; i < 2 && png_ptr->pass == 5; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } if (png_ptr->pass == 6) /* skip top generated row */ { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } break; } case 6: { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); if (png_ptr->pass != 6) break; png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } } } else #endif { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } } void /* PRIVATE */ png_read_push_finish_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* start of interlace block */ PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; /* offset to next interlace block */ PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; /* start of interlace block in the y direction */ PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; /* offset to next interlace block in the y direction */ PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ #endif png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; if (png_ptr->interlaced) { png_ptr->row_number = 0; png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { png_ptr->pass++; if ((png_ptr->pass == 1 && png_ptr->width < 5) || (png_ptr->pass == 3 && png_ptr->width < 3) || (png_ptr->pass == 5 && png_ptr->width < 2)) png_ptr->pass++; if (png_ptr->pass > 7) png_ptr->pass--; if (png_ptr->pass >= 7) break; png_ptr->iwidth = (png_ptr->width + png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1; if (png_ptr->transformations & PNG_INTERLACE) break; png_ptr->num_rows = (png_ptr->height + png_pass_yinc[png_ptr->pass] - 1 - png_pass_ystart[png_ptr->pass]) / png_pass_yinc[png_ptr->pass]; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } } #if defined(PNG_READ_tEXt_SUPPORTED) void /* PRIVATE */ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place tEXt"); info_ptr = info_ptr; /* to quiet some compiler warnings */ } #ifdef PNG_MAX_MALLOC_64K png_ptr->skip_length = 0; /* This may not be necessary */ if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ { png_warning(png_ptr, "tEXt chunk too large to fit in memory"); png_ptr->skip_length = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, (png_uint_32)(length+1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; png_ptr->current_text_left = (png_size_t)length; png_ptr->process_mode = PNG_READ_tEXt_MODE; } void /* PRIVATE */ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->buffer_size && png_ptr->current_text_left) { png_size_t text_size; if (png_ptr->buffer_size < png_ptr->current_text_left) text_size = png_ptr->buffer_size; else text_size = png_ptr->current_text_left; png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); png_ptr->current_text_left -= text_size; png_ptr->current_text_ptr += text_size; } if (!(png_ptr->current_text_left)) { png_textp text_ptr; png_charp text; png_charp key; int ret; if (png_ptr->buffer_size < 4) { png_push_save_buffer(png_ptr); return; } png_push_crc_finish(png_ptr); #if defined(PNG_MAX_MALLOC_64K) if (png_ptr->skip_length) return; #endif key = png_ptr->current_text; for (text = key; *text; text++) /* empty loop */ ; if (text != key + png_ptr->current_text_size) text++; text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)png_sizeof(png_text)); text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; #endif text_ptr->text = text; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, key); png_free(png_ptr, text_ptr); png_ptr->current_text = NULL; if (ret) png_warning(png_ptr, "Insufficient memory to store text chunk."); } } #endif #if defined(PNG_READ_zTXt_SUPPORTED) void /* PRIVATE */ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place zTXt"); info_ptr = info_ptr; /* to quiet some compiler warnings */ } #ifdef PNG_MAX_MALLOC_64K /* We can't handle zTXt chunks > 64K, since we don't have enough space * to be able to store the uncompressed data. Actually, the threshold * is probably around 32K, but it isn't as definite as 64K is. */ if (length > (png_uint_32)65535L) { png_warning(png_ptr, "zTXt chunk too large to fit in memory"); png_push_crc_skip(png_ptr, length); return; } #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, (png_uint_32)(length+1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; png_ptr->current_text_left = (png_size_t)length; png_ptr->process_mode = PNG_READ_zTXt_MODE; } void /* PRIVATE */ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->buffer_size && png_ptr->current_text_left) { png_size_t text_size; if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) text_size = png_ptr->buffer_size; else text_size = png_ptr->current_text_left; png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); png_ptr->current_text_left -= text_size; png_ptr->current_text_ptr += text_size; } if (!(png_ptr->current_text_left)) { png_textp text_ptr; png_charp text; png_charp key; int ret; png_size_t text_size, key_size; if (png_ptr->buffer_size < 4) { png_push_save_buffer(png_ptr); return; } png_push_crc_finish(png_ptr); key = png_ptr->current_text; for (text = key; *text; text++) /* empty loop */ ; /* zTXt can't have zero text */ if (text == key + png_ptr->current_text_size) { png_ptr->current_text = NULL; png_free(png_ptr, key); return; } text++; if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ { png_ptr->current_text = NULL; png_free(png_ptr, key); return; } text++; png_ptr->zstream.next_in = (png_bytep )text; png_ptr->zstream.avail_in = (uInt)(png_ptr->current_text_size - (text - key)); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; key_size = text - key; text_size = 0; text = NULL; ret = Z_STREAM_END; while (png_ptr->zstream.avail_in) { ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); if (ret != Z_OK && ret != Z_STREAM_END) { inflateReset(&png_ptr->zstream); png_ptr->zstream.avail_in = 0; png_ptr->current_text = NULL; png_free(png_ptr, key); png_free(png_ptr, text); return; } if (!(png_ptr->zstream.avail_out) || ret == Z_STREAM_END) { if (text == NULL) { text = (png_charp)png_malloc(png_ptr, (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + key_size + 1)); png_memcpy(text + key_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); png_memcpy(text, key, key_size); text_size = key_size + png_ptr->zbuf_size - png_ptr->zstream.avail_out; *(text + text_size) = '\0'; } else { png_charp tmp; tmp = text; text = (png_charp)png_malloc(png_ptr, text_size + (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); png_memcpy(text + text_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; *(text + text_size) = '\0'; } if (ret != Z_STREAM_END) { png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } } else { break; } if (ret == Z_STREAM_END) break; } inflateReset(&png_ptr->zstream); png_ptr->zstream.avail_in = 0; if (ret != Z_STREAM_END) { png_ptr->current_text = NULL; png_free(png_ptr, key); png_free(png_ptr, text); return; } png_ptr->current_text = NULL; png_free(png_ptr, key); key = text; text += key_size; text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)png_sizeof(png_text)); text_ptr->compression = PNG_TEXT_COMPRESSION_zTXt; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; #endif text_ptr->text = text; ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, key); png_free(png_ptr, text_ptr); if (ret) png_warning(png_ptr, "Insufficient memory to store text chunk."); } } #endif #if defined(PNG_READ_iTXt_SUPPORTED) void /* PRIVATE */ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place iTXt"); info_ptr = info_ptr; /* to quiet some compiler warnings */ } #ifdef PNG_MAX_MALLOC_64K png_ptr->skip_length = 0; /* This may not be necessary */ if (length > (png_uint_32)65535L) /* Can't hold entire string in memory */ { png_warning(png_ptr, "iTXt chunk too large to fit in memory"); png_ptr->skip_length = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, (png_uint_32)(length+1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; png_ptr->current_text_left = (png_size_t)length; png_ptr->process_mode = PNG_READ_iTXt_MODE; } void /* PRIVATE */ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->buffer_size && png_ptr->current_text_left) { png_size_t text_size; if (png_ptr->buffer_size < png_ptr->current_text_left) text_size = png_ptr->buffer_size; else text_size = png_ptr->current_text_left; png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); png_ptr->current_text_left -= text_size; png_ptr->current_text_ptr += text_size; } if (!(png_ptr->current_text_left)) { png_textp text_ptr; png_charp key; int comp_flag; png_charp lang; png_charp lang_key; png_charp text; int ret; if (png_ptr->buffer_size < 4) { png_push_save_buffer(png_ptr); return; } png_push_crc_finish(png_ptr); #if defined(PNG_MAX_MALLOC_64K) if (png_ptr->skip_length) return; #endif key = png_ptr->current_text; for (lang = key; *lang; lang++) /* empty loop */ ; if (lang != key + png_ptr->current_text_size) lang++; comp_flag = *lang++; lang++; /* skip comp_type, always zero */ for (lang_key = lang; *lang_key; lang_key++) /* empty loop */ ; lang_key++; /* skip NUL separator */ for (text = lang_key; *text; text++) /* empty loop */ ; if (text != key + png_ptr->current_text_size) text++; text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)png_sizeof(png_text)); text_ptr->compression = comp_flag + 2; text_ptr->key = key; text_ptr->lang = lang; text_ptr->lang_key = lang_key; text_ptr->text = text; text_ptr->text_length = 0; text_ptr->itxt_length = png_strlen(text); ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_ptr->current_text = NULL; png_free(png_ptr, text_ptr); if (ret) png_warning(png_ptr, "Insufficient memory to store iTXt chunk."); } } #endif /* This function is called when we haven't found a handler for this * chunk. If there isn't a problem with the chunk itself (ie a bad chunk * name or a critical chunk), the chunk is (currently) silently ignored. */ void /* PRIVATE */ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip=0; png_check_chunk_name(png_ptr, png_ptr->chunk_name); if (!(png_ptr->chunk_name[0] & 0x20)) { #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) && png_ptr->read_user_chunk_fn == NULL #endif ) #endif png_chunk_error(png_ptr, "unknown critical chunk"); info_ptr = info_ptr; /* to quiet some compiler warnings */ } #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) if (png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) { #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) { png_warning(png_ptr, "unknown chunk too large to fit in memory"); skip = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif png_strncpy((png_charp)png_ptr->unknown_chunk.name, (png_charp)png_ptr->chunk_name, png_sizeof((png_charp)png_ptr->chunk_name)); png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); png_ptr->unknown_chunk.size = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) if(png_ptr->read_user_chunk_fn != NULL) { /* callback to user unknown chunk handler */ int ret; ret = (*(png_ptr->read_user_chunk_fn)) (png_ptr, &png_ptr->unknown_chunk); if (ret < 0) png_chunk_error(png_ptr, "error in user chunk"); if (ret == 0) { if (!(png_ptr->chunk_name[0] & 0x20)) if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS) png_chunk_error(png_ptr, "unknown critical chunk"); png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); } } #else png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); #endif png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } else #endif skip=length; png_push_crc_skip(png_ptr, skip); } void /* PRIVATE */ png_push_have_info(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->info_fn != NULL) (*(png_ptr->info_fn))(png_ptr, info_ptr); } void /* PRIVATE */ png_push_have_end(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->end_fn != NULL) (*(png_ptr->end_fn))(png_ptr, info_ptr); } void /* PRIVATE */ png_push_have_row(png_structp png_ptr, png_bytep row) { if (png_ptr->row_fn != NULL) (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, (int)png_ptr->pass); } void PNGAPI png_progressive_combine_row (png_structp png_ptr, png_bytep old_row, png_bytep new_row) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST int FARDATA png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; #endif if(png_ptr == NULL) return; if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); } void PNGAPI png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn) { if(png_ptr == NULL) return; png_ptr->info_fn = info_fn; png_ptr->row_fn = row_fn; png_ptr->end_fn = end_fn; png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); } png_voidp PNGAPI png_get_progressive_ptr(png_structp png_ptr) { if(png_ptr == NULL) return (NULL); return png_ptr->io_ptr; } #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ wgd-3.1/src/resources_base/png/pngread.cpp0000644000175000001440000013457511001137472015571 00000000000000 /* pngread.c - read a PNG file * * Last changed in libpng 1.2.19 August 19, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file contains routines that an application calls directly to * read a PNG file or stream. */ #define PNG_INTERNAL #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif #if defined(PNG_READ_SUPPORTED) /* Create a PNG structure for reading, and allocate any memory needed. */ png_structp PNGAPI png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn, warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL)); } /* Alternate create PNG structure for reading, and allocate any memory needed. */ png_structp PNGAPI png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ png_structp png_ptr; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD jmp_buf jmpbuf; #endif #endif int i; png_debug(1, "in png_create_read_struct\n"); #ifdef PNG_USER_MEM_SUPPORTED png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); #else png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); #endif if (png_ptr == NULL) return (NULL); /* added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_ptr->user_width_max=PNG_USER_WIDTH_MAX; png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; #endif #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else if (setjmp(png_ptr->jmpbuf)) #endif { png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf=NULL; #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else png_destroy_struct((png_voidp)png_ptr); #endif return (NULL); } #ifdef USE_FAR_KEYWORD png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); #endif #endif #ifdef PNG_USER_MEM_SUPPORTED png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn); #endif png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); i=0; do { if(user_png_ver[i] != png_libpng_ver[i]) png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; } while (png_libpng_ver[i++]); if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) { /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so * we must recompile any applications that use any older library version. * For versions after libpng 1.0, we will be compatible, so we need * only check the first digit. */ if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] || (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) || (user_png_ver[0] == '0' && user_png_ver[2] < '9')) { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char msg[80]; if (user_png_ver) { png_snprintf(msg, 80, "Application was compiled with png.h from libpng-%.20s", user_png_ver); png_warning(png_ptr, msg); } png_snprintf(msg, 80, "Application is running with png.c from libpng-%.20s", png_libpng_ver); png_warning(png_ptr, msg); #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif png_error(png_ptr, "Incompatible libpng version in application and library"); } } /* initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; png_ptr->zstream.opaque = (voidpf)png_ptr; switch (inflateInit(&png_ptr->zstream)) { case Z_OK: /* Do nothing */ break; case Z_MEM_ERROR: case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break; case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break; default: png_error(png_ptr, "Unknown zlib error"); } png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); #ifdef PNG_SETJMP_SUPPORTED /* Applications that neglect to set up their own setjmp() and then encounter a png_error() will longjmp here. Since the jmpbuf is then meaningless we abort instead of returning. */ #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) PNG_ABORT(); png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); #else if (setjmp(png_ptr->jmpbuf)) PNG_ABORT(); #endif #endif return (png_ptr); } #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* Initialize PNG structure for reading, and allocate any memory needed. This interface is deprecated in favour of the png_create_read_struct(), and it will disappear as of libpng-1.3.0. */ #undef png_read_init void PNGAPI png_read_init(png_structp png_ptr) { /* We only come here via pre-1.0.7-compiled applications */ png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0); } void PNGAPI png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size) { /* We only come here via pre-1.0.12-compiled applications */ if(png_ptr == NULL) return; #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) if(png_sizeof(png_struct) > png_struct_size || png_sizeof(png_info) > png_info_size) { char msg[80]; png_ptr->warning_fn=NULL; if (user_png_ver) { png_snprintf(msg, 80, "Application was compiled with png.h from libpng-%.20s", user_png_ver); png_warning(png_ptr, msg); } png_snprintf(msg, 80, "Application is running with png.c from libpng-%.20s", png_libpng_ver); png_warning(png_ptr, msg); } #endif if(png_sizeof(png_struct) > png_struct_size) { png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif png_error(png_ptr, "The png struct allocated by the application for reading is too small."); } if(png_sizeof(png_info) > png_info_size) { png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED png_ptr->flags=0; #endif png_error(png_ptr, "The info struct allocated by application for reading is too small."); } png_read_init_3(&png_ptr, user_png_ver, png_struct_size); } #endif /* PNG_1_0_X || PNG_1_2_X */ void PNGAPI png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, png_size_t png_struct_size) { #ifdef PNG_SETJMP_SUPPORTED jmp_buf tmp_jmp; /* to save current jump buffer */ #endif int i=0; png_structp png_ptr=*ptr_ptr; if(png_ptr == NULL) return; do { if(user_png_ver[i] != png_libpng_ver[i]) { #ifdef PNG_LEGACY_SUPPORTED png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; #else png_ptr->warning_fn=NULL; png_warning(png_ptr, "Application uses deprecated png_read_init() and should be recompiled."); break; #endif } } while (png_libpng_ver[i++]); png_debug(1, "in png_read_init_3\n"); #ifdef PNG_SETJMP_SUPPORTED /* save jump buffer and error functions */ png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); #endif if(png_sizeof(png_struct) > png_struct_size) { png_destroy_struct(png_ptr); *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); png_ptr = *ptr_ptr; } /* reset all variables to 0 */ png_memset(png_ptr, 0, png_sizeof (png_struct)); #ifdef PNG_SETJMP_SUPPORTED /* restore jump buffer */ png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); #endif /* added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_ptr->user_width_max=PNG_USER_WIDTH_MAX; png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; #endif /* initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; png_ptr->zstream.opaque = (voidpf)png_ptr; switch (inflateInit(&png_ptr->zstream)) { case Z_OK: /* Do nothing */ break; case Z_MEM_ERROR: case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break; case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break; default: png_error(png_ptr, "Unknown zlib error"); } png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL); } #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. This has been * changed in v0.90 to allow reading a file that already has the magic * bytes read from the stream. You can tell libpng how many bytes have * been read from the beginning of the stream (up to the maximum of 8) * via png_set_sig_bytes(), and we will only check the remaining bytes * here. The application can then have access to the signature bytes we * read if it is determined that this isn't a valid PNG file. */ void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr) { if(png_ptr == NULL) return; png_debug(1, "in png_read_info\n"); /* If we haven't checked all of the PNG signature bytes, do so now. */ if (png_ptr->sig_bytes < 8) { png_size_t num_checked = png_ptr->sig_bytes, num_to_check = 8 - num_checked; png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); png_ptr->sig_bytes = 8; if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { if (num_checked < 4 && png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) png_error(png_ptr, "Not a PNG file"); else png_error(png_ptr, "PNG file corrupted by ASCII conversion"); } if (num_checked < 3) png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; } for(;;) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IHDR; PNG_CONST PNG_IDAT; PNG_CONST PNG_IEND; PNG_CONST PNG_PLTE; #if defined(PNG_READ_bKGD_SUPPORTED) PNG_CONST PNG_bKGD; #endif #if defined(PNG_READ_cHRM_SUPPORTED) PNG_CONST PNG_cHRM; #endif #if defined(PNG_READ_gAMA_SUPPORTED) PNG_CONST PNG_gAMA; #endif #if defined(PNG_READ_hIST_SUPPORTED) PNG_CONST PNG_hIST; #endif #if defined(PNG_READ_iCCP_SUPPORTED) PNG_CONST PNG_iCCP; #endif #if defined(PNG_READ_iTXt_SUPPORTED) PNG_CONST PNG_iTXt; #endif #if defined(PNG_READ_oFFs_SUPPORTED) PNG_CONST PNG_oFFs; #endif #if defined(PNG_READ_pCAL_SUPPORTED) PNG_CONST PNG_pCAL; #endif #if defined(PNG_READ_pHYs_SUPPORTED) PNG_CONST PNG_pHYs; #endif #if defined(PNG_READ_sBIT_SUPPORTED) PNG_CONST PNG_sBIT; #endif #if defined(PNG_READ_sCAL_SUPPORTED) PNG_CONST PNG_sCAL; #endif #if defined(PNG_READ_sPLT_SUPPORTED) PNG_CONST PNG_sPLT; #endif #if defined(PNG_READ_sRGB_SUPPORTED) PNG_CONST PNG_sRGB; #endif #if defined(PNG_READ_tEXt_SUPPORTED) PNG_CONST PNG_tEXt; #endif #if defined(PNG_READ_tIME_SUPPORTED) PNG_CONST PNG_tIME; #endif #if defined(PNG_READ_tRNS_SUPPORTED) PNG_CONST PNG_tRNS; #endif #if defined(PNG_READ_zTXt_SUPPORTED) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ png_byte chunk_length[4]; png_uint_32 length; png_read_data(png_ptr, chunk_length, 4); length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, length); /* This should be a binary subdivision search or a hash for * matching the chunk name rather than a linear search. */ if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) if(png_ptr->mode & PNG_AFTER_IDAT) png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) png_ptr->mode |= PNG_HAVE_IDAT; png_handle_unknown(png_ptr, info_ptr, length); if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && !(png_ptr->mode & PNG_HAVE_PLTE)) png_error(png_ptr, "Missing PLTE before IDAT"); break; } } #endif else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && !(png_ptr->mode & PNG_HAVE_PLTE)) png_error(png_ptr, "Missing PLTE before IDAT"); png_ptr->idat_size = length; png_ptr->mode |= PNG_HAVE_IDAT; break; } #if defined(PNG_READ_bKGD_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_cHRM_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_gAMA_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_hIST_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_oFFs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pHYs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sBIT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sRGB_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iCCP_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sPLT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tEXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tIME_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tRNS_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_zTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else png_handle_unknown(png_ptr, info_ptr, length); } } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ /* optional call to update the users info_ptr structure */ void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr) { png_debug(1, "in png_read_update_info\n"); if(png_ptr == NULL) return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); else png_warning(png_ptr, "Ignoring extra png_read_update_info() call; row buffer not reallocated"); png_read_transform_info(png_ptr, info_ptr); } #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Initialize palette, background, etc, after transformations * are set, but before any reading takes place. This allows * the user to obtain a gamma-corrected palette, for example. * If the user doesn't call this, we will do it ourselves. */ void PNGAPI png_start_read_image(png_structp png_ptr) { png_debug(1, "in png_start_read_image\n"); if(png_ptr == NULL) return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED void PNGAPI png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IDAT; PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; #endif int ret; if(png_ptr == NULL) return; png_debug2(1, "in png_read_row (row %lu, pass %d)\n", png_ptr->row_number, png_ptr->pass); if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); if (png_ptr->row_number == 0 && png_ptr->pass == 0) { /* check for transforms that have been set but were defined out */ #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); #endif #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined."); #endif #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined."); #endif #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined."); #endif #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined."); #endif #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined."); #endif #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined."); #endif } #if defined(PNG_READ_INTERLACING_SUPPORTED) /* if interlaced and we do not need a new row, combine row and return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) { case 0: if (png_ptr->row_number & 0x07) { if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; case 1: if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) { if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; case 2: if ((png_ptr->row_number & 0x07) != 4) { if (dsp_row != NULL && (png_ptr->row_number & 4)) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; case 3: if ((png_ptr->row_number & 3) || png_ptr->width < 3) { if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; case 4: if ((png_ptr->row_number & 3) != 2) { if (dsp_row != NULL && (png_ptr->row_number & 2)) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; case 5: if ((png_ptr->row_number & 1) || png_ptr->width < 2) { if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); png_read_finish_row(png_ptr); return; } break; case 6: if (!(png_ptr->row_number & 1)) { png_read_finish_row(png_ptr); return; } break; } } #endif if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "Invalid attempt to read row data"); png_ptr->zstream.next_out = png_ptr->row_buf; png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; do { if (!(png_ptr->zstream.avail_in)) { while (!png_ptr->idat_size) { png_byte chunk_length[4]; png_crc_finish(png_ptr, 0); png_read_data(png_ptr, chunk_length, 4); png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) png_error(png_ptr, "Not enough image data"); } png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; png_ptr->zstream.next_in = png_ptr->zbuf; if (png_ptr->zbuf_size > png_ptr->idat_size) png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; png_crc_read(png_ptr, png_ptr->zbuf, (png_size_t)png_ptr->zstream.avail_in); png_ptr->idat_size -= png_ptr->zstream.avail_in; } ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); if (ret == Z_STREAM_END) { if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in || png_ptr->idat_size) png_error(png_ptr, "Extra compressed data"); png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } if (ret != Z_OK) png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : "Decompression error"); } while (png_ptr->zstream.avail_out); png_ptr->row_info.color_type = png_ptr->color_type; png_ptr->row_info.width = png_ptr->iwidth; png_ptr->row_info.channels = png_ptr->channels; png_ptr->row_info.bit_depth = png_ptr->bit_depth; png_ptr->row_info.pixel_depth = png_ptr->pixel_depth; png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); if(png_ptr->row_buf[0]) png_read_filter_row(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->prev_row + 1, (int)(png_ptr->row_buf[0])); png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf, png_ptr->rowbytes + 1); #if defined(PNG_MNG_FEATURES_SUPPORTED) if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1); } #endif if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) png_do_read_transformations(png_ptr); #if defined(PNG_READ_INTERLACING_SUPPORTED) /* blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) /* old interface (pre-1.0.9): png_do_read_interlace(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); */ png_do_read_interlace(png_ptr); if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, png_pass_dsp_mask[png_ptr->pass]); if (row != NULL) png_combine_row(png_ptr, row, png_pass_mask[png_ptr->pass]); } else #endif { if (row != NULL) png_combine_row(png_ptr, row, 0xff); if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, 0xff); } png_read_finish_row(png_ptr); if (png_ptr->read_row_fn != NULL) (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. If the image is interlaced, * and png_set_interlace_handling() has been called, the rows need to * contain the contents of the rows from the previous pass. If the * image has alpha or transparency, and png_handle_alpha()[*] has been * called, the rows contents must be initialized to the contents of the * screen. * * "row" holds the actual image, and pixels are placed in it * as they arrive. If the image is displayed after each pass, it will * appear to "sparkle" in. "display_row" can be used to display a * "chunky" progressive image, with finer detail added as it becomes * available. If you do not want this "chunky" display, you may pass * NULL for display_row. If you do not want the sparkle display, and * you have not called png_handle_alpha(), you may pass NULL for rows. * If you have called png_handle_alpha(), and the image has either an * alpha channel or a transparency chunk, you must provide a buffer for * rows. In this case, you do not have to provide a display_row buffer * also, but you may. If the image is not interlaced, or if you have * not called png_set_interlace_handling(), the display_row buffer will * be ignored, so pass NULL to it. * * [*] png_handle_alpha() does not exist yet, as of this version of libpng */ void PNGAPI png_read_rows(png_structp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows) { png_uint_32 i; png_bytepp rp; png_bytepp dp; png_debug(1, "in png_read_rows\n"); if(png_ptr == NULL) return; rp = row; dp = display_row; if (rp != NULL && dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp++; png_bytep dptr = *dp++; png_read_row(png_ptr, rptr, dptr); } else if(rp != NULL) for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp; png_read_row(png_ptr, rptr, png_bytep_NULL); rp++; } else if(dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep dptr = *dp; png_read_row(png_ptr, png_bytep_NULL, dptr); dp++; } } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the entire image. If the image has an alpha channel or a tRNS * chunk, and you have called png_handle_alpha()[*], you will need to * initialize the image to the current image that PNG will be overlaying. * We set the num_rows again here, in case it was incorrectly set in * png_read_start_row() by a call to png_read_update_info() or * png_start_read_image() if png_set_interlace_handling() wasn't called * prior to either of these functions like it should have been. You can * only call this function once. If you desire to have an image for * each pass of a interlaced image, use png_read_rows() instead. * * [*] png_handle_alpha() does not exist yet, as of this version of libpng */ void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image) { png_uint_32 i,image_height; int pass, j; png_bytepp rp; png_debug(1, "in png_read_image\n"); if(png_ptr == NULL) return; #ifdef PNG_READ_INTERLACING_SUPPORTED pass = png_set_interlace_handling(png_ptr); #else if (png_ptr->interlaced) png_error(png_ptr, "Cannot read interlaced image -- interlace handler disabled."); pass = 1; #endif image_height=png_ptr->height; png_ptr->num_rows = image_height; /* Make sure this is set correctly */ for (j = 0; j < pass; j++) { rp = image; for (i = 0; i < image_height; i++) { png_read_row(png_ptr, *rp, png_bytep_NULL); rp++; } } } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. Will not read past the end of the * file, will verify the end is accurate, and will read any comments * or time information at the end of the file, if info is not NULL. */ void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr) { png_byte chunk_length[4]; png_uint_32 length; png_debug(1, "in png_read_end\n"); if(png_ptr == NULL) return; png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ do { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IHDR; PNG_CONST PNG_IDAT; PNG_CONST PNG_IEND; PNG_CONST PNG_PLTE; #if defined(PNG_READ_bKGD_SUPPORTED) PNG_CONST PNG_bKGD; #endif #if defined(PNG_READ_cHRM_SUPPORTED) PNG_CONST PNG_cHRM; #endif #if defined(PNG_READ_gAMA_SUPPORTED) PNG_CONST PNG_gAMA; #endif #if defined(PNG_READ_hIST_SUPPORTED) PNG_CONST PNG_hIST; #endif #if defined(PNG_READ_iCCP_SUPPORTED) PNG_CONST PNG_iCCP; #endif #if defined(PNG_READ_iTXt_SUPPORTED) PNG_CONST PNG_iTXt; #endif #if defined(PNG_READ_oFFs_SUPPORTED) PNG_CONST PNG_oFFs; #endif #if defined(PNG_READ_pCAL_SUPPORTED) PNG_CONST PNG_pCAL; #endif #if defined(PNG_READ_pHYs_SUPPORTED) PNG_CONST PNG_pHYs; #endif #if defined(PNG_READ_sBIT_SUPPORTED) PNG_CONST PNG_sBIT; #endif #if defined(PNG_READ_sCAL_SUPPORTED) PNG_CONST PNG_sCAL; #endif #if defined(PNG_READ_sPLT_SUPPORTED) PNG_CONST PNG_sPLT; #endif #if defined(PNG_READ_sRGB_SUPPORTED) PNG_CONST PNG_sRGB; #endif #if defined(PNG_READ_tEXt_SUPPORTED) PNG_CONST PNG_tEXt; #endif #if defined(PNG_READ_tIME_SUPPORTED) PNG_CONST PNG_tIME; #endif #if defined(PNG_READ_tRNS_SUPPORTED) PNG_CONST PNG_tRNS; #endif #if defined(PNG_READ_zTXt_SUPPORTED) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ png_read_data(png_ptr, chunk_length, 4); length = png_get_uint_31(png_ptr,chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); } png_handle_unknown(png_ptr, info_ptr, length); if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; } #endif else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. */ if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); png_crc_finish(png_ptr, length); } else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); #if defined(PNG_READ_bKGD_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_cHRM_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_gAMA_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_hIST_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_oFFs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pHYs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sBIT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sRGB_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iCCP_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sPLT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tEXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tIME_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tRNS_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_zTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else png_handle_unknown(png_ptr, info_ptr, length); } while (!(png_ptr->mode & PNG_HAVE_IEND)); } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ /* free all memory used by the read */ void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr) { png_structp png_ptr = NULL; png_infop info_ptr = NULL, end_info_ptr = NULL; #ifdef PNG_USER_MEM_SUPPORTED png_free_ptr free_fn; png_voidp mem_ptr; #endif png_debug(1, "in png_destroy_read_struct\n"); if (png_ptr_ptr != NULL) png_ptr = *png_ptr_ptr; if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; if (end_info_ptr_ptr != NULL) end_info_ptr = *end_info_ptr_ptr; #ifdef PNG_USER_MEM_SUPPORTED free_fn = png_ptr->free_fn; mem_ptr = png_ptr->mem_ptr; #endif png_read_destroy(png_ptr, info_ptr, end_info_ptr); if (info_ptr != NULL) { #if defined(PNG_TEXT_SUPPORTED) png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1); #endif #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else png_destroy_struct((png_voidp)info_ptr); #endif *info_ptr_ptr = NULL; } if (end_info_ptr != NULL) { #if defined(PNG_READ_TEXT_SUPPORTED) png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1); #endif #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else png_destroy_struct((png_voidp)end_info_ptr); #endif *end_info_ptr_ptr = NULL; } if (png_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr); #else png_destroy_struct((png_voidp)png_ptr); #endif *png_ptr_ptr = NULL; } } /* free all memory used by the read (old method) */ void /* PRIVATE */ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) { #ifdef PNG_SETJMP_SUPPORTED jmp_buf tmp_jmp; #endif png_error_ptr error_fn; png_error_ptr warning_fn; png_voidp error_ptr; #ifdef PNG_USER_MEM_SUPPORTED png_free_ptr free_fn; #endif png_debug(1, "in png_read_destroy\n"); if (info_ptr != NULL) png_info_destroy(png_ptr, info_ptr); if (end_info_ptr != NULL) png_info_destroy(png_ptr, end_info_ptr); png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->big_row_buf); png_free(png_ptr, png_ptr->prev_row); #if defined(PNG_READ_DITHER_SUPPORTED) png_free(png_ptr, png_ptr->palette_lookup); png_free(png_ptr, png_ptr->dither_index); #endif #if defined(PNG_READ_GAMMA_SUPPORTED) png_free(png_ptr, png_ptr->gamma_table); #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) png_free(png_ptr, png_ptr->gamma_from_1); png_free(png_ptr, png_ptr->gamma_to_1); #endif #ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_PLTE) png_zfree(png_ptr, png_ptr->palette); png_ptr->free_me &= ~PNG_FREE_PLTE; #else if (png_ptr->flags & PNG_FLAG_FREE_PLTE) png_zfree(png_ptr, png_ptr->palette); png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; #endif #if defined(PNG_tRNS_SUPPORTED) || \ defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) #ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_TRNS) png_free(png_ptr, png_ptr->trans); png_ptr->free_me &= ~PNG_FREE_TRNS; #else if (png_ptr->flags & PNG_FLAG_FREE_TRNS) png_free(png_ptr, png_ptr->trans); png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; #endif #endif #if defined(PNG_READ_hIST_SUPPORTED) #ifdef PNG_FREE_ME_SUPPORTED if (png_ptr->free_me & PNG_FREE_HIST) png_free(png_ptr, png_ptr->hist); png_ptr->free_me &= ~PNG_FREE_HIST; #else if (png_ptr->flags & PNG_FLAG_FREE_HIST) png_free(png_ptr, png_ptr->hist); png_ptr->flags &= ~PNG_FLAG_FREE_HIST; #endif #endif #if defined(PNG_READ_GAMMA_SUPPORTED) if (png_ptr->gamma_16_table != NULL) { int i; int istop = (1 << (8 - png_ptr->gamma_shift)); for (i = 0; i < istop; i++) { png_free(png_ptr, png_ptr->gamma_16_table[i]); } png_free(png_ptr, png_ptr->gamma_16_table); } #if defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->gamma_16_from_1 != NULL) { int i; int istop = (1 << (8 - png_ptr->gamma_shift)); for (i = 0; i < istop; i++) { png_free(png_ptr, png_ptr->gamma_16_from_1[i]); } png_free(png_ptr, png_ptr->gamma_16_from_1); } if (png_ptr->gamma_16_to_1 != NULL) { int i; int istop = (1 << (8 - png_ptr->gamma_shift)); for (i = 0; i < istop; i++) { png_free(png_ptr, png_ptr->gamma_16_to_1[i]); } png_free(png_ptr, png_ptr->gamma_16_to_1); } #endif #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) png_free(png_ptr, png_ptr->time_buffer); #endif inflateEnd(&png_ptr->zstream); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED png_free(png_ptr, png_ptr->save_buffer); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED #ifdef PNG_TEXT_SUPPORTED png_free(png_ptr, png_ptr->current_text); #endif /* PNG_TEXT_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ /* Save the important info out of the png_struct, in case it is * being used again. */ #ifdef PNG_SETJMP_SUPPORTED png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); #endif error_fn = png_ptr->error_fn; warning_fn = png_ptr->warning_fn; error_ptr = png_ptr->error_ptr; #ifdef PNG_USER_MEM_SUPPORTED free_fn = png_ptr->free_fn; #endif png_memset(png_ptr, 0, png_sizeof (png_struct)); png_ptr->error_fn = error_fn; png_ptr->warning_fn = warning_fn; png_ptr->error_ptr = error_ptr; #ifdef PNG_USER_MEM_SUPPORTED png_ptr->free_fn = free_fn; #endif #ifdef PNG_SETJMP_SUPPORTED png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); #endif } void PNGAPI png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) { if(png_ptr == NULL) return; png_ptr->read_row_fn = read_row_fn; } #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED #if defined(PNG_INFO_IMAGE_SUPPORTED) void PNGAPI png_read_png(png_structp png_ptr, png_infop info_ptr, int transforms, voidp params) { int row; if(png_ptr == NULL) return; #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) /* invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) png_set_invert_alpha(png_ptr); #endif /* png_read_info() gives us all of the information from the * PNG file before the first IDAT (image data chunk). */ png_read_info(png_ptr, info_ptr); if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) png_error(png_ptr,"Image is too high to process with png_read_png()"); /* -------------- image transformations start here ------------------- */ #if defined(PNG_READ_16_TO_8_SUPPORTED) /* tell libpng to strip 16 bit/color files down to 8 bits per color */ if (transforms & PNG_TRANSFORM_STRIP_16) png_set_strip_16(png_ptr); #endif #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) /* Strip alpha bytes from the input data without combining with * the background (not recommended). */ if (transforms & PNG_TRANSFORM_STRIP_ALPHA) png_set_strip_alpha(png_ptr); #endif #if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single * byte into separate bytes (useful for paletted and grayscale images). */ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) /* Change the order of packed pixels to least significant bit first * (not useful if you are using png_set_packing). */ if (transforms & PNG_TRANSFORM_PACKSWAP) png_set_packswap(png_ptr); #endif #if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand paletted colors into true RGB triplets * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel * Expand paletted or RGB images with transparency to full alpha * channels so the data will be available as RGBA quartets. */ if (transforms & PNG_TRANSFORM_EXPAND) if ((png_ptr->bit_depth < 8) || (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) png_set_expand(png_ptr); #endif /* We don't handle background color or gamma transformation or dithering. */ #if defined(PNG_READ_INVERT_SUPPORTED) /* invert monochrome files to have 0 as white and 1 as black */ if (transforms & PNG_TRANSFORM_INVERT_MONO) png_set_invert_mono(png_ptr); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: */ if ((transforms & PNG_TRANSFORM_SHIFT) && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) { png_color_8p sig_bit; png_get_sBIT(png_ptr, info_ptr, &sig_bit); png_set_shift(png_ptr, sig_bit); } #endif #if defined(PNG_READ_BGR_SUPPORTED) /* flip the RGB pixels to BGR (or RGBA to BGRA) */ if (transforms & PNG_TRANSFORM_BGR) png_set_bgr(png_ptr); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) png_set_swap_alpha(png_ptr); #endif #if defined(PNG_READ_SWAP_SUPPORTED) /* swap bytes of 16 bit files to least significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) png_set_swap(png_ptr); #endif /* We don't handle adding filler bytes */ /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to * update the palette for you (i.e., you selected such a transform above). */ png_read_update_info(png_ptr, info_ptr); /* -------------- image transformations end here ------------------- */ #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); #endif if(info_ptr->row_pointers == NULL) { info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, info_ptr->height * png_sizeof(png_bytep)); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; #endif for (row = 0; row < (int)info_ptr->height; row++) { info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); } } png_read_image(png_ptr, info_ptr->row_pointers); info_ptr->valid |= PNG_INFO_IDAT; /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); transforms = transforms; /* quiet compiler warnings */ params = params; } #endif /* PNG_INFO_IMAGE_SUPPORTED */ #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */ wgd-3.1/src/resources_base/png/pngerror.cpp0000644000175000001440000002330411001137472015772 00000000000000 /* pngerror.c - stub functions for i/o and memory allocation * * Last changed in libpng 1.2.20 September 8, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file provides a location for all error handling. Users who * need special error handling are expected to write replacement functions * and use png_set_error_fn() to use those functions. See the instructions * at each function. */ #define PNG_INTERNAL #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) static void /* PRIVATE */ png_default_error PNGARG((png_structp png_ptr, png_const_charp error_message)); #ifndef PNG_NO_WARNINGS static void /* PRIVATE */ png_default_warning PNGARG((png_structp png_ptr, png_const_charp warning_message)); #endif /* PNG_NO_WARNINGS */ /* This function is called whenever there is a fatal error. This function * should not be changed. If there is a need to handle errors differently, * you should supply a replacement error function and use png_set_error_fn() * to replace the error function at run-time. */ #ifndef PNG_NO_ERROR_TEXT void PNGAPI png_error(png_structp png_ptr, png_const_charp error_message) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED char msg[16]; if (png_ptr != NULL) { if (png_ptr->flags& (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) { if (*error_message == '#') { int offset; for (offset=1; offset<15; offset++) if (*(error_message+offset) == ' ') break; if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) { int i; for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) { msg[0]='0'; msg[1]='\0'; error_message=msg; } } } } #endif if (png_ptr != NULL && png_ptr->error_fn != NULL) (*(png_ptr->error_fn))(png_ptr, error_message); /* If the custom handler doesn't exist, or if it returns, use the default handler, which will not return. */ png_default_error(png_ptr, error_message); } #else void PNGAPI png_err(png_structp png_ptr) { if (png_ptr != NULL && png_ptr->error_fn != NULL) (*(png_ptr->error_fn))(png_ptr, '\0'); /* If the custom handler doesn't exist, or if it returns, use the default handler, which will not return. */ png_default_error(png_ptr, '\0'); } #endif /* PNG_NO_ERROR_TEXT */ #ifndef PNG_NO_WARNINGS /* This function is called whenever there is a non-fatal error. This function * should not be changed. If there is a need to handle warnings differently, * you should supply a replacement warning function and use * png_set_error_fn() to replace the warning function at run-time. */ void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message) { int offset = 0; if (png_ptr != NULL) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (png_ptr->flags& (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) #endif { if (*warning_message == '#') { for (offset=1; offset<15; offset++) if (*(warning_message+offset) == ' ') break; } } if (png_ptr != NULL && png_ptr->warning_fn != NULL) (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); } else png_default_warning(png_ptr, warning_message+offset); } #endif /* PNG_NO_WARNINGS */ /* These utilities are used internally to build an error message that relates * to the current chunk. The chunk name comes from png_ptr->chunk_name, * this is used to prefix the message. The message is limited in length * to 63 bytes, the name characters are output as hex digits wrapped in [] * if the character is invalid. */ #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) static PNG_CONST char png_digit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; #if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) static void /* PRIVATE */ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp error_message) { int iout = 0, iin = 0; while (iin < 4) { int c = png_ptr->chunk_name[iin++]; if (isnonalpha(c)) { buffer[iout++] = '['; buffer[iout++] = png_digit[(c & 0xf0) >> 4]; buffer[iout++] = png_digit[c & 0x0f]; buffer[iout++] = ']'; } else { buffer[iout++] = (png_byte)c; } } if (error_message == NULL) buffer[iout] = 0; else { buffer[iout++] = ':'; buffer[iout++] = ' '; png_strncpy(buffer+iout, error_message, 63); buffer[iout+63] = 0; } } #ifdef PNG_READ_SUPPORTED void PNGAPI png_chunk_error(png_structp png_ptr, png_const_charp error_message) { char msg[18+64]; if (png_ptr == NULL) png_error(png_ptr, error_message); else { png_format_buffer(png_ptr, msg, error_message); png_error(png_ptr, msg); } } #endif /* PNG_READ_SUPPORTED */ #endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */ #ifndef PNG_NO_WARNINGS void PNGAPI png_chunk_warning(png_structp png_ptr, png_const_charp warning_message) { char msg[18+64]; if (png_ptr == NULL) png_warning(png_ptr, warning_message); else { png_format_buffer(png_ptr, msg, warning_message); png_warning(png_ptr, msg); } } #endif /* PNG_NO_WARNINGS */ /* This is the default error handling function. Note that replacements for * this function MUST NOT RETURN, or the program will likely crash. This * function is used by default, or if the program supplies NULL for the * error function pointer in png_set_error_fn(). */ static void /* PRIVATE */ png_default_error(png_structp png_ptr, png_const_charp error_message) { #ifndef PNG_NO_CONSOLE_IO #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == '#') { int offset; char error_number[16]; for (offset=0; offset<15; offset++) { error_number[offset] = *(error_message+offset+1); if (*(error_message+offset) == ' ') break; } if((offset > 1) && (offset < 15)) { error_number[offset-1]='\0'; fprintf(stderr, "libpng error no. %s: %s\n", error_number, error_message+offset); } else fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); } else #endif fprintf(stderr, "libpng error: %s\n", error_message); #endif #ifdef PNG_SETJMP_SUPPORTED if (png_ptr) { # ifdef USE_FAR_KEYWORD { jmp_buf jmpbuf; png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf)); longjmp(jmpbuf, 1); } # else longjmp(png_ptr->jmpbuf, 1); # endif } #else PNG_ABORT(); #endif #ifdef PNG_NO_CONSOLE_IO error_message = error_message; /* make compiler happy */ #endif } #ifndef PNG_NO_WARNINGS /* This function is called when there is a warning, but the library thinks * it can continue anyway. Replacement functions don't have to do anything * here if you don't want them to. In the default configuration, png_ptr is * not used, but it is passed in case it may be useful. */ static void /* PRIVATE */ png_default_warning(png_structp png_ptr, png_const_charp warning_message) { #ifndef PNG_NO_CONSOLE_IO # ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*warning_message == '#') { int offset; char warning_number[16]; for (offset=0; offset<15; offset++) { warning_number[offset]=*(warning_message+offset+1); if (*(warning_message+offset) == ' ') break; } if((offset > 1) && (offset < 15)) { warning_number[offset-1]='\0'; fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, warning_message+offset); } else fprintf(stderr, "libpng warning: %s\n", warning_message); } else # endif fprintf(stderr, "libpng warning: %s\n", warning_message); #else warning_message = warning_message; /* make compiler happy */ #endif png_ptr = png_ptr; /* make compiler happy */ } #endif /* PNG_NO_WARNINGS */ /* This function is called when the application wants to use another method * of handling errors and warnings. Note that the error function MUST NOT * return to the calling routine or serious problems will occur. The return * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1) */ void PNGAPI png_set_error_fn(png_structp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn) { if (png_ptr == NULL) return; png_ptr->error_ptr = error_ptr; png_ptr->error_fn = error_fn; png_ptr->warning_fn = warning_fn; } /* This function returns a pointer to the error_ptr associated with the user * functions. The application should free any memory associated with this * pointer before png_write_destroy and png_read_destroy are called. */ png_voidp PNGAPI png_get_error_ptr(png_structp png_ptr) { if (png_ptr == NULL) return NULL; return ((png_voidp)png_ptr->error_ptr); } #ifdef PNG_ERROR_NUMBERS_SUPPORTED void PNGAPI png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) { if(png_ptr != NULL) { png_ptr->flags &= ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); } } #endif #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ wgd-3.1/src/resources_base/png/pngrio.cpp0000644000175000001440000001263110757754260015454 00000000000000 /* pngrio.c - functions for data input * * Last changed in libpng 1.2.13 November 13, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file provides a location for all input. Users who need * special handling are expected to write a function that has the same * arguments as this and performs a similar function, but that possibly * has a different input method. Note that you shouldn't change this * function, but rather write a replacement function and then make * libpng use it at run time with png_set_read_fn(...). */ #define PNG_INTERNAL #include #if defined(PNG_READ_SUPPORTED) /* Read the data from whatever input you are using. The default routine reads from a file pointer. Note that this routine sometimes gets called with very small lengths, so you should implement some kind of simple buffering if you are using unbuffered reads. This should never be asked to read more then 64K on a 16 bit machine. */ void /* PRIVATE */ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_debug1(4,"reading %d bytes\n", (int)length); if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); else png_error(png_ptr, "Call to NULL read function"); } #if !defined(PNG_NO_STDIO) /* This is the function that does the actual reading of data. If you are not reading from a standard C stream, you should create a replacement read_data function and use it at run time with png_set_read_fn(), rather than changing the library. */ #ifndef USE_FAR_KEYWORD void PNGAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; if(png_ptr == NULL) return; /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ #if defined(_WIN32_WCE) if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) check = 0; #else check = (png_size_t)fread(data, (png_size_t)1, length, (png_FILE_p)png_ptr->io_ptr); #endif if (check != length) png_error(png_ptr, "Read Error"); } #else /* this is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) static void PNGAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { int check; png_byte *n_data; png_FILE_p io_ptr; if(png_ptr == NULL) return; /* Check if data really is near. If so, use usual code. */ n_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); if ((png_bytep)n_data == data) { #if defined(_WIN32_WCE) if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) check = 0; #else check = fread(n_data, 1, length, io_ptr); #endif } else { png_byte buf[NEAR_BUF_SIZE]; png_size_t read, remaining, err; check = 0; remaining = length; do { read = MIN(NEAR_BUF_SIZE, remaining); #if defined(_WIN32_WCE) if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) ) err = 0; #else err = fread(buf, (png_size_t)1, read, io_ptr); #endif png_memcpy(data, buf, read); /* copy far buffer to near buffer */ if(err != read) break; else check += err; data += read; remaining -= read; } while (remaining != 0); } if ((png_uint_32)check != (png_uint_32)length) png_error(png_ptr, "read Error"); } #endif #endif /* This function allows the application to supply a new input function for libpng if standard C streams aren't being used. This function takes as its arguments: png_ptr - pointer to a png input data structure io_ptr - pointer to user supplied structure containing info about the input functions. May be NULL. read_data_fn - pointer to a new input function that takes as its arguments a pointer to a png_struct, a pointer to a location where input data can be stored, and a 32-bit unsigned int that is the number of bytes to be read. To exit and output any fatal error messages the new write function should call png_error(png_ptr, "Error msg"). */ void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn) { if(png_ptr == NULL) return; png_ptr->io_ptr = io_ptr; #if !defined(PNG_NO_STDIO) if (read_data_fn != NULL) png_ptr->read_data_fn = read_data_fn; else png_ptr->read_data_fn = png_default_read_data; #else png_ptr->read_data_fn = read_data_fn; #endif /* It is an error to write to a read device */ if (png_ptr->write_data_fn != NULL) { png_ptr->write_data_fn = NULL; png_warning(png_ptr, "It's an error to set both read_data_fn and write_data_fn in the "); png_warning(png_ptr, "same structure. Resetting write_data_fn to NULL."); } #if defined(PNG_WRITE_FLUSH_SUPPORTED) png_ptr->output_flush_fn = NULL; #endif } #endif /* PNG_READ_SUPPORTED */ wgd-3.1/src/resources_base/png/pngtrans.cpp0000644000175000001440000005070610757754260016017 00000000000000 /* pngtrans.c - transforms the data in a row (used by both readers and writers) * * Last changed in libpng 1.2.17 May 15, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL #include #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* turn on BGR-to-RGB mapping */ void PNGAPI png_set_bgr(png_structp png_ptr) { png_debug(1, "in png_set_bgr\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_BGR; } #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* turn on 16 bit byte swapping */ void PNGAPI png_set_swap(png_structp png_ptr) { png_debug(1, "in png_set_swap\n"); if(png_ptr == NULL) return; if (png_ptr->bit_depth == 16) png_ptr->transformations |= PNG_SWAP_BYTES; } #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* turn on pixel packing */ void PNGAPI png_set_packing(png_structp png_ptr) { png_debug(1, "in png_set_packing\n"); if(png_ptr == NULL) return; if (png_ptr->bit_depth < 8) { png_ptr->transformations |= PNG_PACK; png_ptr->usr_bit_depth = 8; } } #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* turn on packed pixel swapping */ void PNGAPI png_set_packswap(png_structp png_ptr) { png_debug(1, "in png_set_packswap\n"); if(png_ptr == NULL) return; if (png_ptr->bit_depth < 8) png_ptr->transformations |= PNG_PACKSWAP; } #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits) { png_debug(1, "in png_set_shift\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_SHIFT; png_ptr->shift = *true_bits; } #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) int PNGAPI png_set_interlace_handling(png_structp png_ptr) { png_debug(1, "in png_set_interlace handling\n"); if (png_ptr && png_ptr->interlaced) { png_ptr->transformations |= PNG_INTERLACE; return (7); } return (1); } #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte on read, or remove a filler or alpha byte on write. * The filler type has changed in v0.95 to allow future 2-byte fillers * for 48-bit input data, as well as to avoid problems with some compilers * that don't like bytes as parameters. */ void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) { png_debug(1, "in png_set_filler\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_FILLER; png_ptr->filler = (png_byte)filler; if (filler_loc == PNG_FILLER_AFTER) png_ptr->flags |= PNG_FLAG_FILLER_AFTER; else png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; /* This should probably go in the "do_read_filler" routine. * I attempted to do that in libpng-1.0.1a but that caused problems * so I restored it in libpng-1.0.2a */ if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { png_ptr->usr_channels = 4; } /* Also I added this in libpng-1.0.2a (what happens when we expand * a less-than-8-bit grayscale to GA? */ if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8) { png_ptr->usr_channels = 2; } } #if !defined(PNG_1_0_X) /* Added to libpng-1.2.7 */ void PNGAPI png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) { png_debug(1, "in png_set_add_alpha\n"); if(png_ptr == NULL) return; png_set_filler(png_ptr, filler, filler_loc); png_ptr->transformations |= PNG_ADD_ALPHA; } #endif #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void PNGAPI png_set_swap_alpha(png_structp png_ptr) { png_debug(1, "in png_set_swap_alpha\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_SWAP_ALPHA; } #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void PNGAPI png_set_invert_alpha(png_structp png_ptr) { png_debug(1, "in png_set_invert_alpha\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_INVERT_ALPHA; } #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) void PNGAPI png_set_invert_mono(png_structp png_ptr) { png_debug(1, "in png_set_invert_mono\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_INVERT_MONO; } /* invert monochrome grayscale data */ void /* PRIVATE */ png_do_invert(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_invert\n"); /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row == NULL || row_info == NULL) return; #endif if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { png_bytep rp = row; png_uint_32 i; png_uint_32 istop = row_info->rowbytes; for (i = 0; i < istop; i++) { *rp = (png_byte)(~(*rp)); rp++; } } else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && row_info->bit_depth == 8) { png_bytep rp = row; png_uint_32 i; png_uint_32 istop = row_info->rowbytes; for (i = 0; i < istop; i+=2) { *rp = (png_byte)(~(*rp)); rp+=2; } } else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && row_info->bit_depth == 16) { png_bytep rp = row; png_uint_32 i; png_uint_32 istop = row_info->rowbytes; for (i = 0; i < istop; i+=4) { *rp = (png_byte)(~(*rp)); *(rp+1) = (png_byte)(~(*(rp+1))); rp+=4; } } } #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* swaps byte order on 16 bit depth images */ void /* PRIVATE */ png_do_swap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_swap\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif row_info->bit_depth == 16) { png_bytep rp = row; png_uint_32 i; png_uint_32 istop= row_info->width * row_info->channels; for (i = 0; i < istop; i++, rp += 2) { png_byte t = *rp; *rp = *(rp + 1); *(rp + 1) = t; } } } #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) static PNG_CONST png_byte onebppswaptable[256] = { 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF }; static PNG_CONST png_byte twobppswaptable[256] = { 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF }; static PNG_CONST png_byte fourbppswaptable[256] = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF }; /* swaps pixel packing order within bytes */ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_packswap\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif row_info->bit_depth < 8) { png_bytep rp, end, table; end = row + row_info->rowbytes; if (row_info->bit_depth == 1) table = (png_bytep)onebppswaptable; else if (row_info->bit_depth == 2) table = (png_bytep)twobppswaptable; else if (row_info->bit_depth == 4) table = (png_bytep)fourbppswaptable; else return; for (rp = row; rp < end; rp++) *rp = table[*rp]; } } #endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */ #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) /* remove filler or alpha byte(s) */ void /* PRIVATE */ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) { png_debug(1, "in png_do_strip_filler\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { png_bytep sp=row; png_bytep dp=row; png_uint_32 row_width=row_info->width; png_uint_32 i; if ((row_info->color_type == PNG_COLOR_TYPE_RGB || (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && (flags & PNG_FLAG_STRIP_ALPHA))) && row_info->channels == 4) { if (row_info->bit_depth == 8) { /* This converts from RGBX or RGBA to RGB */ if (flags & PNG_FLAG_FILLER_AFTER) { dp+=3; sp+=4; for (i = 1; i < row_width; i++) { *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; sp++; } } /* This converts from XRGB or ARGB to RGB */ else { for (i = 0; i < row_width; i++) { sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; } } row_info->pixel_depth = 24; row_info->rowbytes = row_width * 3; } else /* if (row_info->bit_depth == 16) */ { if (flags & PNG_FLAG_FILLER_AFTER) { /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */ sp += 8; dp += 6; for (i = 1; i < row_width; i++) { /* This could be (although png_memcpy is probably slower): png_memcpy(dp, sp, 6); sp += 8; dp += 6; */ *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; sp += 2; } } else { /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */ for (i = 0; i < row_width; i++) { /* This could be (although png_memcpy is probably slower): png_memcpy(dp, sp, 6); sp += 8; dp += 6; */ sp+=2; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp++; } } row_info->pixel_depth = 48; row_info->rowbytes = row_width * 6; } row_info->channels = 3; } else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY || (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && (flags & PNG_FLAG_STRIP_ALPHA))) && row_info->channels == 2) { if (row_info->bit_depth == 8) { /* This converts from GX or GA to G */ if (flags & PNG_FLAG_FILLER_AFTER) { for (i = 0; i < row_width; i++) { *dp++ = *sp++; sp++; } } /* This converts from XG or AG to G */ else { for (i = 0; i < row_width; i++) { sp++; *dp++ = *sp++; } } row_info->pixel_depth = 8; row_info->rowbytes = row_width; } else /* if (row_info->bit_depth == 16) */ { if (flags & PNG_FLAG_FILLER_AFTER) { /* This converts from GGXX or GGAA to GG */ sp += 4; dp += 2; for (i = 1; i < row_width; i++) { *dp++ = *sp++; *dp++ = *sp++; sp += 2; } } else { /* This converts from XXGG or AAGG to GG */ for (i = 0; i < row_width; i++) { sp += 2; *dp++ = *sp++; *dp++ = *sp++; } } row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } row_info->channels = 1; } if (flags & PNG_FLAG_STRIP_ALPHA) row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; } } #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* swaps red and blue bytes within a pixel */ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_bgr\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) { if (row_info->color_type == PNG_COLOR_TYPE_RGB) { png_bytep rp; png_uint_32 i; for (i = 0, rp = row; i < row_width; i++, rp += 3) { png_byte save = *rp; *rp = *(rp + 2); *(rp + 2) = save; } } else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { png_bytep rp; png_uint_32 i; for (i = 0, rp = row; i < row_width; i++, rp += 4) { png_byte save = *rp; *rp = *(rp + 2); *(rp + 2) = save; } } } else if (row_info->bit_depth == 16) { if (row_info->color_type == PNG_COLOR_TYPE_RGB) { png_bytep rp; png_uint_32 i; for (i = 0, rp = row; i < row_width; i++, rp += 6) { png_byte save = *rp; *rp = *(rp + 4); *(rp + 4) = save; save = *(rp + 1); *(rp + 1) = *(rp + 5); *(rp + 5) = save; } } else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { png_bytep rp; png_uint_32 i; for (i = 0, rp = row; i < row_width; i++, rp += 8) { png_byte save = *rp; *rp = *(rp + 4); *(rp + 4) = save; save = *(rp + 1); *(rp + 1) = *(rp + 5); *(rp + 5) = save; } } } } } #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) void PNGAPI png_set_user_transform_info(png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { png_debug(1, "in png_set_user_transform_info\n"); if(png_ptr == NULL) return; #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_channels = (png_byte)user_transform_channels; #else if(user_transform_ptr || user_transform_depth || user_transform_channels) png_warning(png_ptr, "This version of libpng does not support user transform info"); #endif } #endif /* This function returns a pointer to the user_transform_ptr associated with * the user transform functions. The application should free any memory * associated with this pointer before png_write_destroy and png_read_destroy * are called. */ png_voidp PNGAPI png_get_user_transform_ptr(png_structp png_ptr) { #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if (png_ptr == NULL) return (NULL); return ((png_voidp)png_ptr->user_transform_ptr); #else return (NULL); #endif } #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ wgd-3.1/src/resources_base/png/pngrutil.cpp0000644000175000001440000026325111025132561016007 00000000000000 /* pngrutil.c - utilities to read a PNG file * * Last changed in libpng 1.2.19 August 19, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file contains routines that are only called from within * libpng itself during the course of reading an image. */ #define PNG_INTERNAL #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif #if defined(PNG_READ_SUPPORTED) #if defined(_WIN32_WCE) && (_WIN32_WCE<0x500) # define WIN32_WCE_OLD #endif #ifdef PNG_FLOATING_POINT_SUPPORTED # if defined(WIN32_WCE_OLD) /* strtod() function is not supported on WindowsCE */ __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr) { double result = 0; int len; wchar_t *str, *end; len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); if ( NULL != str ) { MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); result = wcstod(str, &end); len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL); *endptr = (char *)nptr + (png_strlen(nptr) - len + 1); png_free(png_ptr, str); } return result; } # else # define png_strtod(p,a,b) strtod(a,b) # endif #endif png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_bytep buf) { png_uint_32 i = png_get_uint_32(buf); if (i > PNG_UINT_31_MAX) png_error(png_ptr, "PNG unsigned integer out of range."); return (i); } #ifndef PNG_READ_BIG_ENDIAN_SUPPORTED /* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ png_uint_32 PNGAPI png_get_uint_32(png_bytep buf) { png_uint_32 i = ((png_uint_32)(*buf) << 24) + ((png_uint_32)(*(buf + 1)) << 16) + ((png_uint_32)(*(buf + 2)) << 8) + (png_uint_32)(*(buf + 3)); return (i); } /* Grab a signed 32-bit integer from a buffer in big-endian format. The * data is stored in the PNG file in two's complement format, and it is * assumed that the machine format for signed integers is the same. */ png_int_32 PNGAPI png_get_int_32(png_bytep buf) { png_int_32 i = ((png_int_32)(*buf) << 24) + ((png_int_32)(*(buf + 1)) << 16) + ((png_int_32)(*(buf + 2)) << 8) + (png_int_32)(*(buf + 3)); return (i); } /* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ png_uint_16 PNGAPI png_get_uint_16(png_bytep buf) { png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) + (png_uint_16)(*(buf + 1))); return (i); } #endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ /* Read data, and (optionally) run it through the CRC. */ void /* PRIVATE */ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) { if(png_ptr == NULL) return; png_read_data(png_ptr, buf, length); png_calculate_crc(png_ptr, buf, length); } /* Optionally skip data and then check the CRC. Depending on whether we are reading a ancillary or critical chunk, and how the program has set things up, we may calculate the CRC on the data and print a message. Returns '1' if there was a CRC error, '0' otherwise. */ int /* PRIVATE */ png_crc_finish(png_structp png_ptr, png_uint_32 skip) { png_size_t i; png_size_t istop = png_ptr->zbuf_size; for (i = (png_size_t)skip; i > istop; i -= istop) { png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); } if (i) { png_crc_read(png_ptr, png_ptr->zbuf, i); } if (png_crc_error(png_ptr)) { if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) { png_chunk_warning(png_ptr, "CRC error"); } else { png_chunk_error(png_ptr, "CRC error"); } return (1); } return (0); } /* Compare the CRC stored in the PNG file with that calculated by libpng from the data it has read thus far. */ int /* PRIVATE */ png_crc_error(png_structp png_ptr) { png_byte crc_bytes[8]; png_uint_32 crc; int need_crc = 1; if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ { if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) need_crc = 0; } else /* critical */ { if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } png_read_data(png_ptr, crc_bytes, 4); if (need_crc) { crc = png_get_uint_32(crc_bytes); return ((int)(crc != png_ptr->crc)); } else return (0); } #if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \ defined(PNG_READ_iCCP_SUPPORTED) /* * Decompress trailing data in a chunk. The assumption is that chunkdata * points at an allocated area holding the contents of a chunk with a * trailing compressed part. What we get back is an allocated area * holding the original prefix part and an uncompressed version of the * trailing part (the malloc area passed in is freed). */ png_charp /* PRIVATE */ png_decompress_chunk(png_structp png_ptr, int comp_type, png_charp chunkdata, png_size_t chunklength, png_size_t prefix_size, png_size_t *newlength) { static PNG_CONST char msg[] = "Error decoding compressed text"; png_charp text; png_size_t text_size; if (comp_type == PNG_COMPRESSION_TYPE_BASE) { int ret = Z_OK; png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; text_size = 0; text = NULL; while (png_ptr->zstream.avail_in) { ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); if (ret != Z_OK && ret != Z_STREAM_END) { if (png_ptr->zstream.msg != NULL) png_warning(png_ptr, png_ptr->zstream.msg); else png_warning(png_ptr, msg); inflateReset(&png_ptr->zstream); png_ptr->zstream.avail_in = 0; if (text == NULL) { text_size = prefix_size + png_sizeof(msg) + 1; text = (png_charp)png_malloc_warn(png_ptr, text_size); if (text == NULL) { png_free(png_ptr,chunkdata); png_error(png_ptr,"Not enough memory to decompress chunk"); } png_memcpy(text, chunkdata, prefix_size); } text[text_size - 1] = 0x00; /* Copy what we can of the error message into the text chunk */ text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); text_size = png_sizeof(msg) > text_size ? text_size : png_sizeof(msg); png_memcpy(text + prefix_size, msg, text_size + 1); break; } if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END) { if (text == NULL) { text_size = prefix_size + png_ptr->zbuf_size - png_ptr->zstream.avail_out; text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); if (text == NULL) { png_free(png_ptr,chunkdata); png_error(png_ptr,"Not enough memory to decompress chunk."); } png_memcpy(text + prefix_size, png_ptr->zbuf, text_size - prefix_size); png_memcpy(text, chunkdata, prefix_size); *(text + text_size) = 0x00; } else { png_charp tmp; tmp = text; text = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(text_size + png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1)); if (text == NULL) { png_free(png_ptr, tmp); png_free(png_ptr, chunkdata); png_error(png_ptr,"Not enough memory to decompress chunk.."); } png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); png_memcpy(text + text_size, png_ptr->zbuf, (png_ptr->zbuf_size - png_ptr->zstream.avail_out)); text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; *(text + text_size) = 0x00; } if (ret == Z_STREAM_END) break; else { png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } } } if (ret != Z_STREAM_END) { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char umsg[52]; if (ret == Z_BUF_ERROR) png_snprintf(umsg, 52, "Buffer error in compressed datastream in %s chunk", png_ptr->chunk_name); else if (ret == Z_DATA_ERROR) png_snprintf(umsg, 52, "Data error in compressed datastream in %s chunk", png_ptr->chunk_name); else png_snprintf(umsg, 52, "Incomplete compressed datastream in %s chunk", png_ptr->chunk_name); png_warning(png_ptr, umsg); #else png_warning(png_ptr, "Incomplete compressed datastream in chunk other than IDAT"); #endif text_size=prefix_size; if (text == NULL) { text = (png_charp)png_malloc_warn(png_ptr, text_size+1); if (text == NULL) { png_free(png_ptr, chunkdata); png_error(png_ptr,"Not enough memory for text."); } png_memcpy(text, chunkdata, prefix_size); } *(text + text_size) = 0x00; } inflateReset(&png_ptr->zstream); png_ptr->zstream.avail_in = 0; png_free(png_ptr, chunkdata); chunkdata = text; *newlength=text_size; } else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char umsg[50]; png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type); png_warning(png_ptr, umsg); #else png_warning(png_ptr, "Unknown zTXt compression type"); #endif *(chunkdata + prefix_size) = 0x00; *newlength=prefix_size; } return chunkdata; } #endif /* read and check the IDHR chunk */ void /* PRIVATE */ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[13]; png_uint_32 width, height; int bit_depth, color_type, compression_type, filter_type; int interlace_type; png_debug(1, "in png_handle_IHDR\n"); if (png_ptr->mode & PNG_HAVE_IHDR) png_error(png_ptr, "Out of place IHDR"); /* check the length */ if (length != 13) png_error(png_ptr, "Invalid IHDR chunk"); png_ptr->mode |= PNG_HAVE_IHDR; png_crc_read(png_ptr, buf, 13); png_crc_finish(png_ptr, 0); width = png_get_uint_31(png_ptr, buf); height = png_get_uint_31(png_ptr, buf + 4); bit_depth = buf[8]; color_type = buf[9]; compression_type = buf[10]; filter_type = buf[11]; interlace_type = buf[12]; /* set internal variables */ png_ptr->width = width; png_ptr->height = height; png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->interlaced = (png_byte)interlace_type; png_ptr->color_type = (png_byte)color_type; #if defined(PNG_MNG_FEATURES_SUPPORTED) png_ptr->filter_type = (png_byte)filter_type; #endif png_ptr->compression_type = (png_byte)compression_type; /* find number of channels */ switch (png_ptr->color_type) { case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_PALETTE: png_ptr->channels = 1; break; case PNG_COLOR_TYPE_RGB: png_ptr->channels = 3; break; case PNG_COLOR_TYPE_GRAY_ALPHA: png_ptr->channels = 2; break; case PNG_COLOR_TYPE_RGB_ALPHA: png_ptr->channels = 4; break; } /* set up other useful info */ png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); png_debug1(3,"channels = %d\n", png_ptr->channels); png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, compression_type, filter_type); } /* read and check the palette */ void /* PRIVATE */ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_color palette[PNG_MAX_PALETTE_LENGTH]; int num, i; #ifndef PNG_NO_POINTER_INDEXING png_colorp pal_ptr; #endif png_debug(1, "in png_handle_PLTE\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before PLTE"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid PLTE after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->mode & PNG_HAVE_PLTE) png_error(png_ptr, "Duplicate PLTE chunk"); png_ptr->mode |= PNG_HAVE_PLTE; if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR)) { png_warning(png_ptr, "Ignoring PLTE chunk in grayscale PNG"); png_crc_finish(png_ptr, length); return; } #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { png_crc_finish(png_ptr, length); return; } #endif if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) { if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) { png_warning(png_ptr, "Invalid palette chunk"); png_crc_finish(png_ptr, length); return; } else { png_error(png_ptr, "Invalid palette chunk"); } } num = (int)length / 3; #ifndef PNG_NO_POINTER_INDEXING for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) { png_byte buf[3]; png_crc_read(png_ptr, buf, 3); pal_ptr->red = buf[0]; pal_ptr->green = buf[1]; pal_ptr->blue = buf[2]; } #else for (i = 0; i < num; i++) { png_byte buf[3]; png_crc_read(png_ptr, buf, 3); /* don't depend upon png_color being any order */ palette[i].red = buf[0]; palette[i].green = buf[1]; palette[i].blue = buf[2]; } #endif /* If we actually NEED the PLTE chunk (ie for a paletted image), we do whatever the normal CRC configuration tells us. However, if we have an RGB image, the PLTE can be considered ancillary, so we will act as though it is. */ #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { png_crc_finish(png_ptr, 0); } #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */ { /* If we don't want to use the data from an ancillary chunk, we have two options: an error abort, or a warning and we ignore the data in this chunk (which should be OK, since it's considered ancillary for a RGB or RGBA image). */ if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE)) { if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) { png_chunk_error(png_ptr, "CRC error"); } else { png_chunk_warning(png_ptr, "CRC error"); return; } } /* Otherwise, we (optionally) emit a warning and use the chunk. */ else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) { png_chunk_warning(png_ptr, "CRC error"); } } #endif png_set_PLTE(png_ptr, info_ptr, palette, num); #if defined(PNG_READ_tRNS_SUPPORTED) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { if (png_ptr->num_trans > (png_uint_16)num) { png_warning(png_ptr, "Truncating incorrect tRNS chunk length"); png_ptr->num_trans = (png_uint_16)num; } if (info_ptr->num_trans > (png_uint_16)num) { png_warning(png_ptr, "Truncating incorrect info tRNS chunk length"); info_ptr->num_trans = (png_uint_16)num; } } } #endif } void /* PRIVATE */ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_debug(1, "in png_handle_IEND\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) { png_error(png_ptr, "No image in file"); } png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); if (length != 0) { png_warning(png_ptr, "Incorrect IEND chunk length"); } png_crc_finish(png_ptr, length); info_ptr =info_ptr; /* quiet compiler warnings about unused info_ptr */ } #if defined(PNG_READ_gAMA_SUPPORTED) void /* PRIVATE */ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_fixed_point igamma; #ifdef PNG_FLOATING_POINT_SUPPORTED float file_gamma; #endif png_byte buf[4]; png_debug(1, "in png_handle_gAMA\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before gAMA"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid gAMA after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->mode & PNG_HAVE_PLTE) /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Out of place gAMA chunk"); if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) #if defined(PNG_READ_sRGB_SUPPORTED) && !(info_ptr->valid & PNG_INFO_sRGB) #endif ) { png_warning(png_ptr, "Duplicate gAMA chunk"); png_crc_finish(png_ptr, length); return; } if (length != 4) { png_warning(png_ptr, "Incorrect gAMA chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 4); if (png_crc_finish(png_ptr, 0)) return; igamma = (png_fixed_point)png_get_uint_32(buf); /* check for zero gamma */ if (igamma == 0) { png_warning(png_ptr, "Ignoring gAMA chunk with gamma=0"); return; } #if defined(PNG_READ_sRGB_SUPPORTED) if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) { png_warning(png_ptr, "Ignoring incorrect gAMA value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); #endif return; } #endif /* PNG_READ_sRGB_SUPPORTED */ #ifdef PNG_FLOATING_POINT_SUPPORTED file_gamma = (float)igamma / (float)100000.0; # ifdef PNG_READ_GAMMA_SUPPORTED png_ptr->gamma = file_gamma; # endif png_set_gAMA(png_ptr, info_ptr, file_gamma); #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_set_gAMA_fixed(png_ptr, info_ptr, igamma); #endif } #endif #if defined(PNG_READ_sBIT_SUPPORTED) void /* PRIVATE */ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_size_t truelen; png_byte buf[4]; png_debug(1, "in png_handle_sBIT\n"); buf[0] = buf[1] = buf[2] = buf[3] = 0; if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sBIT"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid sBIT after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->mode & PNG_HAVE_PLTE) { /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Out of place sBIT chunk"); } if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)) { png_warning(png_ptr, "Duplicate sBIT chunk"); png_crc_finish(png_ptr, length); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) truelen = 3; else truelen = (png_size_t)png_ptr->channels; if (length != truelen || length > 4) { png_warning(png_ptr, "Incorrect sBIT chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, truelen); if (png_crc_finish(png_ptr, 0)) return; if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) { png_ptr->sig_bit.red = buf[0]; png_ptr->sig_bit.green = buf[1]; png_ptr->sig_bit.blue = buf[2]; png_ptr->sig_bit.alpha = buf[3]; } else { png_ptr->sig_bit.gray = buf[0]; png_ptr->sig_bit.red = buf[0]; png_ptr->sig_bit.green = buf[0]; png_ptr->sig_bit.blue = buf[0]; png_ptr->sig_bit.alpha = buf[1]; } png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); } #endif #if defined(PNG_READ_cHRM_SUPPORTED) void /* PRIVATE */ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[4]; #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, int_y_green, int_x_blue, int_y_blue; png_uint_32 uint_x, uint_y; png_debug(1, "in png_handle_cHRM\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before cHRM"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid cHRM after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->mode & PNG_HAVE_PLTE) /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Missing PLTE before cHRM"); if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM) #if defined(PNG_READ_sRGB_SUPPORTED) && !(info_ptr->valid & PNG_INFO_sRGB) #endif ) { png_warning(png_ptr, "Duplicate cHRM chunk"); png_crc_finish(png_ptr, length); return; } if (length != 32) { png_warning(png_ptr, "Incorrect cHRM chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 4); uint_x = png_get_uint_32(buf); png_crc_read(png_ptr, buf, 4); uint_y = png_get_uint_32(buf); if (uint_x > 80000L || uint_y > 80000L || uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM white point"); png_crc_finish(png_ptr, 24); return; } int_x_white = (png_fixed_point)uint_x; int_y_white = (png_fixed_point)uint_y; png_crc_read(png_ptr, buf, 4); uint_x = png_get_uint_32(buf); png_crc_read(png_ptr, buf, 4); uint_y = png_get_uint_32(buf); if (uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM red point"); png_crc_finish(png_ptr, 16); return; } int_x_red = (png_fixed_point)uint_x; int_y_red = (png_fixed_point)uint_y; png_crc_read(png_ptr, buf, 4); uint_x = png_get_uint_32(buf); png_crc_read(png_ptr, buf, 4); uint_y = png_get_uint_32(buf); if (uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM green point"); png_crc_finish(png_ptr, 8); return; } int_x_green = (png_fixed_point)uint_x; int_y_green = (png_fixed_point)uint_y; png_crc_read(png_ptr, buf, 4); uint_x = png_get_uint_32(buf); png_crc_read(png_ptr, buf, 4); uint_y = png_get_uint_32(buf); if (uint_x + uint_y > 100000L) { png_warning(png_ptr, "Invalid cHRM blue point"); png_crc_finish(png_ptr, 0); return; } int_x_blue = (png_fixed_point)uint_x; int_y_blue = (png_fixed_point)uint_y; #ifdef PNG_FLOATING_POINT_SUPPORTED white_x = (float)int_x_white / (float)100000.0; white_y = (float)int_y_white / (float)100000.0; red_x = (float)int_x_red / (float)100000.0; red_y = (float)int_y_red / (float)100000.0; green_x = (float)int_x_green / (float)100000.0; green_y = (float)int_y_green / (float)100000.0; blue_x = (float)int_x_blue / (float)100000.0; blue_y = (float)int_y_blue / (float)100000.0; #endif #if defined(PNG_READ_sRGB_SUPPORTED) if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB)) { if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) || PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) || PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) || PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) || PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) || PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) || PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) || PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000)) { png_warning(png_ptr, "Ignoring incorrect cHRM value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO #ifdef PNG_FLOATING_POINT_SUPPORTED fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", white_x, white_y, red_x, red_y); fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", green_x, green_y, blue_x, blue_y); #else fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", int_x_white, int_y_white, int_x_red, int_y_red); fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", int_x_green, int_y_green, int_x_blue, int_y_blue); #endif #endif /* PNG_NO_CONSOLE_IO */ } png_crc_finish(png_ptr, 0); return; } #endif /* PNG_READ_sRGB_SUPPORTED */ #ifdef PNG_FLOATING_POINT_SUPPORTED png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_set_cHRM_fixed(png_ptr, info_ptr, int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, int_y_green, int_x_blue, int_y_blue); #endif if (png_crc_finish(png_ptr, 0)) return; } #endif #if defined(PNG_READ_sRGB_SUPPORTED) void /* PRIVATE */ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { int intent; png_byte buf[1]; png_debug(1, "in png_handle_sRGB\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sRGB"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid sRGB after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->mode & PNG_HAVE_PLTE) /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Out of place sRGB chunk"); if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)) { png_warning(png_ptr, "Duplicate sRGB chunk"); png_crc_finish(png_ptr, length); return; } if (length != 1) { png_warning(png_ptr, "Incorrect sRGB chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 1); if (png_crc_finish(png_ptr, 0)) return; intent = buf[0]; /* check for bad intent */ if (intent >= PNG_sRGB_INTENT_LAST) { png_warning(png_ptr, "Unknown sRGB intent"); return; } #if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)) { png_fixed_point igamma; #ifdef PNG_FIXED_POINT_SUPPORTED igamma=info_ptr->int_gamma; #else # ifdef PNG_FLOATING_POINT_SUPPORTED igamma=(png_fixed_point)(info_ptr->gamma * 100000.); # endif #endif if (PNG_OUT_OF_RANGE(igamma, 45500L, 500)) { png_warning(png_ptr, "Ignoring incorrect gAMA value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO # ifdef PNG_FIXED_POINT_SUPPORTED fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); # else # ifdef PNG_FLOATING_POINT_SUPPORTED fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); # endif # endif #endif } } #endif /* PNG_READ_gAMA_SUPPORTED */ #ifdef PNG_READ_cHRM_SUPPORTED #ifdef PNG_FIXED_POINT_SUPPORTED if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) || PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000)) { png_warning(png_ptr, "Ignoring incorrect cHRM value when sRGB is also present"); } #endif /* PNG_FIXED_POINT_SUPPORTED */ #endif /* PNG_READ_cHRM_SUPPORTED */ png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent); } #endif /* PNG_READ_sRGB_SUPPORTED */ #if defined(PNG_READ_iCCP_SUPPORTED) void /* PRIVATE */ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { png_charp chunkdata; png_byte compression_type; png_bytep pC; png_charp profile; png_uint_32 skip = 0; png_uint_32 profile_size, profile_length; png_size_t slength, prefix_length, data_length; png_debug(1, "in png_handle_iCCP\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iCCP"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid iCCP after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->mode & PNG_HAVE_PLTE) /* Should be an error, but we can cope with it */ png_warning(png_ptr, "Out of place iCCP chunk"); if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)) { png_warning(png_ptr, "Duplicate iCCP chunk"); png_crc_finish(png_ptr, length); return; } #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) { png_warning(png_ptr, "iCCP chunk too large to fit in memory"); skip = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif chunkdata = (png_charp)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { png_free(png_ptr, chunkdata); return; } chunkdata[slength] = 0x00; for (profile = chunkdata; *profile; profile++) /* empty loop to find end of name */ ; ++profile; /* there should be at least one zero (the compression type byte) following the separator, and we should be on it */ if ( profile >= chunkdata + slength - 1) { png_free(png_ptr, chunkdata); png_warning(png_ptr, "Malformed iCCP chunk"); return; } /* compression_type should always be zero */ compression_type = *profile++; if (compression_type) { png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 wrote nonzero) */ } prefix_length = profile - chunkdata; chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, slength, prefix_length, &data_length); profile_length = data_length - prefix_length; if ( prefix_length > data_length || profile_length < 4) { png_free(png_ptr, chunkdata); png_warning(png_ptr, "Profile size field missing from iCCP chunk"); return; } /* Check the profile_size recorded in the first 32 bits of the ICC profile */ pC = (png_bytep)(chunkdata+prefix_length); profile_size = ((*(pC ))<<24) | ((*(pC+1))<<16) | ((*(pC+2))<< 8) | ((*(pC+3)) ); if(profile_size < profile_length) profile_length = profile_size; if(profile_size > profile_length) { png_free(png_ptr, chunkdata); png_warning(png_ptr, "Ignoring truncated iCCP profile."); return; } png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, chunkdata + prefix_length, profile_length); png_free(png_ptr, chunkdata); } #endif /* PNG_READ_iCCP_SUPPORTED */ #if defined(PNG_READ_sPLT_SUPPORTED) void /* PRIVATE */ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { png_bytep chunkdata; png_bytep entry_start; png_sPLT_t new_palette; #ifdef PNG_NO_POINTER_INDEXING png_sPLT_entryp pp; #endif int data_length, entry_size, i; png_uint_32 skip = 0; png_size_t slength; png_debug(1, "in png_handle_sPLT\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sPLT"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid sPLT after IDAT"); png_crc_finish(png_ptr, length); return; } #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) { png_warning(png_ptr, "sPLT chunk too large to fit in memory"); skip = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { png_free(png_ptr, chunkdata); return; } chunkdata[slength] = 0x00; for (entry_start = chunkdata; *entry_start; entry_start++) /* empty loop to find end of name */ ; ++entry_start; /* a sample depth should follow the separator, and we should be on it */ if (entry_start > chunkdata + slength - 2) { png_free(png_ptr, chunkdata); png_warning(png_ptr, "malformed sPLT chunk"); return; } new_palette.depth = *entry_start++; entry_size = (new_palette.depth == 8 ? 6 : 10); data_length = (slength - (entry_start - chunkdata)); /* integrity-check the data length */ if (data_length % entry_size) { png_free(png_ptr, chunkdata); png_warning(png_ptr, "sPLT chunk has bad length"); return; } new_palette.nentries = (png_int_32) ( data_length / entry_size); if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / png_sizeof(png_sPLT_entry))) { png_warning(png_ptr, "sPLT chunk too long"); return; } new_palette.entries = (png_sPLT_entryp)png_malloc_warn( png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry)); if (new_palette.entries == NULL) { png_warning(png_ptr, "sPLT chunk requires too much memory"); return; } #ifndef PNG_NO_POINTER_INDEXING for (i = 0; i < new_palette.nentries; i++) { png_sPLT_entryp pp = new_palette.entries + i; if (new_palette.depth == 8) { pp->red = *entry_start++; pp->green = *entry_start++; pp->blue = *entry_start++; pp->alpha = *entry_start++; } else { pp->red = png_get_uint_16(entry_start); entry_start += 2; pp->green = png_get_uint_16(entry_start); entry_start += 2; pp->blue = png_get_uint_16(entry_start); entry_start += 2; pp->alpha = png_get_uint_16(entry_start); entry_start += 2; } pp->frequency = png_get_uint_16(entry_start); entry_start += 2; } #else pp = new_palette.entries; for (i = 0; i < new_palette.nentries; i++) { if (new_palette.depth == 8) { pp[i].red = *entry_start++; pp[i].green = *entry_start++; pp[i].blue = *entry_start++; pp[i].alpha = *entry_start++; } else { pp[i].red = png_get_uint_16(entry_start); entry_start += 2; pp[i].green = png_get_uint_16(entry_start); entry_start += 2; pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; } pp->frequency = png_get_uint_16(entry_start); entry_start += 2; } #endif /* discard all chunk data except the name and stash that */ new_palette.name = (png_charp)chunkdata; png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); png_free(png_ptr, chunkdata); png_free(png_ptr, new_palette.entries); } #endif /* PNG_READ_sPLT_SUPPORTED */ #if defined(PNG_READ_tRNS_SUPPORTED) void /* PRIVATE */ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; int bit_mask; png_debug(1, "in png_handle_tRNS\n"); /* For non-indexed color, mask off any bits in the tRNS value that * exceed the bit depth. Some creators were writing extra bits there. * This is not needed for indexed color. */ bit_mask = (1 << png_ptr->bit_depth) - 1; if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tRNS"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid tRNS after IDAT"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { png_warning(png_ptr, "Duplicate tRNS chunk"); png_crc_finish(png_ptr, length); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { png_byte buf[2]; if (length != 2) { png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 2); png_ptr->num_trans = 1; png_ptr->trans_values.gray = png_get_uint_16(buf) & bit_mask; } else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { png_byte buf[6]; if (length != 6) { png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, (png_size_t)length); png_ptr->num_trans = 1; png_ptr->trans_values.red = png_get_uint_16(buf) & bit_mask; png_ptr->trans_values.green = png_get_uint_16(buf + 2) & bit_mask; png_ptr->trans_values.blue = png_get_uint_16(buf + 4) & bit_mask; } else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (!(png_ptr->mode & PNG_HAVE_PLTE)) { /* Should be an error, but we can cope with it. */ png_warning(png_ptr, "Missing PLTE before tRNS"); } if (length > (png_uint_32)png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH) { png_warning(png_ptr, "Incorrect tRNS chunk length"); png_crc_finish(png_ptr, length); return; } if (length == 0) { png_warning(png_ptr, "Zero length tRNS chunk"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, readbuf, (png_size_t)length); png_ptr->num_trans = (png_uint_16)length; } else { png_warning(png_ptr, "tRNS chunk not allowed with alpha channel"); png_crc_finish(png_ptr, length); return; } if (png_crc_finish(png_ptr, 0)) { png_ptr->num_trans = 0; return; } png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, &(png_ptr->trans_values)); } #endif #if defined(PNG_READ_bKGD_SUPPORTED) void /* PRIVATE */ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_size_t truelen; png_byte buf[6]; png_debug(1, "in png_handle_bKGD\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before bKGD"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid bKGD after IDAT"); png_crc_finish(png_ptr, length); return; } else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && !(png_ptr->mode & PNG_HAVE_PLTE)) { png_warning(png_ptr, "Missing PLTE before bKGD"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)) { png_warning(png_ptr, "Duplicate bKGD chunk"); png_crc_finish(png_ptr, length); return; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) truelen = 1; else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) truelen = 6; else truelen = 2; if (length != truelen) { png_warning(png_ptr, "Incorrect bKGD chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, truelen); if (png_crc_finish(png_ptr, 0)) return; /* We convert the index value into RGB components so that we can allow * arbitrary RGB values for background when we have transparency, and * so it is easy to determine the RGB values of the background color * from the info_ptr struct. */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { png_ptr->background.index = buf[0]; if(info_ptr->num_palette) { if(buf[0] > info_ptr->num_palette) { png_warning(png_ptr, "Incorrect bKGD chunk index value"); return; } png_ptr->background.red = (png_uint_16)png_ptr->palette[buf[0]].red; png_ptr->background.green = (png_uint_16)png_ptr->palette[buf[0]].green; png_ptr->background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue; } } else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */ { png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray = png_get_uint_16(buf); } else { png_ptr->background.red = png_get_uint_16(buf); png_ptr->background.green = png_get_uint_16(buf + 2); png_ptr->background.blue = png_get_uint_16(buf + 4); } png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background)); } #endif #if defined(PNG_READ_hIST_SUPPORTED) void /* PRIVATE */ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { unsigned int num, i; png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; png_debug(1, "in png_handle_hIST\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before hIST"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid hIST after IDAT"); png_crc_finish(png_ptr, length); return; } else if (!(png_ptr->mode & PNG_HAVE_PLTE)) { png_warning(png_ptr, "Missing PLTE before hIST"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)) { png_warning(png_ptr, "Duplicate hIST chunk"); png_crc_finish(png_ptr, length); return; } num = length / 2 ; if (num != (unsigned int) png_ptr->num_palette || num > (unsigned int) PNG_MAX_PALETTE_LENGTH) { png_warning(png_ptr, "Incorrect hIST chunk length"); png_crc_finish(png_ptr, length); return; } for (i = 0; i < num; i++) { png_byte buf[2]; png_crc_read(png_ptr, buf, 2); readbuf[i] = png_get_uint_16(buf); } if (png_crc_finish(png_ptr, 0)) return; png_set_hIST(png_ptr, info_ptr, readbuf); } #endif #if defined(PNG_READ_pHYs_SUPPORTED) void /* PRIVATE */ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[9]; png_uint_32 res_x, res_y; int unit_type; png_debug(1, "in png_handle_pHYs\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before pHYs"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid pHYs after IDAT"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { png_warning(png_ptr, "Duplicate pHYs chunk"); png_crc_finish(png_ptr, length); return; } if (length != 9) { png_warning(png_ptr, "Incorrect pHYs chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 9); if (png_crc_finish(png_ptr, 0)) return; res_x = png_get_uint_32(buf); res_y = png_get_uint_32(buf + 4); unit_type = buf[8]; png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); } #endif #if defined(PNG_READ_oFFs_SUPPORTED) void /* PRIVATE */ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[9]; png_int_32 offset_x, offset_y; int unit_type; png_debug(1, "in png_handle_oFFs\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before oFFs"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid oFFs after IDAT"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)) { png_warning(png_ptr, "Duplicate oFFs chunk"); png_crc_finish(png_ptr, length); return; } if (length != 9) { png_warning(png_ptr, "Incorrect oFFs chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 9); if (png_crc_finish(png_ptr, 0)) return; offset_x = png_get_int_32(buf); offset_y = png_get_int_32(buf + 4); unit_type = buf[8]; png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); } #endif #if defined(PNG_READ_pCAL_SUPPORTED) /* read the pCAL chunk (described in the PNG Extensions document) */ void /* PRIVATE */ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_charp purpose; png_int_32 X0, X1; png_byte type, nparams; png_charp buf, units, endptr; png_charpp params; png_size_t slength; int i; png_debug(1, "in png_handle_pCAL\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before pCAL"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid pCAL after IDAT"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)) { png_warning(png_ptr, "Duplicate pCAL chunk"); png_crc_finish(png_ptr, length); return; } png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", length + 1); purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); if (purpose == NULL) { png_warning(png_ptr, "No memory for pCAL purpose."); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)purpose, slength); if (png_crc_finish(png_ptr, 0)) { png_free(png_ptr, purpose); return; } purpose[slength] = 0x00; /* null terminate the last string */ png_debug(3, "Finding end of pCAL purpose string\n"); for (buf = purpose; *buf; buf++) /* empty loop */ ; endptr = purpose + slength; /* We need to have at least 12 bytes after the purpose string in order to get the parameter information. */ if (endptr <= buf + 12) { png_warning(png_ptr, "Invalid pCAL data"); png_free(png_ptr, purpose); return; } png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); X0 = png_get_int_32((png_bytep)buf+1); X1 = png_get_int_32((png_bytep)buf+5); type = buf[9]; nparams = buf[10]; units = buf + 11; png_debug(3, "Checking pCAL equation type and number of parameters\n"); /* Check that we have the right number of parameters for known equation types. */ if ((type == PNG_EQUATION_LINEAR && nparams != 2) || (type == PNG_EQUATION_BASE_E && nparams != 3) || (type == PNG_EQUATION_ARBITRARY && nparams != 3) || (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) { png_warning(png_ptr, "Invalid pCAL parameters for equation type"); png_free(png_ptr, purpose); return; } else if (type >= PNG_EQUATION_LAST) { png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); } for (buf = units; *buf; buf++) /* Empty loop to move past the units string. */ ; png_debug(3, "Allocating pCAL parameters array\n"); params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams *png_sizeof(png_charp))) ; if (params == NULL) { png_free(png_ptr, purpose); png_warning(png_ptr, "No memory for pCAL params."); return; } /* Get pointers to the start of each parameter string. */ for (i = 0; i < (int)nparams; i++) { buf++; /* Skip the null string terminator from previous parameter. */ png_debug1(3, "Reading pCAL parameter %d\n", i); for (params[i] = buf; *buf != 0x00 && buf <= endptr; buf++) /* Empty loop to move past each parameter string */ ; /* Make sure we haven't run out of data yet */ if (buf > endptr) { png_warning(png_ptr, "Invalid pCAL data"); png_free(png_ptr, purpose); png_free(png_ptr, params); return; } } png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, units, params); png_free(png_ptr, purpose); png_free(png_ptr, params); } #endif #if defined(PNG_READ_sCAL_SUPPORTED) /* read the sCAL chunk */ void /* PRIVATE */ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_charp buffer, ep; #ifdef PNG_FLOATING_POINT_SUPPORTED double width, height; png_charp vp; #else #ifdef PNG_FIXED_POINT_SUPPORTED png_charp swidth, sheight; #endif #endif png_size_t slength; png_debug(1, "in png_handle_sCAL\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sCAL"); else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid sCAL after IDAT"); png_crc_finish(png_ptr, length); return; } else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL)) { png_warning(png_ptr, "Duplicate sCAL chunk"); png_crc_finish(png_ptr, length); return; } png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", length + 1); buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); if (buffer == NULL) { png_warning(png_ptr, "Out of memory while processing sCAL chunk"); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)buffer, slength); if (png_crc_finish(png_ptr, 0)) { png_free(png_ptr, buffer); return; } buffer[slength] = 0x00; /* null terminate the last string */ ep = buffer + 1; /* skip unit byte */ #ifdef PNG_FLOATING_POINT_SUPPORTED width = png_strtod(png_ptr, ep, &vp); if (*vp) { png_warning(png_ptr, "malformed width string in sCAL chunk"); return; } #else #ifdef PNG_FIXED_POINT_SUPPORTED swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); if (swidth == NULL) { png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); return; } png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); #endif #endif for (ep = buffer; *ep; ep++) /* empty loop */ ; ep++; #ifdef PNG_FLOATING_POINT_SUPPORTED height = png_strtod(png_ptr, ep, &vp); if (*vp) { png_warning(png_ptr, "malformed height string in sCAL chunk"); return; } #else #ifdef PNG_FIXED_POINT_SUPPORTED sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); if (swidth == NULL) { png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); return; } png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); #endif #endif if (buffer + slength < ep #ifdef PNG_FLOATING_POINT_SUPPORTED || width <= 0. || height <= 0. #endif ) { png_warning(png_ptr, "Invalid sCAL data"); png_free(png_ptr, buffer); #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); png_free(png_ptr, sheight); #endif return; } #ifdef PNG_FLOATING_POINT_SUPPORTED png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); #else #ifdef PNG_FIXED_POINT_SUPPORTED png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); #endif #endif png_free(png_ptr, buffer); #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); png_free(png_ptr, sheight); #endif } #endif #if defined(PNG_READ_tIME_SUPPORTED) void /* PRIVATE */ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte buf[7]; png_time mod_time; png_debug(1, "in png_handle_tIME\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Out of place tIME chunk"); else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)) { png_warning(png_ptr, "Duplicate tIME chunk"); png_crc_finish(png_ptr, length); return; } if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; if (length != 7) { png_warning(png_ptr, "Incorrect tIME chunk length"); png_crc_finish(png_ptr, length); return; } png_crc_read(png_ptr, buf, 7); if (png_crc_finish(png_ptr, 0)) return; mod_time.second = buf[6]; mod_time.minute = buf[5]; mod_time.hour = buf[4]; mod_time.day = buf[3]; mod_time.month = buf[2]; mod_time.year = png_get_uint_16(buf); png_set_tIME(png_ptr, info_ptr, &mod_time); } #endif #if defined(PNG_READ_tEXt_SUPPORTED) /* Note: this does not properly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; png_charp key; png_charp text; png_uint_32 skip = 0; png_size_t slength; int ret; png_debug(1, "in png_handle_tEXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tEXt"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) { png_warning(png_ptr, "tEXt chunk too large to fit in memory"); skip = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif key = (png_charp)png_malloc_warn(png_ptr, length + 1); if (key == NULL) { png_warning(png_ptr, "No memory to process text chunk."); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)key, slength); if (png_crc_finish(png_ptr, skip)) { png_free(png_ptr, key); return; } key[slength] = 0x00; for (text = key; *text; text++) /* empty loop to find end of key */ ; if (text != key + slength) text++; text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { png_warning(png_ptr, "Not enough memory to process text chunk."); png_free(png_ptr, key); return; } text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; text_ptr->key = key; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; text_ptr->itxt_length = 0; #endif text_ptr->text = text; text_ptr->text_length = png_strlen(text); ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, key); png_free(png_ptr, text_ptr); if (ret) png_warning(png_ptr, "Insufficient memory to process text chunk."); } #endif #if defined(PNG_READ_zTXt_SUPPORTED) /* note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; png_charp chunkdata; png_charp text; int comp_type; int ret; png_size_t slength, prefix_len, data_len; png_debug(1, "in png_handle_zTXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before zTXt"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K /* We will no doubt have problems with chunks even half this size, but there is no hard and fast rule to tell us where to stop. */ if (length > (png_uint_32)65535L) { png_warning(png_ptr,"zTXt chunk too large to fit in memory"); png_crc_finish(png_ptr, length); return; } #endif chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (chunkdata == NULL) { png_warning(png_ptr,"Out of memory processing zTXt chunk."); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { png_free(png_ptr, chunkdata); return; } chunkdata[slength] = 0x00; for (text = chunkdata; *text; text++) /* empty loop */ ; /* zTXt must have some text after the chunkdataword */ if (text == chunkdata + slength - 1) { png_warning(png_ptr, "Truncated zTXt chunk"); png_free(png_ptr, chunkdata); return; } else { comp_type = *(++text); if (comp_type != PNG_TEXT_COMPRESSION_zTXt) { png_warning(png_ptr, "Unknown compression type in zTXt chunk"); comp_type = PNG_TEXT_COMPRESSION_zTXt; } text++; /* skip the compression_method byte */ } prefix_len = text - chunkdata; chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, (png_size_t)length, prefix_len, &data_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { png_warning(png_ptr,"Not enough memory to process zTXt chunk."); png_free(png_ptr, chunkdata); return; } text_ptr->compression = comp_type; text_ptr->key = chunkdata; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; text_ptr->itxt_length = 0; #endif text_ptr->text = chunkdata + prefix_len; text_ptr->text_length = data_len; ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, text_ptr); png_free(png_ptr, chunkdata); if (ret) png_error(png_ptr, "Insufficient memory to store zTXt chunk."); } #endif #if defined(PNG_READ_iTXt_SUPPORTED) /* note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; png_charp chunkdata; png_charp key, lang, text, lang_key; int comp_flag; int comp_type = 0; int ret; png_size_t slength, prefix_len, data_len; png_debug(1, "in png_handle_iTXt\n"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iTXt"); if (png_ptr->mode & PNG_HAVE_IDAT) png_ptr->mode |= PNG_AFTER_IDAT; #ifdef PNG_MAX_MALLOC_64K /* We will no doubt have problems with chunks even half this size, but there is no hard and fast rule to tell us where to stop. */ if (length > (png_uint_32)65535L) { png_warning(png_ptr,"iTXt chunk too large to fit in memory"); png_crc_finish(png_ptr, length); return; } #endif chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); if (chunkdata == NULL) { png_warning(png_ptr, "No memory to process iTXt chunk."); return; } slength = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { png_free(png_ptr, chunkdata); return; } chunkdata[slength] = 0x00; for (lang = chunkdata; *lang; lang++) /* empty loop */ ; lang++; /* skip NUL separator */ /* iTXt must have a language tag (possibly empty), two compression bytes, translated keyword (possibly empty), and possibly some text after the keyword */ if (lang >= chunkdata + slength - 3) { png_warning(png_ptr, "Truncated iTXt chunk"); png_free(png_ptr, chunkdata); return; } else { comp_flag = *lang++; comp_type = *lang++; } for (lang_key = lang; *lang_key; lang_key++) /* empty loop */ ; lang_key++; /* skip NUL separator */ for (text = lang_key; *text; text++) /* empty loop */ ; text++; /* skip NUL separator */ if (text >= chunkdata + slength) { png_warning(png_ptr, "Malformed iTXt chunk"); png_free(png_ptr, chunkdata); return; } prefix_len = text - chunkdata; key=chunkdata; if (comp_flag) chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, (size_t)length, prefix_len, &data_len); else data_len=png_strlen(chunkdata + prefix_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { png_warning(png_ptr,"Not enough memory to process iTXt chunk."); png_free(png_ptr, chunkdata); return; } text_ptr->compression = (int)comp_flag + 1; text_ptr->lang_key = chunkdata+(lang_key-key); text_ptr->lang = chunkdata+(lang-key); text_ptr->itxt_length = data_len; text_ptr->text_length = 0; text_ptr->key = chunkdata; text_ptr->text = chunkdata + prefix_len; ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, text_ptr); png_free(png_ptr, chunkdata); if (ret) png_error(png_ptr, "Insufficient memory to store iTXt chunk."); } #endif /* This function is called when we haven't found a handler for a chunk. If there isn't a problem with the chunk itself (ie bad chunk name, CRC, or a critical chunk), the chunk is silently ignored -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which case it will be saved away to be written out later. */ void /* PRIVATE */ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip = 0; png_debug(1, "in png_handle_unknown\n"); if (png_ptr->mode & PNG_HAVE_IDAT) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IDAT; #endif if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ png_ptr->mode |= PNG_AFTER_IDAT; } png_check_chunk_name(png_ptr, png_ptr->chunk_name); if (!(png_ptr->chunk_name[0] & 0x20)) { #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) && png_ptr->read_user_chunk_fn == NULL #endif ) #endif png_chunk_error(png_ptr, "unknown critical chunk"); } #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || (png_ptr->read_user_chunk_fn != NULL)) { #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) { png_warning(png_ptr, "unknown chunk too large to fit in memory"); skip = length - (png_uint_32)65535L; length = (png_uint_32)65535L; } #endif png_strncpy((png_charp)png_ptr->unknown_chunk.name, (png_charp)png_ptr->chunk_name, png_sizeof((png_charp)png_ptr->chunk_name)); png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); png_ptr->unknown_chunk.size = (png_size_t)length; png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) if(png_ptr->read_user_chunk_fn != NULL) { /* callback to user unknown chunk handler */ int ret; ret = (*(png_ptr->read_user_chunk_fn)) (png_ptr, &png_ptr->unknown_chunk); if (ret < 0) png_chunk_error(png_ptr, "error in user chunk"); if (ret == 0) { if (!(png_ptr->chunk_name[0] & 0x20)) if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS) png_chunk_error(png_ptr, "unknown critical chunk"); png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); } } #else png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); #endif png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } else #endif skip = length; png_crc_finish(png_ptr, skip); #if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ #endif } /* This function is called to verify that a chunk name is valid. This function can't have the "critical chunk check" incorporated into it, since in the future we will need to be able to call user functions to handle unknown critical chunks after we check that the chunk name itself is valid. */ #define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) void /* PRIVATE */ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) { png_debug(1, "in png_check_chunk_name\n"); if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) { png_chunk_error(png_ptr, "invalid chunk type"); } } /* Combines the row recently read in with the existing pixels in the row. This routine takes care of alpha and transparency if requested. This routine also handles the two methods of progressive display of interlaced images, depending on the mask value. The mask value describes which pixels are to be combined with the row. The pattern always repeats every 8 pixels, so just 8 bits are needed. A one indicates the pixel is to be combined, a zero indicates the pixel is to be skipped. This is in addition to any alpha or transparency value associated with the pixel. If you want all pixels to be combined, pass 0xff (255) in mask. */ void /* PRIVATE */ png_combine_row(png_structp png_ptr, png_bytep row, int mask) { png_debug(1,"in png_combine_row\n"); if (mask == 0xff) { png_memcpy(row, png_ptr->row_buf + 1, PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width)); } else { switch (png_ptr->row_info.pixel_depth) { case 1: { png_bytep sp = png_ptr->row_buf + 1; png_bytep dp = row; int s_inc, s_start, s_end; int m = 0x80; int shift; png_uint_32 i; png_uint_32 row_width = png_ptr->width; #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 7; s_inc = 1; } else #endif { s_start = 7; s_end = 0; s_inc = -1; } shift = s_start; for (i = 0; i < row_width; i++) { if (m & mask) { int value; value = (*sp >> shift) & 0x01; *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); *dp |= (png_byte)(value << shift); } if (shift == s_end) { shift = s_start; sp++; dp++; } else shift += s_inc; if (m == 1) m = 0x80; else m >>= 1; } break; } case 2: { png_bytep sp = png_ptr->row_buf + 1; png_bytep dp = row; int s_start, s_end, s_inc; int m = 0x80; int shift; png_uint_32 i; png_uint_32 row_width = png_ptr->width; int value; #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 6; s_inc = 2; } else #endif { s_start = 6; s_end = 0; s_inc = -2; } shift = s_start; for (i = 0; i < row_width; i++) { if (m & mask) { value = (*sp >> shift) & 0x03; *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *dp |= (png_byte)(value << shift); } if (shift == s_end) { shift = s_start; sp++; dp++; } else shift += s_inc; if (m == 1) m = 0x80; else m >>= 1; } break; } case 4: { png_bytep sp = png_ptr->row_buf + 1; png_bytep dp = row; int s_start, s_end, s_inc; int m = 0x80; int shift; png_uint_32 i; png_uint_32 row_width = png_ptr->width; int value; #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 4; s_inc = 4; } else #endif { s_start = 4; s_end = 0; s_inc = -4; } shift = s_start; for (i = 0; i < row_width; i++) { if (m & mask) { value = (*sp >> shift) & 0xf; *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *dp |= (png_byte)(value << shift); } if (shift == s_end) { shift = s_start; sp++; dp++; } else shift += s_inc; if (m == 1) m = 0x80; else m >>= 1; } break; } default: { png_bytep sp = png_ptr->row_buf + 1; png_bytep dp = row; png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3); png_uint_32 i; png_uint_32 row_width = png_ptr->width; png_byte m = 0x80; for (i = 0; i < row_width; i++) { if (m & mask) { png_memcpy(dp, sp, pixel_bytes); } sp += pixel_bytes; dp += pixel_bytes; if (m == 1) m = 0x80; else m >>= 1; } break; } } } } #ifdef PNG_READ_INTERLACING_SUPPORTED /* OLD pre-1.0.9 interface: void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations) */ void /* PRIVATE */ png_do_read_interlace(png_structp png_ptr) { png_row_infop row_info = &(png_ptr->row_info); png_bytep row = png_ptr->row_buf + 1; int pass = png_ptr->pass; png_uint_32 transformations = png_ptr->transformations; #ifdef PNG_USE_LOCAL_ARRAYS /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; #endif png_debug(1,"in png_do_read_interlace\n"); if (row != NULL && row_info != NULL) { png_uint_32 final_width; final_width = row_info->width * png_pass_inc[pass]; switch (row_info->pixel_depth) { case 1: { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); int sshift, dshift; int s_start, s_end, s_inc; int jstop = png_pass_inc[pass]; png_byte v; png_uint_32 i; int j; #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { sshift = (int)((row_info->width + 7) & 0x07); dshift = (int)((final_width + 7) & 0x07); s_start = 7; s_end = 0; s_inc = -1; } else #endif { sshift = 7 - (int)((row_info->width + 7) & 0x07); dshift = 7 - (int)((final_width + 7) & 0x07); s_start = 0; s_end = 7; s_inc = 1; } for (i = 0; i < row_info->width; i++) { v = (png_byte)((*sp >> sshift) & 0x01); for (j = 0; j < jstop; j++) { *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff); *dp |= (png_byte)(v << dshift); if (dshift == s_end) { dshift = s_start; dp--; } else dshift += s_inc; } if (sshift == s_end) { sshift = s_start; sp--; } else sshift += s_inc; } break; } case 2: { png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); int sshift, dshift; int s_start, s_end, s_inc; int jstop = png_pass_inc[pass]; png_uint_32 i; #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 3) & 0x03) << 1); dshift = (int)(((final_width + 3) & 0x03) << 1); s_start = 6; s_end = 0; s_inc = -2; } else #endif { sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); s_start = 0; s_end = 6; s_inc = 2; } for (i = 0; i < row_info->width; i++) { png_byte v; int j; v = (png_byte)((*sp >> sshift) & 0x03); for (j = 0; j < jstop; j++) { *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff); *dp |= (png_byte)(v << dshift); if (dshift == s_end) { dshift = s_start; dp--; } else dshift += s_inc; } if (sshift == s_end) { sshift = s_start; sp--; } else sshift += s_inc; } break; } case 4: { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); int sshift, dshift; int s_start, s_end, s_inc; png_uint_32 i; int jstop = png_pass_inc[pass]; #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (transformations & PNG_PACKSWAP) { sshift = (int)(((row_info->width + 1) & 0x01) << 2); dshift = (int)(((final_width + 1) & 0x01) << 2); s_start = 4; s_end = 0; s_inc = -4; } else #endif { sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); s_start = 0; s_end = 4; s_inc = 4; } for (i = 0; i < row_info->width; i++) { png_byte v = (png_byte)((*sp >> sshift) & 0xf); int j; for (j = 0; j < jstop; j++) { *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff); *dp |= (png_byte)(v << dshift); if (dshift == s_end) { dshift = s_start; dp--; } else dshift += s_inc; } if (sshift == s_end) { sshift = s_start; sp--; } else sshift += s_inc; } break; } default: { png_size_t pixel_bytes = (row_info->pixel_depth >> 3); png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes; png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; int jstop = png_pass_inc[pass]; png_uint_32 i; for (i = 0; i < row_info->width; i++) { png_byte v[8]; int j; png_memcpy(v, sp, pixel_bytes); for (j = 0; j < jstop; j++) { png_memcpy(dp, v, pixel_bytes); dp -= pixel_bytes; } sp -= pixel_bytes; } break; } } row_info->width = final_width; row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); } #if !defined(PNG_READ_PACKSWAP_SUPPORTED) transformations = transformations; /* silence compiler warning */ #endif } #endif /* PNG_READ_INTERLACING_SUPPORTED */ void /* PRIVATE */ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter) { png_debug(1, "in png_read_filter_row\n"); png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); switch (filter) { case PNG_FILTER_VALUE_NONE: break; case PNG_FILTER_VALUE_SUB: { png_uint_32 i; png_uint_32 istop = row_info->rowbytes; png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; png_bytep rp = row + bpp; png_bytep lp = row; for (i = bpp; i < istop; i++) { *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff); rp++; } break; } case PNG_FILTER_VALUE_UP: { png_uint_32 i; png_uint_32 istop = row_info->rowbytes; png_bytep rp = row; png_bytep pp = prev_row; for (i = 0; i < istop; i++) { *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); rp++; } break; } case PNG_FILTER_VALUE_AVG: { png_uint_32 i; png_bytep rp = row; png_bytep pp = prev_row; png_bytep lp = row; png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; png_uint_32 istop = row_info->rowbytes - bpp; for (i = 0; i < bpp; i++) { *rp = (png_byte)(((int)(*rp) + ((int)(*pp++) / 2 )) & 0xff); rp++; } for (i = 0; i < istop; i++) { *rp = (png_byte)(((int)(*rp) + (int)(*pp++ + *lp++) / 2 ) & 0xff); rp++; } break; } case PNG_FILTER_VALUE_PAETH: { png_uint_32 i; png_bytep rp = row; png_bytep pp = prev_row; png_bytep lp = row; png_bytep cp = prev_row; png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3; png_uint_32 istop=row_info->rowbytes - bpp; for (i = 0; i < bpp; i++) { *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); rp++; } for (i = 0; i < istop; i++) /* use leftover rp,pp */ { int a, b, c, pa, pb, pc, p; a = *lp++; b = *pp++; c = *cp++; p = b - c; pc = a - c; #ifdef PNG_USE_ABS pa = abs(p); pb = abs(pc); pc = abs(p + pc); #else pa = p < 0 ? -p : p; pb = pc < 0 ? -pc : pc; pc = (p + pc) < 0 ? -(p + pc) : p + pc; #endif /* if (pa <= pb && pa <= pc) p = a; else if (pb <= pc) p = b; else p = c; */ p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; *rp = (png_byte)(((int)(*rp) + p) & 0xff); rp++; } break; } default: png_warning(png_ptr, "Ignoring bad adaptive filter type"); *row=0; break; } } void /* PRIVATE */ png_read_finish_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* start of interlace block */ PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; /* offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; /* start of interlace block in the y direction */ PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; /* offset to next interlace block in the y direction */ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif png_debug(1, "in png_read_finish_row\n"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; if (png_ptr->interlaced) { png_ptr->row_number = 0; png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); do { png_ptr->pass++; if (png_ptr->pass >= 7) break; png_ptr->iwidth = (png_ptr->width + png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1; if (!(png_ptr->transformations & PNG_INTERLACE)) { png_ptr->num_rows = (png_ptr->height + png_pass_yinc[png_ptr->pass] - 1 - png_pass_ystart[png_ptr->pass]) / png_pass_yinc[png_ptr->pass]; if (!(png_ptr->num_rows)) continue; } else /* if (png_ptr->transformations & PNG_INTERLACE) */ break; } while (png_ptr->iwidth == 0); if (png_ptr->pass < 7) return; } if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IDAT; #endif char extra; int ret; png_ptr->zstream.next_out = (Byte *)&extra; png_ptr->zstream.avail_out = (uInt)1; for(;;) { if (!(png_ptr->zstream.avail_in)) { while (!png_ptr->idat_size) { png_byte chunk_length[4]; png_crc_finish(png_ptr, 0); png_read_data(png_ptr, chunk_length, 4); png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); if (png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4)) png_error(png_ptr, "Not enough image data"); } png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size; png_ptr->zstream.next_in = png_ptr->zbuf; if (png_ptr->zbuf_size > png_ptr->idat_size) png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size; png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in); png_ptr->idat_size -= png_ptr->zstream.avail_in; } ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); if (ret == Z_STREAM_END) { if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in || png_ptr->idat_size) png_warning(png_ptr, "Extra compressed data"); png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } if (ret != Z_OK) png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg : "Decompression Error"); if (!(png_ptr->zstream.avail_out)) { png_warning(png_ptr, "Extra compressed data."); png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED; break; } } png_ptr->zstream.avail_out = 0; } if (png_ptr->idat_size || png_ptr->zstream.avail_in) png_warning(png_ptr, "Extra compression data"); inflateReset(&png_ptr->zstream); png_ptr->mode |= PNG_AFTER_IDAT; } void /* PRIVATE */ png_read_start_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* start of interlace block */ PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; /* offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; /* start of interlace block in the y direction */ PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; /* offset to next interlace block in the y direction */ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif int max_pixel_depth; png_uint_32 row_bytes; png_debug(1, "in png_read_start_row\n"); png_ptr->zstream.avail_in = 0; png_init_read_transformations(png_ptr); if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - png_pass_ystart[0]) / png_pass_yinc[0]; else png_ptr->num_rows = png_ptr->height; png_ptr->iwidth = (png_ptr->width + png_pass_inc[png_ptr->pass] - 1 - png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; png_ptr->irowbytes = (png_size_t)row_bytes; if((png_uint_32)png_ptr->irowbytes != row_bytes) png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); } else { png_ptr->num_rows = png_ptr->height; png_ptr->iwidth = png_ptr->width; png_ptr->irowbytes = png_ptr->rowbytes + 1; } max_pixel_depth = png_ptr->pixel_depth; #if defined(PNG_READ_PACK_SUPPORTED) if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8) max_pixel_depth = 8; #endif #if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (png_ptr->num_trans) max_pixel_depth = 32; else max_pixel_depth = 24; } else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { if (max_pixel_depth < 8) max_pixel_depth = 8; if (png_ptr->num_trans) max_pixel_depth *= 2; } else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { if (png_ptr->num_trans) { max_pixel_depth *= 4; max_pixel_depth /= 3; } } } #endif #if defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & (PNG_FILLER)) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) max_pixel_depth = 32; else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) { if (max_pixel_depth <= 8) max_pixel_depth = 16; else max_pixel_depth = 32; } else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) { if (max_pixel_depth <= 32) max_pixel_depth = 32; else max_pixel_depth = 64; } } #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) if (png_ptr->transformations & PNG_GRAY_TO_RGB) { if ( #if defined(PNG_READ_EXPAND_SUPPORTED) (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) || #endif #if defined(PNG_READ_FILLER_SUPPORTED) (png_ptr->transformations & (PNG_FILLER)) || #endif png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (max_pixel_depth <= 16) max_pixel_depth = 32; else max_pixel_depth = 64; } else { if (max_pixel_depth <= 8) { if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) max_pixel_depth = 32; else max_pixel_depth = 24; } else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) max_pixel_depth = 64; else max_pixel_depth = 48; } } #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if(png_ptr->transformations & PNG_USER_TRANSFORM) { int user_pixel_depth=png_ptr->user_transform_depth* png_ptr->user_transform_channels; if(user_pixel_depth > max_pixel_depth) max_pixel_depth=user_pixel_depth; } #endif /* align the width on the next larger 8 pixels. Mainly used for interlacing */ row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); /* calculate the maximum bytes needed, adding a byte and a pixel for safety's sake */ row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + 1 + ((max_pixel_depth + 7) >> 3); #ifdef PNG_MAX_MALLOC_64K if (row_bytes > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); png_ptr->row_buf = png_ptr->big_row_buf+32; #ifdef PNG_MAX_MALLOC_64K if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) png_error(png_ptr, "Row has too many bytes to allocate in memory."); png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( png_ptr->rowbytes + 1)); png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); png_debug1(3, "width = %lu,\n", png_ptr->width); png_debug1(3, "height = %lu,\n", png_ptr->height); png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); png_ptr->flags |= PNG_FLAG_ROW_INIT; } #endif /* PNG_READ_SUPPORTED */ wgd-3.1/src/resources_base/png/pngmem.cpp0000644000175000001440000004106710757754260015446 00000000000000 /* pngmem.c - stub functions for memory allocation * * Last changed in libpng 1.2.13 November 13, 2006 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2006 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file provides a location for all memory allocation. Users who * need special memory handling are expected to supply replacement * functions for png_malloc() and png_free(), and to use * png_create_read_struct_2() and png_create_write_struct_2() to * identify the replacement functions. */ #define PNG_INTERNAL #include #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Borland DOS special memory handler */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) /* if you change this, be sure to change the one in png.h also */ /* Allocate memory for a png_struct. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance. */ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); } /* Alternate version of png_create_struct, for use with user-defined malloc. */ png_voidp /* PRIVATE */ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ png_size_t size; png_voidp struct_ptr; if (type == PNG_STRUCT_INFO) size = png_sizeof(png_info); else if (type == PNG_STRUCT_PNG) size = png_sizeof(png_struct); else return (png_get_copyright(NULL)); #ifdef PNG_USER_MEM_SUPPORTED if(malloc_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; png_ptr->mem_ptr=mem_ptr; struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size); } else #endif /* PNG_USER_MEM_SUPPORTED */ struct_ptr = (png_voidp)farmalloc(size); if (struct_ptr != NULL) png_memset(struct_ptr, 0, size); return (struct_ptr); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr) { #endif if (struct_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED if(free_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; png_ptr->mem_ptr=mem_ptr; (*(free_fn))(png_ptr, struct_ptr); return; } #endif /* PNG_USER_MEM_SUPPORTED */ farfree (struct_ptr); } } /* Allocate memory. For reasonable files, size should never exceed * 64K. However, zlib may allocate more then 64K if you don't tell * it not to. See zconf.h and png.h for more information. zlib does * need to allocate exactly 64K, so whatever you call here must * have the ability to do that. * * Borland seems to have a problem in DOS mode for exactly 64K. * It gives you a segment with an offset of 8 (perhaps to store its * memory stuff). zlib doesn't like this at all, so we have to * detect and deal with it. This code should not be needed in * Windows or OS/2 modes, and only in 16 bit mode. This code has * been updated by Alexander Lehmann for version 0.89 to waste less * memory. * * Note that we can't use png_size_t for the "size" declaration, * since on some systems a png_size_t is a 16-bit quantity, and as a * result, we would be truncating potentially larger memory requests * (which should cause a fatal error) and introducing major problems. */ png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size) { png_voidp ret; if (png_ptr == NULL || size == 0) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if(png_ptr->malloc_fn != NULL) ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of memory!"); return (ret); } png_voidp PNGAPI png_malloc_default(png_structp png_ptr, png_uint_32 size) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ if (png_ptr == NULL || size == 0) return (NULL); #ifdef PNG_MAX_MALLOC_64K if (size > (png_uint_32)65536L) { png_warning(png_ptr, "Cannot Allocate > 64K"); ret = NULL; } else #endif if (size != (size_t)size) ret = NULL; else if (size == (png_uint_32)65536L) { if (png_ptr->offset_table == NULL) { /* try to see if we need to do any of this fancy stuff */ ret = farmalloc(size); if (ret == NULL || ((png_size_t)ret & 0xffff)) { int num_blocks; png_uint_32 total_size; png_bytep table; int i; png_byte huge * hptr; if (ret != NULL) { farfree(ret); ret = NULL; } if(png_ptr->zlib_window_bits > 14) num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); else num_blocks = 1; if (png_ptr->zlib_mem_level >= 7) num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7)); else num_blocks++; total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16; table = farmalloc(total_size); if (table == NULL) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */ else png_warning(png_ptr, "Out Of Memory."); #endif return (NULL); } if ((png_size_t)table & 0xfff0) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Farmalloc didn't return normalized pointer"); else png_warning(png_ptr, "Farmalloc didn't return normalized pointer"); #endif return (NULL); } png_ptr->offset_table = table; png_ptr->offset_table_ptr = farmalloc(num_blocks * png_sizeof (png_bytep)); if (png_ptr->offset_table_ptr == NULL) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */ else png_warning(png_ptr, "Out Of memory."); #endif return (NULL); } hptr = (png_byte huge *)table; if ((png_size_t)hptr & 0xf) { hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L); hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */ } for (i = 0; i < num_blocks; i++) { png_ptr->offset_table_ptr[i] = (png_bytep)hptr; hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */ } png_ptr->offset_table_number = num_blocks; png_ptr->offset_table_count = 0; png_ptr->offset_table_count_free = 0; } } if (png_ptr->offset_table_count >= png_ptr->offset_table_number) { #ifndef PNG_USER_MEM_SUPPORTED if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */ else png_warning(png_ptr, "Out of Memory."); #endif return (NULL); } ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++]; } else ret = farmalloc(size); #ifndef PNG_USER_MEM_SUPPORTED if (ret == NULL) { if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */ else png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */ } #endif return (ret); } /* free a pointer allocated by png_malloc(). In the default configuration, png_ptr is not used, but is passed in case it is needed. If ptr is NULL, return without taking any action. */ void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) return; #ifdef PNG_USER_MEM_SUPPORTED if (png_ptr->free_fn != NULL) { (*(png_ptr->free_fn))(png_ptr, ptr); return; } else png_free_default(png_ptr, ptr); } void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ if(png_ptr == NULL) return; if (png_ptr->offset_table != NULL) { int i; for (i = 0; i < png_ptr->offset_table_count; i++) { if (ptr == png_ptr->offset_table_ptr[i]) { ptr = NULL; png_ptr->offset_table_count_free++; break; } } if (png_ptr->offset_table_count_free == png_ptr->offset_table_count) { farfree(png_ptr->offset_table); farfree(png_ptr->offset_table_ptr); png_ptr->offset_table = NULL; png_ptr->offset_table_ptr = NULL; } } if (ptr != NULL) { farfree(ptr); } } #else /* Not the Borland DOS special memory handler */ /* Allocate memory for a png_struct or a png_info. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance noticably. */ png_voidp /* PRIVATE */ png_create_struct(int type) { #ifdef PNG_USER_MEM_SUPPORTED return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL)); } /* Allocate memory for a png_struct or a png_info. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance noticably. */ png_voidp /* PRIVATE */ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ png_size_t size; png_voidp struct_ptr; if (type == PNG_STRUCT_INFO) size = png_sizeof(png_info); else if (type == PNG_STRUCT_PNG) size = png_sizeof(png_struct); else return (NULL); #ifdef PNG_USER_MEM_SUPPORTED if(malloc_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; png_ptr->mem_ptr=mem_ptr; struct_ptr = (*(malloc_fn))(png_ptr, size); if (struct_ptr != NULL) png_memset(struct_ptr, 0, size); return (struct_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ #if defined(__TURBOC__) && !defined(__FLAT__) struct_ptr = (png_voidp)farmalloc(size); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) struct_ptr = (png_voidp)halloc(size,1); # else struct_ptr = (png_voidp)malloc(size); # endif #endif if (struct_ptr != NULL) png_memset(struct_ptr, 0, size); return (struct_ptr); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ png_destroy_struct(png_voidp struct_ptr) { #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL); } /* Free memory allocated by a png_create_struct() call */ void /* PRIVATE */ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, png_voidp mem_ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ if (struct_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED if(free_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; png_ptr->mem_ptr=mem_ptr; (*(free_fn))(png_ptr, struct_ptr); return; } #endif /* PNG_USER_MEM_SUPPORTED */ #if defined(__TURBOC__) && !defined(__FLAT__) farfree(struct_ptr); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) hfree(struct_ptr); # else free(struct_ptr); # endif #endif } } /* Allocate memory. For reasonable files, size should never exceed 64K. However, zlib may allocate more then 64K if you don't tell it not to. See zconf.h and png.h for more information. zlib does need to allocate exactly 64K, so whatever you call here must have the ability to do that. */ png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size) { png_voidp ret; #ifdef PNG_USER_MEM_SUPPORTED if (png_ptr == NULL || size == 0) return (NULL); if(png_ptr->malloc_fn != NULL) ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of Memory!"); return (ret); } png_voidp PNGAPI png_malloc_default(png_structp png_ptr, png_uint_32 size) { png_voidp ret; #endif /* PNG_USER_MEM_SUPPORTED */ if (png_ptr == NULL || size == 0) return (NULL); #ifdef PNG_MAX_MALLOC_64K if (size > (png_uint_32)65536L) { #ifndef PNG_USER_MEM_SUPPORTED if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Cannot Allocate > 64K"); else #endif return NULL; } #endif /* Check for overflow */ #if defined(__TURBOC__) && !defined(__FLAT__) if (size != (unsigned long)size) ret = NULL; else ret = farmalloc(size); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) if (size != (unsigned long)size) ret = NULL; else ret = halloc(size, 1); # else if (size != (size_t)size) ret = NULL; else ret = malloc((size_t)size); # endif #endif #ifndef PNG_USER_MEM_SUPPORTED if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of Memory"); #endif return (ret); } /* Free a pointer allocated by png_malloc(). If ptr is NULL, return without taking any action. */ void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) return; #ifdef PNG_USER_MEM_SUPPORTED if (png_ptr->free_fn != NULL) { (*(png_ptr->free_fn))(png_ptr, ptr); return; } else png_free_default(png_ptr, ptr); } void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr) { if (png_ptr == NULL || ptr == NULL) return; #endif /* PNG_USER_MEM_SUPPORTED */ #if defined(__TURBOC__) && !defined(__FLAT__) farfree(ptr); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) hfree(ptr); # else free(ptr); # endif #endif } #endif /* Not Borland DOS special memory handler */ #if defined(PNG_1_0_X) # define png_malloc_warn png_malloc #else /* This function was added at libpng version 1.2.3. The png_malloc_warn() * function will set up png_malloc() to issue a png_warning and return NULL * instead of issuing a png_error, if it fails to allocate the requested * memory. */ png_voidp PNGAPI png_malloc_warn(png_structp png_ptr, png_uint_32 size) { png_voidp ptr; png_uint_32 save_flags; if(png_ptr == NULL) return (NULL); save_flags=png_ptr->flags; png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); png_ptr->flags=save_flags; return(ptr); } #endif png_voidp PNGAPI png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, png_uint_32 length) { png_size_t size; size = (png_size_t)length; if ((png_uint_32)size != length) png_error(png_ptr,"Overflow in png_memcpy_check."); return(png_memcpy (s1, s2, size)); } png_voidp PNGAPI png_memset_check (png_structp png_ptr, png_voidp s1, int value, png_uint_32 length) { png_size_t size; size = (png_size_t)length; if ((png_uint_32)size != length) png_error(png_ptr,"Overflow in png_memset_check."); return (png_memset (s1, value, size)); } #ifdef PNG_USER_MEM_SUPPORTED /* This function is called when the application wants to use another method * of allocating and freeing memory. */ void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { if(png_ptr != NULL) { png_ptr->mem_ptr = mem_ptr; png_ptr->malloc_fn = malloc_fn; png_ptr->free_fn = free_fn; } } /* This function returns a pointer to the mem_ptr associated with the user * functions. The application should free any memory associated with this * pointer before png_write_destroy and png_read_destroy are called. */ png_voidp PNGAPI png_get_mem_ptr(png_structp png_ptr) { if(png_ptr == NULL) return (NULL); return ((png_voidp)png_ptr->mem_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ wgd-3.1/src/resources_base/png/pngrtran.cpp0000644000175000001440000043663011001137472016001 00000000000000 /* pngrtran.c - transforms the data in a row for PNG readers * * Last changed in libpng 1.2.19 August 19, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * This file contains functions optionally called by an application * in order to tell libpng how to handle data when reading a PNG. * Transformations that are used in both reading and writing are * in pngtrans.c. */ #define PNG_INTERNAL #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif #if defined(PNG_READ_SUPPORTED) /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) { png_debug(1, "in png_set_crc_action\n"); /* Tell libpng how we react to CRC errors in critical chunks */ if(png_ptr == NULL) return; switch (crit_action) { case PNG_CRC_NO_CHANGE: /* leave setting as is */ break; case PNG_CRC_WARN_USE: /* warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; break; case PNG_CRC_QUIET_USE: /* quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | PNG_FLAG_CRC_CRITICAL_IGNORE; break; case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ png_warning(png_ptr, "Can't discard critical data on CRC error."); case PNG_CRC_ERROR_QUIT: /* error/quit */ case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; break; } switch (ancil_action) { case PNG_CRC_NO_CHANGE: /* leave setting as is */ break; case PNG_CRC_WARN_USE: /* warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; break; case PNG_CRC_QUIET_USE: /* quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN; break; case PNG_CRC_ERROR_QUIT: /* error/quit */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; break; case PNG_CRC_WARN_DISCARD: /* warn/discard data */ case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; break; } } #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ defined(PNG_FLOATING_POINT_SUPPORTED) /* handle alpha and tRNS via a background color */ void PNGAPI png_set_background(png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma) { png_debug(1, "in png_set_background\n"); if(png_ptr == NULL) return; if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) { png_warning(png_ptr, "Application must supply a known background gamma"); return; } png_ptr->transformations |= PNG_BACKGROUND; png_memcpy(&(png_ptr->background), background_color, png_sizeof(png_color_16)); png_ptr->background_gamma = (float)background_gamma; png_ptr->background_gamma_type = (png_byte)(background_gamma_code); png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); } #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) /* strip 16 bit depth files to 8 bit depth */ void PNGAPI png_set_strip_16(png_structp png_ptr) { png_debug(1, "in png_set_strip_16\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_16_TO_8; } #endif #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) void PNGAPI png_set_strip_alpha(png_structp png_ptr) { png_debug(1, "in png_set_strip_alpha\n"); if(png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; } #endif #if defined(PNG_READ_DITHER_SUPPORTED) /* Dither file to 8 bit. Supply a palette, the current number * of elements in the palette, the maximum number of elements * allowed, and a histogram if possible. If the current number * of colors is greater then the maximum number, the palette will be * modified to fit in the maximum number. "full_dither" indicates * whether we need a dithering cube set up for RGB images, or if we * simply are reducing the number of colors in a paletted image. */ typedef struct png_dsort_struct { struct png_dsort_struct FAR * next; png_byte left; png_byte right; } png_dsort; typedef png_dsort FAR * png_dsortp; typedef png_dsort FAR * FAR * png_dsortpp; void PNGAPI png_set_dither(png_structp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither) { png_debug(1, "in png_set_dither\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_DITHER; if (!full_dither) { int i; png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette * png_sizeof (png_byte))); for (i = 0; i < num_palette; i++) png_ptr->dither_index[i] = (png_byte)i; } if (num_palette > maximum_colors) { if (histogram != NULL) { /* This is easy enough, just throw out the least used colors. Perhaps not the best solution, but good enough. */ int i; /* initialize an array to sort colors */ png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette * png_sizeof (png_byte))); /* initialize the dither_sort array */ for (i = 0; i < num_palette; i++) png_ptr->dither_sort[i] = (png_byte)i; /* Find the least used palette entries by starting a bubble sort, and running it until we have sorted out enough colors. Note that we don't care about sorting all the colors, just finding which are least used. */ for (i = num_palette - 1; i >= maximum_colors; i--) { int done; /* to stop early if the list is pre-sorted */ int j; done = 1; for (j = 0; j < i; j++) { if (histogram[png_ptr->dither_sort[j]] < histogram[png_ptr->dither_sort[j + 1]]) { png_byte t; t = png_ptr->dither_sort[j]; png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; png_ptr->dither_sort[j + 1] = t; done = 0; } } if (done) break; } /* swap the palette around, and set up a table, if necessary */ if (full_dither) { int j = num_palette; /* put all the useful colors within the max, but don't move the others */ for (i = 0; i < maximum_colors; i++) { if ((int)png_ptr->dither_sort[i] >= maximum_colors) { do j--; while ((int)png_ptr->dither_sort[j] >= maximum_colors); palette[i] = palette[j]; } } } else { int j = num_palette; /* move all the used colors inside the max limit, and develop a translation table */ for (i = 0; i < maximum_colors; i++) { /* only move the colors we need to */ if ((int)png_ptr->dither_sort[i] >= maximum_colors) { png_color tmp_color; do j--; while ((int)png_ptr->dither_sort[j] >= maximum_colors); tmp_color = palette[j]; palette[j] = palette[i]; palette[i] = tmp_color; /* indicate where the color went */ png_ptr->dither_index[j] = (png_byte)i; png_ptr->dither_index[i] = (png_byte)j; } } /* find closest color for those colors we are not using */ for (i = 0; i < num_palette; i++) { if ((int)png_ptr->dither_index[i] >= maximum_colors) { int min_d, k, min_k, d_index; /* find the closest color to one we threw out */ d_index = png_ptr->dither_index[i]; min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); for (k = 1, min_k = 0; k < maximum_colors; k++) { int d; d = PNG_COLOR_DIST(palette[d_index], palette[k]); if (d < min_d) { min_d = d; min_k = k; } } /* point to closest color */ png_ptr->dither_index[i] = (png_byte)min_k; } } } png_free(png_ptr, png_ptr->dither_sort); png_ptr->dither_sort=NULL; } else { /* This is much harder to do simply (and quickly). Perhaps we need to go through a median cut routine, but those don't always behave themselves with only a few colors as input. So we will just find the closest two colors, and throw out one of them (chosen somewhat randomly). [We don't understand this at all, so if someone wants to work on improving it, be our guest - AED, GRP] */ int i; int max_d; int num_new_palette; png_dsortp t; png_dsortpp hash; t=NULL; /* initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette * png_sizeof (png_byte))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette * png_sizeof (png_byte))); /* initialize the sort array */ for (i = 0; i < num_palette; i++) { png_ptr->index_to_palette[i] = (png_byte)i; png_ptr->palette_to_index[i] = (png_byte)i; } hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * png_sizeof (png_dsortp))); for (i = 0; i < 769; i++) hash[i] = NULL; /* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ num_new_palette = num_palette; /* initial wild guess at how far apart the farthest pixel pair we will be eliminating will be. Larger numbers mean more areas will be allocated, Smaller numbers run the risk of not saving enough data, and having to do this all over again. I have not done extensive checking on this number. */ max_d = 96; while (num_new_palette > maximum_colors) { for (i = 0; i < num_new_palette - 1; i++) { int j; for (j = i + 1; j < num_new_palette; j++) { int d; d = PNG_COLOR_DIST(palette[i], palette[j]); if (d <= max_d) { t = (png_dsortp)png_malloc_warn(png_ptr, (png_uint_32)(png_sizeof(png_dsort))); if (t == NULL) break; t->next = hash[d]; t->left = (png_byte)i; t->right = (png_byte)j; hash[d] = t; } } if (t == NULL) break; } if (t != NULL) for (i = 0; i <= max_d; i++) { if (hash[i] != NULL) { png_dsortp p; for (p = hash[i]; p; p = p->next) { if ((int)png_ptr->index_to_palette[p->left] < num_new_palette && (int)png_ptr->index_to_palette[p->right] < num_new_palette) { int j, next_j; if (num_new_palette & 0x01) { j = p->left; next_j = p->right; } else { j = p->right; next_j = p->left; } num_new_palette--; palette[png_ptr->index_to_palette[j]] = palette[num_new_palette]; if (!full_dither) { int k; for (k = 0; k < num_palette; k++) { if (png_ptr->dither_index[k] == png_ptr->index_to_palette[j]) png_ptr->dither_index[k] = png_ptr->index_to_palette[next_j]; if ((int)png_ptr->dither_index[k] == num_new_palette) png_ptr->dither_index[k] = png_ptr->index_to_palette[j]; } } png_ptr->index_to_palette[png_ptr->palette_to_index [num_new_palette]] = png_ptr->index_to_palette[j]; png_ptr->palette_to_index[png_ptr->index_to_palette[j]] = png_ptr->palette_to_index[num_new_palette]; png_ptr->index_to_palette[j] = (png_byte)num_new_palette; png_ptr->palette_to_index[num_new_palette] = (png_byte)j; } if (num_new_palette <= maximum_colors) break; } if (num_new_palette <= maximum_colors) break; } } for (i = 0; i < 769; i++) { if (hash[i] != NULL) { png_dsortp p = hash[i]; while (p) { t = p->next; png_free(png_ptr, p); p = t; } } hash[i] = 0; } max_d += 96; } png_free(png_ptr, hash); png_free(png_ptr, png_ptr->palette_to_index); png_free(png_ptr, png_ptr->index_to_palette); png_ptr->palette_to_index=NULL; png_ptr->index_to_palette=NULL; } num_palette = maximum_colors; } if (png_ptr->palette == NULL) { png_ptr->palette = palette; } png_ptr->num_palette = (png_uint_16)num_palette; if (full_dither) { int i; png_bytep distance; int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS; int num_red = (1 << PNG_DITHER_RED_BITS); int num_green = (1 << PNG_DITHER_GREEN_BITS); int num_blue = (1 << PNG_DITHER_BLUE_BITS); png_size_t num_entries = ((png_size_t)1 << total_bits); png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, (png_uint_32)(num_entries * png_sizeof (png_byte))); png_memset(png_ptr->palette_lookup, 0, num_entries * png_sizeof (png_byte)); distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * png_sizeof(png_byte))); png_memset(distance, 0xff, num_entries * png_sizeof(png_byte)); for (i = 0; i < num_palette; i++) { int ir, ig, ib; int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS)); int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS)); int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS)); for (ir = 0; ir < num_red; ir++) { /* int dr = abs(ir - r); */ int dr = ((ir > r) ? ir - r : r - ir); int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS)); for (ig = 0; ig < num_green; ig++) { /* int dg = abs(ig - g); */ int dg = ((ig > g) ? ig - g : g - ig); int dt = dr + dg; int dm = ((dr > dg) ? dr : dg); int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS); for (ib = 0; ib < num_blue; ib++) { int d_index = index_g | ib; /* int db = abs(ib - b); */ int db = ((ib > b) ? ib - b : b - ib); int dmax = ((dm > db) ? dm : db); int d = dmax + dt + db; if (d < (int)distance[d_index]) { distance[d_index] = (png_byte)d; png_ptr->palette_lookup[d_index] = (png_byte)i; } } } } } png_free(png_ptr, distance); } } #endif #if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) /* Transform the image from the file_gamma to the screen_gamma. We * only do transformations on images where the file_gamma and screen_gamma * are not close reciprocals, otherwise it slows things down slightly, and * also needlessly introduces small errors. * * We will turn off gamma transformation later if no semitransparent entries * are present in the tRNS array for palette images. We can't do it here * because we don't necessarily have the tRNS chunk yet. */ void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) { png_debug(1, "in png_set_gamma\n"); if(png_ptr == NULL) return; if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) png_ptr->transformations |= PNG_GAMMA; png_ptr->gamma = (float)file_gamma; png_ptr->screen_gamma = (float)scrn_gamma; } #endif #if defined(PNG_READ_EXPAND_SUPPORTED) /* Expand paletted images to RGB, expand grayscale images of * less than 8-bit depth to 8-bit depth, and expand tRNS chunks * to alpha channels. */ void PNGAPI png_set_expand(png_structp png_ptr) { png_debug(1, "in png_set_expand\n"); if(png_ptr == NULL) return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); #ifdef PNG_WARN_UNINITIALIZED_ROW png_ptr->flags &= !(PNG_FLAG_ROW_INIT); #endif } /* GRR 19990627: the following three functions currently are identical * to png_set_expand(). However, it is entirely reasonable that someone * might wish to expand an indexed image to RGB but *not* expand a single, * fully transparent palette entry to a full alpha channel--perhaps instead * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace * the transparent color with a particular RGB value, or drop tRNS entirely. * IOW, a future version of the library may make the transformations flag * a bit more fine-grained, with separate bits for each of these three * functions. * * More to the point, these functions make it obvious what libpng will be * doing, whereas "expand" can (and does) mean any number of things. * * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified * to expand only the sample depth but not to expand the tRNS to alpha. */ /* Expand paletted images to RGB. */ void PNGAPI png_set_palette_to_rgb(png_structp png_ptr) { png_debug(1, "in png_set_palette_to_rgb\n"); if(png_ptr == NULL) return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); #ifdef PNG_WARN_UNINITIALIZED_ROW png_ptr->flags &= !(PNG_FLAG_ROW_INIT); #endif } #if !defined(PNG_1_0_X) /* Expand grayscale images of less than 8-bit depth to 8 bits. */ void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) { png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); if(png_ptr == NULL) return; png_ptr->transformations |= PNG_EXPAND; #ifdef PNG_WARN_UNINITIALIZED_ROW png_ptr->flags &= !(PNG_FLAG_ROW_INIT); #endif } #endif #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* Expand grayscale images of less than 8-bit depth to 8 bits. */ /* Deprecated as of libpng-1.2.9 */ void PNGAPI png_set_gray_1_2_4_to_8(png_structp png_ptr) { png_debug(1, "in png_set_gray_1_2_4_to_8\n"); if(png_ptr == NULL) return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); } #endif /* Expand tRNS chunks to alpha channels. */ void PNGAPI png_set_tRNS_to_alpha(png_structp png_ptr) { png_debug(1, "in png_set_tRNS_to_alpha\n"); png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); #ifdef PNG_WARN_UNINITIALIZED_ROW png_ptr->flags &= !(PNG_FLAG_ROW_INIT); #endif } #endif /* defined(PNG_READ_EXPAND_SUPPORTED) */ #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) void PNGAPI png_set_gray_to_rgb(png_structp png_ptr) { png_debug(1, "in png_set_gray_to_rgb\n"); png_ptr->transformations |= PNG_GRAY_TO_RGB; #ifdef PNG_WARN_UNINITIALIZED_ROW png_ptr->flags &= !(PNG_FLAG_ROW_INIT); #endif } #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) #if defined(PNG_FLOATING_POINT_SUPPORTED) /* Convert a RGB image to a grayscale of the same width. This allows us, * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. */ void PNGAPI png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, double green) { int red_fixed = (int)((float)red*100000.0 + 0.5); int green_fixed = (int)((float)green*100000.0 + 0.5); if(png_ptr == NULL) return; png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); } #endif void PNGAPI png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_fixed_point red, png_fixed_point green) { png_debug(1, "in png_set_rgb_to_gray\n"); if(png_ptr == NULL) return; switch(error_action) { case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; break; case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; break; case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #if defined(PNG_READ_EXPAND_SUPPORTED) png_ptr->transformations |= PNG_EXPAND; #else { png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); png_ptr->transformations &= ~PNG_RGB_TO_GRAY; } #endif { png_uint_16 red_int, green_int; if(red < 0 || green < 0) { red_int = 6968; /* .212671 * 32768 + .5 */ green_int = 23434; /* .715160 * 32768 + .5 */ } else if(red + green < 100000L) { red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); } else { png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); red_int = 6968; green_int = 23434; } png_ptr->rgb_to_gray_red_coeff = red_int; png_ptr->rgb_to_gray_green_coeff = green_int; png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); } } #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_LEGACY_SUPPORTED) void PNGAPI png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr read_user_transform_fn) { png_debug(1, "in png_set_read_user_transform_fn\n"); if(png_ptr == NULL) return; #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; #endif #ifdef PNG_LEGACY_SUPPORTED if(read_user_transform_fn) png_warning(png_ptr, "This version of libpng does not support user transforms"); #endif } #endif /* Initialize everything needed for the read. This includes modifying * the palette. */ void /* PRIVATE */ png_init_read_transformations(png_structp png_ptr) { png_debug(1, "in png_init_read_transformations\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if(png_ptr != NULL) #endif { #if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ || defined(PNG_READ_GAMMA_SUPPORTED) int color_type = png_ptr->color_type; #endif #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* Detect gray background and attempt to enable optimization * for gray --> RGB case */ /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or * RGB_ALPHA (in which case need_expand is superfluous anyway), the * background color might actually be gray yet not be flagged as such. * This is not a problem for the current code, which uses * PNG_BACKGROUND_IS_GRAY only to decide when to do the * png_do_gray_to_rgb() transformation. */ if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && !(color_type & PNG_COLOR_MASK_COLOR)) { png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; } else if ((png_ptr->transformations & PNG_BACKGROUND) && !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && (png_ptr->transformations & PNG_GRAY_TO_RGB) && png_ptr->background.red == png_ptr->background.green && png_ptr->background.red == png_ptr->background.blue) { png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; png_ptr->background.gray = png_ptr->background.red; } #endif if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && (png_ptr->transformations & PNG_EXPAND)) { if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ { /* expand background and tRNS chunks */ switch (png_ptr->bit_depth) { case 1: png_ptr->background.gray *= (png_uint_16)0xff; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) { png_ptr->trans_values.gray *= (png_uint_16)0xff; png_ptr->trans_values.red = png_ptr->trans_values.green = png_ptr->trans_values.blue = png_ptr->trans_values.gray; } break; case 2: png_ptr->background.gray *= (png_uint_16)0x55; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) { png_ptr->trans_values.gray *= (png_uint_16)0x55; png_ptr->trans_values.red = png_ptr->trans_values.green = png_ptr->trans_values.blue = png_ptr->trans_values.gray; } break; case 4: png_ptr->background.gray *= (png_uint_16)0x11; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) { png_ptr->trans_values.gray *= (png_uint_16)0x11; png_ptr->trans_values.red = png_ptr->trans_values.green = png_ptr->trans_values.blue = png_ptr->trans_values.gray; } break; case 8: case 16: png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; break; } } else if (color_type == PNG_COLOR_TYPE_PALETTE) { png_ptr->background.red = png_ptr->palette[png_ptr->background.index].red; png_ptr->background.green = png_ptr->palette[png_ptr->background.index].green; png_ptr->background.blue = png_ptr->palette[png_ptr->background.index].blue; #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_ALPHA) { #if defined(PNG_READ_EXPAND_SUPPORTED) if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) #endif { /* invert the alpha channel (in tRNS) unless the pixels are going to be expanded, in which case leave it for later */ int i,istop; istop=(int)png_ptr->num_trans; for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); } } #endif } } #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) png_ptr->background_1 = png_ptr->background; #endif #if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) < PNG_GAMMA_THRESHOLD)) { int i,k; k=0; for (i=0; inum_trans; i++) { if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) k=1; /* partial transparency is present */ } if (k == 0) png_ptr->transformations &= (~PNG_GAMMA); } if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && png_ptr->gamma != 0.0) { png_build_gamma_table(png_ptr); #if defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->transformations & PNG_BACKGROUND) { if (color_type == PNG_COLOR_TYPE_PALETTE) { /* could skip if no transparency and */ png_color back, back_1; png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) { back.red = png_ptr->gamma_table[png_ptr->background.red]; back.green = png_ptr->gamma_table[png_ptr->background.green]; back.blue = png_ptr->gamma_table[png_ptr->background.blue]; back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; } else { double g, gs; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: g = (png_ptr->screen_gamma); gs = 1.0; break; case PNG_BACKGROUND_GAMMA_FILE: g = 1.0 / (png_ptr->gamma); gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: g = 1.0 / (png_ptr->background_gamma); gs = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); break; default: g = 1.0; /* back_1 */ gs = 1.0; /* back */ } if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD) { back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; } else { back.red = (png_byte)(pow( (double)png_ptr->background.red/255, gs) * 255.0 + .5); back.green = (png_byte)(pow( (double)png_ptr->background.green/255, gs) * 255.0 + .5); back.blue = (png_byte)(pow( (double)png_ptr->background.blue/255, gs) * 255.0 + .5); } back_1.red = (png_byte)(pow( (double)png_ptr->background.red/255, g) * 255.0 + .5); back_1.green = (png_byte)(pow( (double)png_ptr->background.green/255, g) * 255.0 + .5); back_1.blue = (png_byte)(pow( (double)png_ptr->background.blue/255, g) * 255.0 + .5); } for (i = 0; i < num_palette; i++) { if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) { if (png_ptr->trans[i] == 0) { palette[i] = back; } else /* if (png_ptr->trans[i] != 0xff) */ { png_byte v, w; v = png_ptr->gamma_to_1[palette[i].red]; png_composite(w, v, png_ptr->trans[i], back_1.red); palette[i].red = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[palette[i].green]; png_composite(w, v, png_ptr->trans[i], back_1.green); palette[i].green = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[palette[i].blue]; png_composite(w, v, png_ptr->trans[i], back_1.blue); palette[i].blue = png_ptr->gamma_from_1[w]; } } else { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } } /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ else /* color_type != PNG_COLOR_TYPE_PALETTE */ { double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); double g = 1.0; double gs = 1.0; switch (png_ptr->background_gamma_type) { case PNG_BACKGROUND_GAMMA_SCREEN: g = (png_ptr->screen_gamma); gs = 1.0; break; case PNG_BACKGROUND_GAMMA_FILE: g = 1.0 / (png_ptr->gamma); gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: g = 1.0 / (png_ptr->background_gamma); gs = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); break; } png_ptr->background_1.gray = (png_uint_16)(pow( (double)png_ptr->background.gray / m, g) * m + .5); png_ptr->background.gray = (png_uint_16)(pow( (double)png_ptr->background.gray / m, gs) * m + .5); if ((png_ptr->background.red != png_ptr->background.green) || (png_ptr->background.red != png_ptr->background.blue) || (png_ptr->background.red != png_ptr->background.gray)) { /* RGB or RGBA with color background */ png_ptr->background_1.red = (png_uint_16)(pow( (double)png_ptr->background.red / m, g) * m + .5); png_ptr->background_1.green = (png_uint_16)(pow( (double)png_ptr->background.green / m, g) * m + .5); png_ptr->background_1.blue = (png_uint_16)(pow( (double)png_ptr->background.blue / m, g) * m + .5); png_ptr->background.red = (png_uint_16)(pow( (double)png_ptr->background.red / m, gs) * m + .5); png_ptr->background.green = (png_uint_16)(pow( (double)png_ptr->background.green / m, gs) * m + .5); png_ptr->background.blue = (png_uint_16)(pow( (double)png_ptr->background.blue / m, gs) * m + .5); } else { /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ png_ptr->background_1.red = png_ptr->background_1.green = png_ptr->background_1.blue = png_ptr->background_1.gray; png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; } } } else /* transformation does not include PNG_BACKGROUND */ #endif /* PNG_READ_BACKGROUND_SUPPORTED */ if (color_type == PNG_COLOR_TYPE_PALETTE) { png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; int i; for (i = 0; i < num_palette; i++) { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } } #if defined(PNG_READ_BACKGROUND_SUPPORTED) else #endif #endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */ #if defined(PNG_READ_BACKGROUND_SUPPORTED) /* No GAMMA transformation */ if ((png_ptr->transformations & PNG_BACKGROUND) && (color_type == PNG_COLOR_TYPE_PALETTE)) { int i; int istop = (int)png_ptr->num_trans; png_color back; png_colorp palette = png_ptr->palette; back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; for (i = 0; i < istop; i++) { if (png_ptr->trans[i] == 0) { palette[i] = back; } else if (png_ptr->trans[i] != 0xff) { /* The png_composite() macro is defined in png.h */ png_composite(palette[i].red, palette[i].red, png_ptr->trans[i], back.red); png_composite(palette[i].green, palette[i].green, png_ptr->trans[i], back.green); png_composite(palette[i].blue, palette[i].blue, png_ptr->trans[i], back.blue); } } } #endif /* PNG_READ_BACKGROUND_SUPPORTED */ #if defined(PNG_READ_SHIFT_SUPPORTED) if ((png_ptr->transformations & PNG_SHIFT) && (color_type == PNG_COLOR_TYPE_PALETTE)) { png_uint_16 i; png_uint_16 istop = png_ptr->num_palette; int sr = 8 - png_ptr->sig_bit.red; int sg = 8 - png_ptr->sig_bit.green; int sb = 8 - png_ptr->sig_bit.blue; if (sr < 0 || sr > 8) sr = 0; if (sg < 0 || sg > 8) sg = 0; if (sb < 0 || sb > 8) sb = 0; for (i = 0; i < istop; i++) { png_ptr->palette[i].red >>= sr; png_ptr->palette[i].green >>= sg; png_ptr->palette[i].blue >>= sb; } } #endif /* PNG_READ_SHIFT_SUPPORTED */ } #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ && !defined(PNG_READ_BACKGROUND_SUPPORTED) if(png_ptr) return; #endif } /* Modify the info structure to reflect the transformations. The * info should be updated so a PNG file could be written with it, * assuming the transformations result in valid PNG data. */ void /* PRIVATE */ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) { png_debug(1, "in png_read_transform_info\n"); #if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; else info_ptr->color_type = PNG_COLOR_TYPE_RGB; info_ptr->bit_depth = 8; info_ptr->num_trans = 0; } else { if (png_ptr->num_trans) { if (png_ptr->transformations & PNG_EXPAND_tRNS) info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; else info_ptr->color_type |= PNG_COLOR_MASK_COLOR; } if (info_ptr->bit_depth < 8) info_ptr->bit_depth = 8; info_ptr->num_trans = 0; } } #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->transformations & PNG_BACKGROUND) { info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; info_ptr->num_trans = 0; info_ptr->background = png_ptr->background; } #endif #if defined(PNG_READ_GAMMA_SUPPORTED) if (png_ptr->transformations & PNG_GAMMA) { #ifdef PNG_FLOATING_POINT_SUPPORTED info_ptr->gamma = png_ptr->gamma; #endif #ifdef PNG_FIXED_POINT_SUPPORTED info_ptr->int_gamma = png_ptr->int_gamma; #endif } #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) info_ptr->bit_depth = 8; #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) if (png_ptr->transformations & PNG_GRAY_TO_RGB) info_ptr->color_type |= PNG_COLOR_MASK_COLOR; #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) if (png_ptr->transformations & PNG_RGB_TO_GRAY) info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR; #endif #if defined(PNG_READ_DITHER_SUPPORTED) if (png_ptr->transformations & PNG_DITHER) { if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && png_ptr->palette_lookup && info_ptr->bit_depth == 8) { info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; } } #endif #if defined(PNG_READ_PACK_SUPPORTED) if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) info_ptr->bit_depth = 8; #endif if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; else info_ptr->channels = 1; #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA; #endif if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; #if defined(PNG_READ_FILLER_SUPPORTED) /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ if ((png_ptr->transformations & PNG_FILLER) && ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) { info_ptr->channels++; /* if adding a true alpha channel not just filler */ #if !defined(PNG_1_0_X) if (png_ptr->transformations & PNG_ADD_ALPHA) info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; #endif } #endif #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) if(png_ptr->transformations & PNG_USER_TRANSFORM) { if(info_ptr->bit_depth < png_ptr->user_transform_depth) info_ptr->bit_depth = png_ptr->user_transform_depth; if(info_ptr->channels < png_ptr->user_transform_channels) info_ptr->channels = png_ptr->user_transform_channels; } #endif info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); #if !defined(PNG_READ_EXPAND_SUPPORTED) if(png_ptr) return; #endif } /* Transform the row. The order of transformations is significant, * and is very touchy. If you add a transformation, take care to * decide how it fits in with the other transformations here. */ void /* PRIVATE */ png_do_read_transformations(png_structp png_ptr) { png_debug(1, "in png_do_read_transformations\n"); if (png_ptr->row_buf == NULL) { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char msg[50]; png_snprintf2(msg, 50, "NULL row buffer for row %ld, pass %d", (long int)png_ptr->row_number, png_ptr->pass); png_error(png_ptr, msg); #else png_error(png_ptr, "NULL row buffer"); #endif } #ifdef PNG_WARN_UNINITIALIZED_ROW if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) /* Application has failed to call either png_read_start_image() * or png_read_update_info() after setting transforms that expand * pixels. This check added to libpng-1.2.19 */ #if (PNG_WARN_UNINITIALIZED_ROW==1) png_error(png_ptr, "Uninitialized row"); #else png_warning(png_ptr, "Uninitialized row"); #endif #endif #if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) { png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->palette, png_ptr->trans, png_ptr->num_trans); } else { if (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND_tRNS)) png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, &(png_ptr->trans_values)); else png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, NULL); } } #endif #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) if (png_ptr->transformations & PNG_RGB_TO_GRAY) { int rgb_error = png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); if(rgb_error) { png_ptr->rgb_to_gray_status=1; if((png_ptr->transformations & PNG_RGB_TO_GRAY) == PNG_RGB_TO_GRAY_WARN) png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); if((png_ptr->transformations & PNG_RGB_TO_GRAY) == PNG_RGB_TO_GRAY_ERR) png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); } } #endif /* From Andreas Dilger e-mail to png-implement, 26 March 1998: In most cases, the "simple transparency" should be done prior to doing gray-to-RGB, or you will have to test 3x as many bytes to check if a pixel is transparent. You would also need to make sure that the transparency information is upgraded to RGB. To summarize, the current flow is: - Gray + simple transparency -> compare 1 or 2 gray bytes and composite with background "in place" if transparent, convert to RGB if necessary - Gray + alpha -> composite with gray background and remove alpha bytes, convert to RGB if necessary To support RGB backgrounds for gray images we need: - Gray + simple transparency -> convert to RGB + simple transparency, compare 3 or 6 bytes and composite with background "in place" if transparent (3x compare/pixel compared to doing composite with gray bkgrnd) - Gray + alpha -> convert to RGB + alpha, composite with background and remove alpha bytes (3x float operations/pixel compared with composite on gray background) Greg's change will do this. The reason it wasn't done before is for performance, as this increases the per-pixel operations. If we would check in advance if the background was gray or RGB, and position the gray-to-RGB transform appropriately, then it would save a lot of work/time. */ #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* if gray -> RGB, do so now only if background is non-gray; else do later * for performance reasons */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) if ((png_ptr->transformations & PNG_BACKGROUND) && ((png_ptr->num_trans != 0 ) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, &(png_ptr->trans_values), &(png_ptr->background) #if defined(PNG_READ_GAMMA_SUPPORTED) , &(png_ptr->background_1), png_ptr->gamma_table, png_ptr->gamma_from_1, png_ptr->gamma_to_1, png_ptr->gamma_16_table, png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, png_ptr->gamma_shift #endif ); #endif #if defined(PNG_READ_GAMMA_SUPPORTED) if ((png_ptr->transformations & PNG_GAMMA) && #if defined(PNG_READ_BACKGROUND_SUPPORTED) !((png_ptr->transformations & PNG_BACKGROUND) && ((png_ptr->num_trans != 0) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && #endif (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->gamma_table, png_ptr->gamma_16_table, png_ptr->gamma_shift); #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) if (png_ptr->transformations & PNG_16_TO_8) png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_DITHER_SUPPORTED) if (png_ptr->transformations & PNG_DITHER) { png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->palette_lookup, png_ptr->dither_index); if(png_ptr->row_info.rowbytes == (png_uint_32)0) png_error(png_ptr, "png_do_dither returned rowbytes=0"); } #endif #if defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) if (png_ptr->transformations & PNG_SHIFT) png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, &(png_ptr->shift)); #endif #if defined(PNG_READ_PACK_SUPPORTED) if (png_ptr->transformations & PNG_PACK) png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_BGR_SUPPORTED) if (png_ptr->transformations & PNG_BGR) png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* if gray -> RGB, do so now only if we did not do so above */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_FILLER_SUPPORTED) if (png_ptr->transformations & PNG_FILLER) png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, (png_uint_32)png_ptr->filler, png_ptr->flags); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_ALPHA) png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_ALPHA) png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_SWAP_SUPPORTED) if (png_ptr->transformations & PNG_SWAP_BYTES) png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) if (png_ptr->transformations & PNG_USER_TRANSFORM) { if(png_ptr->read_user_transform_fn != NULL) (*(png_ptr->read_user_transform_fn)) /* user read transform function */ (png_ptr, /* png_ptr */ &(png_ptr->row_info), /* row_info: */ /* png_uint_32 width; width of row */ /* png_uint_32 rowbytes; number of bytes in row */ /* png_byte color_type; color type of pixels */ /* png_byte bit_depth; bit depth of samples */ /* png_byte channels; number of channels (1-4) */ /* png_byte pixel_depth; bits per pixel (depth*channels) */ png_ptr->row_buf + 1); /* start of pixel data for row */ #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if(png_ptr->user_transform_depth) png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; if(png_ptr->user_transform_channels) png_ptr->row_info.channels = png_ptr->user_transform_channels; #endif png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * png_ptr->row_info.channels); png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); } #endif } #if defined(PNG_READ_PACK_SUPPORTED) /* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, * without changing the actual values. Thus, if you had a row with * a bit depth of 1, you would end up with bytes that only contained * the numbers 0 or 1. If you would rather they contain 0 and 255, use * png_do_shift() after this. */ void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_unpack\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && row_info->bit_depth < 8) #else if (row_info->bit_depth < 8) #endif { png_uint_32 i; png_uint_32 row_width=row_info->width; switch (row_info->bit_depth) { case 1: { png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); png_bytep dp = row + (png_size_t)row_width - 1; png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x01); if (shift == 7) { shift = 0; sp--; } else shift++; dp--; } break; } case 2: { png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); png_bytep dp = row + (png_size_t)row_width - 1; png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x03); if (shift == 6) { shift = 0; sp--; } else shift += 2; dp--; } break; } case 4: { png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); png_bytep dp = row + (png_size_t)row_width - 1; png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x0f); if (shift == 4) { shift = 0; sp--; } else shift = 4; dp--; } break; } } row_info->bit_depth = 8; row_info->pixel_depth = (png_byte)(8 * row_info->channels); row_info->rowbytes = row_width * row_info->channels; } } #endif #if defined(PNG_READ_SHIFT_SUPPORTED) /* Reverse the effects of png_do_shift. This routine merely shifts the * pixels back to their significant bits values. Thus, if you have * a row of bit depth 8, but only 5 are significant, this will shift * the values back to 0 through 31. */ void /* PRIVATE */ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) { png_debug(1, "in png_do_unshift\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && sig_bits != NULL && #endif row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift[4]; int channels = 0; int c; png_uint_16 value = 0; png_uint_32 row_width = row_info->width; if (row_info->color_type & PNG_COLOR_MASK_COLOR) { shift[channels++] = row_info->bit_depth - sig_bits->red; shift[channels++] = row_info->bit_depth - sig_bits->green; shift[channels++] = row_info->bit_depth - sig_bits->blue; } else { shift[channels++] = row_info->bit_depth - sig_bits->gray; } if (row_info->color_type & PNG_COLOR_MASK_ALPHA) { shift[channels++] = row_info->bit_depth - sig_bits->alpha; } for (c = 0; c < channels; c++) { if (shift[c] <= 0) shift[c] = 0; else value = 1; } if (!value) return; switch (row_info->bit_depth) { case 2: { png_bytep bp; png_uint_32 i; png_uint_32 istop = row_info->rowbytes; for (bp = row, i = 0; i < istop; i++) { *bp >>= 1; *bp++ &= 0x55; } break; } case 4: { png_bytep bp = row; png_uint_32 i; png_uint_32 istop = row_info->rowbytes; png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) | (png_byte)((int)0xf >> shift[0])); for (i = 0; i < istop; i++) { *bp >>= shift[0]; *bp++ &= mask; } break; } case 8: { png_bytep bp = row; png_uint_32 i; png_uint_32 istop = row_width * channels; for (i = 0; i < istop; i++) { *bp++ >>= shift[i%channels]; } break; } case 16: { png_bytep bp = row; png_uint_32 i; png_uint_32 istop = channels * row_width; for (i = 0; i < istop; i++) { value = (png_uint_16)((*bp << 8) + *(bp + 1)); value >>= shift[i%channels]; *bp++ = (png_byte)(value >> 8); *bp++ = (png_byte)(value & 0xff); } break; } } } } #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) /* chop rows of bit depth 16 down to 8 */ void /* PRIVATE */ png_do_chop(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_chop\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && row_info->bit_depth == 16) #else if (row_info->bit_depth == 16) #endif { png_bytep sp = row; png_bytep dp = row; png_uint_32 i; png_uint_32 istop = row_info->width * row_info->channels; for (i = 0; i> 8)) >> 8; * * Approximate calculation with shift/add instead of multiply/divide: * *dp = ((((png_uint_32)(*sp) << 8) | * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8; * * What we actually do to avoid extra shifting and conversion: */ *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0); #else /* Simply discard the low order byte */ *dp = *sp; #endif } row_info->bit_depth = 8; row_info->pixel_depth = (png_byte)(8 * row_info->channels); row_info->rowbytes = row_info->width * row_info->channels; } } #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_swap_alpha\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { png_uint_32 row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { /* This converts from RGBA to ARGB */ if (row_info->bit_depth == 8) { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_byte save; png_uint_32 i; for (i = 0; i < row_width; i++) { save = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = save; } } /* This converts from RRGGBBAA to AARRGGBB */ else { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_byte save[2]; png_uint_32 i; for (i = 0; i < row_width; i++) { save[0] = *(--sp); save[1] = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = save[0]; *(--dp) = save[1]; } } } else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { /* This converts from GA to AG */ if (row_info->bit_depth == 8) { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_byte save; png_uint_32 i; for (i = 0; i < row_width; i++) { save = *(--sp); *(--dp) = *(--sp); *(--dp) = save; } } /* This converts from GGAA to AAGG */ else { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_byte save[2]; png_uint_32 i; for (i = 0; i < row_width; i++) { save[0] = *(--sp); save[1] = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = save[0]; *(--dp) = save[1]; } } } } } #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_invert_alpha\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { png_uint_32 row_width = row_info->width; if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { /* This inverts the alpha channel in RGBA */ if (row_info->bit_depth == 8) { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; for (i = 0; i < row_width; i++) { *(--dp) = (png_byte)(255 - *(--sp)); /* This does nothing: *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); We can replace it with: */ sp-=3; dp=sp; } } /* This inverts the alpha channel in RRGGBBAA */ else { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; for (i = 0; i < row_width; i++) { *(--dp) = (png_byte)(255 - *(--sp)); *(--dp) = (png_byte)(255 - *(--sp)); /* This does nothing: *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); We can replace it with: */ sp-=6; dp=sp; } } } else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { /* This inverts the alpha channel in GA */ if (row_info->bit_depth == 8) { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; for (i = 0; i < row_width; i++) { *(--dp) = (png_byte)(255 - *(--sp)); *(--dp) = *(--sp); } } /* This inverts the alpha channel in GGAA */ else { png_bytep sp = row + row_info->rowbytes; png_bytep dp = sp; png_uint_32 i; for (i = 0; i < row_width; i++) { *(--dp) = (png_byte)(255 - *(--sp)); *(--dp) = (png_byte)(255 - *(--sp)); /* *(--dp) = *(--sp); *(--dp) = *(--sp); */ sp-=2; dp=sp; } } } } } #endif #if defined(PNG_READ_FILLER_SUPPORTED) /* Add filler channel if we have RGB color */ void /* PRIVATE */ png_do_read_filler(png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags) { png_uint_32 i; png_uint_32 row_width = row_info->width; png_byte hi_filler = (png_byte)((filler>>8) & 0xff); png_byte lo_filler = (png_byte)(filler & 0xff); png_debug(1, "in png_do_read_filler\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif row_info->color_type == PNG_COLOR_TYPE_GRAY) { if(row_info->bit_depth == 8) { /* This changes the data from G to GX */ if (flags & PNG_FLAG_FILLER_AFTER) { png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) { *(--dp) = lo_filler; *(--dp) = *(--sp); } *(--dp) = lo_filler; row_info->channels = 2; row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } /* This changes the data from G to XG */ else { png_bytep sp = row + (png_size_t)row_width; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) { *(--dp) = *(--sp); *(--dp) = lo_filler; } row_info->channels = 2; row_info->pixel_depth = 16; row_info->rowbytes = row_width * 2; } } else if(row_info->bit_depth == 16) { /* This changes the data from GG to GGXX */ if (flags & PNG_FLAG_FILLER_AFTER) { png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) { *(--dp) = hi_filler; *(--dp) = lo_filler; *(--dp) = *(--sp); *(--dp) = *(--sp); } *(--dp) = hi_filler; *(--dp) = lo_filler; row_info->channels = 2; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } /* This changes the data from GG to XXGG */ else { png_bytep sp = row + (png_size_t)row_width * 2; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = hi_filler; *(--dp) = lo_filler; } row_info->channels = 2; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } } } /* COLOR_TYPE == GRAY */ else if (row_info->color_type == PNG_COLOR_TYPE_RGB) { if(row_info->bit_depth == 8) { /* This changes the data from RGB to RGBX */ if (flags & PNG_FLAG_FILLER_AFTER) { png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 1; i < row_width; i++) { *(--dp) = lo_filler; *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); } *(--dp) = lo_filler; row_info->channels = 4; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } /* This changes the data from RGB to XRGB */ else { png_bytep sp = row + (png_size_t)row_width * 3; png_bytep dp = sp + (png_size_t)row_width; for (i = 0; i < row_width; i++) { *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = lo_filler; } row_info->channels = 4; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; } } else if(row_info->bit_depth == 16) { /* This changes the data from RRGGBB to RRGGBBXX */ if (flags & PNG_FLAG_FILLER_AFTER) { png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 1; i < row_width; i++) { *(--dp) = hi_filler; *(--dp) = lo_filler; *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); } *(--dp) = hi_filler; *(--dp) = lo_filler; row_info->channels = 4; row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } /* This changes the data from RRGGBB to XXRRGGBB */ else { png_bytep sp = row + (png_size_t)row_width * 6; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = *(--sp); *(--dp) = hi_filler; *(--dp) = lo_filler; } row_info->channels = 4; row_info->pixel_depth = 64; row_info->rowbytes = row_width * 8; } } } /* COLOR_TYPE == RGB */ } #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* expand grayscale files to RGB, with or without alpha */ void /* PRIVATE */ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) { png_uint_32 i; png_uint_32 row_width = row_info->width; png_debug(1, "in png_do_gray_to_rgb\n"); if (row_info->bit_depth >= 8 && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif !(row_info->color_type & PNG_COLOR_MASK_COLOR)) { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { if (row_info->bit_depth == 8) { png_bytep sp = row + (png_size_t)row_width - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { *(dp--) = *sp; *(dp--) = *sp; *(dp--) = *(sp--); } } else { png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) { *(dp--) = *sp; *(dp--) = *(sp - 1); *(dp--) = *sp; *(dp--) = *(sp - 1); *(dp--) = *(sp--); *(dp--) = *(sp--); } } } else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { if (row_info->bit_depth == 8) { png_bytep sp = row + (png_size_t)row_width * 2 - 1; png_bytep dp = sp + (png_size_t)row_width * 2; for (i = 0; i < row_width; i++) { *(dp--) = *(sp--); *(dp--) = *sp; *(dp--) = *sp; *(dp--) = *(sp--); } } else { png_bytep sp = row + (png_size_t)row_width * 4 - 1; png_bytep dp = sp + (png_size_t)row_width * 4; for (i = 0; i < row_width; i++) { *(dp--) = *(sp--); *(dp--) = *(sp--); *(dp--) = *sp; *(dp--) = *(sp - 1); *(dp--) = *sp; *(dp--) = *(sp - 1); *(dp--) = *(sp--); *(dp--) = *(sp--); } } } row_info->channels += (png_byte)2; row_info->color_type |= PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * row_info->bit_depth); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } } #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) /* reduce RGB files to grayscale, with or without alpha * using the equation given in Poynton's ColorFAQ at * * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net * * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B * * We approximate this with * * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B * * which can be expressed with integers as * * Y = (6969 * R + 23434 * G + 2365 * B)/32768 * * The calculation is to be done in a linear colorspace. * * Other integer coefficents can be used via png_set_rgb_to_gray(). */ int /* PRIVATE */ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) { png_uint_32 i; png_uint_32 row_width = row_info->width; int rgb_error = 0; png_debug(1, "in png_do_rgb_to_gray\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; if (row_info->color_type == PNG_COLOR_TYPE_RGB) { if (row_info->bit_depth == 8) { #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_byte red = png_ptr->gamma_to_1[*(sp++)]; png_byte green = png_ptr->gamma_to_1[*(sp++)]; png_byte blue = png_ptr->gamma_to_1[*(sp++)]; if(red != green || red != blue) { rgb_error |= 1; *(dp++) = png_ptr->gamma_from_1[ (rc*red+gc*green+bc*blue)>>15]; } else *(dp++) = *(sp-1); } } else #endif { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_byte red = *(sp++); png_byte green = *(sp++); png_byte blue = *(sp++); if(red != green || red != blue) { rgb_error |= 1; *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); } else *(dp++) = *(sp-1); } } } else /* RGB bit_depth == 16 */ { #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, w; red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; if(red == green && red == blue) w = red; else { png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> png_ptr->gamma_shift][red>>8]; png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> png_ptr->gamma_shift][green>>8]; png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> png_ptr->gamma_shift][blue>>8]; png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 + bc*blue_1)>>15); w = png_ptr->gamma_16_from_1[(gray16&0xff) >> png_ptr->gamma_shift][gray16 >> 8]; rgb_error |= 1; } *(dp++) = (png_byte)((w>>8) & 0xff); *(dp++) = (png_byte)(w & 0xff); } } else #endif { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, gray16; red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; if(red != green || red != blue) rgb_error |= 1; gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); *(dp++) = (png_byte)((gray16>>8) & 0xff); *(dp++) = (png_byte)(gray16 & 0xff); } } } } if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) { if (row_info->bit_depth == 8) { #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_byte red = png_ptr->gamma_to_1[*(sp++)]; png_byte green = png_ptr->gamma_to_1[*(sp++)]; png_byte blue = png_ptr->gamma_to_1[*(sp++)]; if(red != green || red != blue) rgb_error |= 1; *(dp++) = png_ptr->gamma_from_1 [(rc*red + gc*green + bc*blue)>>15]; *(dp++) = *(sp++); /* alpha */ } } else #endif { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_byte red = *(sp++); png_byte green = *(sp++); png_byte blue = *(sp++); if(red != green || red != blue) rgb_error |= 1; *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); *(dp++) = *(sp++); /* alpha */ } } } else /* RGBA bit_depth == 16 */ { #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, w; red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; if(red == green && red == blue) w = red; else { png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> png_ptr->gamma_shift][red>>8]; png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >> png_ptr->gamma_shift][green>>8]; png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> png_ptr->gamma_shift][blue>>8]; png_uint_16 gray16 = (png_uint_16)((rc * red_1 + gc * green_1 + bc * blue_1)>>15); w = png_ptr->gamma_16_from_1[(gray16&0xff) >> png_ptr->gamma_shift][gray16 >> 8]; rgb_error |= 1; } *(dp++) = (png_byte)((w>>8) & 0xff); *(dp++) = (png_byte)(w & 0xff); *(dp++) = *(sp++); /* alpha */ *(dp++) = *(sp++); } } else #endif { png_bytep sp = row; png_bytep dp = row; for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, gray16; red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; if(red != green || red != blue) rgb_error |= 1; gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); *(dp++) = (png_byte)((gray16>>8) & 0xff); *(dp++) = (png_byte)(gray16 & 0xff); *(dp++) = *(sp++); /* alpha */ *(dp++) = *(sp++); } } } } row_info->channels -= (png_byte)2; row_info->color_type &= ~PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * row_info->bit_depth); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } return rgb_error; } #endif /* Build a grayscale palette. Palette is assumed to be 1 << bit_depth * large of png_color. This lets grayscale images be treated as * paletted. Most useful for gamma correction and simplification * of code. */ void PNGAPI png_build_grayscale_palette(int bit_depth, png_colorp palette) { int num_palette; int color_inc; int i; int v; png_debug(1, "in png_do_build_grayscale_palette\n"); if (palette == NULL) return; switch (bit_depth) { case 1: num_palette = 2; color_inc = 0xff; break; case 2: num_palette = 4; color_inc = 0x55; break; case 4: num_palette = 16; color_inc = 0x11; break; case 8: num_palette = 256; color_inc = 1; break; default: num_palette = 0; color_inc = 0; break; } for (i = 0, v = 0; i < num_palette; i++, v += color_inc) { palette[i].red = (png_byte)v; palette[i].green = (png_byte)v; palette[i].blue = (png_byte)v; } } /* This function is currently unused. Do we really need it? */ #if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED) void /* PRIVATE */ png_correct_palette(png_structp png_ptr, png_colorp palette, int num_palette) { png_debug(1, "in png_correct_palette\n"); #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) { png_color back, back_1; if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) { back.red = png_ptr->gamma_table[png_ptr->background.red]; back.green = png_ptr->gamma_table[png_ptr->background.green]; back.blue = png_ptr->gamma_table[png_ptr->background.blue]; back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; } else { double g; g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN || fabs(g - 1.0) < PNG_GAMMA_THRESHOLD) { back.red = png_ptr->background.red; back.green = png_ptr->background.green; back.blue = png_ptr->background.blue; } else { back.red = (png_byte)(pow((double)png_ptr->background.red/255, g) * 255.0 + 0.5); back.green = (png_byte)(pow((double)png_ptr->background.green/255, g) * 255.0 + 0.5); back.blue = (png_byte)(pow((double)png_ptr->background.blue/255, g) * 255.0 + 0.5); } g = 1.0 / png_ptr->background_gamma; back_1.red = (png_byte)(pow((double)png_ptr->background.red/255, g) * 255.0 + 0.5); back_1.green = (png_byte)(pow((double)png_ptr->background.green/255, g) * 255.0 + 0.5); back_1.blue = (png_byte)(pow((double)png_ptr->background.blue/255, g) * 255.0 + 0.5); } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { png_uint_32 i; for (i = 0; i < (png_uint_32)num_palette; i++) { if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) { palette[i] = back; } else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) { png_byte v, w; v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; png_composite(w, v, png_ptr->trans[i], back_1.red); palette[i].red = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; png_composite(w, v, png_ptr->trans[i], back_1.green); palette[i].green = png_ptr->gamma_from_1[w]; v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; png_composite(w, v, png_ptr->trans[i], back_1.blue); palette[i].blue = png_ptr->gamma_from_1[w]; } else { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } } else { int i; for (i = 0; i < num_palette; i++) { if (palette[i].red == (png_byte)png_ptr->trans_values.gray) { palette[i] = back; } else { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } } } else #endif #if defined(PNG_READ_GAMMA_SUPPORTED) if (png_ptr->transformations & PNG_GAMMA) { int i; for (i = 0; i < num_palette; i++) { palette[i].red = png_ptr->gamma_table[palette[i].red]; palette[i].green = png_ptr->gamma_table[palette[i].green]; palette[i].blue = png_ptr->gamma_table[palette[i].blue]; } } #if defined(PNG_READ_BACKGROUND_SUPPORTED) else #endif #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) if (png_ptr->transformations & PNG_BACKGROUND) { if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { png_color back; back.red = (png_byte)png_ptr->background.red; back.green = (png_byte)png_ptr->background.green; back.blue = (png_byte)png_ptr->background.blue; for (i = 0; i < (int)png_ptr->num_trans; i++) { if (png_ptr->trans[i] == 0) { palette[i].red = back.red; palette[i].green = back.green; palette[i].blue = back.blue; } else if (png_ptr->trans[i] != 0xff) { png_composite(palette[i].red, png_ptr->palette[i].red, png_ptr->trans[i], back.red); png_composite(palette[i].green, png_ptr->palette[i].green, png_ptr->trans[i], back.green); png_composite(palette[i].blue, png_ptr->palette[i].blue, png_ptr->trans[i], back.blue); } } } else /* assume grayscale palette (what else could it be?) */ { int i; for (i = 0; i < num_palette; i++) { if (i == (png_byte)png_ptr->trans_values.gray) { palette[i].red = (png_byte)png_ptr->background.red; palette[i].green = (png_byte)png_ptr->background.green; palette[i].blue = (png_byte)png_ptr->background.blue; } } } } #endif } #endif #if defined(PNG_READ_BACKGROUND_SUPPORTED) /* Replace any alpha or transparency with the supplied background color. * "background" is already in the screen gamma, while "background_1" is * at a gamma of 1.0. Paletted files have already been taken care of. */ void /* PRIVATE */ png_do_background(png_row_infop row_info, png_bytep row, png_color_16p trans_values, png_color_16p background #if defined(PNG_READ_GAMMA_SUPPORTED) , png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int gamma_shift #endif ) { png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; int shift; png_debug(1, "in png_do_background\n"); if (background != NULL && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) || (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values))) { switch (row_info->color_type) { case PNG_COLOR_TYPE_GRAY: { switch (row_info->bit_depth) { case 1: { sp = row; shift = 7; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x01) == trans_values->gray) { *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } if (!shift) { shift = 7; sp++; } else shift--; } break; } case 2: { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; shift = 6; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) == trans_values->gray) { *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } else { png_byte p = (png_byte)((*sp >> shift) & 0x03); png_byte g = (png_byte)((gamma_table [p | (p << 2) | (p << 4) | (p << 6)] >> 6) & 0x03); *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *sp |= (png_byte)(g << shift); } if (!shift) { shift = 6; sp++; } else shift -= 2; } } else #endif { sp = row; shift = 6; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x03) == trans_values->gray) { *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } if (!shift) { shift = 6; sp++; } else shift -= 2; } } break; } case 4: { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; shift = 4; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) == trans_values->gray) { *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } else { png_byte p = (png_byte)((*sp >> shift) & 0x0f); png_byte g = (png_byte)((gamma_table[p | (p << 4)] >> 4) & 0x0f); *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *sp |= (png_byte)(g << shift); } if (!shift) { shift = 4; sp++; } else shift -= 4; } } else #endif { sp = row; shift = 4; for (i = 0; i < row_width; i++) { if ((png_uint_16)((*sp >> shift) & 0x0f) == trans_values->gray) { *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *sp |= (png_byte)(background->gray << shift); } if (!shift) { shift = 4; sp++; } else shift -= 4; } } break; } case 8: { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp++) { if (*sp == trans_values->gray) { *sp = (png_byte)background->gray; } else { *sp = gamma_table[*sp]; } } } else #endif { sp = row; for (i = 0; i < row_width; i++, sp++) { if (*sp == trans_values->gray) { *sp = (png_byte)background->gray; } } } break; } case 16: { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 2) { png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); if (v == trans_values->gray) { /* background is already in screen gamma */ *sp = (png_byte)((background->gray >> 8) & 0xff); *(sp + 1) = (png_byte)(background->gray & 0xff); } else { v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); } } } else #endif { sp = row; for (i = 0; i < row_width; i++, sp += 2) { png_uint_16 v; v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); if (v == trans_values->gray) { *sp = (png_byte)((background->gray >> 8) & 0xff); *(sp + 1) = (png_byte)(background->gray & 0xff); } } } break; } } break; } case PNG_COLOR_TYPE_RGB: { if (row_info->bit_depth == 8) { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_table != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 3) { if (*sp == trans_values->red && *(sp + 1) == trans_values->green && *(sp + 2) == trans_values->blue) { *sp = (png_byte)background->red; *(sp + 1) = (png_byte)background->green; *(sp + 2) = (png_byte)background->blue; } else { *sp = gamma_table[*sp]; *(sp + 1) = gamma_table[*(sp + 1)]; *(sp + 2) = gamma_table[*(sp + 2)]; } } } else #endif { sp = row; for (i = 0; i < row_width; i++, sp += 3) { if (*sp == trans_values->red && *(sp + 1) == trans_values->green && *(sp + 2) == trans_values->blue) { *sp = (png_byte)background->red; *(sp + 1) = (png_byte)background->green; *(sp + 2) = (png_byte)background->blue; } } } } else /* if (row_info->bit_depth == 16) */ { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL) { sp = row; for (i = 0; i < row_width; i++, sp += 6) { png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); if (r == trans_values->red && g == trans_values->green && b == trans_values->blue) { /* background is already in screen gamma */ *sp = (png_byte)((background->red >> 8) & 0xff); *(sp + 1) = (png_byte)(background->red & 0xff); *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); *(sp + 3) = (png_byte)(background->green & 0xff); *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); *(sp + 5) = (png_byte)(background->blue & 0xff); } else { png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; *(sp + 2) = (png_byte)((v >> 8) & 0xff); *(sp + 3) = (png_byte)(v & 0xff); v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; *(sp + 4) = (png_byte)((v >> 8) & 0xff); *(sp + 5) = (png_byte)(v & 0xff); } } } else #endif { sp = row; for (i = 0; i < row_width; i++, sp += 6) { png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1)); png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5)); if (r == trans_values->red && g == trans_values->green && b == trans_values->blue) { *sp = (png_byte)((background->red >> 8) & 0xff); *(sp + 1) = (png_byte)(background->red & 0xff); *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); *(sp + 3) = (png_byte)(background->green & 0xff); *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff); *(sp + 5) = (png_byte)(background->blue & 0xff); } } } } break; } case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 2, dp++) { png_uint_16 a = *(sp + 1); if (a == 0xff) { *dp = gamma_table[*sp]; } else if (a == 0) { /* background is already in screen gamma */ *dp = (png_byte)background->gray; } else { png_byte v, w; v = gamma_to_1[*sp]; png_composite(w, v, a, background_1->gray); *dp = gamma_from_1[w]; } } } else #endif { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 2, dp++) { png_byte a = *(sp + 1); if (a == 0xff) { *dp = *sp; } #if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) { *dp = (png_byte)background->gray; } else { png_composite(*dp, *sp, a, background_1->gray); } #else *dp = (png_byte)background->gray; #endif } } } else /* if (png_ptr->bit_depth == 16) */ { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 4, dp += 2) { png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); if (a == (png_uint_16)0xffff) { png_uint_16 v; v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); } #if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) #else else #endif { /* background is already in screen gamma */ *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } #if defined(PNG_READ_GAMMA_SUPPORTED) else { png_uint_16 g, v, w; g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; png_composite_16(v, g, a, background_1->gray); w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8]; *dp = (png_byte)((w >> 8) & 0xff); *(dp + 1) = (png_byte)(w & 0xff); } #endif } } else #endif { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 4, dp += 2) { png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3)); if (a == (png_uint_16)0xffff) { png_memcpy(dp, sp, 2); } #if defined(PNG_READ_GAMMA_SUPPORTED) else if (a == 0) #else else #endif { *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } #if defined(PNG_READ_GAMMA_SUPPORTED) else { png_uint_16 g, v; g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); png_composite_16(v, g, a, background_1->gray); *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); } #endif } } } break; } case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_to_1 != NULL && gamma_from_1 != NULL && gamma_table != NULL) { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 4, dp += 3) { png_byte a = *(sp + 3); if (a == 0xff) { *dp = gamma_table[*sp]; *(dp + 1) = gamma_table[*(sp + 1)]; *(dp + 2) = gamma_table[*(sp + 2)]; } else if (a == 0) { /* background is already in screen gamma */ *dp = (png_byte)background->red; *(dp + 1) = (png_byte)background->green; *(dp + 2) = (png_byte)background->blue; } else { png_byte v, w; v = gamma_to_1[*sp]; png_composite(w, v, a, background_1->red); *dp = gamma_from_1[w]; v = gamma_to_1[*(sp + 1)]; png_composite(w, v, a, background_1->green); *(dp + 1) = gamma_from_1[w]; v = gamma_to_1[*(sp + 2)]; png_composite(w, v, a, background_1->blue); *(dp + 2) = gamma_from_1[w]; } } } else #endif { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 4, dp += 3) { png_byte a = *(sp + 3); if (a == 0xff) { *dp = *sp; *(dp + 1) = *(sp + 1); *(dp + 2) = *(sp + 2); } else if (a == 0) { *dp = (png_byte)background->red; *(dp + 1) = (png_byte)background->green; *(dp + 2) = (png_byte)background->blue; } else { png_composite(*dp, *sp, a, background->red); png_composite(*(dp + 1), *(sp + 1), a, background->green); png_composite(*(dp + 2), *(sp + 2), a, background->blue); } } } } else /* if (row_info->bit_depth == 16) */ { #if defined(PNG_READ_GAMMA_SUPPORTED) if (gamma_16 != NULL && gamma_16_from_1 != NULL && gamma_16_to_1 != NULL) { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 8, dp += 6) { png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) << 8) + (png_uint_16)(*(sp + 7))); if (a == (png_uint_16)0xffff) { png_uint_16 v; v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; *(dp + 2) = (png_byte)((v >> 8) & 0xff); *(dp + 3) = (png_byte)(v & 0xff); v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; *(dp + 4) = (png_byte)((v >> 8) & 0xff); *(dp + 5) = (png_byte)(v & 0xff); } else if (a == 0) { /* background is already in screen gamma */ *dp = (png_byte)((background->red >> 8) & 0xff); *(dp + 1) = (png_byte)(background->red & 0xff); *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); *(dp + 3) = (png_byte)(background->green & 0xff); *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); *(dp + 5) = (png_byte)(background->blue & 0xff); } else { png_uint_16 v, w, x; v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; png_composite_16(w, v, a, background_1->red); x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; *dp = (png_byte)((x >> 8) & 0xff); *(dp + 1) = (png_byte)(x & 0xff); v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; png_composite_16(w, v, a, background_1->green); x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8]; *(dp + 2) = (png_byte)((x >> 8) & 0xff); *(dp + 3) = (png_byte)(x & 0xff); v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; png_composite_16(w, v, a, background_1->blue); x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8]; *(dp + 4) = (png_byte)((x >> 8) & 0xff); *(dp + 5) = (png_byte)(x & 0xff); } } } else #endif { sp = row; dp = row; for (i = 0; i < row_width; i++, sp += 8, dp += 6) { png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) << 8) + (png_uint_16)(*(sp + 7))); if (a == (png_uint_16)0xffff) { png_memcpy(dp, sp, 6); } else if (a == 0) { *dp = (png_byte)((background->red >> 8) & 0xff); *(dp + 1) = (png_byte)(background->red & 0xff); *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); *(dp + 3) = (png_byte)(background->green & 0xff); *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff); *(dp + 5) = (png_byte)(background->blue & 0xff); } else { png_uint_16 v; png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) + *(sp + 3)); png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) + *(sp + 5)); png_composite_16(v, r, a, background->red); *dp = (png_byte)((v >> 8) & 0xff); *(dp + 1) = (png_byte)(v & 0xff); png_composite_16(v, g, a, background->green); *(dp + 2) = (png_byte)((v >> 8) & 0xff); *(dp + 3) = (png_byte)(v & 0xff); png_composite_16(v, b, a, background->blue); *(dp + 4) = (png_byte)((v >> 8) & 0xff); *(dp + 5) = (png_byte)(v & 0xff); } } } } break; } } if (row_info->color_type & PNG_COLOR_MASK_ALPHA) { row_info->color_type &= ~PNG_COLOR_MASK_ALPHA; row_info->channels--; row_info->pixel_depth = (png_byte)(row_info->channels * row_info->bit_depth); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } } } #endif #if defined(PNG_READ_GAMMA_SUPPORTED) /* Gamma correct the image, avoiding the alpha channel. Make sure * you do this after you deal with the transparency issue on grayscale * or RGB images. If your bit depth is 8, use gamma_table, if it * is 16, use gamma_16_table and gamma_shift. Build these with * build_gamma_table(). */ void /* PRIVATE */ png_do_gamma(png_row_infop row_info, png_bytep row, png_bytep gamma_table, png_uint_16pp gamma_16_table, int gamma_shift) { png_bytep sp; png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_gamma\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif ((row_info->bit_depth <= 8 && gamma_table != NULL) || (row_info->bit_depth == 16 && gamma_16_table != NULL))) { switch (row_info->color_type) { case PNG_COLOR_TYPE_RGB: { if (row_info->bit_depth == 8) { sp = row; for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp++; *sp = gamma_table[*sp]; sp++; *sp = gamma_table[*sp]; sp++; } } else /* if (row_info->bit_depth == 16) */ { sp = row; for (i = 0; i < row_width; i++) { png_uint_16 v; v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; } } break; } case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) { sp = row; for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp++; *sp = gamma_table[*sp]; sp++; *sp = gamma_table[*sp]; sp++; sp++; } } else /* if (row_info->bit_depth == 16) */ { sp = row; for (i = 0; i < row_width; i++) { png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 4; } } break; } case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) { sp = row; for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp += 2; } } else /* if (row_info->bit_depth == 16) */ { sp = row; for (i = 0; i < row_width; i++) { png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 4; } } break; } case PNG_COLOR_TYPE_GRAY: { if (row_info->bit_depth == 2) { sp = row; for (i = 0; i < row_width; i += 4) { int a = *sp & 0xc0; int b = *sp & 0x30; int c = *sp & 0x0c; int d = *sp & 0x03; *sp = (png_byte)( ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); sp++; } } if (row_info->bit_depth == 4) { sp = row; for (i = 0; i < row_width; i += 2) { int msb = *sp & 0xf0; int lsb = *sp & 0x0f; *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); sp++; } } else if (row_info->bit_depth == 8) { sp = row; for (i = 0; i < row_width; i++) { *sp = gamma_table[*sp]; sp++; } } else if (row_info->bit_depth == 16) { sp = row; for (i = 0; i < row_width; i++) { png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; *sp = (png_byte)((v >> 8) & 0xff); *(sp + 1) = (png_byte)(v & 0xff); sp += 2; } } break; } } } } #endif #if defined(PNG_READ_EXPAND_SUPPORTED) /* Expands a palette row to an RGB or RGBA row depending * upon whether you supply trans and num_trans. */ void /* PRIVATE */ png_do_expand_palette(png_row_infop row_info, png_bytep row, png_colorp palette, png_bytep trans, int num_trans) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand_palette\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif row_info->color_type == PNG_COLOR_TYPE_PALETTE) { if (row_info->bit_depth < 8) { switch (row_info->bit_depth) { case 1: { sp = row + (png_size_t)((row_width - 1) >> 3); dp = row + (png_size_t)row_width - 1; shift = 7 - (int)((row_width + 7) & 0x07); for (i = 0; i < row_width; i++) { if ((*sp >> shift) & 0x01) *dp = 1; else *dp = 0; if (shift == 7) { shift = 0; sp--; } else shift++; dp--; } break; } case 2: { sp = row + (png_size_t)((row_width - 1) >> 2); dp = row + (png_size_t)row_width - 1; shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); for (i = 0; i < row_width; i++) { value = (*sp >> shift) & 0x03; *dp = (png_byte)value; if (shift == 6) { shift = 0; sp--; } else shift += 2; dp--; } break; } case 4: { sp = row + (png_size_t)((row_width - 1) >> 1); dp = row + (png_size_t)row_width - 1; shift = (int)((row_width & 0x01) << 2); for (i = 0; i < row_width; i++) { value = (*sp >> shift) & 0x0f; *dp = (png_byte)value; if (shift == 4) { shift = 0; sp--; } else shift += 4; dp--; } break; } } row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; } switch (row_info->bit_depth) { case 8: { if (trans != NULL) { sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width << 2) - 1; for (i = 0; i < row_width; i++) { if ((int)(*sp) >= num_trans) *dp-- = 0xff; else *dp-- = trans[*sp]; *dp-- = palette[*sp].blue; *dp-- = palette[*sp].green; *dp-- = palette[*sp].red; sp--; } row_info->bit_depth = 8; row_info->pixel_depth = 32; row_info->rowbytes = row_width * 4; row_info->color_type = 6; row_info->channels = 4; } else { sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width * 3) - 1; for (i = 0; i < row_width; i++) { *dp-- = palette[*sp].blue; *dp-- = palette[*sp].green; *dp-- = palette[*sp].red; sp--; } row_info->bit_depth = 8; row_info->pixel_depth = 24; row_info->rowbytes = row_width * 3; row_info->color_type = 2; row_info->channels = 3; } break; } } } } /* If the bit depth < 8, it is expanded to 8. Also, if the already * expanded transparency value is supplied, an alpha channel is built. */ void /* PRIVATE */ png_do_expand(png_row_infop row_info, png_bytep row, png_color_16p trans_value) { int shift, value; png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_expand\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { if (row_info->color_type == PNG_COLOR_TYPE_GRAY) { png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0); if (row_info->bit_depth < 8) { switch (row_info->bit_depth) { case 1: { gray = (png_uint_16)((gray&0x01)*0xff); sp = row + (png_size_t)((row_width - 1) >> 3); dp = row + (png_size_t)row_width - 1; shift = 7 - (int)((row_width + 7) & 0x07); for (i = 0; i < row_width; i++) { if ((*sp >> shift) & 0x01) *dp = 0xff; else *dp = 0; if (shift == 7) { shift = 0; sp--; } else shift++; dp--; } break; } case 2: { gray = (png_uint_16)((gray&0x03)*0x55); sp = row + (png_size_t)((row_width - 1) >> 2); dp = row + (png_size_t)row_width - 1; shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); for (i = 0; i < row_width; i++) { value = (*sp >> shift) & 0x03; *dp = (png_byte)(value | (value << 2) | (value << 4) | (value << 6)); if (shift == 6) { shift = 0; sp--; } else shift += 2; dp--; } break; } case 4: { gray = (png_uint_16)((gray&0x0f)*0x11); sp = row + (png_size_t)((row_width - 1) >> 1); dp = row + (png_size_t)row_width - 1; shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); for (i = 0; i < row_width; i++) { value = (*sp >> shift) & 0x0f; *dp = (png_byte)(value | (value << 4)); if (shift == 4) { shift = 0; sp--; } else shift = 4; dp--; } break; } } row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; } if (trans_value != NULL) { if (row_info->bit_depth == 8) { gray = gray & 0xff; sp = row + (png_size_t)row_width - 1; dp = row + (png_size_t)(row_width << 1) - 1; for (i = 0; i < row_width; i++) { if (*sp == gray) *dp-- = 0; else *dp-- = 0xff; *dp-- = *sp--; } } else if (row_info->bit_depth == 16) { png_byte gray_high = (gray >> 8) & 0xff; png_byte gray_low = gray & 0xff; sp = row + row_info->rowbytes - 1; dp = row + (row_info->rowbytes << 1) - 1; for (i = 0; i < row_width; i++) { if (*(sp-1) == gray_high && *(sp) == gray_low) { *dp-- = 0; *dp-- = 0; } else { *dp-- = 0xff; *dp-- = 0xff; } *dp-- = *sp--; *dp-- = *sp--; } } row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; row_info->channels = 2; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } } else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value) { if (row_info->bit_depth == 8) { png_byte red = trans_value->red & 0xff; png_byte green = trans_value->green & 0xff; png_byte blue = trans_value->blue & 0xff; sp = row + (png_size_t)row_info->rowbytes - 1; dp = row + (png_size_t)(row_width << 2) - 1; for (i = 0; i < row_width; i++) { if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue) *dp-- = 0; else *dp-- = 0xff; *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; } } else if (row_info->bit_depth == 16) { png_byte red_high = (trans_value->red >> 8) & 0xff; png_byte green_high = (trans_value->green >> 8) & 0xff; png_byte blue_high = (trans_value->blue >> 8) & 0xff; png_byte red_low = trans_value->red & 0xff; png_byte green_low = trans_value->green & 0xff; png_byte blue_low = trans_value->blue & 0xff; sp = row + row_info->rowbytes - 1; dp = row + (png_size_t)(row_width << 3) - 1; for (i = 0; i < row_width; i++) { if (*(sp - 5) == red_high && *(sp - 4) == red_low && *(sp - 3) == green_high && *(sp - 2) == green_low && *(sp - 1) == blue_high && *(sp ) == blue_low) { *dp-- = 0; *dp-- = 0; } else { *dp-- = 0xff; *dp-- = 0xff; } *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; *dp-- = *sp--; } } row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; row_info->channels = 4; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } } } #endif #if defined(PNG_READ_DITHER_SUPPORTED) void /* PRIVATE */ png_do_dither(png_row_infop row_info, png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup) { png_bytep sp, dp; png_uint_32 i; png_uint_32 row_width=row_info->width; png_debug(1, "in png_do_dither\n"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif { if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup && row_info->bit_depth == 8) { int r, g, b, p; sp = row; dp = row; for (i = 0; i < row_width; i++) { r = *sp++; g = *sp++; b = *sp++; /* this looks real messy, but the compiler will reduce it down to a reasonable formula. For example, with 5 bits per color, we get: p = (((r >> 3) & 0x1f) << 10) | (((g >> 3) & 0x1f) << 5) | ((b >> 3) & 0x1f); */ p = (((r >> (8 - PNG_DITHER_RED_BITS)) & ((1 << PNG_DITHER_RED_BITS) - 1)) << (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | (((g >> (8 - PNG_DITHER_GREEN_BITS)) & ((1 << PNG_DITHER_GREEN_BITS) - 1)) << (PNG_DITHER_BLUE_BITS)) | ((b >> (8 - PNG_DITHER_BLUE_BITS)) & ((1 << PNG_DITHER_BLUE_BITS) - 1)); *dp++ = palette_lookup[p]; } row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && palette_lookup != NULL && row_info->bit_depth == 8) { int r, g, b, p; sp = row; dp = row; for (i = 0; i < row_width; i++) { r = *sp++; g = *sp++; b = *sp++; sp++; p = (((r >> (8 - PNG_DITHER_RED_BITS)) & ((1 << PNG_DITHER_RED_BITS) - 1)) << (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | (((g >> (8 - PNG_DITHER_GREEN_BITS)) & ((1 << PNG_DITHER_GREEN_BITS) - 1)) << (PNG_DITHER_BLUE_BITS)) | ((b >> (8 - PNG_DITHER_BLUE_BITS)) & ((1 << PNG_DITHER_BLUE_BITS) - 1)); *dp++ = palette_lookup[p]; } row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); } else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && dither_lookup && row_info->bit_depth == 8) { sp = row; for (i = 0; i < row_width; i++, sp++) { *sp = dither_lookup[*sp]; } } } } #endif #ifdef PNG_FLOATING_POINT_SUPPORTED #if defined(PNG_READ_GAMMA_SUPPORTED) static PNG_CONST int png_gamma_shift[] = {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00}; /* We build the 8- or 16-bit gamma tables here. Note that for 16-bit * tables, we don't make a full table if we are reducing to 8-bit in * the future. Note also how the gamma_16 tables are segmented so that * we don't need to allocate > 64K chunks for a full 16-bit table. */ void /* PRIVATE */ png_build_gamma_table(png_structp png_ptr) { png_debug(1, "in png_build_gamma_table\n"); if (png_ptr->bit_depth <= 8) { int i; double g; if (png_ptr->screen_gamma > .000001) g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); else g = 1.0; png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, (png_uint_32)256); for (i = 0; i < 256; i++) { png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, g) * 255.0 + .5); } #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) { g = 1.0 / (png_ptr->gamma); png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, (png_uint_32)256); for (i = 0; i < 256; i++) { png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, g) * 255.0 + .5); } png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, (png_uint_32)256); if(png_ptr->screen_gamma > 0.000001) g = 1.0 / png_ptr->screen_gamma; else g = png_ptr->gamma; /* probably doing rgb_to_gray */ for (i = 0; i < 256; i++) { png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, g) * 255.0 + .5); } } #endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ } else { double g; int i, j, shift, num; int sig_bit; png_uint_32 ig; if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) { sig_bit = (int)png_ptr->sig_bit.red; if ((int)png_ptr->sig_bit.green > sig_bit) sig_bit = png_ptr->sig_bit.green; if ((int)png_ptr->sig_bit.blue > sig_bit) sig_bit = png_ptr->sig_bit.blue; } else { sig_bit = (int)png_ptr->sig_bit.gray; } if (sig_bit > 0) shift = 16 - sig_bit; else shift = 0; if (png_ptr->transformations & PNG_16_TO_8) { if (shift < (16 - PNG_MAX_GAMMA_8)) shift = (16 - PNG_MAX_GAMMA_8); } if (shift > 8) shift = 8; if (shift < 0) shift = 0; png_ptr->gamma_shift = (png_byte)shift; num = (1 << (8 - shift)); if (png_ptr->screen_gamma > .000001) g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); else g = 1.0; png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof (png_uint_16p))); if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) { double fin, fout; png_uint_32 last, max; for (i = 0; i < num; i++) { png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(256 * png_sizeof (png_uint_16))); } g = 1.0 / g; last = 0; for (i = 0; i < 256; i++) { fout = ((double)i + 0.5) / 256.0; fin = pow(fout, g); max = (png_uint_32)(fin * (double)((png_uint_32)num << 8)); while (last <= max) { png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] [(int)(last >> (8 - shift))] = (png_uint_16)( (png_uint_16)i | ((png_uint_16)i << 8)); last++; } } while (last < ((png_uint_32)num << 8)) { png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] [(int)(last >> (8 - shift))] = (png_uint_16)65535L; last++; } } else { for (i = 0; i < num; i++) { png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(256 * png_sizeof (png_uint_16))); ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); for (j = 0; j < 256; j++) { png_ptr->gamma_16_table[i][j] = (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / 65535.0, g) * 65535.0 + .5); } } } #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) { g = 1.0 / (png_ptr->gamma); png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof (png_uint_16p ))); for (i = 0; i < num; i++) { png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(256 * png_sizeof (png_uint_16))); ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); for (j = 0; j < 256; j++) { png_ptr->gamma_16_to_1[i][j] = (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / 65535.0, g) * 65535.0 + .5); } } if(png_ptr->screen_gamma > 0.000001) g = 1.0 / png_ptr->screen_gamma; else g = png_ptr->gamma; /* probably doing rgb_to_gray */ png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, (png_uint_32)(num * png_sizeof (png_uint_16p))); for (i = 0; i < num; i++) { png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, (png_uint_32)(256 * png_sizeof (png_uint_16))); ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); for (j = 0; j < 256; j++) { png_ptr->gamma_16_from_1[i][j] = (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) / 65535.0, g) * 65535.0 + .5); } } } #endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */ } } #endif /* To do: install integer version of png_build_gamma_table here */ #endif #if defined(PNG_MNG_FEATURES_SUPPORTED) /* undoes intrapixel differencing */ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { png_debug(1, "in png_do_read_intrapixel\n"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif (row_info->color_type & PNG_COLOR_MASK_COLOR)) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; if (row_info->bit_depth == 8) { png_bytep rp; png_uint_32 i; if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff); *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff); } } else if (row_info->bit_depth == 16) { png_bytep rp; png_uint_32 i; if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); *(rp ) = (png_byte)((red >> 8) & 0xff); *(rp+1) = (png_byte)(red & 0xff); *(rp+4) = (png_byte)((blue >> 8) & 0xff); *(rp+5) = (png_byte)(blue & 0xff); } } } } #endif /* PNG_MNG_FEATURES_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */ wgd-3.1/src/resources_base/png/pnggccrd.cpp0000644000175000001440000001125410755642352015741 00000000000000/* pnggccrd.c was removed from libpng-1.2.20. */ /* This code snippet is for use by configure's compilation test. */ #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ defined(PNG_MMX_CODE_SUPPORTED) int PNGAPI png_dummy_mmx_support(void); static int _mmx_supported = 2; // 0: no MMX; 1: MMX supported; 2: not tested int PNGAPI png_dummy_mmx_support(void) __attribute__((noinline)); int PNGAPI png_dummy_mmx_support(void) { int result; #if defined(PNG_MMX_CODE_SUPPORTED) // superfluous, but what the heck __asm__ __volatile__ ( #if defined(__x86_64__) "pushq %%rbx \n\t" // rbx gets clobbered by CPUID instruction "pushq %%rcx \n\t" // so does rcx... "pushq %%rdx \n\t" // ...and rdx (but rcx & rdx safe on Linux) "pushfq \n\t" // save Eflag to stack "popq %%rax \n\t" // get Eflag from stack into rax "movq %%rax, %%rcx \n\t" // make another copy of Eflag in rcx "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) "pushq %%rax \n\t" // save modified Eflag back to stack "popfq \n\t" // restore modified value to Eflag reg "pushfq \n\t" // save Eflag to stack "popq %%rax \n\t" // get Eflag from stack "pushq %%rcx \n\t" // save original Eflag to stack "popfq \n\t" // restore original Eflag #else "pushl %%ebx \n\t" // ebx gets clobbered by CPUID instruction "pushl %%ecx \n\t" // so does ecx... "pushl %%edx \n\t" // ...and edx (but ecx & edx safe on Linux) "pushfl \n\t" // save Eflag to stack "popl %%eax \n\t" // get Eflag from stack into eax "movl %%eax, %%ecx \n\t" // make another copy of Eflag in ecx "xorl $0x200000, %%eax \n\t" // toggle ID bit in Eflag (i.e., bit 21) "pushl %%eax \n\t" // save modified Eflag back to stack "popfl \n\t" // restore modified value to Eflag reg "pushfl \n\t" // save Eflag to stack "popl %%eax \n\t" // get Eflag from stack "pushl %%ecx \n\t" // save original Eflag to stack "popfl \n\t" // restore original Eflag #endif "xorl %%ecx, %%eax \n\t" // compare new Eflag with original Eflag "jz 0f \n\t" // if same, CPUID instr. is not supported "xorl %%eax, %%eax \n\t" // set eax to zero // ".byte 0x0f, 0xa2 \n\t" // CPUID instruction (two-byte opcode) "cpuid \n\t" // get the CPU identification info "cmpl $1, %%eax \n\t" // make sure eax return non-zero value "jl 0f \n\t" // if eax is zero, MMX is not supported "xorl %%eax, %%eax \n\t" // set eax to zero and... "incl %%eax \n\t" // ...increment eax to 1. This pair is // faster than the instruction "mov eax, 1" "cpuid \n\t" // get the CPU identification info again "andl $0x800000, %%edx \n\t" // mask out all bits but MMX bit (23) "cmpl $0, %%edx \n\t" // 0 = MMX not supported "jz 0f \n\t" // non-zero = yes, MMX IS supported "movl $1, %%eax \n\t" // set return value to 1 "jmp 1f \n\t" // DONE: have MMX support "0: \n\t" // .NOT_SUPPORTED: target label for jump instructions "movl $0, %%eax \n\t" // set return value to 0 "1: \n\t" // .RETURN: target label for jump instructions #if defined(__x86_64__) "popq %%rdx \n\t" // restore rdx "popq %%rcx \n\t" // restore rcx "popq %%rbx \n\t" // restore rbx #else "popl %%edx \n\t" // restore edx "popl %%ecx \n\t" // restore ecx "popl %%ebx \n\t" // restore ebx #endif // "ret \n\t" // DONE: no MMX support // (fall through to standard C "ret") : "=a" (result) // output list : // any variables used on input (none) // no clobber list // , "%ebx", "%ecx", "%edx" // GRR: we handle these manually // , "memory" // if write to a variable gcc thought was in a reg // , "cc" // "condition codes" (flag bits) ); _mmx_supported = result; #else _mmx_supported = 0; #endif /* PNG_MMX_CODE_SUPPORTED */ return _mmx_supported; } #endif wgd-3.1/src/resources_base/png/png.cpp0000644000175000001440000005474111001137472014731 00000000000000 /* png.c - location for general purpose libpng functions * * Last changed in libpng 1.2.19 August 19, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ #define PNG_INTERNAL #define PNG_NO_EXTERN #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif /* Generate a compiler error if there is an old png.h in the search path. */ typedef version_1_2_20 Your_png_h_is_not_version_1_2_20; /* Version information for C files. This had better match the version * string defined in png.h. */ #ifdef PNG_USE_GLOBAL_ARRAYS /* png_libpng_ver was changed to a function in version 1.0.5c */ PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING; #ifdef PNG_READ_SUPPORTED /* png_sig was changed to a function in version 1.0.5c */ /* Place to hold the signature string for a PNG file. */ PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10}; #endif /* PNG_READ_SUPPORTED */ /* Invoke global declarations for constant strings for known chunk types */ PNG_IHDR; PNG_IDAT; PNG_IEND; PNG_PLTE; PNG_bKGD; PNG_cHRM; PNG_gAMA; PNG_hIST; PNG_iCCP; PNG_iTXt; PNG_oFFs; PNG_pCAL; PNG_sCAL; PNG_pHYs; PNG_sBIT; PNG_sPLT; PNG_sRGB; PNG_tEXt; PNG_tIME; PNG_tRNS; PNG_zTXt; #ifdef PNG_READ_SUPPORTED /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* start of interlace block */ PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; /* offset to next interlace block */ PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; /* start of interlace block in the y direction */ PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; /* offset to next interlace block in the y direction */ PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need * it, uncomment it here and in png.h PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; */ /* Mask to determine which pixels are valid in a pass */ PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; /* Mask to determine which pixels to overwrite while displaying */ PNG_CONST int FARDATA png_pass_dsp_mask[] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; #endif /* PNG_READ_SUPPORTED */ #endif /* PNG_USE_GLOBAL_ARRAYS */ /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another * stream we can set num_bytes = 8 so that libpng will not attempt to read * or write any of the magic bytes before it starts on the IHDR. */ #ifdef PNG_READ_SUPPORTED void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes) { if(png_ptr == NULL) return; png_debug(1, "in png_set_sig_bytes\n"); if (num_bytes > 8) png_error(png_ptr, "Too many bytes for PNG signature."); png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes); } /* Checks whether the supplied bytes match the PNG signature. We allow * checking less than the full 8-byte signature so that those apps that * already read the first few bytes of a file to determine the file type * can simply check the remaining bytes for extra assurance. Returns * an integer less than, equal to, or greater than zero if sig is found, * respectively, to be less than, to match, or be greater than the correct * PNG signature (this is the same behaviour as strcmp, memcmp, etc). */ int PNGAPI png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check) { png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; if (num_to_check > 8) num_to_check = 8; else if (num_to_check < 1) return (-1); if (start > 7) return (-1); if (start + num_to_check > 8) num_to_check = 8 - start; return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check))); } #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* (Obsolete) function to check signature bytes. It does not allow one * to check a partial signature. This function might be removed in the * future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG. */ int PNGAPI png_check_sig(png_bytep sig, int num) { return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num)); } #endif #endif /* PNG_READ_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Function to allocate memory for zlib and clear it to 0. */ #ifdef PNG_1_0_X voidpf PNGAPI #else voidpf /* private */ #endif png_zalloc(voidpf png_ptr, uInt items, uInt size) { png_voidp ptr; png_structp p=(png_structp)png_ptr; png_uint_32 save_flags=p->flags; png_uint_32 num_bytes; if(png_ptr == NULL) return (NULL); if (items > PNG_UINT_32_MAX/size) { png_warning (p, "Potential overflow in png_zalloc()"); return (NULL); } num_bytes = (png_uint_32)items * size; p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes); p->flags=save_flags; #if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO) if (ptr == NULL) return ((voidpf)ptr); if (num_bytes > (png_uint_32)0x8000L) { png_memset(ptr, 0, (png_size_t)0x8000L); png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0, (png_size_t)(num_bytes - (png_uint_32)0x8000L)); } else { png_memset(ptr, 0, (png_size_t)num_bytes); } #endif return ((voidpf)ptr); } /* function to free memory for zlib */ #ifdef PNG_1_0_X void PNGAPI #else void /* private */ #endif png_zfree(voidpf png_ptr, voidpf ptr) { png_free((png_structp)png_ptr, (png_voidp)ptr); } /* Reset the CRC variable to 32 bits of 1's. Care must be taken * in case CRC is > 32 bits to leave the top bits 0. */ void /* PRIVATE */ png_reset_crc(png_structp png_ptr) { png_ptr->crc = crc32(0, Z_NULL, 0); } /* Calculate the CRC over a section of data. We can only pass as * much data to this routine as the largest single buffer size. We * also check that this data will actually be used before going to the * trouble of calculating it. */ void /* PRIVATE */ png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length) { int need_crc = 1; if (png_ptr->chunk_name[0] & 0x20) /* ancillary */ { if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) need_crc = 0; } else /* critical */ { if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) need_crc = 0; } if (need_crc) png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length); } /* Allocate the memory for an info_struct for the application. We don't * really need the png_ptr, but it could potentially be useful in the * future. This should be used in favour of malloc(png_sizeof(png_info)) * and png_info_init() so that applications that want to use a shared * libpng don't have to be recompiled if png_info changes size. */ png_infop PNGAPI png_create_info_struct(png_structp png_ptr) { png_infop info_ptr; png_debug(1, "in png_create_info_struct\n"); if(png_ptr == NULL) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, png_ptr->malloc_fn, png_ptr->mem_ptr); #else info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); #endif if (info_ptr != NULL) png_info_init_3(&info_ptr, png_sizeof(png_info)); return (info_ptr); } /* This function frees the memory associated with a single info struct. * Normally, one would use either png_destroy_read_struct() or * png_destroy_write_struct() to free an info struct, but this may be * useful for some applications. */ void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) { png_infop info_ptr = NULL; if(png_ptr == NULL) return; png_debug(1, "in png_destroy_info_struct\n"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; if (info_ptr != NULL) { png_info_destroy(png_ptr, info_ptr); #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn, png_ptr->mem_ptr); #else png_destroy_struct((png_voidp)info_ptr); #endif *info_ptr_ptr = NULL; } } /* Initialize the info structure. This is now an internal function (0.89) * and applications using it are urged to use png_create_info_struct() * instead. */ #if defined(PNG_1_0_X) || defined(PNG_1_2_X) #undef png_info_init void PNGAPI png_info_init(png_infop info_ptr) { /* We only come here via pre-1.0.12-compiled applications */ png_info_init_3(&info_ptr, 0); } #endif void PNGAPI png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) { png_infop info_ptr = *ptr_ptr; if(info_ptr == NULL) return; png_debug(1, "in png_info_init_3\n"); if(png_sizeof(png_info) > png_info_struct_size) { png_destroy_struct(info_ptr); info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); *ptr_ptr = info_ptr; } /* set everything to 0 */ png_memset(info_ptr, 0, png_sizeof (png_info)); } #ifdef PNG_FREE_ME_SUPPORTED void PNGAPI png_data_freer(png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask) { png_debug(1, "in png_data_freer\n"); if (png_ptr == NULL || info_ptr == NULL) return; if(freer == PNG_DESTROY_WILL_FREE_DATA) info_ptr->free_me |= mask; else if(freer == PNG_USER_WILL_FREE_DATA) info_ptr->free_me &= ~mask; else png_warning(png_ptr, "Unknown freer parameter in png_data_freer."); } #endif void PNGAPI png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num) { png_debug(1, "in png_free_data\n"); if (png_ptr == NULL || info_ptr == NULL) return; #if defined(PNG_TEXT_SUPPORTED) /* free text item num or (if num == -1) all text items */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) #else if (mask & PNG_FREE_TEXT) #endif { if (num != -1) { if (info_ptr->text && info_ptr->text[num].key) { png_free(png_ptr, info_ptr->text[num].key); info_ptr->text[num].key = NULL; } } else { int i; for (i = 0; i < info_ptr->num_text; i++) png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); png_free(png_ptr, info_ptr->text); info_ptr->text = NULL; info_ptr->num_text=0; } } #endif #if defined(PNG_tRNS_SUPPORTED) /* free any tRNS entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) #else if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) #endif { png_free(png_ptr, info_ptr->trans); info_ptr->valid &= ~PNG_INFO_tRNS; #ifndef PNG_FREE_ME_SUPPORTED png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; #endif info_ptr->trans = NULL; } #endif #if defined(PNG_sCAL_SUPPORTED) /* free any sCAL entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) #else if (mask & PNG_FREE_SCAL) #endif { #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, info_ptr->scal_s_width); png_free(png_ptr, info_ptr->scal_s_height); info_ptr->scal_s_width = NULL; info_ptr->scal_s_height = NULL; #endif info_ptr->valid &= ~PNG_INFO_sCAL; } #endif #if defined(PNG_pCAL_SUPPORTED) /* free any pCAL entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) #else if (mask & PNG_FREE_PCAL) #endif { png_free(png_ptr, info_ptr->pcal_purpose); png_free(png_ptr, info_ptr->pcal_units); info_ptr->pcal_purpose = NULL; info_ptr->pcal_units = NULL; if (info_ptr->pcal_params != NULL) { int i; for (i = 0; i < (int)info_ptr->pcal_nparams; i++) { png_free(png_ptr, info_ptr->pcal_params[i]); info_ptr->pcal_params[i]=NULL; } png_free(png_ptr, info_ptr->pcal_params); info_ptr->pcal_params = NULL; } info_ptr->valid &= ~PNG_INFO_pCAL; } #endif #if defined(PNG_iCCP_SUPPORTED) /* free any iCCP entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) #else if (mask & PNG_FREE_ICCP) #endif { png_free(png_ptr, info_ptr->iccp_name); png_free(png_ptr, info_ptr->iccp_profile); info_ptr->iccp_name = NULL; info_ptr->iccp_profile = NULL; info_ptr->valid &= ~PNG_INFO_iCCP; } #endif #if defined(PNG_sPLT_SUPPORTED) /* free a given sPLT entry, or (if num == -1) all sPLT entries */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) #else if (mask & PNG_FREE_SPLT) #endif { if (num != -1) { if(info_ptr->splt_palettes) { png_free(png_ptr, info_ptr->splt_palettes[num].name); png_free(png_ptr, info_ptr->splt_palettes[num].entries); info_ptr->splt_palettes[num].name = NULL; info_ptr->splt_palettes[num].entries = NULL; } } else { if(info_ptr->splt_palettes_num) { int i; for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); png_free(png_ptr, info_ptr->splt_palettes); info_ptr->splt_palettes = NULL; info_ptr->splt_palettes_num = 0; } info_ptr->valid &= ~PNG_INFO_sPLT; } } #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) if(png_ptr->unknown_chunk.data) { png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) #else if (mask & PNG_FREE_UNKN) #endif { if (num != -1) { if(info_ptr->unknown_chunks) { png_free(png_ptr, info_ptr->unknown_chunks[num].data); info_ptr->unknown_chunks[num].data = NULL; } } else { int i; if(info_ptr->unknown_chunks_num) { for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); png_free(png_ptr, info_ptr->unknown_chunks); info_ptr->unknown_chunks = NULL; info_ptr->unknown_chunks_num = 0; } } } #endif #if defined(PNG_hIST_SUPPORTED) /* free any hIST entry */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_HIST) & info_ptr->free_me) #else if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) #endif { png_free(png_ptr, info_ptr->hist); info_ptr->hist = NULL; info_ptr->valid &= ~PNG_INFO_hIST; #ifndef PNG_FREE_ME_SUPPORTED png_ptr->flags &= ~PNG_FLAG_FREE_HIST; #endif } #endif /* free any PLTE entry that was internally allocated */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) #else if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) #endif { png_zfree(png_ptr, info_ptr->palette); info_ptr->palette = NULL; info_ptr->valid &= ~PNG_INFO_PLTE; #ifndef PNG_FREE_ME_SUPPORTED png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; #endif info_ptr->num_palette = 0; } #if defined(PNG_INFO_IMAGE_SUPPORTED) /* free any image bits attached to the info structure */ #ifdef PNG_FREE_ME_SUPPORTED if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) #else if (mask & PNG_FREE_ROWS) #endif { if(info_ptr->row_pointers) { int row; for (row = 0; row < (int)info_ptr->height; row++) { png_free(png_ptr, info_ptr->row_pointers[row]); info_ptr->row_pointers[row]=NULL; } png_free(png_ptr, info_ptr->row_pointers); info_ptr->row_pointers=NULL; } info_ptr->valid &= ~PNG_INFO_IDAT; } #endif #ifdef PNG_FREE_ME_SUPPORTED if(num == -1) info_ptr->free_me &= ~mask; else info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); #endif } /* This is an internal routine to free any memory that the info struct is * pointing to before re-using it or freeing the struct itself. Recall * that png_free() checks for NULL pointers for us. */ void /* PRIVATE */ png_info_destroy(png_structp png_ptr, png_infop info_ptr) { png_debug(1, "in png_info_destroy\n"); png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) if (png_ptr->num_chunk_list) { png_free(png_ptr, png_ptr->chunk_list); png_ptr->chunk_list=NULL; png_ptr->num_chunk_list=0; } #endif png_info_init_3(&info_ptr, png_sizeof(png_info)); } #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ /* This function returns a pointer to the io_ptr associated with the user * functions. The application should free any memory associated with this * pointer before png_write_destroy() or png_read_destroy() are called. */ png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr) { if(png_ptr == NULL) return (NULL); return (png_ptr->io_ptr); } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if !defined(PNG_NO_STDIO) /* Initialize the default input/output functions for the PNG file. If you * use your own read or write routines, you can call either png_set_read_fn() * or png_set_write_fn() instead of png_init_io(). If you have defined * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't * necessarily available. */ void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp) { png_debug(1, "in png_init_io\n"); if(png_ptr == NULL) return; png_ptr->io_ptr = (png_voidp)fp; } #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) /* Convert the supplied time into an RFC 1123 string suitable for use in * a "Creation Time" or other text-based time string. */ png_charp PNGAPI png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) { static PNG_CONST char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; if(png_ptr == NULL) return (NULL); if (png_ptr->time_buffer == NULL) { png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* png_sizeof(char))); } #if defined(_WIN32_WCE) { wchar_t time_buf[29]; wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"), ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29, NULL, NULL); } #else #ifdef USE_FAR_KEYWORD { char near_time_buf[29]; png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); png_memcpy(png_ptr->time_buffer, near_time_buf, 29*png_sizeof(char)); } #else png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); #endif #endif /* _WIN32_WCE */ return ((png_charp)png_ptr->time_buffer); } #endif /* PNG_TIME_RFC1123_SUPPORTED */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ png_charp PNGAPI png_get_copyright(png_structp png_ptr) { png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ return ((png_charp) "\n libpng version 1.2.20 - September 8, 2007\n\ Copyright (c) 1998-2007 Glenn Randers-Pehrson\n\ Copyright (c) 1996-1997 Andreas Dilger\n\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); } /* The following return the library version as a short string in the * format 1.0.0 through 99.99.99zz. To get the version of *.h files * used with your application, print out PNG_LIBPNG_VER_STRING, which * is defined in png.h. * Note: now there is no difference between png_get_libpng_ver() and * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, * it is guaranteed that png.c uses the correct version of png.h. */ png_charp PNGAPI png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ return ((png_charp) PNG_LIBPNG_VER_STRING); } png_charp PNGAPI png_get_header_ver(png_structp png_ptr) { /* Version of *.h files used when building libpng */ png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ return ((png_charp) PNG_LIBPNG_VER_STRING); } png_charp PNGAPI png_get_header_version(png_structp png_ptr) { /* Returns longer string containing both version and date */ png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ return ((png_charp) PNG_HEADER_VERSION_STRING #ifndef PNG_READ_SUPPORTED " (NO READ SUPPORT)" #endif "\n"); } #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) { /* check chunk_name and return "keep" value if it's on the list, else 0 */ int i; png_bytep p; if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) return 0; p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; for (i = png_ptr->num_chunk_list; i; i--, p-=5) if (!png_memcmp(chunk_name, p, 4)) return ((int)*(p+4)); return 0; } #endif /* This function, added to libpng-1.0.6g, is untested. */ int PNGAPI png_reset_zstream(png_structp png_ptr) { if (png_ptr == NULL) return Z_STREAM_ERROR; return (inflateReset(&png_ptr->zstream)); } #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ /* This function was added to libpng-1.0.7 */ png_uint_32 PNGAPI png_access_version_number(void) { /* Version of *.c files used when building libpng */ return((png_uint_32) PNG_LIBPNG_VER); } #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) #if !defined(PNG_1_0_X) /* this function was added to libpng 1.2.0 */ int PNGAPI png_mmx_support(void) { /* obsolete, to be removed from libpng-1.4.0 */ return -1; } #endif /* PNG_1_0_X */ #endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */ #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #ifdef PNG_SIZE_T /* Added at libpng version 1.2.6 */ PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size)); png_size_t PNGAPI png_convert_size(size_t size) { if (size > (png_size_t)-1) PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ return ((png_size_t)size); } #endif /* PNG_SIZE_T */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ wgd-3.1/src/resources_base/png/pngset.cpp0000644000175000001440000011452211001137472015437 00000000000000 /* pngset.c - storage of image information into info struct * * Last changed in libpng 1.2.17 May 15, 2007 * For conditions of distribution and use, see copyright notice in png.h * Copyright (c) 1998-2007 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * * The functions here are used during reads to store data from the file * into the info struct, and during writes to store application data * into the info struct for writing into the file. This abstracts the * info struct and allows us to change the structure in the future. */ #define PNG_INTERNAL #include #ifdef _MSC_VER #pragma warning( disable : 4996 ) #endif #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_bKGD_SUPPORTED) void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) { png_debug1(1, "in %s storage function\n", "bKGD"); if (png_ptr == NULL || info_ptr == NULL) return; png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16)); info_ptr->valid |= PNG_INFO_bKGD; } #endif #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_cHRM(png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y) { png_debug1(1, "in %s storage function\n", "cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; if (white_x < 0.0 || white_y < 0.0 || red_x < 0.0 || red_y < 0.0 || green_x < 0.0 || green_y < 0.0 || blue_x < 0.0 || blue_y < 0.0) { png_warning(png_ptr, "Ignoring attempt to set negative chromaticity value"); return; } if (white_x > 21474.83 || white_y > 21474.83 || red_x > 21474.83 || red_y > 21474.83 || green_x > 21474.83 || green_y > 21474.83 || blue_x > 21474.83 || blue_y > 21474.83) { png_warning(png_ptr, "Ignoring attempt to set chromaticity value exceeding 21474.83"); return; } info_ptr->x_white = (float)white_x; info_ptr->y_white = (float)white_y; info_ptr->x_red = (float)red_x; info_ptr->y_red = (float)red_y; info_ptr->x_green = (float)green_x; info_ptr->y_green = (float)green_y; info_ptr->x_blue = (float)blue_x; info_ptr->y_blue = (float)blue_y; #ifdef PNG_FIXED_POINT_SUPPORTED info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5); info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5); info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5); info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5); info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5); info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5); info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5); info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5); #endif info_ptr->valid |= PNG_INFO_cHRM; } #endif #ifdef PNG_FIXED_POINT_SUPPORTED void PNGAPI png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y) { png_debug1(1, "in %s storage function\n", "cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; if (white_x < 0 || white_y < 0 || red_x < 0 || red_y < 0 || green_x < 0 || green_y < 0 || blue_x < 0 || blue_y < 0) { png_warning(png_ptr, "Ignoring attempt to set negative chromaticity value"); return; } #ifdef PNG_FLOATING_POINT_SUPPORTED if (white_x > (double) PNG_UINT_31_MAX || white_y > (double) PNG_UINT_31_MAX || red_x > (double) PNG_UINT_31_MAX || red_y > (double) PNG_UINT_31_MAX || green_x > (double) PNG_UINT_31_MAX || green_y > (double) PNG_UINT_31_MAX || blue_x > (double) PNG_UINT_31_MAX || blue_y > (double) PNG_UINT_31_MAX) #else if (white_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || white_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || red_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || red_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || green_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || green_y > (png_fixed_point) PNG_UINT_31_MAX/100000L || blue_x > (png_fixed_point) PNG_UINT_31_MAX/100000L || blue_y > (png_fixed_point) PNG_UINT_31_MAX/100000L) #endif { png_warning(png_ptr, "Ignoring attempt to set chromaticity value exceeding 21474.83"); return; } info_ptr->int_x_white = white_x; info_ptr->int_y_white = white_y; info_ptr->int_x_red = red_x; info_ptr->int_y_red = red_y; info_ptr->int_x_green = green_x; info_ptr->int_y_green = green_y; info_ptr->int_x_blue = blue_x; info_ptr->int_y_blue = blue_y; #ifdef PNG_FLOATING_POINT_SUPPORTED info_ptr->x_white = (float)(white_x/100000.); info_ptr->y_white = (float)(white_y/100000.); info_ptr->x_red = (float)( red_x/100000.); info_ptr->y_red = (float)( red_y/100000.); info_ptr->x_green = (float)(green_x/100000.); info_ptr->y_green = (float)(green_y/100000.); info_ptr->x_blue = (float)( blue_x/100000.); info_ptr->y_blue = (float)( blue_y/100000.); #endif info_ptr->valid |= PNG_INFO_cHRM; } #endif #endif #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) { double gamma; png_debug1(1, "in %s storage function\n", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; /* Check for overflow */ if (file_gamma > 21474.83) { png_warning(png_ptr, "Limiting gamma to 21474.83"); gamma=21474.83; } else gamma=file_gamma; info_ptr->gamma = (float)gamma; #ifdef PNG_FIXED_POINT_SUPPORTED info_ptr->int_gamma = (int)(gamma*100000.+.5); #endif info_ptr->valid |= PNG_INFO_gAMA; if(gamma == 0.0) png_warning(png_ptr, "Setting gamma=0"); } #endif void PNGAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point int_gamma) { png_fixed_point gamma; png_debug1(1, "in %s storage function\n", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) { png_warning(png_ptr, "Limiting gamma to 21474.83"); gamma=PNG_UINT_31_MAX; } else { if (int_gamma < 0) { png_warning(png_ptr, "Setting negative gamma to zero"); gamma=0; } else gamma=int_gamma; } #ifdef PNG_FLOATING_POINT_SUPPORTED info_ptr->gamma = (float)(gamma/100000.); #endif #ifdef PNG_FIXED_POINT_SUPPORTED info_ptr->int_gamma = gamma; #endif info_ptr->valid |= PNG_INFO_gAMA; if(gamma == 0) png_warning(png_ptr, "Setting gamma=0"); } #endif #if defined(PNG_hIST_SUPPORTED) void PNGAPI png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) { int i; png_debug1(1, "in %s storage function\n", "hIST"); if (png_ptr == NULL || info_ptr == NULL) return; if (info_ptr->num_palette <= 0 || info_ptr->num_palette > PNG_MAX_PALETTE_LENGTH) { png_warning(png_ptr, "Invalid palette size, hIST allocation skipped."); return; } #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); #endif /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); if (png_ptr->hist == NULL) { png_warning(png_ptr, "Insufficient memory for hIST chunk data."); return; } for (i = 0; i < info_ptr->num_palette; i++) png_ptr->hist[i] = hist[i]; info_ptr->hist = png_ptr->hist; info_ptr->valid |= PNG_INFO_hIST; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_HIST; #else png_ptr->flags |= PNG_FLAG_FREE_HIST; #endif } #endif void PNGAPI png_set_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_type, int compression_type, int filter_type) { png_debug1(1, "in %s storage function\n", "IHDR"); if (png_ptr == NULL || info_ptr == NULL) return; /* check for width and height valid values */ if (width == 0 || height == 0) png_error(png_ptr, "Image width or height is zero in IHDR"); #ifdef PNG_SET_USER_LIMITS_SUPPORTED if (width > png_ptr->user_width_max || height > png_ptr->user_height_max) png_error(png_ptr, "image size exceeds user limits in IHDR"); #else if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX) png_error(png_ptr, "image size exceeds user limits in IHDR"); #endif if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX) png_error(png_ptr, "Invalid image size in IHDR"); if ( width > (PNG_UINT_32_MAX >> 3) /* 8-byte RGBA pixels */ - 64 /* bigrowbuf hack */ - 1 /* filter byte */ - 7*8 /* rounding of width to multiple of 8 pixels */ - 8) /* extra max_pixel_depth pad */ png_warning(png_ptr, "Width is too large for libpng to process pixels"); /* check other values */ if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth in IHDR"); if (color_type < 0 || color_type == 1 || color_type == 5 || color_type > 6) png_error(png_ptr, "Invalid color type in IHDR"); if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || ((color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY_ALPHA || color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) png_error(png_ptr, "Invalid color type/bit depth combination in IHDR"); if (interlace_type >= PNG_INTERLACE_LAST) png_error(png_ptr, "Unknown interlace method in IHDR"); if (compression_type != PNG_COMPRESSION_TYPE_BASE) png_error(png_ptr, "Unknown compression method in IHDR"); #if defined(PNG_MNG_FEATURES_SUPPORTED) /* Accept filter_method 64 (intrapixel differencing) only if * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and * 2. Libpng did not read a PNG signature (this filter_method is only * used in PNG datastreams that are embedded in MNG datastreams) and * 3. The application called png_permit_mng_features with a mask that * included PNG_FLAG_MNG_FILTER_64 and * 4. The filter_method is 64 and * 5. The color_type is RGB or RGBA */ if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); if(filter_type != PNG_FILTER_TYPE_BASE) { if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA))) png_error(png_ptr, "Unknown filter method in IHDR"); if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) png_warning(png_ptr, "Invalid filter method in IHDR"); } #else if(filter_type != PNG_FILTER_TYPE_BASE) png_error(png_ptr, "Unknown filter method in IHDR"); #endif info_ptr->width = width; info_ptr->height = height; info_ptr->bit_depth = (png_byte)bit_depth; info_ptr->color_type =(png_byte) color_type; info_ptr->compression_type = (png_byte)compression_type; info_ptr->filter_type = (png_byte)filter_type; info_ptr->interlace_type = (png_byte)interlace_type; if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->channels = 1; else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR) info_ptr->channels = 3; else info_ptr->channels = 1; if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA) info_ptr->channels++; info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); /* check for potential overflow */ if (width > (PNG_UINT_32_MAX >> 3) /* 8-byte RGBA pixels */ - 64 /* bigrowbuf hack */ - 1 /* filter byte */ - 7*8 /* rounding of width to multiple of 8 pixels */ - 8) /* extra max_pixel_depth pad */ info_ptr->rowbytes = (png_size_t)0; else info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); } #if defined(PNG_oFFs_SUPPORTED) void PNGAPI png_set_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type) { png_debug1(1, "in %s storage function\n", "oFFs"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->x_offset = offset_x; info_ptr->y_offset = offset_y; info_ptr->offset_unit_type = (png_byte)unit_type; info_ptr->valid |= PNG_INFO_oFFs; } #endif #if defined(PNG_pCAL_SUPPORTED) void PNGAPI png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) { png_uint_32 length; int i; png_debug1(1, "in %s storage function\n", "pCAL"); if (png_ptr == NULL || info_ptr == NULL) return; length = png_strlen(purpose) + 1; png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL purpose."); return; } png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); png_debug(3, "storing X0, X1, type, and nparams in info\n"); info_ptr->pcal_X0 = X0; info_ptr->pcal_X1 = X1; info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_nparams = (png_byte)nparams; length = png_strlen(units) + 1; png_debug1(3, "allocating units for info (%lu bytes)\n", length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_units == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL units."); return; } png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); if (info_ptr->pcal_params == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL params."); return; } info_ptr->pcal_params[nparams] = NULL; for (i = 0; i < nparams; i++) { length = png_strlen(params[i]) + 1; png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_params[i] == NULL) { png_warning(png_ptr, "Insufficient memory for pCAL parameter."); return; } png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); } info_ptr->valid |= PNG_INFO_pCAL; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_PCAL; #endif } #endif #if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, double height) { png_debug1(1, "in %s storage function\n", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->scal_unit = (png_byte)unit; info_ptr->scal_pixel_width = width; info_ptr->scal_pixel_height = height; info_ptr->valid |= PNG_INFO_sCAL; } #else #ifdef PNG_FIXED_POINT_SUPPORTED void PNGAPI png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, int unit, png_charp swidth, png_charp sheight) { png_uint_32 length; png_debug1(1, "in %s storage function\n", "sCAL"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->scal_unit = (png_byte)unit; length = png_strlen(swidth) + 1; png_debug1(3, "allocating unit for info (%d bytes)\n", length); info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_width == NULL) { png_warning(png_ptr, "Memory allocation failed while processing sCAL."); } png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); length = png_strlen(sheight) + 1; png_debug1(3, "allocating unit for info (%d bytes)\n", length); info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_height == NULL) { png_free (png_ptr, info_ptr->scal_s_width); png_warning(png_ptr, "Memory allocation failed while processing sCAL."); } png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length); info_ptr->valid |= PNG_INFO_sCAL; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_SCAL; #endif } #endif #endif #endif #if defined(PNG_pHYs_SUPPORTED) void PNGAPI png_set_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type) { png_debug1(1, "in %s storage function\n", "pHYs"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->x_pixels_per_unit = res_x; info_ptr->y_pixels_per_unit = res_y; info_ptr->phys_unit_type = (png_byte)unit_type; info_ptr->valid |= PNG_INFO_pHYs; } #endif void PNGAPI png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp palette, int num_palette) { png_debug1(1, "in %s storage function\n", "PLTE"); if (png_ptr == NULL || info_ptr == NULL) return; if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) { if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Invalid palette length"); else { png_warning(png_ptr, "Invalid palette length"); return; } } /* * It may not actually be necessary to set png_ptr->palette here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. */ #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); #endif /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead of num_palette entries, in case of an invalid PNG file that has too-large sample values. */ png_ptr->palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_PLTE; #else png_ptr->flags |= PNG_FLAG_FREE_PLTE; #endif info_ptr->valid |= PNG_INFO_PLTE; } #if defined(PNG_sBIT_SUPPORTED) void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit) { png_debug1(1, "in %s storage function\n", "sBIT"); if (png_ptr == NULL || info_ptr == NULL) return; png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); info_ptr->valid |= PNG_INFO_sBIT; } #endif #if defined(PNG_sRGB_SUPPORTED) void PNGAPI png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) { png_debug1(1, "in %s storage function\n", "sRGB"); if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->srgb_intent = (png_byte)intent; info_ptr->valid |= PNG_INFO_sRGB; } void PNGAPI png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, int intent) { #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED float file_gamma; #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_fixed_point int_file_gamma; #endif #endif #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif #ifdef PNG_FIXED_POINT_SUPPORTED png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y; #endif #endif png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); if (png_ptr == NULL || info_ptr == NULL) return; png_set_sRGB(png_ptr, info_ptr, intent); #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED file_gamma = (float).45455; png_set_gAMA(png_ptr, info_ptr, file_gamma); #endif #ifdef PNG_FIXED_POINT_SUPPORTED int_file_gamma = 45455L; png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma); #endif #endif #if defined(PNG_cHRM_SUPPORTED) #ifdef PNG_FIXED_POINT_SUPPORTED int_white_x = 31270L; int_white_y = 32900L; int_red_x = 64000L; int_red_y = 33000L; int_green_x = 30000L; int_green_y = 60000L; int_blue_x = 15000L; int_blue_y = 6000L; png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y); #endif #ifdef PNG_FLOATING_POINT_SUPPORTED white_x = (float).3127; white_y = (float).3290; red_x = (float).64; red_y = (float).33; green_x = (float).30; green_y = (float).60; blue_x = (float).15; blue_y = (float).06; png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); #endif #endif } #endif #if defined(PNG_iCCP_SUPPORTED) void PNGAPI png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_charp name, int compression_type, png_charp profile, png_uint_32 proflen) { png_charp new_iccp_name; png_charp new_iccp_profile; png_debug1(1, "in %s storage function\n", "iCCP"); if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; new_iccp_name = (png_charp)png_malloc_warn(png_ptr, png_strlen(name)+1); if (new_iccp_name == NULL) { png_warning(png_ptr, "Insufficient memory to process iCCP chunk."); return; } png_strncpy(new_iccp_name, name, png_sizeof(new_iccp_name)); new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen); if (new_iccp_profile == NULL) { png_free (png_ptr, new_iccp_name); png_warning(png_ptr, "Insufficient memory to process iCCP profile."); return; } png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); info_ptr->iccp_proflen = proflen; info_ptr->iccp_name = new_iccp_name; info_ptr->iccp_profile = new_iccp_profile; /* Compression is always zero but is here so the API and info structure * does not have to change if we introduce multiple compression types */ info_ptr->iccp_compression = (png_byte)compression_type; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ICCP; #endif info_ptr->valid |= PNG_INFO_iCCP; } #endif #if defined(PNG_TEXT_SUPPORTED) void PNGAPI png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text) { int ret; ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); if (ret) png_error(png_ptr, "Insufficient memory to store text"); } int /* PRIVATE */ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, int num_text) { int i; png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? "text" : (png_const_charp)png_ptr->chunk_name)); if (png_ptr == NULL || info_ptr == NULL || num_text == 0) return(0); /* Make sure we have enough space in the "text" array in info_struct * to hold all of the incoming text_ptr objects. */ if (info_ptr->num_text + num_text > info_ptr->max_text) { if (info_ptr->text != NULL) { png_textp old_text; int old_max; old_max = info_ptr->max_text; info_ptr->max_text = info_ptr->num_text + num_text + 8; old_text = info_ptr->text; info_ptr->text = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); if (info_ptr->text == NULL) { png_free(png_ptr, old_text); return(1); } png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * png_sizeof(png_text))); png_free(png_ptr, old_text); } else { info_ptr->max_text = num_text + 8; info_ptr->num_text = 0; info_ptr->text = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); if (info_ptr->text == NULL) return(1); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TEXT; #endif } png_debug1(3, "allocated %d entries for info_ptr->text\n", info_ptr->max_text); } for (i = 0; i < num_text; i++) { png_size_t text_length,key_len; png_size_t lang_len,lang_key_len; png_textp textp = &(info_ptr->text[info_ptr->num_text]); if (text_ptr[i].key == NULL) continue; key_len = png_strlen(text_ptr[i].key); if(text_ptr[i].compression <= 0) { lang_len = 0; lang_key_len = 0; } else #ifdef PNG_iTXt_SUPPORTED { /* set iTXt data */ if (text_ptr[i].lang != NULL) lang_len = png_strlen(text_ptr[i].lang); else lang_len = 0; if (text_ptr[i].lang_key != NULL) lang_key_len = png_strlen(text_ptr[i].lang_key); else lang_key_len = 0; } #else { png_warning(png_ptr, "iTXt chunk not supported."); continue; } #endif if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') { text_length = 0; #ifdef PNG_iTXt_SUPPORTED if(text_ptr[i].compression > 0) textp->compression = PNG_ITXT_COMPRESSION_NONE; else #endif textp->compression = PNG_TEXT_COMPRESSION_NONE; } else { text_length = png_strlen(text_ptr[i].text); textp->compression = text_ptr[i].compression; } textp->key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); if (textp->key == NULL) return(1); png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), (int)textp->key); png_memcpy(textp->key, text_ptr[i].key, (png_size_t)(key_len)); *(textp->key+key_len) = '\0'; #ifdef PNG_iTXt_SUPPORTED if (text_ptr[i].compression > 0) { textp->lang=textp->key + key_len + 1; png_memcpy(textp->lang, text_ptr[i].lang, lang_len); *(textp->lang+lang_len) = '\0'; textp->lang_key=textp->lang + lang_len + 1; png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); *(textp->lang_key+lang_key_len) = '\0'; textp->text=textp->lang_key + lang_key_len + 1; } else #endif { #ifdef PNG_iTXt_SUPPORTED textp->lang=NULL; textp->lang_key=NULL; #endif textp->text=textp->key + key_len + 1; } if(text_length) png_memcpy(textp->text, text_ptr[i].text, (png_size_t)(text_length)); *(textp->text+text_length) = '\0'; #ifdef PNG_iTXt_SUPPORTED if(textp->compression > 0) { textp->text_length = 0; textp->itxt_length = text_length; } else #endif { textp->text_length = text_length; #ifdef PNG_iTXt_SUPPORTED textp->itxt_length = 0; #endif } info_ptr->num_text++; png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); } return(0); } #endif #if defined(PNG_tIME_SUPPORTED) void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) { png_debug1(1, "in %s storage function\n", "tIME"); if (png_ptr == NULL || info_ptr == NULL || (png_ptr->mode & PNG_WROTE_tIME)) return; png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); info_ptr->valid |= PNG_INFO_tIME; } #endif #if defined(PNG_tRNS_SUPPORTED) void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, png_color_16p trans_values) { png_debug1(1, "in %s storage function\n", "tRNS"); if (png_ptr == NULL || info_ptr == NULL) return; if (trans != NULL) { /* * It may not actually be necessary to set png_ptr->trans here; * we do it for backward compatibility with the way the png_handle_tRNS * function used to do the allocation. */ #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); #endif /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, (png_uint_32)PNG_MAX_PALETTE_LENGTH); if (num_trans <= PNG_MAX_PALETTE_LENGTH) png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TRNS; #else png_ptr->flags |= PNG_FLAG_FREE_TRNS; #endif } if (trans_values != NULL) { png_memcpy(&(info_ptr->trans_values), trans_values, png_sizeof(png_color_16)); if (num_trans == 0) num_trans = 1; } info_ptr->num_trans = (png_uint_16)num_trans; info_ptr->valid |= PNG_INFO_tRNS; } #endif #if defined(PNG_sPLT_SUPPORTED) void PNGAPI png_set_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tp entries, int nentries) { png_sPLT_tp np; int i; if (png_ptr == NULL || info_ptr == NULL) return; np = (png_sPLT_tp)png_malloc_warn(png_ptr, (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); if (np == NULL) { png_warning(png_ptr, "No memory for sPLT palettes."); return; } png_memcpy(np, info_ptr->splt_palettes, info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); png_free(png_ptr, info_ptr->splt_palettes); info_ptr->splt_palettes=NULL; for (i = 0; i < nentries; i++) { png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; png_sPLT_tp from = entries + i; to->name = (png_charp)png_malloc_warn(png_ptr, png_strlen(from->name) + 1); if (to->name == NULL) { png_warning(png_ptr, "Out of memory while processing sPLT chunk"); } /* TODO: use png_malloc_warn */ png_strncpy(to->name, from->name, png_strlen(from->name)); to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, from->nentries * png_sizeof(png_sPLT_entry)); /* TODO: use png_malloc_warn */ png_memcpy(to->entries, from->entries, from->nentries * png_sizeof(png_sPLT_entry)); if (to->entries == NULL) { png_warning(png_ptr, "Out of memory while processing sPLT chunk"); png_free(png_ptr,to->name); to->name = NULL; } to->nentries = from->nentries; to->depth = from->depth; } info_ptr->splt_palettes = np; info_ptr->splt_palettes_num += nentries; info_ptr->valid |= PNG_INFO_sPLT; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_SPLT; #endif } #endif /* PNG_sPLT_SUPPORTED */ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) void PNGAPI png_set_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) { png_unknown_chunkp np; int i; if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) return; np = (png_unknown_chunkp)png_malloc_warn(png_ptr, (info_ptr->unknown_chunks_num + num_unknowns) * png_sizeof(png_unknown_chunk)); if (np == NULL) { png_warning(png_ptr, "Out of memory while processing unknown chunk."); return; } png_memcpy(np, info_ptr->unknown_chunks, info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); png_free(png_ptr, info_ptr->unknown_chunks); info_ptr->unknown_chunks=NULL; for (i = 0; i < num_unknowns; i++) { png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; png_unknown_chunkp from = unknowns + i; png_strncpy((png_charp)to->name, (png_charp)from->name, 5); to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); if (to->data == NULL) { png_warning(png_ptr, "Out of memory while processing unknown chunk."); } else { png_memcpy(to->data, from->data, from->size); to->size = from->size; /* note our location in the read or write sequence */ to->location = (png_byte)(png_ptr->mode & 0xff); } } info_ptr->unknown_chunks = np; info_ptr->unknown_chunks_num += num_unknowns; #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_UNKN; #endif } void PNGAPI png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, int chunk, int location) { if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < (int)info_ptr->unknown_chunks_num) info_ptr->unknown_chunks[chunk].location = (png_byte)location; } #endif #if defined(PNG_1_0_X) || defined(PNG_1_2_X) #if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) void PNGAPI png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) { /* This function is deprecated in favor of png_permit_mng_features() and will be removed from libpng-1.3.0 */ png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); if (png_ptr == NULL) return; png_ptr->mng_features_permitted = (png_byte) ((png_ptr->mng_features_permitted & (~(PNG_FLAG_MNG_EMPTY_PLTE))) | ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE))); } #endif #endif #if defined(PNG_MNG_FEATURES_SUPPORTED) png_uint_32 PNGAPI png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) { png_debug(1, "in png_permit_mng_features\n"); if (png_ptr == NULL) return (png_uint_32)0; png_ptr->mng_features_permitted = (png_byte)(mng_features & PNG_ALL_MNG_FEATURES); return (png_uint_32)png_ptr->mng_features_permitted; } #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) void PNGAPI png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep chunk_list, int num_chunks) { png_bytep new_list, p; int i, old_num_chunks; if (png_ptr == NULL) return; if (num_chunks == 0) { if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; else png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; if(keep == PNG_HANDLE_CHUNK_ALWAYS) png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; else png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; return; } if (chunk_list == NULL) return; old_num_chunks=png_ptr->num_chunk_list; new_list=(png_bytep)png_malloc(png_ptr, (png_uint_32)(5*(num_chunks+old_num_chunks))); if(png_ptr->chunk_list != NULL) { png_memcpy(new_list, png_ptr->chunk_list, (png_size_t)(5*old_num_chunks)); png_free(png_ptr, png_ptr->chunk_list); png_ptr->chunk_list=NULL; } png_memcpy(new_list+5*old_num_chunks, chunk_list, (png_size_t)(5*num_chunks)); for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; png_ptr->chunk_list=new_list; #ifdef PNG_FREE_ME_SUPPORTED png_ptr->free_me |= PNG_FREE_LIST; #endif } #endif #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) void PNGAPI png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn) { png_debug(1, "in png_set_read_user_chunk_fn\n"); if (png_ptr == NULL) return; png_ptr->read_user_chunk_fn = read_user_chunk_fn; png_ptr->user_chunk_ptr = user_chunk_ptr; } #endif #if defined(PNG_INFO_IMAGE_SUPPORTED) void PNGAPI png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) { png_debug1(1, "in %s storage function\n", "rows"); if (png_ptr == NULL || info_ptr == NULL) return; if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); info_ptr->row_pointers = row_pointers; if(row_pointers) info_ptr->valid |= PNG_INFO_IDAT; } #endif #ifdef PNG_WRITE_SUPPORTED void PNGAPI png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) { if (png_ptr == NULL) return; if(png_ptr->zbuf) png_free(png_ptr, png_ptr->zbuf); png_ptr->zbuf_size = (png_size_t)size; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } #endif void PNGAPI png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) { if (png_ptr && info_ptr) info_ptr->valid &= ~(mask); } #ifndef PNG_1_0_X #ifdef PNG_ASSEMBLER_CODE_SUPPORTED /* function was added to libpng 1.2.0 and should always exist by default */ void PNGAPI png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) { /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ if (png_ptr != NULL) png_ptr->asm_flags = 0; } /* this function was added to libpng 1.2.0 */ void PNGAPI png_set_mmx_thresholds (png_structp png_ptr, png_byte mmx_bitdepth_threshold, png_uint_32 mmx_rowbytes_threshold) { /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ if (png_ptr == NULL) return; } #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED /* this function was added to libpng 1.2.6 */ void PNGAPI png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max) { /* Images with dimensions larger than these limits will be * rejected by png_set_IHDR(). To accept any PNG datastream * regardless of dimensions, set both limits to 0x7ffffffL. */ if(png_ptr == NULL) return; png_ptr->user_width_max = user_width_max; png_ptr->user_height_max = user_height_max; } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ #endif /* ?PNG_1_0_X */ #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ wgd-3.1/src/resources_base/rendertarget.cpp0000644000175000001440000001053411233311614016036 00000000000000#include #include using namespace wgd; using namespace doste; using namespace doste::dvm; RenderTarget::RenderTarget(const OID &o) : Agent(o) { //check extension if(!Extensions::hasFBO()) { std::cout << "Framebuffers not supported\n"; std::cout.flush(); return; } if (get("clear") == Null) clear(true); Texture *tex = texture(); m_width = tex->get("width"); tex->width(m_width); m_height = tex->get("height"); tex->height(m_height); tex->compress(false); if (tex->isLoaded() == false) tex->make(RGBA_HDR); Texture *dtex = depthTexture(); m_dbuf = 0; if (depth()) { if (dtex == 0) { WGDglGenRenderbuffersEXT(1, &m_dbuf); WGDglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_dbuf); WGDglRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT32, m_width, m_height); } else { dtex->compress(false); dtex->width(m_width); dtex->height(m_height); if (dtex->isLoaded() == false) dtex->make(DEPTH_32); } } // create FBO itself WGDglGenFramebuffersEXT(1, &m_fbo); WGDglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); WGDglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex->getGLID(), 0); if (depth()) { if (dtex == 0) { WGDglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_dbuf); } else { WGDglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, dtex->getGLID(), 0); } } if (WGDglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { std::cout << "Framebuffer creation error\n"; } WGDglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } RenderTarget::~RenderTarget() { WGDglDeleteFramebuffersEXT(1, &m_fbo); //Destroy texture? //Resource::destroy(m_tex); if (depth() && (m_dbuf != 0)) { WGDglDeleteRenderbuffersEXT(1, &m_dbuf); } } void RenderTarget::draw() { if (get(ix::source) == Null) { //Use camera and scene Camera *cam = camera(); Scene *sc = scene(); if (cam == 0 || sc == 0) return; //glEnable(GL_TEXTURE_2D); begin(); if (clear()) doclear(); if (Extensions::hasColourClamp()) { WGDglClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE); WGDglClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE); } //glViewport(0,m_height,m_width,m_height); cam->size(m_width, m_height); glEnable(GL_DEPTH_TEST); glDepthMask(1); cam->bind(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glShadeModel(GL_SMOOTH); glDisable(GL_TEXTURE_2D); //glEnable(GL_BLEND); float poss[] = {0.0f,0.0f,0.0f,1.0f}; glLightfv(GL_LIGHT0, GL_POSITION, poss); float amb[] = {0.2f,0.2f,0.2f, 1.0f}; glLightfv(GL_LIGHT0, GL_AMBIENT, amb); float diff[] = {1.0f,1.0f,1.0f, 1.0f}; glLightfv(GL_LIGHT0, GL_DIFFUSE, diff); float spec[] = {1.0f,1.0f,1.0f, 1.0f}; glLightfv(GL_LIGHT0, GL_SPECULAR, spec); sc->draw(cam); //glDisable(GL_BLEND); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); cam->unbind(); glDepthMask(0); glDisable(GL_DEPTH_TEST); if (Extensions::hasColourClamp()) { WGDglClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_TRUE); WGDglClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FIXED_ONLY_ARB); } end(); } else { //glEnable(GL_DEPTH_TEST); //glDepthMask(1); //Use rendertarget. RenderTarget *src = source(); Material *mat = material(); src->draw(); begin(); if (clear()) doclear(); src->bind(); if (mat) mat->bind(); glColor4f(1.0,1.0,1.0,1.0); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex2i(-1, -1); glTexCoord2f(1.0, 0.0); glVertex2i(1, -1); glTexCoord2f(1.0, 1.0); glVertex2i(1, 1); glTexCoord2f(0.0, 1.0); glVertex2i(-1, 1); glEnd(); if (mat) mat->unbind(); src->unbind(); //glDepthMask(0); //glDisable(GL_DEPTH_TEST); end(); } } void RenderTarget::begin() { WGDglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); glViewport(0, 0, m_width, m_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //glOrtho(0, m_width, m_height, 0, 0, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void RenderTarget::end() { WGDglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } void RenderTarget::bind() { texture()->bind(); } void RenderTarget::unbind() { texture()->unbind(); } void RenderTarget::doclear() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | (depth() ? GL_DEPTH_BUFFER_BIT : 0)); } wgd-3.1/src/resources_base/font.cpp0000644000175000001440000001724711233311614014326 00000000000000#include #ifdef WIN32 #include #endif #include #ifdef LINUX #include #include #endif #include #include #include #ifdef _MSC_VER #pragma warning(disable:4996) #endif using namespace wgd; using namespace doste; using namespace doste::dvm; wgd::Font::Font() : Agent() { registerEvents(); } wgd::Font::Font(const OID &res) : Agent(res) { //m_base = 0xFFFFFFFF; //m_needsbuild = false; registerEvents(); //m_needsbuild = true; //if (get(ix::name) != Null) // buildFont(); } wgd::Font::Font(const char* fname, int fsize, bool fbold) : Agent() { registerEvents(); name(fname); size(fsize); bold(fbold); buildFont(); } wgd::Font::~Font() { //if (m_base != 0xFFFFFFFF) // destroyFont(); } namespace wgd { OnEvent(Font, evt_changed) { m_needsbuild = true; //if (m_needsbuild) buildFont(); } OnEvent(Font, evt_make) { } IMPLEMENT_EVENTS(Font,Agent); }; int wgd::Font::CharHeight(char c) { return m_cdata[(int)c].height; } int wgd::Font::CharWidth(char c) { return m_cdata[(int)c].width; } int wgd::Font::CharX(char c) { return m_cdata[(int)c].x; } int wgd::Font::CharY(char c) { return m_cdata[(int)c].y; } void wgd::Font::bind() { if (m_needsbuild) buildFont(); m_needsbuild = false; Texture *tex = texture(); if (tex != 0) tex->bind(); } void wgd::Font::unbind() { Texture *tex = texture(); if (tex != 0) tex->unbind(); } void wgd::Font::buildFont() { //Delete any existing font display lists //if (m_base != 0xFFFFFFFF) // destroyFont(); //Create new GL display lists for this font //m_base = glGenLists(96); Texture *tex; //Make a texture for it if (get(ix::texture) == Null) { tex = new Texture(); tex->compress(false); tex->nearest(true); if (size() < 32) { tex->width(256); tex->height(256); } else { tex->width(512); tex->height(512); } texture(tex); //Processor::processAll(); tex->make(RGBA); //Processor::processAll(); } else { tex = texture(); if (!tex->isLoaded()) { tex->compress(false); tex->nearest(true); if (size() < 32) { tex->width(256); tex->height(256); } else { tex->width(512); tex->height(512); } tex->make(RGBA); } } if (tex == 0) return; #ifdef WIN32 HFONT font; HFONT oldfont; #ifdef UNICODE int wLen = name().size() + 1; wchar_t *wFont = new wchar_t[wLen]; mbstowcs(wFont, name(), wLen); #else char *wFont = strdup(name()); #endif //Ask windows for a font font = CreateFont( -size(),//Height 0, //Width 0, //Angle 0, //Orientation (bold()) ? FW_BOLD : FW_REGULAR,//Weight FALSE, //Italic FALSE, //UNDERLINE FALSE, //Strikeout ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | DEFAULT_PITCH, wFont); //Font name HDC memDC = CreateCompatibleDC(wgd::window->getHDC()); //Select this new font and save the current one. oldfont = (HFONT)SelectObject(memDC, font); //Get windows to generate display lists for this font //wglUseFontBitmaps(memDC, 32, 96, m_base); HBITMAP bmp = CreateCompatibleBitmap(memDC, tex->width(),tex->height()); HBITMAP oldbmp = (HBITMAP)SelectObject(memDC, bmp); char letter = '@'; int x = 0; int y = 0;// size(); int w; int h; //GetCharWidth(memDC, letter, letter, &w); TEXTMETRIC tmet; GetTextMetrics(memDC, &tmet); SetTextColor(memDC, 0x00FFFFFF); SetBkColor(memDC, 0x00000000); w = tmet.tmAveCharWidth; h = tmet.tmHeight; //width(w); //height(h); for (int i=32; i<128; i++) { //if (i >= 65 && i <= 90) // letter = i+33; //else letter = i; GetCharWidth(memDC, letter, letter, &w); #ifdef UNICODE wchar_t *wbuf = new wchar_t[2]; mbstowcs(wbuf, &letter, 2); TextOut(memDC, x, y, (LPCWSTR)wbuf, 1); #else TextOut(memDC, x, y, &letter, 1); #endif m_cdata[i].width = w; m_cdata[i].x = x; m_cdata[i].y = y; m_cdata[i].height = h; x += w; if (x+w > tex->width()) { y += h; x = 0; } }; BITMAPINFO binfo; binfo.bmiHeader.biSize = sizeof(binfo); binfo.bmiHeader.biWidth = tex->width(); binfo.bmiHeader.biHeight = -tex->height(); binfo.bmiHeader.biPlanes = 1; binfo.bmiHeader.biBitCount = 32; binfo.bmiHeader.biCompression = BI_RGB; binfo.bmiHeader.biSizeImage = 0; colour4i *data = new colour4i[tex->width()*tex->height()]; GetDIBits(memDC, bmp, 0, tex->width(), data, &binfo, DIB_RGB_COLORS); for (int i=0; iwidth()*tex->height(); i++) { if (data[i].r != 0 || data[i].g != 0 || data[i].b != 0) data[i].a = 255; //data[i].r = 255; } if (!tex->setPixels(0,0,tex->width(),tex->height(), data)) { std::cout << "Failed to set font pixels\n"; } delete [] data; //Restore the previous font. SelectObject(memDC, oldfont); SelectObject(memDC, oldbmp); DeleteObject(bmp); DeleteObject(font); DeleteDC(memDC); #endif #ifdef LINUX XFontStruct *font; //Linux needs a font string so create it char *fstring = new char[1000]; sprintf(fstring,"-*-%s-%s-r-*-*-*-%i-75-75-*-*-*-*", (const char*)name(), ((bold()) ? "bold" : "medium"), size()*10); //std::cout << "Font String: " << fstring << std::endl; //Ask X to find and then load this font if it exists. font = XLoadQueryFont(wgd::window->getXDisplay(), fstring); //"-*-helvetica-bold-r-normal--24-*-*-*-p-*-iso8859-1"); delete [] fstring; //Font did not exist so load the default font which surely will exist if (font == NULL) { font = XLoadQueryFont(wgd::window->getXDisplay(), "fixed"); std::cout << "Unable to load correct font.\n"; } //Ask glX to create display lists using this X font. //glXUseXFont(font->fid, 32, 96, m_base); unsigned long valuemask = 0; XGCValues values; Pixmap pix = XCreatePixmap(wgd::window->getXDisplay(), wgd::window->getXWindow(), tex->width(), tex->height(), 32); GC gc = XCreateGC(wgd::window->getXDisplay(), pix, valuemask, &values); XSetFont(wgd::window->getXDisplay(), gc, font->fid); XSetForeground(wgd::window->getXDisplay(), gc, BlackPixel(wgd::window->getXDisplay(), wgd::window->getXScreen())); XFillRectangle(wgd::window->getXDisplay(), pix, gc, 0, 0, tex->width(), tex->height()); XSetForeground(wgd::window->getXDisplay(), gc, WhitePixel(wgd::window->getXDisplay(), wgd::window->getXScreen())); char letter = '@'; int x = 0; int h = font->max_bounds.ascent + font->max_bounds.descent; int y = font->max_bounds.ascent; int w = XTextWidth(font, &letter, 1); std::cout << "Font height = " << h << "\n"; //width(w); //height(size()); //XCharStruct charinfo; for (int i=32; i<128; i++) { letter = i; w = XTextWidth(font, &letter, 1); //XTextExtents(font, &letter, 1, 0, 0, 0, &charinfo); XDrawString(wgd::window->getXDisplay(), pix, gc, x, y, &letter, 1); m_cdata[i].width = w; m_cdata[i].height = h; m_cdata[i].x = x; m_cdata[i].y = y-font->max_bounds.ascent; x += w; if (x+w >= tex->width()) { y += h; x = 0; } }; XImage *img = XGetImage(wgd::window->getXDisplay(), pix, 0, 0, tex->width(), tex->height(), AllPlanes, ZPixmap); //wgd::cout << "Image bits: " << img->depth << "\n"; colour4i *data = (colour4i*)img->data; for (int i=0; iwidth()*tex->height(); i++) { if (data[i].r != 0 || data[i].g != 0 || data[i].b != 0) data[i].a = 255; data[i].r = 255; data[i].g = 255; data[i].b = 255; } if (img == 0) { std::cout << "No font image\n"; } else if (img->data == 0) { std::cout << "No font image data\n"; } else { if (!tex->setPixels(0,0,tex->width(),tex->height(), data)) { std::cout << "Failed to set font pixels\n"; } } XFreePixmap(wgd::window->getXDisplay(), pix); XFreeGC(wgd::window->getXDisplay(), gc); XFreeFont(wgd::window->getXDisplay(), font); #endif } void wgd::Font::destroyFont() { //glDeleteLists(m_base, 96); } wgd-3.1/src/resources_base/texturetga.cpp0000644000175000001440000000657511027450314015560 00000000000000#include #include using namespace wgd; using namespace doste; using namespace doste::dvm; bool TextureTGA::validate(File *f) { unsigned char TGAheaderN[12] = {0,0,2,0,0,0,0,0,0,0,0,0}; unsigned char TGAheaderC[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; unsigned char TGAcompare[12]; f->read(TGAcompare); f->seek(0, File::BEG); if ((memcmp(TGAheaderC, TGAcompare, 12) == 0) || (memcmp(TGAheaderN, TGAcompare, 12) == 0)) { return true; } else { return false; } } bool TextureTGA::load() { unsigned char TGAheaderC[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; unsigned char TGAcompare[12]; unsigned char header[6]; unsigned int bytesperpixel; unsigned int imagesize; unsigned int temp; int mwidth; int mheight; int mcdepth; unsigned char *mdata; File *f = file(); f->open(File::READ); f->read(TGAcompare); //Read the header and extract width and height f->read(header); mwidth = header[1] * 256 + header[0]; mheight = header[3] * 256 + header[2]; //Colour depth, bpp mcdepth = header[4]; bytesperpixel = mcdepth / 8; imagesize = mwidth * mheight * bytesperpixel; //Must be either 24 or 32 bpp. if (header[4] != 24 && header[4] != 32 && header[4] != 8) { std::cout << "Invalid TGA file\n"; f->close(); return false; } mdata = new unsigned char[imagesize+4]; if (memcmp(TGAheaderC, TGAcompare, 12) == 0) { //TGA is compressed with RLE coding. //Buffer to store entire file... faster int curpos = f->tell(); int fsize = f->size() - curpos; f->seek(curpos, File::BEG); char *databuf = new char[fsize]; f->read(databuf, fsize); curpos = 0; int pixcount = mwidth*mheight; int curpix = 0; int curbyte = 0; char colbuf[4]; //Max 4 bytes per pixel. unsigned char chunk; do { //f->read(chunk); chunk = databuf[curpos++]; if (chunk < 128) { //This is a raw chunk. chunk++; //f->read((char*)&mdata[curbyte], bytesperpixel*chunk); memcpy((char*)&mdata[curbyte], &databuf[curpos], bytesperpixel*chunk); curpos += bytesperpixel*chunk; if (mcdepth >= 24) { for (int i=0; iread((char*)colbuf, bytesperpixel); memcpy((char*)colbuf, &databuf[curpos], bytesperpixel); curpos += bytesperpixel; for (int i=0; i= 3) { mdata[curbyte] = colbuf[2]; mdata[curbyte+1] = colbuf[1]; mdata[curbyte+2] = colbuf[0]; if (bytesperpixel == 4) { mdata[curbyte+3] = colbuf[3]; } } else { mdata[curbyte] = colbuf[0]; } curbyte += bytesperpixel; curpix++; } } } while (curpix < pixcount); delete [] databuf; } else { //TGA is uncompressed so read raw data f->read((char*)mdata, imagesize); //Swap bgr to rgb if (bytesperpixel >= 3) { for (unsigned int i=0; iclose(); data(mdata); width(mwidth); height(mheight); switch (mcdepth) { case 8: format(ALPHA); break; case 24: format(RGB); break; case 32: format(RGBA); break; default: Error(0, "There be something wrong with this tga file."); } return true; } wgd-3.1/src/resources_base/zlib/0000777000175000001440000000000011265576313013703 500000000000000wgd-3.1/src/resources_base/zlib/uncompr.cpp0000644000175000001440000000377610755642352016023 00000000000000/* uncompr.c -- decompress a memory buffer * Copyright (C) 1995-2003 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include /* =========================================================================== Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the compressed buffer. This function can be used to decompress a whole file at once if the input file is mmap'ed. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted. */ int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) { z_stream stream; int err; stream.next_in = (Bytef*)source; stream.avail_in = (uInt)sourceLen; /* Check for source > 64K on 16-bit machine: */ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; stream.next_out = dest; stream.avail_out = (uInt)*destLen; if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; err = inflateInit(&stream); if (err != Z_OK) return err; err = inflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { inflateEnd(&stream); if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) return Z_DATA_ERROR; return err; } *destLen = stream.total_out; err = inflateEnd(&stream); return err; } wgd-3.1/src/resources_base/zlib/inftrees.cpp0000644000175000001440000003270710755642352016153 00000000000000/* inftrees.c -- generate Huffman trees for efficient decoding * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include #include #define MAXBITS 15 const char inflate_copyright[] = " inflate 1.2.3 Copyright 1995-2005 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep thiss copyright string in the executable of your product. */ /* Build a set of tables to decode the provided canonical Huffman code. The code lengths are lens[0..codes-1]. The result starts at *table, whose indices are 0..2^bits-1. work is a writable array of at least lens shorts, which is used as a work area. type is the type of code to be generated, CODES, LENS, or DISTS. On return, zero is success, -1 is an invalid code, and +1 means that ENOUGH isn't enough. table on return points to the next available entry's address. bits is the requested root table index bits, and on return it is the actual root table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ unsigned root; /* number of index bits for root table */ unsigned curr; /* number of index bits for current table */ unsigned drop; /* code bits to drop for sub-table */ int left; /* number of prefix codes available */ unsigned used; /* code entries in table used */ unsigned huff; /* Huffman code */ unsigned incr; /* for incrementing code, index */ unsigned fill; /* index for replicating entries */ unsigned low; /* low bits for current root entry */ unsigned mask; /* mask for low root bits */ code thiss; /* table entry for duplication */ code FAR *next; /* next available space in table */ const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR *extra; /* extra bits table to use */ int end; /* use base and extra for symbol > end */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64}; /* Process a set of code lengths to create a canonical Huffman code. The code lengths are lens[0..codes-1]. Each length corresponds to the symbols 0..codes-1. The Huffman code is generated by first sorting the symbols by length from short to long, and retaining the symbol order for codes with equal lengths. Then the code starts with all zero bits for the first code of the shortest length, and the codes are integer increments for the same length, and zeros are appended as the length increases. For the deflate format, these bits are stored backwards from their more natural integer increment ordering, and so when the decoding tables are built in the large loop below, the integer codes are incremented backwards. thiss routine assumes, but does not check, that all of the entries in lens[] are in the range 0..MAXBITS. The caller must assure thiss. 1..MAXBITS is interpreted as that code length. zero means that that symbol does not occur in thiss code. The codes are sorted by computing a count of codes for each length, creating from that a table of starting indices for each length in the sorted table, and then entering the symbols in order in the sorted table. The sorted table is work[], with that space being provided by the caller. The length counts are used for other purposes as well, i.e. finding the minimum and maximum length codes, determining if there are any codes at all, checking for a valid set of lengths, and looking ahead at length counts to determine sub-table sizes when building the decoding tables. */ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ for (len = 0; len <= MAXBITS; len++) count[len] = 0; for (sym = 0; sym < codes; sym++) count[lens[sym]]++; /* bound code lengths, force root to be within code lengths */ root = *bits; for (max = MAXBITS; max >= 1; max--) if (count[max] != 0) break; if (root > max) root = max; if (max == 0) { /* no symbols to code at all */ thiss.op = (unsigned char)64; /* invalid code marker */ thiss.bits = (unsigned char)1; thiss.val = (unsigned short)0; *(*table)++ = thiss; /* make a table to force an error */ *(*table)++ = thiss; *bits = 1; return 0; /* no symbols, but wait for decoding to report error */ } for (min = 1; min <= MAXBITS; min++) if (count[min] != 0) break; if (root < min) root = min; /* check for an over-subscribed or incomplete set of lengths */ left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= count[len]; if (left < 0) return -1; /* over-subscribed */ } if (left > 0 && (type == CODES || max != 1)) return -1; /* incomplete set */ /* generate offsets into symbol table for each length for sorting */ offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + count[len]; /* sort symbols by length, by symbol order within each length */ for (sym = 0; sym < codes; sym++) if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; /* Create and fill in decoding tables. In thiss loop, the table being filled is at next and has curr index bits. The code being used is huff with length len. That code is converted to an index by dropping drop bits off of the bottom. For codes where len is less than drop + curr, those top drop + curr - len bits are incremented through all values to fill the table with replicated entries. root is the number of index bits for the root table. When len exceeds root, sub-tables are created pointed to by the root entry with an index of the low root bits of huff. thiss is saved in low to check for when a new sub-table should be started. drop is zero when the root table is being filled, and drop is root when sub-tables are being filled. When a new sub-table is needed, it is necessary to look ahead in the code lengths to determine what size sub-table is needed. The length counts are used for thiss, and so count[] is decremented as codes are entered in the tables. used keeps track of how many table entries have been allocated from the provided *table space. It is checked when a LENS table is being made against the space in *table, ENOUGH, minus the maximum space needed by the worst case distance code, MAXD. thiss should never happen, but the sufficiency of ENOUGH has not been proven exhaustively, hence the check. thiss assumes that when type == LENS, bits == 9. sym increments through all symbols, and the loop terminates when all codes of length max, i.e. all codes, have been processed. thiss routine permits incomplete codes, so another loop after thiss one fills in the rest of the decoding tables with invalid code markers. */ /* set up for code type */ switch (type) { case CODES: base = extra = work; /* dummy value--not used */ end = 19; break; case LENS: base = lbase; base -= 257; extra = lext; extra -= 257; end = 256; break; default: /* DISTS */ base = dbase; extra = dext; end = -1; } /* initialize state for loop */ huff = 0; /* starting code */ sym = 0; /* starting code symbol */ len = min; /* starting code length */ next = *table; /* current table to fill in */ curr = root; /* current table index bits */ drop = 0; /* current bits to drop from code for index */ low = (unsigned)(-1); /* trigger new sub-table when len > root */ used = 1U << root; /* use root table entries */ mask = used - 1; /* mask for comparing low */ /* check available table space */ if (type == LENS && used >= ENOUGH - MAXD) return 1; /* process all codes and make table entries */ for (;;) { /* create table entry */ thiss.bits = (unsigned char)(len - drop); if ((int)(work[sym]) < end) { thiss.op = (unsigned char)0; thiss.val = work[sym]; } else if ((int)(work[sym]) > end) { thiss.op = (unsigned char)(extra[work[sym]]); thiss.val = base[work[sym]]; } else { thiss.op = (unsigned char)(32 + 64); /* end of block */ thiss.val = 0; } /* replicate for those indices with low len bits equal to huff */ incr = 1U << (len - drop); fill = 1U << curr; min = fill; /* save offset to next table */ do { fill -= incr; next[(huff >> drop) + fill] = thiss; } while (fill != 0); /* backwards increment the len-bit code huff */ incr = 1U << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { huff &= incr - 1; huff += incr; } else huff = 0; /* go to next symbol, update count, len */ sym++; if (--(count[len]) == 0) { if (len == max) break; len = lens[work[sym]]; } /* create new sub-table if needed */ if (len > root && (huff & mask) != low) { /* if first time, transition to sub-tables */ if (drop == 0) drop = root; /* increment past last table */ next += min; /* here min is 1 << curr */ /* determine length of next table */ curr = len - drop; left = (int)(1 << curr); while (curr + drop < max) { left -= count[curr + drop]; if (left <= 0) break; curr++; left <<= 1; } /* check for enough space */ used += 1U << curr; if (type == LENS && used >= ENOUGH - MAXD) return 1; /* point entry in root table to sub-table */ low = huff & mask; (*table)[low].op = (unsigned char)curr; (*table)[low].bits = (unsigned char)root; (*table)[low].val = (unsigned short)(next - *table); } } /* Fill in rest of table for incomplete codes. thiss loop is similar to the loop above in incrementing huff for table indices. It is assumed that len is equal to curr + drop, so there is no loop needed to increment through high index bits. When the current sub-table is filled, the loop drops back to the root table to fill in any remaining entries there. */ thiss.op = (unsigned char)64; /* invalid code marker */ thiss.bits = (unsigned char)(len - drop); thiss.val = (unsigned short)0; while (huff != 0) { /* when done with sub-table, drop back to root table */ if (drop != 0 && (huff & mask) != low) { drop = 0; len = root; next = *table; thiss.bits = (unsigned char)len; } /* put invalid code marker in table */ next[huff >> drop] = thiss; /* backwards increment the len-bit code huff */ incr = 1U << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { huff &= incr - 1; huff += incr; } else huff = 0; } /* set return parameters */ *table += used; *bits = root; return 0; } wgd-3.1/src/resources_base/zlib/zutil.cpp0000644000175000001440000001565210755642352015503 00000000000000/* zutil.c -- target dependent utility functions for the compression library * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include #ifndef NO_DUMMY_DECL struct internal_state {int dummy;}; /* for buggy compilers */ #endif const char * const z_errmsg[10] = { "need dictionary", /* Z_NEED_DICT 2 */ "stream end", /* Z_STREAM_END 1 */ "", /* Z_OK 0 */ "file error", /* Z_ERRNO (-1) */ "stream error", /* Z_STREAM_ERROR (-2) */ "data error", /* Z_DATA_ERROR (-3) */ "insufficient memory", /* Z_MEM_ERROR (-4) */ "buffer error", /* Z_BUF_ERROR (-5) */ "incompatible version",/* Z_VERSION_ERROR (-6) */ ""}; const char * ZEXPORT zlibVersion() { return ZLIB_VERSION; } uLong ZEXPORT zlibCompileFlags() { uLong flags; flags = 0; switch (sizeof(uInt)) { case 2: break; case 4: flags += 1; break; case 8: flags += 2; break; default: flags += 3; } switch (sizeof(uLong)) { case 2: break; case 4: flags += 1 << 2; break; case 8: flags += 2 << 2; break; default: flags += 3 << 2; } switch (sizeof(voidpf)) { case 2: break; case 4: flags += 1 << 4; break; case 8: flags += 2 << 4; break; default: flags += 3 << 4; } switch (sizeof(z_off_t)) { case 2: break; case 4: flags += 1 << 6; break; case 8: flags += 2 << 6; break; default: flags += 3 << 6; } #ifdef DEBUG flags += 1 << 8; #endif #if defined(ASMV) || defined(ASMINF) flags += 1 << 9; #endif #ifdef ZLIB_WINAPI flags += 1 << 10; #endif #ifdef BUILDFIXED flags += 1 << 12; #endif #ifdef DYNAMIC_CRC_TABLE flags += 1 << 13; #endif #ifdef NO_GZCOMPRESS flags += 1L << 16; #endif #ifdef NO_GZIP flags += 1L << 17; #endif #ifdef PKZIP_BUG_WORKAROUND flags += 1L << 20; #endif #ifdef FASTEST flags += 1L << 21; #endif #ifdef STDC # ifdef NO_vsnprintf flags += 1L << 25; # ifdef HAS_vsprintf_void flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void flags += 1L << 26; # endif # endif #else flags += 1L << 24; # ifdef NO_snprintf flags += 1L << 25; # ifdef HAS_sprintf_void flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void flags += 1L << 26; # endif # endif #endif return flags; } #ifdef DEBUG # ifndef verbose # define verbose 0 # endif int z_verbose = verbose; void z_error (m) char *m; { fprintf(stderr, "%s\n", m); exit(1); } #endif /* exported to allow conversion of error code to string for compress() and * uncompress() */ const char * ZEXPORT zError(int err) { return ERR_MSG(err); } #if defined(_WIN32_WCE) /* The Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. */ int errno = 0; #endif #ifndef HAVE_MEMCPY void zmemcpy(dest, source, len) Bytef* dest; const Bytef* source; uInt len; { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } int zmemcmp(s1, s2, len) const Bytef* s1; const Bytef* s2; uInt len; { uInt j; for (j = 0; j < len; j++) { if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; } return 0; } void zmemzero(dest, len) Bytef* dest; uInt len; { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ } while (--len != 0); } #endif #ifdef SYS16BIT #ifdef __TURBOC__ /* Turbo C in 16-bit mode */ # define MY_ZCALLOC /* Turbo C malloc() does not allow dynamic allocation of 64K bytes * and farmalloc(64K) returns a pointer with an offset of 8, so we * must fix the pointer. Warning: the pointer must be put back to its * original form in order to free it, use zcfree(). */ #define MAX_PTR 10 /* 10*64K = 640K */ local int next_ptr = 0; typedef struct ptr_table_s { voidpf org_ptr; voidpf new_ptr; } ptr_table; local ptr_table table[MAX_PTR]; /* This table is used to remember the original form of pointers * to large buffers (64K). Such pointers are normalized with a zero offset. * Since MSDOS is not a preemptive multitasking OS, this table is not * protected from concurrent access. This hack doesn't work anyway on * a protected system like OS/2. Use Microsoft C instead. */ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { voidpf buf = opaque; /* just to make some compilers happy */ ulg bsize = (ulg)items*size; /* If we allocate less than 65520 bytes, we assume that farmalloc * will return a usable pointer which doesn't have to be normalized. */ if (bsize < 65520L) { buf = farmalloc(bsize); if (*(ush*)&buf != 0) return buf; } else { buf = farmalloc(bsize + 16L); } if (buf == NULL || next_ptr >= MAX_PTR) return NULL; table[next_ptr].org_ptr = buf; /* Normalize the pointer to seg:0 */ *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *(ush*)&buf = 0; table[next_ptr++].new_ptr = buf; return buf; } void zcfree (voidpf opaque, voidpf ptr) { int n; if (*(ush*)&ptr != 0) { /* object < 64K */ farfree(ptr); return; } /* Find the original pointer */ for (n = 0; n < next_ptr; n++) { if (ptr != table[n].new_ptr) continue; farfree(table[n].org_ptr); while (++n < next_ptr) { table[n-1] = table[n]; } next_ptr--; return; } ptr = opaque; /* just to make some compilers happy */ Assert(0, "zcfree: ptr not found"); } #endif /* __TURBOC__ */ #ifdef M_I86 /* Microsoft C in 16-bit mode */ # define MY_ZCALLOC #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) # define _halloc halloc # define _hfree hfree #endif voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { if (opaque) opaque = 0; /* to make compiler happy */ return _halloc((long)items, size); } void zcfree (voidpf opaque, voidpf ptr) { if (opaque) opaque = 0; /* to make compiler happy */ _hfree(ptr); } #endif /* M_I86 */ #endif /* SYS16BIT */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC extern voidp malloc OF((uInt size)); extern voidp calloc OF((uInt items, uInt size)); extern void free OF((voidpf ptr)); #endif voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) { if (opaque) items += size - size; /* make compiler happy */ return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } void zcfree (voidpf opaque, voidpf ptr) { free(ptr); if (opaque) return; /* make compiler happy */ } #endif /* MY_ZCALLOC */ wgd-3.1/src/resources_base/zlib/adler32.cpp0000644000175000001440000001115710755642352015564 00000000000000/* adler32.c -- compute the Adler-32 checksum of a data stream * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include #define BASE 65521UL /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); /* use NO_DIVIDE if your processor does not do division in hardware */ #ifdef NO_DIVIDE # define MOD(a) \ do { \ if (a >= (BASE << 16)) a -= (BASE << 16); \ if (a >= (BASE << 15)) a -= (BASE << 15); \ if (a >= (BASE << 14)) a -= (BASE << 14); \ if (a >= (BASE << 13)) a -= (BASE << 13); \ if (a >= (BASE << 12)) a -= (BASE << 12); \ if (a >= (BASE << 11)) a -= (BASE << 11); \ if (a >= (BASE << 10)) a -= (BASE << 10); \ if (a >= (BASE << 9)) a -= (BASE << 9); \ if (a >= (BASE << 8)) a -= (BASE << 8); \ if (a >= (BASE << 7)) a -= (BASE << 7); \ if (a >= (BASE << 6)) a -= (BASE << 6); \ if (a >= (BASE << 5)) a -= (BASE << 5); \ if (a >= (BASE << 4)) a -= (BASE << 4); \ if (a >= (BASE << 3)) a -= (BASE << 3); \ if (a >= (BASE << 2)) a -= (BASE << 2); \ if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) # define MOD4(a) \ do { \ if (a >= (BASE << 4)) a -= (BASE << 4); \ if (a >= (BASE << 3)) a -= (BASE << 3); \ if (a >= (BASE << 2)) a -= (BASE << 2); \ if (a >= (BASE << 1)) a -= (BASE << 1); \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE # define MOD4(a) a %= BASE #endif /* ========================================================================= */ uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) //uLong ZEXPORT adler32(adler, buf, len) // uLong adler; // const Bytef *buf; // uInt len; { unsigned long sum2; unsigned n; /* split Adler-32 into component sums */ sum2 = (adler >> 16) & 0xffff; adler &= 0xffff; /* in case user likes doing a byte at a time, keep it fast */ if (len == 1) { adler += buf[0]; if (adler >= BASE) adler -= BASE; sum2 += adler; if (sum2 >= BASE) sum2 -= BASE; return adler | (sum2 << 16); } /* initial Adler-32 value (deferred check for len == 1 speed) */ if (buf == Z_NULL) return 1L; /* in case short lengths are provided, keep it somewhat fast */ if (len < 16) { while (len--) { adler += *buf++; sum2 += adler; } if (adler >= BASE) adler -= BASE; MOD4(sum2); /* only added so many BASE's */ return adler | (sum2 << 16); } /* do length NMAX blocks -- requires just one modulo operation */ while (len >= NMAX) { len -= NMAX; n = NMAX / 16; /* NMAX is divisible by 16 */ do { DO16(buf); /* 16 sums unrolled */ buf += 16; } while (--n); MOD(adler); MOD(sum2); } /* do remaining bytes (less than NMAX, still just one modulo) */ if (len) { /* avoid modulos if none remaining */ while (len >= 16) { len -= 16; DO16(buf); buf += 16; } while (len--) { adler += *buf++; sum2 += adler; } MOD(adler); MOD(sum2); } /* return recombined sums */ return adler | (sum2 << 16); } /* ========================================================================= */ uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) //uLong ZEXPORT adler32_combine(adler1, adler2, len2) // uLong adler1; // uLong adler2; // z_off_t len2; { unsigned long sum1; unsigned long sum2; unsigned rem; /* the derivation of this formula is left as an exercise for the reader */ rem = (unsigned)(len2 % BASE); sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); sum1 += (adler2 & 0xffff) + BASE - 1; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; if (sum1 > BASE) sum1 -= BASE; if (sum1 > BASE) sum1 -= BASE; if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); if (sum2 > BASE) sum2 -= BASE; return sum1 | (sum2 << 16); } wgd-3.1/src/resources_base/zlib/trees.cpp0000644000175000001440000012347710755642352015463 00000000000000/* trees.c -- output deflated data using Huffman coding * Copyright (C) 1995-2005 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process uses several Huffman trees. The more * common source values are represented by shorter bit sequences. * * Each code tree is stored in a compressed form which is itself * a Huffman encoding of the lengths of all the code strings (in * ascending order by source values). The actual code strings are * reconstructed from the lengths in the inflate process, as described * in the deflate specification. * * REFERENCES * * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc * * Storer, James A. * Data Compression: Methods and Theory, pp. 49-50. * Computer Science Press, 1988. ISBN 0-7167-8156-5. * * Sedgewick, R. * Algorithms, p290. * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ /* @(#) $Id$ */ /* #define GEN_TREES_H */ #include #ifdef DEBUG # include #endif /* =========================================================================== * Constants */ #define MAX_BL_BITS 7 /* Bit length codes must not exceed MAX_BL_BITS bits */ #define END_BLOCK 256 /* end of block literal code */ #define REP_3_6 16 /* repeat previous bit length 3-6 times (2 bits of repeat count) */ #define REPZ_3_10 17 /* repeat a zero length 3-10 times (3 bits of repeat count) */ #define REPZ_11_138 18 /* repeat a zero length 11-138 times (7 bits of repeat count) */ local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; local const int extra_dbits[D_CODES] /* extra bits for each distance code */ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; local const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; /* The lengths of the bit length codes are sent in order of decreasing * probability, to avoid transmitting the lengths for unused bit length codes. */ #define Buf_size (8 * 2*sizeof(char)) /* Number of bits used within bi_buf. (bi_buf might be implemented on * more than 16 bits on some systems.) */ /* =========================================================================== * Local data. These are initialized only once. */ #define DIST_CODE_LEN 512 /* see definition of array dist_code below */ #if defined(GEN_TREES_H) || !defined(STDC) /* non ANSI compilers may not accept trees.h */ local ct_data static_ltree[L_CODES+2]; /* The static literal tree. Since the bit lengths are imposed, there is no * need for the L_CODES extra codes used during heap construction. However * The codes 286 and 287 are needed to build a canonical tree (see _tr_init * below). */ local ct_data static_dtree[D_CODES]; /* The static distance tree. (Actually a trivial tree since all codes use * 5 bits.) */ uch _dist_code[DIST_CODE_LEN]; /* Distance codes. The first 256 values correspond to the distances * 3 .. 258, the last 256 values correspond to the top 8 bits of * the 15 bit distances. */ uch _length_code[MAX_MATCH-MIN_MATCH+1]; /* length code for each normalized match length (0 == MIN_MATCH) */ local int base_length[LENGTH_CODES]; /* First normalized length for each code (0 = MIN_MATCH) */ local int base_dist[D_CODES]; /* First normalized distance for each code (0 = distance of 1) */ #else # include #endif /* GEN_TREES_H */ struct static_tree_desc_s { const ct_data *static_tree; /* static tree or NULL */ const intf *extra_bits; /* extra bits for each code or NULL */ int extra_base; /* base index for extra_bits */ int elems; /* max number of elements in the tree */ int max_length; /* max bit length for the codes */ }; local static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; local static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; local static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== * Local (static) routines in this file. */ local void tr_static_init OF((void)); local void init_block OF((deflate_state *s)); local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); local void build_tree OF((deflate_state *s, tree_desc *desc)); local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); local int build_bl_tree OF((deflate_state *s)); local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, int blcodes)); local void compress_block OF((deflate_state *s, ct_data *ltree, ct_data *dtree)); local void set_data_type OF((deflate_state *s)); local unsigned bi_reverse OF((unsigned value, int length)); local void bi_windup OF((deflate_state *s)); local void bi_flush OF((deflate_state *s)); local void copy_block OF((deflate_state *s, charf *buf, unsigned len, int header)); #ifdef GEN_TREES_H local void gen_trees_header OF((void)); #endif #ifndef DEBUG # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) /* Send a code of the given tree. c and tree must not have side effects */ #else /* DEBUG */ # define send_code(s, c, tree) \ { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ send_bits(s, tree[c].Code, tree[c].Len); } #endif /* =========================================================================== * Output a short LSB first on the stream. * IN assertion: there is enough room in pendingBuf. */ #define put_short(s, w) { \ put_byte(s, (uch)((w) & 0xff)); \ put_byte(s, (uch)((ush)(w) >> 8)); \ } /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef DEBUG local void send_bits OF((deflate_state *s, int value, int length)); local void send_bits(s, value, length) deflate_state *s; int value; /* value to send */ int length; /* number of bits */ { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; /* If not enough room in bi_buf, use (valid) bits from bi_buf and * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) * unused bits in value. */ if (s->bi_valid > (int)Buf_size - length) { s->bi_buf |= (value << s->bi_valid); put_short(s, s->bi_buf); s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); s->bi_valid += length - Buf_size; } else { s->bi_buf |= value << s->bi_valid; s->bi_valid += length; } } #else /* !DEBUG */ #define send_bits(s, value, length) \ { int len = length;\ if (s->bi_valid > (int)Buf_size - len) {\ int val = value;\ s->bi_buf |= (val << s->bi_valid);\ put_short(s, s->bi_buf);\ s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ s->bi_valid += len - Buf_size;\ } else {\ s->bi_buf |= (value) << s->bi_valid;\ s->bi_valid += len;\ }\ } #endif /* DEBUG */ /* the arguments must not have side effects */ /* =========================================================================== * Initialize the various 'constant' tables. */ local void tr_static_init() { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ int bits; /* bit counter */ int length; /* length value */ int code; /* code value */ int dist; /* distance index */ ush bl_count[MAX_BITS+1]; /* number of codes at each bit length for an optimal tree */ if (static_init_done) return; /* For some embedded targets, global variables are not initialized: */ static_l_desc.static_tree = static_ltree; static_l_desc.extra_bits = extra_lbits; static_d_desc.static_tree = static_dtree; static_d_desc.extra_bits = extra_dbits; static_bl_desc.extra_bits = extra_blbits; /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { base_length[code] = length; for (n = 0; n < (1< dist code (0..29) */ dist = 0; for (code = 0 ; code < 16; code++) { base_dist[code] = dist; for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ for ( ; code < D_CODES; code++) { base_dist[code] = dist << 7; for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { _dist_code[256 + dist++] = (uch)code; } } Assert (dist == 256, "tr_static_init: 256+dist != 512"); /* Construct the codes of the static literal tree */ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; n = 0; while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; /* Codes 286 and 287 do not exist, but we must include them in the * tree construction to get a canonical Huffman tree (longest code * all ones) */ gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { static_dtree[n].Len = 5; static_dtree[n].Code = bi_reverse((unsigned)n, 5); } static_init_done = 1; # ifdef GEN_TREES_H gen_trees_header(); # endif #endif /* defined(GEN_TREES_H) || !defined(STDC) */ } /* =========================================================================== * Genererate the file trees.h describing the static trees. */ #ifdef GEN_TREES_H # ifndef DEBUG # include # endif # define SEPARATOR(i, last, width) \ ((i) == (last)? "\n};\n\n" : \ ((i) % (width) == (width)-1 ? ",\n" : ", ")) void gen_trees_header() { FILE *header = fopen("trees.h", "w"); int i; Assert (header != NULL, "Can't open trees.h"); fprintf(header, "/* header created automatically with -DGEN_TREES_H */\n\n"); fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); for (i = 0; i < L_CODES+2; i++) { fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); } fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); } fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n"); for (i = 0; i < DIST_CODE_LEN; i++) { fprintf(header, "%2u%s", _dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); } fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { fprintf(header, "%2u%s", _length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); } fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); for (i = 0; i < LENGTH_CODES; i++) { fprintf(header, "%1u%s", base_length[i], SEPARATOR(i, LENGTH_CODES-1, 20)); } fprintf(header, "local const int base_dist[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { fprintf(header, "%5u%s", base_dist[i], SEPARATOR(i, D_CODES-1, 10)); } fclose(header); } #endif /* GEN_TREES_H */ /* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ void _tr_init(deflate_state *s) { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.stat_desc = &static_l_desc; s->d_desc.dyn_tree = s->dyn_dtree; s->d_desc.stat_desc = &static_d_desc; s->bl_desc.dyn_tree = s->bl_tree; s->bl_desc.stat_desc = &static_bl_desc; s->bi_buf = 0; s->bi_valid = 0; s->last_eob_len = 8; /* enough lookahead for inflate */ #ifdef DEBUG s->compressed_len = 0L; s->bits_sent = 0L; #endif /* Initialize the first block of the first file: */ init_block(s); } /* =========================================================================== * Initialize a new block. */ local void init_block(deflate_state *s) { int n; /* iterates over tree elements */ /* Initialize the trees. */ for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; s->dyn_ltree[END_BLOCK].Freq = 1; s->opt_len = s->static_len = 0L; s->last_lit = s->matches = 0; } #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. */ #define pqremove(s, tree, top) \ {\ top = s->heap[SMALLEST]; \ s->heap[SMALLEST] = s->heap[s->heap_len--]; \ pqdownheap(s, tree, SMALLEST); \ } /* =========================================================================== * Compares to subtrees, using the tree depth as tie breaker when * the subtrees have equal frequency. This minimizes the worst case length. */ #define smaller(tree, n, m, depth) \ (tree[n].Freq < tree[m].Freq || \ (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) /* =========================================================================== * Restore the heap property by moving down the tree starting at node k, * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). */ local void pqdownheap(deflate_state *s, ct_data *tree, int k) { int v = s->heap[k]; int j = k << 1; /* left son of k */ while (j <= s->heap_len) { /* Set j to the smallest of the two sons: */ if (j < s->heap_len && smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { j++; } /* Exit if v is smaller than both sons */ if (smaller(tree, v, s->heap[j], s->depth)) break; /* Exchange v with the smallest son */ s->heap[k] = s->heap[j]; k = j; /* And continue down the tree, setting j to the left son of k */ j <<= 1; } s->heap[k] = v; } /* =========================================================================== * Compute the optimal bit lengths for a tree and update the total bit length * for the current block. * IN assertion: the fields freq and dad are set, heap[heap_max] and * above are the tree nodes sorted by increasing frequency. * OUT assertions: the field len is set to the optimal bit length, the * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. */ local void gen_bitlen(deflate_state *s, tree_desc *desc) /* the tree descriptor */ { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; const ct_data *stree = desc->stat_desc->static_tree; const intf *extra = desc->stat_desc->extra_bits; int base = desc->stat_desc->extra_base; int max_length = desc->stat_desc->max_length; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ int xbits; /* extra bits */ ush f; /* frequency */ int overflow = 0; /* number of elements with bit length too large */ for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ for (h = s->heap_max+1; h < HEAP_SIZE; h++) { n = s->heap[h]; bits = tree[tree[n].Dad].Len + 1; if (bits > max_length) bits = max_length, overflow++; tree[n].Len = (ush)bits; /* We overwrite tree[n].Dad which is no longer needed */ if (n > max_code) continue; /* not a leaf node */ s->bl_count[bits]++; xbits = 0; if (n >= base) xbits = extra[n-base]; f = tree[n].Freq; s->opt_len += (ulg)f * (bits + xbits); if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits); } if (overflow == 0) return; Trace((stderr,"\nbit length overflow\n")); /* This happens for example on obj2 and pic of the Calgary corpus */ /* Find the first bit length which could increase: */ do { bits = max_length-1; while (s->bl_count[bits] == 0) bits--; s->bl_count[bits]--; /* move one leaf down the tree */ s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ s->bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] */ overflow -= 2; } while (overflow > 0); /* Now recompute all bit lengths, scanning in increasing frequency. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all * lengths instead of fixing only the wrong ones. This idea is taken * from 'ar' written by Haruhiko Okumura.) */ for (bits = max_length; bits != 0; bits--) { n = s->bl_count[bits]; while (n != 0) { m = s->heap[--h]; if (m > max_code) continue; if ((unsigned) tree[m].Len != (unsigned) bits) { Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); s->opt_len += ((long)bits - (long)tree[m].Len) *(long)tree[m].Freq; tree[m].Len = (ush)bits; } n--; } } } /* =========================================================================== * Generate the codes for a given tree and bit counts (which need not be * optimal). * IN assertion: the array bl_count contains the bit length statistics for * the given tree and the field len is set for all tree elements. * OUT assertion: the field code is set for all tree elements of non * zero code length. */ local void gen_codes (ct_data *tree, int max_code, ushf *bl_count) /* number of codes at each bit length */ { ush next_code[MAX_BITS+1]; /* next code value for each bit length */ ush code = 0; /* running code value */ int bits; /* bit index */ int n; /* code index */ /* The distribution counts are first used to generate the code values * without bit reversal. */ for (bits = 1; bits <= MAX_BITS; bits++) { next_code[bits] = code = (code + bl_count[bits-1]) << 1; } /* Check that the bit counts in bl_count are consistent. The last code * must be all ones. */ Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; int elems = desc->stat_desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node; /* new node being created */ /* Construct the initial heap, with least frequent element in * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ s->heap_len = 0, s->heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].Freq != 0) { s->heap[++(s->heap_len)] = max_code = n; s->depth[n] = 0; } else { tree[n].Len = 0; } } /* The pkzip format requires that at least one distance code exists, * and that at least one bit should be sent even if there is only one * possible code. So to avoid special checks later on we force at least * two codes of non zero frequency. */ while (s->heap_len < 2) { node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); tree[node].Freq = 1; s->depth[node] = 0; s->opt_len--; if (stree) s->static_len -= stree[node].Len; /* node is 0 or 1 so it does not have extra bits */ } desc->max_code = max_code; /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, * establish sub-heaps of increasing lengths: */ for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); /* Construct the Huffman tree by repeatedly combining the least two * frequent nodes. */ node = elems; /* next internal node of the tree */ do { pqremove(s, tree, n); /* n = node of least frequency */ m = s->heap[SMALLEST]; /* m = node of next least frequency */ s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ s->heap[--(s->heap_max)] = m; /* Create a new node father of n and m */ tree[node].Freq = tree[n].Freq + tree[m].Freq; s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? s->depth[n] : s->depth[m]) + 1); tree[n].Dad = tree[m].Dad = (ush)node; #ifdef DUMP_BL_TREE if (tree == s->bl_tree) { fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); } #endif /* and insert the new node in the heap */ s->heap[SMALLEST] = node++; pqdownheap(s, tree, SMALLEST); } while (s->heap_len >= 2); s->heap[--(s->heap_max)] = s->heap[SMALLEST]; /* At this point, the fields freq and dad are set. We can now * generate the bit lengths. */ gen_bitlen(s, (tree_desc *)desc); /* The field len is now set, we can generate the bit codes */ gen_codes ((ct_data *)tree, max_code, s->bl_count); } /* =========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ local void scan_tree (deflate_state *s, ct_data *tree, int max_code) /* and its largest code of non zero frequency */ { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; tree[max_code+1].Len = (ush)0xffff; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { s->bl_tree[curlen].Freq += count; } else if (curlen != 0) { if (curlen != prevlen) s->bl_tree[curlen].Freq++; s->bl_tree[REP_3_6].Freq++; } else if (count <= 10) { s->bl_tree[REPZ_3_10].Freq++; } else { s->bl_tree[REPZ_11_138].Freq++; } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ local void send_tree (deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ /* tree[max_code+1].Len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n+1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(s, curlen, s->bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { send_code(s, curlen, s->bl_tree); count--; } Assert(count >= 3 && count <= 6, " 3_6?"); send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); } else if (count <= 10) { send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); } else { send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ local int build_bl_tree(deflate_state *s) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); /* Build the bit length tree: */ build_tree(s, (tree_desc *)(&(s->bl_desc))); /* opt_len now includes the length of the tree representations, except * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; } /* Update opt_len to include the bit length tree and counts */ s->opt_len += 3*(max_blindex+1) + 5+5+4; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); return max_blindex; } /* =========================================================================== * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes) /* number of codes for each tree */ { int rank; /* index in bl_order */ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Tracev((stderr, "\nbl counts: ")); send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ send_bits(s, dcodes-1, 5); send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Tracev((stderr, "\nbl code %2d ", bl_order[rank])); send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); } Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); } /* =========================================================================== * Send a stored block */ void _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int eof) { send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ #ifdef DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; #endif copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ } /* =========================================================================== * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. * The current inflate code requires 9 bits of lookahead. If the * last two codes for the previous block (real code plus EOB) were coded * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode * the last real code. In this case we send two empty static blocks instead * of one. (There are no problems if the previous block is stored or fixed.) * To simplify the code, we assume the worst case of last real code encoded * on one bit only. */ void _tr_align(deflate_state *s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef DEBUG s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ #endif bi_flush(s); /* Of the 10 bits for the empty block, we have already sent * (10 - bi_valid) bits. The lookahead for the last real code (before * the EOB of the previous block) was thus at least one plus the length * of the EOB plus what we have just sent of the empty static block. */ if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef DEBUG s->compressed_len += 10L; #endif bi_flush(s); } s->last_eob_len = 7; } /* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and output the encoded block to the zip file. */ void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ /* Build the Huffman trees unless a stored block is forced */ if (s->level > 0) { /* Check if the file is binary or text */ if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN) set_data_type(s); /* Construct the literal and distance trees */ build_tree(s, (tree_desc *)(&(s->l_desc))); Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, s->static_len)); build_tree(s, (tree_desc *)(&(s->d_desc))); Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, s->static_len)); /* At this point, opt_len and static_len are the total bit lengths of * the compressed block data, excluding the tree representations. */ /* Build the bit length tree for the above two trees, and get the index * in bl_order of the last bit length code to send. */ max_blindex = build_bl_tree(s); /* Determine the best encoding. Compute the block lengths in bytes. */ opt_lenb = (s->opt_len+3+7)>>3; static_lenb = (s->static_len+3+7)>>3; Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, s->last_lit)); if (static_lenb <= opt_lenb) opt_lenb = static_lenb; } else { Assert(buf != (char*)0, "lost buf"); opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ } #ifdef FORCE_STORED if (buf != (char*)0) { /* force stored block */ #else if (stored_len+4 <= opt_lenb && buf != (char*)0) { /* 4: two words for the lengths */ #endif /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. * Otherwise we can't have processed more than WSIZE input bytes since * the last block flush, because compression would have been * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to * transform a block into a stored block. */ _tr_stored_block(s, buf, stored_len, eof); #ifdef FORCE_STATIC } else if (static_lenb >= 0) { /* force static trees */ #else } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { #endif send_bits(s, (STATIC_TREES<<1)+eof, 3); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); #ifdef DEBUG s->compressed_len += 3 + s->static_len; #endif } else { send_bits(s, (DYN_TREES<<1)+eof, 3); send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, max_blindex+1); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); #ifdef DEBUG s->compressed_len += 3 + s->opt_len; #endif } Assert (s->compressed_len == s->bits_sent, "bad compressed size"); /* The above check is made mod 2^32, for files larger than 512 MB * and uLong implemented on 32 bits. */ init_block(s); if (eof) { bi_windup(s); #ifdef DEBUG s->compressed_len += 7; /* align on byte boundary */ #endif } Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, s->compressed_len-7*eof)); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ int _tr_tally (deflate_state *s, unsigned dist, unsigned lc) { s->d_buf[s->last_lit] = (ush)dist; s->l_buf[s->last_lit++] = (uch)lc; if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; } else { s->matches++; /* Here, lc is the match length - MIN_MATCH */ dist--; /* dist = match distance - 1 */ Assert((ush)dist < (ush)MAX_DIST(s) && (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; s->dyn_dtree[d_code(dist)].Freq++; } #ifdef TRUNCATE_BLOCK /* Try to guess if it is profitable to stop the current block here */ if ((s->last_lit & 0x1fff) == 0 && s->level > 2) { /* Compute an upper bound for the compressed length */ ulg out_length = (ulg)s->last_lit*8L; ulg in_length = (ulg)((long)s->strstart - s->block_start); int dcode; for (dcode = 0; dcode < D_CODES; dcode++) { out_length += (ulg)s->dyn_dtree[dcode].Freq * (5L+extra_dbits[dcode]); } out_length >>= 3; Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ", s->last_lit, in_length, out_length, 100L - out_length*100L/in_length)); if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1; } #endif return (s->last_lit == s->lit_bufsize-1); /* We avoid equality with lit_bufsize because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. */ } /* =========================================================================== * Send the block data compressed using the given Huffman trees */ local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree) { unsigned dist; /* distance of matched string */ int lc; /* match length or unmatched char (if dist == 0) */ unsigned lx = 0; /* running index in l_buf */ unsigned code; /* the code to send */ int extra; /* number of extra bits to send */ if (s->last_lit != 0) do { dist = s->d_buf[lx]; lc = s->l_buf[lx++]; if (dist == 0) { send_code(s, lc, ltree); /* send a literal byte */ Tracecv(isgraph(lc), (stderr," '%c' ", lc)); } else { /* Here, lc is the match length - MIN_MATCH */ code = _length_code[lc]; send_code(s, code+LITERALS+1, ltree); /* send the length code */ extra = extra_lbits[code]; if (extra != 0) { lc -= base_length[code]; send_bits(s, lc, extra); /* send the extra length bits */ } dist--; /* dist is now the match distance - 1 */ code = d_code(dist); Assert (code < D_CODES, "bad d_code"); send_code(s, code, dtree); /* send the distance code */ extra = extra_dbits[code]; if (extra != 0) { dist -= base_dist[code]; send_bits(s, dist, extra); /* send the extra distance bits */ } } /* literal or match pair ? */ /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */ Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx, "pendingBuf overflow"); } while (lx < s->last_lit); send_code(s, END_BLOCK, ltree); s->last_eob_len = ltree[END_BLOCK].Len; } /* =========================================================================== * Set the data type to BINARY or TEXT, using a crude approximation: * set it to Z_TEXT if all symbols are either printable characters (33 to 255) * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise. * IN assertion: the fields Freq of dyn_ltree are set. */ local void set_data_type(deflate_state *s) { int n; for (n = 0; n < 9; n++) if (s->dyn_ltree[n].Freq != 0) break; if (n == 9) for (n = 14; n < 32; n++) if (s->dyn_ltree[n].Freq != 0) break; s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY; } /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ local unsigned bi_reverse(unsigned code, int len) { register unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; } while (--len > 0); return res >> 1; } /* =========================================================================== * Flush the bit buffer, keeping at most 7 bits in it. */ local void bi_flush(deflate_state *s) { if (s->bi_valid == 16) { put_short(s, s->bi_buf); s->bi_buf = 0; s->bi_valid = 0; } else if (s->bi_valid >= 8) { put_byte(s, (Byte)s->bi_buf); s->bi_buf >>= 8; s->bi_valid -= 8; } } /* =========================================================================== * Flush the bit buffer and align the output on a byte boundary */ local void bi_windup(deflate_state *s) { if (s->bi_valid > 8) { put_short(s, s->bi_buf); } else if (s->bi_valid > 0) { put_byte(s, (Byte)s->bi_buf); } s->bi_buf = 0; s->bi_valid = 0; #ifdef DEBUG s->bits_sent = (s->bits_sent+7) & ~7; #endif } /* =========================================================================== * Copy a stored block, storing first the length and its * one's complement if requested. */ local void copy_block(deflate_state *s, charf *buf, unsigned len, int header) { bi_windup(s); /* align on byte boundary */ s->last_eob_len = 8; /* enough lookahead for inflate */ if (header) { put_short(s, (ush)len); put_short(s, (ush)~len); #ifdef DEBUG s->bits_sent += 2*16; #endif } #ifdef DEBUG s->bits_sent += (ulg)len<<3; #endif while (len--) { put_byte(s, *buf++); } } wgd-3.1/src/resources_base/zlib/inflate.cpp0000644000175000001440000013732110755642352015754 00000000000000/* inflate.c -- zlib decompression * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* * Change history: * * 1.2.beta0 24 Nov 2002 * - First version -- complete rewrite of inflate to simplify code, avoid * creation of window when not needed, minimize use of window when it is * needed, make inffast.c even faster, implement gzip decoding, and to * improve code readability and style over the previous zlib inflate code * * 1.2.beta1 25 Nov 2002 * - Use pointers for available input and output checking in inffast.c * - Remove input and output counters in inffast.c * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 * - Remove unnecessary second byte pull from length extra in inffast.c * - Unroll direct copy to three copies per loop in inffast.c * * 1.2.beta2 4 Dec 2002 * - Change external routine names to reduce potential conflicts * - Correct filename to inffixed.h for fixed tables in inflate.c * - Make hbuf[] unsigned char to match parameter type in inflate.c * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) * to avoid negation problem on Alphas (64 bit) in inflate.c * * 1.2.beta3 22 Dec 2002 * - Add comments on state->bits assertion in inffast.c * - Add comments on op field in inftrees.h * - Fix bug in reuse of allocated window after inflateReset() * - Remove bit fields--back to byte structure for speed * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths * - Change post-increments to pre-increments in inflate_fast(), PPC biased? * - Add compile time option, POSTINC, to use post-increments instead (Intel?) * - Make MATCH copy in inflate() much faster for when inflate_fast() not used * - Use local copies of stream next and avail values, as well as local bit * buffer and bit count in inflate()--for speed when inflate_fast() not used * * 1.2.beta4 1 Jan 2003 * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings * - Move a comment on output buffer sizes from inffast.c to inflate.c * - Add comments in inffast.c to introduce the inflate_fast() routine * - Rearrange window copies in inflate_fast() for speed and simplification * - Unroll last copy for window match in inflate_fast() * - Use local copies of window variables in inflate_fast() for speed * - Pull out common write == 0 case for speed in inflate_fast() * - Make op and len in inflate_fast() unsigned for consistency * - Add FAR to lcode and dcode declarations in inflate_fast() * - Simplified bad distance check in inflate_fast() * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new * source file infback.c to provide a call-back interface to inflate for * programs like gzip and unzip -- uses window as output buffer to avoid * window copying * * 1.2.beta5 1 Jan 2003 * - Improved inflateBack() interface to allow the caller to provide initial * input in strm. * - Fixed stored blocks bug in inflateBack() * * 1.2.beta6 4 Jan 2003 * - Added comments in inffast.c on effectiveness of POSTINC * - Typecasting all around to reduce compiler warnings * - Changed loops from while (1) or do {} while (1) to for (;;), again to * make compilers happy * - Changed type of window in inflateBackInit() to unsigned char * * * 1.2.beta7 27 Jan 2003 * - Changed many types to unsigned or unsigned short to avoid warnings * - Added inflateCopy() function * * 1.2.0 9 Mar 2003 * - Changed inflateBack() interface to provide separate opaque descriptors * for the in() and out() functions * - Changed inflateBack() argument and in_func typedef to swap the length * and buffer address return values for the input function * - Check next_in and next_out for Z_NULL on entry to inflate() * * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. */ #include #include #include #include #ifdef MAKEFIXED # ifndef BUILDFIXED # define BUILDFIXED # endif #endif /* function prototypes */ local void fixedtables OF((struct inflate_state FAR *state)); local int updatewindow OF((z_streamp strm, unsigned out)); #ifdef BUILDFIXED void makefixed OF((void)); #endif local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, unsigned len)); int ZEXPORT inflateReset(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; strm->adler = 1; /* to support ill-conceived Java test suite */ state->mode = HEAD; state->last = 0; state->havedict = 0; state->dmax = 32768U; state->head = Z_NULL; state->wsize = 0; state->whave = 0; state->write = 0; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; Tracev((stderr, "inflate: reset\n")); return Z_OK; } int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; value &= (1L << bits) - 1; state->hold += value << state->bits; state->bits += bits; return Z_OK; } int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size) { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; state = (struct inflate_state FAR *) ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; if (windowBits < 0) { state->wrap = 0; windowBits = -windowBits; } else { state->wrap = (windowBits >> 4) + 1; #ifdef GUNZIP if (windowBits < 48) windowBits &= 15; #endif } if (windowBits < 8 || windowBits > 15) { ZFREE(strm, state); strm->state = Z_NULL; return Z_STREAM_ERROR; } state->wbits = (unsigned)windowBits; state->window = Z_NULL; return inflateReset(strm); } int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size) { return inflateInit2_(strm, DEF_WBITS, version, stream_size); } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; static code fixed[544]; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { unsigned sym, bits; static code *next; /* literal/length table */ sym = 0; while (sym < 144) state->lens[sym++] = 8; while (sym < 256) state->lens[sym++] = 9; while (sym < 280) state->lens[sym++] = 7; while (sym < 288) state->lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; } #else /* !BUILDFIXED */ # include #endif /* BUILDFIXED */ state->lencode = lenfix; state->lenbits = 9; state->distcode = distfix; state->distbits = 5; } #ifdef MAKEFIXED #include /* Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also defines BUILDFIXED, so the tables are built on the fly. makefixed() writes those tables to stdout, which would be piped to inffixed.h. A small program can simply call makefixed to do this: void makefixed(void); int main(void) { makefixed(); return 0; } Then that can be linked with zlib built with MAKEFIXED defined and run: a.out > inffixed.h */ void makefixed() { unsigned low, size; struct inflate_state state; fixedtables(&state); puts(" /* inffixed.h -- table for decoding fixed codes"); puts(" * Generated automatically by makefixed()."); puts(" */"); puts(""); puts(" /* WARNING: this file should *not* be used by applications."); puts(" It is part of the implementation of this library and is"); puts(" subject to change. Applications should only use zlib.h."); puts(" */"); puts(""); size = 1U << 9; printf(" static const code lenfix[%u] = {", size); low = 0; for (;;) { if ((low % 7) == 0) printf("\n "); printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, state.lencode[low].val); if (++low == size) break; putchar(','); } puts("\n };"); size = 1U << 5; printf("\n static const code distfix[%u] = {", size); low = 0; for (;;) { if ((low % 6) == 0) printf("\n "); printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val); if (++low == size) break; putchar(','); } puts("\n };"); } #endif /* MAKEFIXED */ /* Update the window with the last wsize (normally 32K) bytes written before returning. If window does not exist yet, create it. This is only called when a window is already in use, or when output has been written during this inflate call, but the end of the deflate stream has not been reached yet. It is also called to create a window for dictionary data when a dictionary is loaded. Providing output buffers larger than 32K to inflate() should provide a speed advantage, since only the last 32K of output is copied to the sliding window upon return from inflate(), and since all distances after the first 32K of output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ local int updatewindow(z_streamp strm, unsigned out) { struct inflate_state FAR *state; unsigned copy, dist; state = (struct inflate_state FAR *)strm->state; /* if it hasn't been done already, allocate space for the window */ if (state->window == Z_NULL) { state->window = (unsigned char FAR *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char)); if (state->window == Z_NULL) return 1; } /* if window not in use yet, initialize */ if (state->wsize == 0) { state->wsize = 1U << state->wbits; state->write = 0; state->whave = 0; } /* copy state->wsize or less output bytes into the circular window */ copy = out - strm->avail_out; if (copy >= state->wsize) { zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); state->write = 0; state->whave = state->wsize; } else { dist = state->wsize - state->write; if (dist > copy) dist = copy; zmemcpy(state->window + state->write, strm->next_out - copy, dist); copy -= dist; if (copy) { zmemcpy(state->window, strm->next_out - copy, copy); state->write = copy; state->whave = state->wsize; } else { state->write += dist; if (state->write == state->wsize) state->write = 0; if (state->whave < state->wsize) state->whave += dist; } } return 0; } /* Macros for inflate(): */ /* check function to use adler32() for zlib or crc32() for gzip */ #ifdef GUNZIP # define UPDATE(check, buf, len) \ (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) #else # define UPDATE(check, buf, len) adler32(check, buf, len) #endif /* check macros for header crc */ #ifdef GUNZIP # define CRC2(check, word) \ do { \ hbuf[0] = (unsigned char)(word); \ hbuf[1] = (unsigned char)((word) >> 8); \ check = crc32(check, hbuf, 2); \ } while (0) # define CRC4(check, word) \ do { \ hbuf[0] = (unsigned char)(word); \ hbuf[1] = (unsigned char)((word) >> 8); \ hbuf[2] = (unsigned char)((word) >> 16); \ hbuf[3] = (unsigned char)((word) >> 24); \ check = crc32(check, hbuf, 4); \ } while (0) #endif /* Load registers with state in inflate() for speed */ #define LOAD() \ do { \ put = strm->next_out; \ left = strm->avail_out; \ next = strm->next_in; \ have = strm->avail_in; \ hold = state->hold; \ bits = state->bits; \ } while (0) /* Restore state from registers in inflate() */ #define RESTORE() \ do { \ strm->next_out = put; \ strm->avail_out = left; \ strm->next_in = next; \ strm->avail_in = have; \ state->hold = hold; \ state->bits = bits; \ } while (0) /* Clear the input bit accumulator */ #define INITBITS() \ do { \ hold = 0; \ bits = 0; \ } while (0) /* Get a byte of input into the bit accumulator, or return from inflate() if there is no input available. */ #define PULLBYTE() \ do { \ if (have == 0) goto inf_leave; \ have--; \ hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) /* Assure that there are at least n bits in the bit accumulator. If there is not enough available input to do that, then return from inflate(). */ #define NEEDBITS(n) \ do { \ while (bits < (unsigned)(n)) \ PULLBYTE(); \ } while (0) /* Return the low n bits of the bit accumulator (n < 16) */ #define BITS(n) \ ((unsigned)hold & ((1U << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ do { \ hold >>= (n); \ bits -= (unsigned)(n); \ } while (0) /* Remove zero to seven bits as needed to go to a byte boundary */ #define BYTEBITS() \ do { \ hold >>= bits & 7; \ bits -= bits & 7; \ } while (0) /* Reverse the bytes in a 32-bit value */ #define REVERSE(q) \ ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) /* inflate() uses a state machine to process as much input data and generate as much output data as possible before returning. The state machine is structured roughly as follows: for (;;) switch (state) { ... case STATEn: if (not enough input data or output space to make progress) return; ... make progress ... state = STATEm; break; ... } so when inflate() is called again, the same case is attempted again, and if the appropriate resources are provided, the machine proceeds to the next state. The NEEDBITS() macro is usually the way the state evaluates whether it can proceed or should return. NEEDBITS() does the return if the requested bits are not available. The typical use of the BITS macros is: NEEDBITS(n); ... do something with BITS(n) ... DROPBITS(n); where NEEDBITS(n) either returns from inflate() if there isn't enough input left to load n bits into the accumulator, or it continues. BITS(n) gives the low n bits in the accumulator. When done, DROPBITS(n) drops the low n bits off the accumulator. INITBITS() clears the accumulator and sets the number of available bits to zero. BYTEBITS() discards just enough bits to put the accumulator on a byte boundary. After BYTEBITS() and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return if there is no input available. The decoding of variable length codes uses PULLBYTE() directly in order to pull just enough bytes to decode the next code, and no more. Some states loop until they get enough input, making sure that enough state information is maintained to continue the loop where it left off if NEEDBITS() returns in the loop. For example, want, need, and keep would all have to actually be part of the saved state in case NEEDBITS() returns: case STATEw: while (want < need) { NEEDBITS(n); keep[want++] = BITS(n); DROPBITS(n); } state = STATEx; case STATEx: As shown above, if the next state is also the next case, then the break is omitted. A state may also return if there is not enough output space available to complete that state. Those states are copying stored data, writing a literal byte, and copying a matching string. When returning, a "goto inf_leave" is used to update the total counters, update the check value, and determine whether any progress has been made during that inflate() call in order to return the proper return code. Progress is defined as a change in either strm->avail_in or strm->avail_out. When there is a window, goto inf_leave will update the window with the last output written. If a goto inf_leave occurs in the middle of decompression and there is no window currently, goto inf_leave will create one and copy output to the window for the next call of inflate(). In this implementation, the flush parameter of inflate() only affects the return code (per zlib.h). inflate() always writes as much as possible to strm->next_out, given the space available and the provided input--the effect documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers the allocation of and copying into a sliding window until necessary, which provides the effect documented in zlib.h for Z_FINISH when the entire input stream available. So the only thing the flush parameter actually does is: when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it will return Z_BUF_ERROR if it has not reached the end of the stream. */ int ZEXPORT inflate(z_streamp strm, int flush) { struct inflate_state FAR *state; unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned in, out; /* save starting available input and output */ unsigned copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code thiss; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ #ifdef GUNZIP unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ #endif static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ LOAD(); in = have; out = left; ret = Z_OK; for (;;) switch (state->mode) { case HEAD: if (state->wrap == 0) { state->mode = TYPEDO; break; } NEEDBITS(16); #ifdef GUNZIP if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ state->check = crc32(0L, Z_NULL, 0); CRC2(state->check, hold); INITBITS(); state->mode = FLAGS; break; } state->flags = 0; /* expect zlib header */ if (state->head != Z_NULL) state->head->done = -1; if (!(state->wrap & 1) || /* check if zlib header allowed */ #else if ( #endif ((BITS(8) << 8) + (hold >> 8)) % 31) { strm->msg = (char *)"incorrect header check"; state->mode = BAD; break; } if (BITS(4) != Z_DEFLATED) { strm->msg = (char *)"unknown compression method"; state->mode = BAD; break; } DROPBITS(4); len = BITS(4) + 8; if (len > state->wbits) { strm->msg = (char *)"invalid window size"; state->mode = BAD; break; } state->dmax = 1U << len; Tracev((stderr, "inflate: zlib header ok\n")); strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = hold & 0x200 ? DICTID : TYPE; INITBITS(); break; #ifdef GUNZIP case FLAGS: NEEDBITS(16); state->flags = (int)(hold); if ((state->flags & 0xff) != Z_DEFLATED) { strm->msg = (char *)"unknown compression method"; state->mode = BAD; break; } if (state->flags & 0xe000) { strm->msg = (char *)"unknown header flags set"; state->mode = BAD; break; } if (state->head != Z_NULL) state->head->text = (int)((hold >> 8) & 1); if (state->flags & 0x0200) CRC2(state->check, hold); INITBITS(); state->mode = TIME; case TIME: NEEDBITS(32); if (state->head != Z_NULL) state->head->time = hold; if (state->flags & 0x0200) CRC4(state->check, hold); INITBITS(); state->mode = OS; case OS: NEEDBITS(16); if (state->head != Z_NULL) { state->head->xflags = (int)(hold & 0xff); state->head->os = (int)(hold >> 8); } if (state->flags & 0x0200) CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; case EXLEN: if (state->flags & 0x0400) { NEEDBITS(16); state->length = (unsigned)(hold); if (state->head != Z_NULL) state->head->extra_len = (unsigned)hold; if (state->flags & 0x0200) CRC2(state->check, hold); INITBITS(); } else if (state->head != Z_NULL) state->head->extra = Z_NULL; state->mode = EXTRA; case EXTRA: if (state->flags & 0x0400) { copy = state->length; if (copy > have) copy = have; if (copy) { if (state->head != Z_NULL && state->head->extra != Z_NULL) { len = state->head->extra_len - state->length; zmemcpy(state->head->extra + len, next, len + copy > state->head->extra_max ? state->head->extra_max - len : copy); } if (state->flags & 0x0200) state->check = crc32(state->check, next, copy); have -= copy; next += copy; state->length -= copy; } if (state->length) goto inf_leave; } state->length = 0; state->mode = NAME; case NAME: if (state->flags & 0x0800) { if (have == 0) goto inf_leave; copy = 0; do { len = (unsigned)(next[copy++]); if (state->head != Z_NULL && state->head->name != Z_NULL && state->length < state->head->name_max) state->head->name[state->length++] = len; } while (len && copy < have); if (state->flags & 0x0200) state->check = crc32(state->check, next, copy); have -= copy; next += copy; if (len) goto inf_leave; } else if (state->head != Z_NULL) state->head->name = Z_NULL; state->length = 0; state->mode = COMMENT; case COMMENT: if (state->flags & 0x1000) { if (have == 0) goto inf_leave; copy = 0; do { len = (unsigned)(next[copy++]); if (state->head != Z_NULL && state->head->comment != Z_NULL && state->length < state->head->comm_max) state->head->comment[state->length++] = len; } while (len && copy < have); if (state->flags & 0x0200) state->check = crc32(state->check, next, copy); have -= copy; next += copy; if (len) goto inf_leave; } else if (state->head != Z_NULL) state->head->comment = Z_NULL; state->mode = HCRC; case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); if (hold != (state->check & 0xffff)) { strm->msg = (char *)"header crc mismatch"; state->mode = BAD; break; } INITBITS(); } if (state->head != Z_NULL) { state->head->hcrc = (int)((state->flags >> 9) & 1); state->head->done = 1; } strm->adler = state->check = crc32(0L, Z_NULL, 0); state->mode = TYPE; break; #endif case DICTID: NEEDBITS(32); strm->adler = state->check = REVERSE(hold); INITBITS(); state->mode = DICT; case DICT: if (state->havedict == 0) { RESTORE(); return Z_NEED_DICT; } strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = TYPE; case TYPE: if (flush == Z_BLOCK) goto inf_leave; case TYPEDO: if (state->last) { BYTEBITS(); state->mode = CHECK; break; } NEEDBITS(3); state->last = BITS(1); DROPBITS(1); switch (BITS(2)) { case 0: /* stored block */ Tracev((stderr, "inflate: stored block%s\n", state->last ? " (last)" : "")); state->mode = STORED; break; case 1: /* fixed block */ fixedtables(state); Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : "")); state->mode = LEN; /* decode codes */ break; case 2: /* dynamic block */ Tracev((stderr, "inflate: dynamic codes block%s\n", state->last ? " (last)" : "")); state->mode = TABLE; break; case 3: strm->msg = (char *)"invalid block type"; state->mode = BAD; } DROPBITS(2); break; case STORED: BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = (char *)"invalid stored block lengths"; state->mode = BAD; break; } state->length = (unsigned)hold & 0xffff; Tracev((stderr, "inflate: stored length %u\n", state->length)); INITBITS(); state->mode = COPY; case COPY: copy = state->length; if (copy) { if (copy > have) copy = have; if (copy > left) copy = left; if (copy == 0) goto inf_leave; zmemcpy(put, next, copy); have -= copy; next += copy; left -= copy; put += copy; state->length -= copy; break; } Tracev((stderr, "inflate: stored end\n")); state->mode = TYPE; break; case TABLE: NEEDBITS(14); state->nlen = BITS(5) + 257; DROPBITS(5); state->ndist = BITS(5) + 1; DROPBITS(5); state->ncode = BITS(4) + 4; DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { strm->msg = (char *)"too many length or distance symbols"; state->mode = BAD; break; } #endif Tracev((stderr, "inflate: table sizes ok\n")); state->have = 0; state->mode = LENLENS; case LENLENS: while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (unsigned short)BITS(3); DROPBITS(3); } while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); state->have = 0; state->mode = CODELENS; case CODELENS: while (state->have < state->nlen + state->ndist) { for (;;) { thiss = state->lencode[BITS(state->lenbits)]; if ((unsigned)(thiss.bits) <= bits) break; PULLBYTE(); } if (thiss.val < 16) { NEEDBITS(thiss.bits); DROPBITS(thiss.bits); state->lens[state->have++] = thiss.val; } else { if (thiss.val == 16) { NEEDBITS(thiss.bits + 2); DROPBITS(thiss.bits); if (state->have == 0) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } len = state->lens[state->have - 1]; copy = 3 + BITS(2); DROPBITS(2); } else if (thiss.val == 17) { NEEDBITS(thiss.bits + 3); DROPBITS(thiss.bits); len = 0; copy = 3 + BITS(3); DROPBITS(3); } else { NEEDBITS(thiss.bits + 7); DROPBITS(thiss.bits); len = 0; copy = 11 + BITS(7); DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } while (copy--) state->lens[state->have++] = (unsigned short)len; } } /* handle error breaks in while */ if (state->mode == BAD) break; /* build code tables */ state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; break; } state->distcode = (code const FAR *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; state->mode = BAD; break; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; case LEN: if (have >= 6 && left >= 258) { RESTORE(); inflate_fast(strm, out); LOAD(); break; } for (;;) { thiss = state->lencode[BITS(state->lenbits)]; if ((unsigned)(thiss.bits) <= bits) break; PULLBYTE(); } if (thiss.op && (thiss.op & 0xf0) == 0) { last = thiss; for (;;) { thiss = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + thiss.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(thiss.bits); state->length = (unsigned)thiss.val; if ((int)(thiss.op) == 0) { Tracevv((stderr, thiss.val >= 0x20 && thiss.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", thiss.val)); state->mode = LIT; break; } if (thiss.op & 32) { Tracevv((stderr, "inflate: end of block\n")); state->mode = TYPE; break; } if (thiss.op & 64) { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } state->extra = (unsigned)(thiss.op) & 15; state->mode = LENEXT; case LENEXT: if (state->extra) { NEEDBITS(state->extra); state->length += BITS(state->extra); DROPBITS(state->extra); } Tracevv((stderr, "inflate: length %u\n", state->length)); state->mode = DIST; case DIST: for (;;) { thiss = state->distcode[BITS(state->distbits)]; if ((unsigned)(thiss.bits) <= bits) break; PULLBYTE(); } if ((thiss.op & 0xf0) == 0) { last = thiss; for (;;) { thiss = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + thiss.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(thiss.bits); if (thiss.op & 64) { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } state->offset = (unsigned)thiss.val; state->extra = (unsigned)(thiss.op) & 15; state->mode = DISTEXT; case DISTEXT: if (state->extra) { NEEDBITS(state->extra); state->offset += BITS(state->extra); DROPBITS(state->extra); } #ifdef INFLATE_STRICT if (state->offset > state->dmax) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } #endif if (state->offset > state->whave + out - left) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } Tracevv((stderr, "inflate: distance %u\n", state->offset)); state->mode = MATCH; case MATCH: if (left == 0) goto inf_leave; copy = out - left; if (state->offset > copy) { /* copy from window */ copy = state->offset - copy; if (copy > state->write) { copy -= state->write; from = state->window + (state->wsize - copy); } else from = state->window + (state->write - copy); if (copy > state->length) copy = state->length; } else { /* copy from output */ from = put - state->offset; copy = state->length; } if (copy > left) copy = left; left -= copy; state->length -= copy; do { *put++ = *from++; } while (--copy); if (state->length == 0) state->mode = LEN; break; case LIT: if (left == 0) goto inf_leave; *put++ = (unsigned char)(state->length); left--; state->mode = LEN; break; case CHECK: if (state->wrap) { NEEDBITS(32); out -= left; strm->total_out += out; state->total += out; if (out) strm->adler = state->check = UPDATE(state->check, put - out, out); out = left; if (( #ifdef GUNZIP state->flags ? hold : #endif REVERSE(hold)) != state->check) { strm->msg = (char *)"incorrect data check"; state->mode = BAD; break; } INITBITS(); Tracev((stderr, "inflate: check matches trailer\n")); } #ifdef GUNZIP state->mode = LENGTH; case LENGTH: if (state->wrap && state->flags) { NEEDBITS(32); if (hold != (state->total & 0xffffffffUL)) { strm->msg = (char *)"incorrect length check"; state->mode = BAD; break; } INITBITS(); Tracev((stderr, "inflate: length matches trailer\n")); } #endif state->mode = DONE; case DONE: ret = Z_STREAM_END; goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; case MEM: return Z_MEM_ERROR; case SYNC: default: return Z_STREAM_ERROR; } /* Return from inflate(), updating the total counts and the check value. If there was no progress during the inflate() call, return a buffer error. Call updatewindow() to create and/or update the window state. Note: a memory error from inflate() is non-recoverable. */ inf_leave: RESTORE(); if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) if (updatewindow(strm, out)) { state->mode = MEM; return Z_MEM_ERROR; } in -= strm->avail_in; out -= strm->avail_out; strm->total_in += in; strm->total_out += out; state->total += out; if (state->wrap && out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out); strm->data_type = state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0); if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) ret = Z_BUF_ERROR; return ret; } int ZEXPORT inflateEnd(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->window != Z_NULL) ZFREE(strm, state->window); ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength) { struct inflate_state FAR *state; unsigned long id; /* check state */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->wrap != 0 && state->mode != DICT) return Z_STREAM_ERROR; /* check for correct dictionary id */ if (state->mode == DICT) { id = adler32(0L, Z_NULL, 0); id = adler32(id, dictionary, dictLength); if (id != state->check) return Z_DATA_ERROR; } /* copy dictionary to window */ if (updatewindow(strm, strm->avail_out)) { state->mode = MEM; return Z_MEM_ERROR; } if (dictLength > state->wsize) { zmemcpy(state->window, dictionary + dictLength - state->wsize, state->wsize); state->whave = state->wsize; } else { zmemcpy(state->window + state->wsize - dictLength, dictionary, dictLength); state->whave = dictLength; } state->havedict = 1; Tracev((stderr, "inflate: dictionary set\n")); return Z_OK; } int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { struct inflate_state FAR *state; /* check state */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; /* save header structure */ state->head = head; head->done = 0; return Z_OK; } /* Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found or when out of input. When called, *have is the number of pattern bytes found in order so far, in 0..3. On return *have is updated to the new state. If on return *have equals four, then the pattern was found and the return value is how many bytes were read including the last byte of the pattern. If *have is less than four, then the pattern has not been found yet and the return value is len. In the latter case, syncsearch() can be called again with more data and the *have state. *have is initialized to zero for the first call. */ local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf, unsigned len) { unsigned got; unsigned next; got = *have; next = 0; while (next < len && got < 4) { if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) got++; else if (buf[next]) got = 0; else got = 4 - got; next++; } *have = got; return next; } int ZEXPORT inflateSync(z_streamp strm) { unsigned len; /* number of bytes to look at or looked at */ unsigned long in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state FAR *state; /* check parameters */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; state->hold <<= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { buf[len++] = (unsigned char)(state->hold); state->hold >>= 8; state->bits -= 8; } state->have = 0; syncsearch(&(state->have), buf, len); } /* search available input */ len = syncsearch(&(state->have), strm->next_in, strm->avail_in); strm->avail_in -= len; strm->next_in += len; strm->total_in += len; /* return no joy or set up to restart inflate() on a new block */ if (state->have != 4) return Z_DATA_ERROR; in = strm->total_in; out = strm->total_out; inflateReset(strm); strm->total_in = in; strm->total_out = out; state->mode = TYPE; return Z_OK; } /* Returns true if inflate is currently at the end of a block generated by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ int ZEXPORT inflateSyncPoint(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; return state->mode == STORED && state->bits == 0; } int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { struct inflate_state FAR *state; struct inflate_state FAR *copy; unsigned char FAR *window; unsigned wsize; /* check input */ if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)source->state; /* allocate space */ copy = (struct inflate_state FAR *) ZALLOC(source, 1, sizeof(struct inflate_state)); if (copy == Z_NULL) return Z_MEM_ERROR; window = Z_NULL; if (state->window != Z_NULL) { window = (unsigned char FAR *) ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); if (window == Z_NULL) { ZFREE(source, copy); return Z_MEM_ERROR; } } /* copy state */ zmemcpy(dest, source, sizeof(z_stream)); zmemcpy(copy, state, sizeof(struct inflate_state)); if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); copy->distcode = copy->codes + (state->distcode - state->codes); } copy->next = copy->codes + (state->next - state->codes); if (window != Z_NULL) { wsize = 1U << state->wbits; zmemcpy(window, state->window, wsize); } copy->window = window; dest->state = (struct internal_state FAR *)copy; return Z_OK; } wgd-3.1/src/resources_base/zlib/inffast.cpp0000644000175000001440000003050010755642352015753 00000000000000/* inffast.c -- fast decoding * Copyright (C) 1995-2004 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include #include #include #include #ifndef ASMINF /* Allow machine dependent optimization for post-increment or pre-increment. Based on testing to date, Pre-increment preferred for: - PowerPC G3 (Adler) - MIPS R5000 (Randers-Pehrson) Post-increment preferred for: - none No measurable difference: - Pentium III (Anderson) - M68060 (Nikl) */ #ifdef POSTINC # define OFF 0 # define PUP(a) *(a)++ #else # define OFF 1 # define PUP(a) *++(a) #endif /* Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is available, an end-of-block is encountered, or a data error is encountered. When large enough input and output buffers are supplied to inflate(), for example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time is spent in this routine. Entry assumptions: state->mode == LEN strm->avail_in >= 6 strm->avail_out >= 258 start >= strm->avail_out state->bits < 8 On return, state->mode is one of: LEN -- ran out of enough output space or enough available input TYPE -- reached end of block code, inflate() to interpret next block BAD -- error in block data Notes: - The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, and 13 bits for the distance extra. This totals 48 bits, or six bytes. Therefore if strm->avail_in >= 6, then there is enough input to avoid checking for available input while decoding. - The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ void inflate_fast(z_streamp strm, unsigned start) /* inflate()'s starting value for strm->avail_out */ { struct inflate_state FAR *state; unsigned char FAR *in; /* local strm->next_in */ unsigned char FAR *last; /* while in < last, enough input available */ unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR *end; /* while out < end, enough space available */ #ifdef INFLATE_STRICT unsigned dmax; /* maximum distance from zlib header */ #endif unsigned wsize; /* window size or zero if not using window */ unsigned whave; /* valid bytes in the window */ unsigned write; /* window write index */ unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ unsigned long hold; /* local strm->hold */ unsigned bits; /* local strm->bits */ code const FAR *lcode; /* local strm->lencode */ code const FAR *dcode; /* local strm->distcode */ unsigned lmask; /* mask for first level of length codes */ unsigned dmask; /* mask for first level of distance codes */ code thiss; /* retrieved table entry */ unsigned op; /* code bits, operation, extra bits, or */ /* window position, window bytes to copy */ unsigned len; /* match length, unused bytes */ unsigned dist; /* match distance */ unsigned char FAR *from; /* where to copy match from */ /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; in = strm->next_in - OFF; last = in + (strm->avail_in - 5); out = strm->next_out - OFF; beg = out - (start - strm->avail_out); end = out + (strm->avail_out - 257); #ifdef INFLATE_STRICT dmax = state->dmax; #endif wsize = state->wsize; whave = state->whave; write = state->write; window = state->window; hold = state->hold; bits = state->bits; lcode = state->lencode; dcode = state->distcode; lmask = (1U << state->lenbits) - 1; dmask = (1U << state->distbits) - 1; /* decode literals and length/distances until end-of-block or not enough input data or output space */ do { if (bits < 15) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; hold += (unsigned long)(PUP(in)) << bits; bits += 8; } thiss = lcode[hold & lmask]; dolen: op = (unsigned)(thiss.bits); hold >>= op; bits -= op; op = (unsigned)(thiss.op); if (op == 0) { /* literal */ Tracevv((stderr, thiss.val >= 0x20 && thiss.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", thiss.val)); PUP(out) = (unsigned char)(thiss.val); } else if (op & 16) { /* length base */ len = (unsigned)(thiss.val); op &= 15; /* number of extra bits */ if (op) { if (bits < op) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; } len += (unsigned)hold & ((1U << op) - 1); hold >>= op; bits -= op; } Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; hold += (unsigned long)(PUP(in)) << bits; bits += 8; } thiss = dcode[hold & dmask]; dodist: op = (unsigned)(thiss.bits); hold >>= op; bits -= op; op = (unsigned)(thiss.op); if (op & 16) { /* distance base */ dist = (unsigned)(thiss.val); op &= 15; /* number of extra bits */ if (bits < op) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; if (bits < op) { hold += (unsigned long)(PUP(in)) << bits; bits += 8; } } dist += (unsigned)hold & ((1U << op) - 1); #ifdef INFLATE_STRICT if (dist > dmax) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } #endif hold >>= op; bits -= op; Tracevv((stderr, "inflate: distance %u\n", dist)); op = (unsigned)(out - beg); /* max distance in output */ if (dist > op) { /* see if copy from window */ op = dist - op; /* distance back in window */ if (op > whave) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } from = window - OFF; if (write == 0) { /* very common case */ from += wsize - op; if (op < len) { /* some from window */ len -= op; do { PUP(out) = PUP(from); } while (--op); from = out - dist; /* rest from output */ } } else if (write < op) { /* wrap around window */ from += wsize + write - op; op -= write; if (op < len) { /* some from end of window */ len -= op; do { PUP(out) = PUP(from); } while (--op); from = window - OFF; if (write < len) { /* some from start of window */ op = write; len -= op; do { PUP(out) = PUP(from); } while (--op); from = out - dist; /* rest from output */ } } } else { /* contiguous in window */ from += write - op; if (op < len) { /* some from window */ len -= op; do { PUP(out) = PUP(from); } while (--op); from = out - dist; /* rest from output */ } } while (len > 2) { PUP(out) = PUP(from); PUP(out) = PUP(from); PUP(out) = PUP(from); len -= 3; } if (len) { PUP(out) = PUP(from); if (len > 1) PUP(out) = PUP(from); } } else { from = out - dist; /* copy direct from output */ do { /* minimum length is three */ PUP(out) = PUP(from); PUP(out) = PUP(from); PUP(out) = PUP(from); len -= 3; } while (len > 2); if (len) { PUP(out) = PUP(from); if (len > 1) PUP(out) = PUP(from); } } } else if ((op & 64) == 0) { /* 2nd level distance code */ thiss = dcode[thiss.val + (hold & ((1U << op) - 1))]; goto dodist; } else { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } } else if ((op & 64) == 0) { /* 2nd level length code */ thiss = lcode[thiss.val + (hold & ((1U << op) - 1))]; goto dolen; } else if (op & 32) { /* end-of-block */ Tracevv((stderr, "inflate: end of block\n")); state->mode = TYPE; break; } else { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } } while (in < last && out < end); /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ len = bits >> 3; in -= len; bits -= len << 3; hold &= (1U << bits) - 1; /* update state and return */ strm->next_in = in + OFF; strm->next_out = out + OFF; strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end)); state->hold = hold; state->bits = bits; return; } /* inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - Using bit fields for code structure - Different op definition to avoid & for extra bits (do & for table bits) - Three separate decoding do-loops for direct, window, and write == 0 - Special case for distance > 1 copies to do overlapped load and store copy - Explicit branch predictions (based on measured branch probabilities) - Deferring match copy and interspersed it with decoding subsequent codes - Swapping literal/length else - Swapping window/direct else - Larger unrolled copy loops (three is about right) - Moving len -= 3 statement into middle of loop */ #endif /* !ASMINF */ wgd-3.1/src/resources_base/zlib/infback.cpp0000644000175000001440000005321310755642352015724 00000000000000/* infback.c -- inflate using a call-back interface * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* This code is largely copied from inflate.c. Normally either infback.o or inflate.o would be linked into an application--not both. The interface with inffast.c is retained so that optimized assembler-coded versions of inflate_fast() can be used with either inflate.c or infback.c. */ #include #include #include #include /* function prototypes */ local void fixedtables OF((struct inflate_state FAR *state)); /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size) { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL || window == Z_NULL || windowBits < 8 || windowBits > 15) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; state = (struct inflate_state FAR *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; state->dmax = 32768U; state->wbits = windowBits; state->wsize = 1U << windowBits; state->window = window; state->write = 0; state->whave = 0; return Z_OK; } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; static code fixed[544]; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { unsigned sym, bits; static code *next; /* literal/length table */ sym = 0; while (sym < 144) state->lens[sym++] = 8; while (sym < 256) state->lens[sym++] = 9; while (sym < 280) state->lens[sym++] = 7; while (sym < 288) state->lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; } #else /* !BUILDFIXED */ # include #endif /* BUILDFIXED */ state->lencode = lenfix; state->lenbits = 9; state->distcode = distfix; state->distbits = 5; } /* Macros for inflateBack(): */ /* Load returned state from inflate_fast() */ #define LOAD() \ do { \ put = strm->next_out; \ left = strm->avail_out; \ next = strm->next_in; \ have = strm->avail_in; \ hold = state->hold; \ bits = state->bits; \ } while (0) /* Set state from registers for inflate_fast() */ #define RESTORE() \ do { \ strm->next_out = put; \ strm->avail_out = left; \ strm->next_in = next; \ strm->avail_in = have; \ state->hold = hold; \ state->bits = bits; \ } while (0) /* Clear the input bit accumulator */ #define INITBITS() \ do { \ hold = 0; \ bits = 0; \ } while (0) /* Assure that some input is available. If input is requested, but denied, then return a Z_BUF_ERROR from inflateBack(). */ #define PULL() \ do { \ if (have == 0) { \ have = in(in_desc, &next); \ if (have == 0) { \ next = Z_NULL; \ ret = Z_BUF_ERROR; \ goto inf_leave; \ } \ } \ } while (0) /* Get a byte of input into the bit accumulator, or return from inflateBack() with an error if there is no input available. */ #define PULLBYTE() \ do { \ PULL(); \ have--; \ hold += (unsigned long)(*next++) << bits; \ bits += 8; \ } while (0) /* Assure that there are at least n bits in the bit accumulator. If there is not enough available input to do that, then return from inflateBack() with an error. */ #define NEEDBITS(n) \ do { \ while (bits < (unsigned)(n)) \ PULLBYTE(); \ } while (0) /* Return the low n bits of the bit accumulator (n < 16) */ #define BITS(n) \ ((unsigned)hold & ((1U << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ do { \ hold >>= (n); \ bits -= (unsigned)(n); \ } while (0) /* Remove zero to seven bits as needed to go to a byte boundary */ #define BYTEBITS() \ do { \ hold >>= bits & 7; \ bits -= bits & 7; \ } while (0) /* Assure that some output space is available, by writing out the window if it's full. If the write fails, return from inflateBack() with a Z_BUF_ERROR. */ #define ROOM() \ do { \ if (left == 0) { \ put = state->window; \ left = state->wsize; \ state->whave = left; \ if (out(out_desc, put, left)) { \ ret = Z_BUF_ERROR; \ goto inf_leave; \ } \ } \ } while (0) /* strm provides the memory allocation functions and window buffer on input, and provides information on the unused input on return. For Z_DATA_ERROR returns, strm will also provide an error message. in() and out() are the call-back input and output functions. When inflateBack() needs more input, it calls in(). When inflateBack() has filled the window with output, or when it completes with data in the window, it calls out() to write out the data. The application must not change the provided input until in() is called again or inflateBack() returns. The application must not change the window/output buffer until inflateBack() returns. in() and out() are called with a descriptor parameter provided in the inflateBack() call. This parameter can be a structure that provides the information required to do the read or write, as well as accumulated information on the input and output such as totals and check values. in() should return zero on failure. out() should return non-zero on failure. If either in() or out() fails, than inflateBack() returns a Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it was in() or out() that caused in the error. Otherwise, inflateBack() returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format error, or Z_MEM_ERROR if it could not allocate memory for the state. inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc) { struct inflate_state FAR *state; unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code thiss; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; /* Check that the strm exists and that the state was initialized */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* Reset the state */ strm->msg = Z_NULL; state->mode = TYPE; state->last = 0; state->whave = 0; next = strm->next_in; have = next != Z_NULL ? strm->avail_in : 0; hold = 0; bits = 0; put = state->window; left = state->wsize; /* Inflate until end of block marked as last */ for (;;) switch (state->mode) { case TYPE: /* determine and dispatch block type */ if (state->last) { BYTEBITS(); state->mode = DONE; break; } NEEDBITS(3); state->last = BITS(1); DROPBITS(1); switch (BITS(2)) { case 0: /* stored block */ Tracev((stderr, "inflate: stored block%s\n", state->last ? " (last)" : "")); state->mode = STORED; break; case 1: /* fixed block */ fixedtables(state); Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : "")); state->mode = LEN; /* decode codes */ break; case 2: /* dynamic block */ Tracev((stderr, "inflate: dynamic codes block%s\n", state->last ? " (last)" : "")); state->mode = TABLE; break; case 3: strm->msg = (char *)"invalid block type"; state->mode = BAD; } DROPBITS(2); break; case STORED: /* get and verify stored block length */ BYTEBITS(); /* go to byte boundary */ NEEDBITS(32); if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { strm->msg = (char *)"invalid stored block lengths"; state->mode = BAD; break; } state->length = (unsigned)hold & 0xffff; Tracev((stderr, "inflate: stored length %u\n", state->length)); INITBITS(); /* copy stored block from input to output */ while (state->length != 0) { copy = state->length; PULL(); ROOM(); if (copy > have) copy = have; if (copy > left) copy = left; zmemcpy(put, next, copy); have -= copy; next += copy; left -= copy; put += copy; state->length -= copy; } Tracev((stderr, "inflate: stored end\n")); state->mode = TYPE; break; case TABLE: /* get dynamic table entries descriptor */ NEEDBITS(14); state->nlen = BITS(5) + 257; DROPBITS(5); state->ndist = BITS(5) + 1; DROPBITS(5); state->ncode = BITS(4) + 4; DROPBITS(4); #ifndef PKZIP_BUG_WORKAROUND if (state->nlen > 286 || state->ndist > 30) { strm->msg = (char *)"too many length or distance symbols"; state->mode = BAD; break; } #endif Tracev((stderr, "inflate: table sizes ok\n")); /* get code length code lengths (not a typo) */ state->have = 0; while (state->have < state->ncode) { NEEDBITS(3); state->lens[order[state->have++]] = (unsigned short)BITS(3); DROPBITS(3); } while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid code lengths set"; state->mode = BAD; break; } Tracev((stderr, "inflate: code lengths ok\n")); /* get length and distance code code lengths */ state->have = 0; while (state->have < state->nlen + state->ndist) { for (;;) { thiss = state->lencode[BITS(state->lenbits)]; if ((unsigned)(thiss.bits) <= bits) break; PULLBYTE(); } if (thiss.val < 16) { NEEDBITS(thiss.bits); DROPBITS(thiss.bits); state->lens[state->have++] = thiss.val; } else { if (thiss.val == 16) { NEEDBITS(thiss.bits + 2); DROPBITS(thiss.bits); if (state->have == 0) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } len = (unsigned)(state->lens[state->have - 1]); copy = 3 + BITS(2); DROPBITS(2); } else if (thiss.val == 17) { NEEDBITS(thiss.bits + 3); DROPBITS(thiss.bits); len = 0; copy = 3 + BITS(3); DROPBITS(3); } else { NEEDBITS(thiss.bits + 7); DROPBITS(thiss.bits); len = 0; copy = 11 + BITS(7); DROPBITS(7); } if (state->have + copy > state->nlen + state->ndist) { strm->msg = (char *)"invalid bit length repeat"; state->mode = BAD; break; } while (copy--) state->lens[state->have++] = (unsigned short)len; } } /* handle error breaks in while */ if (state->mode == BAD) break; /* build code tables */ state->next = state->codes; state->lencode = (code const FAR *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); if (ret) { strm->msg = (char *)"invalid literal/lengths set"; state->mode = BAD; break; } state->distcode = (code const FAR *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); if (ret) { strm->msg = (char *)"invalid distances set"; state->mode = BAD; break; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; case LEN: /* use inflate_fast() if we have enough input and output */ if (have >= 6 && left >= 258) { RESTORE(); if (state->whave < state->wsize) state->whave = state->wsize - left; inflate_fast(strm, state->wsize); LOAD(); break; } /* get a literal, length, or end-of-block code */ for (;;) { thiss = state->lencode[BITS(state->lenbits)]; if ((unsigned)(thiss.bits) <= bits) break; PULLBYTE(); } if (thiss.op && (thiss.op & 0xf0) == 0) { last = thiss; for (;;) { thiss = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + thiss.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(thiss.bits); state->length = (unsigned)thiss.val; /* process literal */ if (thiss.op == 0) { Tracevv((stderr, thiss.val >= 0x20 && thiss.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", thiss.val)); ROOM(); *put++ = (unsigned char)(state->length); left--; state->mode = LEN; break; } /* process end of block */ if (thiss.op & 32) { Tracevv((stderr, "inflate: end of block\n")); state->mode = TYPE; break; } /* invalid code */ if (thiss.op & 64) { strm->msg = (char *)"invalid literal/length code"; state->mode = BAD; break; } /* length code -- get extra bits, if any */ state->extra = (unsigned)(thiss.op) & 15; if (state->extra != 0) { NEEDBITS(state->extra); state->length += BITS(state->extra); DROPBITS(state->extra); } Tracevv((stderr, "inflate: length %u\n", state->length)); /* get distance code */ for (;;) { thiss = state->distcode[BITS(state->distbits)]; if ((unsigned)(thiss.bits) <= bits) break; PULLBYTE(); } if ((thiss.op & 0xf0) == 0) { last = thiss; for (;;) { thiss = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + thiss.bits) <= bits) break; PULLBYTE(); } DROPBITS(last.bits); } DROPBITS(thiss.bits); if (thiss.op & 64) { strm->msg = (char *)"invalid distance code"; state->mode = BAD; break; } state->offset = (unsigned)thiss.val; /* get distance extra bits, if any */ state->extra = (unsigned)(thiss.op) & 15; if (state->extra != 0) { NEEDBITS(state->extra); state->offset += BITS(state->extra); DROPBITS(state->extra); } if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) { strm->msg = (char *)"invalid distance too far back"; state->mode = BAD; break; } Tracevv((stderr, "inflate: distance %u\n", state->offset)); /* copy match from window to output */ do { ROOM(); copy = state->wsize - state->offset; if (copy < left) { from = put + copy; copy = left - copy; } else { from = put - state->offset; copy = left; } if (copy > state->length) copy = state->length; state->length -= copy; left -= copy; do { *put++ = *from++; } while (--copy); } while (state->length != 0); break; case DONE: /* inflate stream terminated properly -- write leftover output */ ret = Z_STREAM_END; if (left < state->wsize) { if (out(out_desc, state->window, state->wsize - left)) ret = Z_BUF_ERROR; } goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; default: /* can't happen, but makes compilers happy */ ret = Z_STREAM_ERROR; goto inf_leave; } /* Return unused input */ inf_leave: strm->next_in = next; strm->avail_in = have; return ret; } int ZEXPORT inflateBackEnd(z_streamp strm) { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } wgd-3.1/src/resources_base/zlib/deflate.cpp0000644000175000001440000017411510757755626015753 00000000000000/* deflate.c -- compress data using the deflation algorithm * Copyright (C) 1995-2005 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process depends on being able to identify portions * of the input text which are identical to earlier input (within a * sliding window trailing behind the input currently being processed). * * The most straightforward technique turns out to be the fastest for * most input files: try all possible matches and select the longest. * The key feature of this algorithm is that insertions into the string * dictionary are very simple and thus fast, and deletions are avoided * completely. Insertions are performed at each input character, whereas * string matches are performed only when the previous match ends. So it * is preferable to spend more time in matches to allow very fast string * insertions and avoid deletions. The matching algorithm for small * strings is inspired from that of Rabin & Karp. A brute force approach * is used to find longer strings when a small match has been found. * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze * (by Leonid Broukhis). * A previous version of this file used a more sophisticated algorithm * (by Fiala and Greene) which is guaranteed to run in linear amortized * time, but has a larger average cost, uses more memory and is patented. * However the F&G algorithm may be faster for some highly redundant * files if the parameter max_chain_length (described below) is too large. * * ACKNOWLEDGEMENTS * * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and * I found it in 'freeze' written by Leonid Broukhis. * Thanks to many people for bug reports and testing. * * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". * Available in http://www.ietf.org/rfc/rfc1951.txt * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. * * Fiala,E.R., and Greene,D.H. * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 * */ /* @(#) $Id$ */ #include const char deflate_copyright[] = " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ /* =========================================================================== * Function prototypes. */ typedef enum { need_more, /* block not completed, need more input or more output */ block_done, /* block flush performed */ finish_started, /* finish started, need only more output at next deflate */ finish_done /* finish done, accept no more input or output */ } block_state; typedef block_state (*compress_func) OF((deflate_state *s, int flush)); /* Compression function. Returns the block state after the call. */ local void fill_window OF((deflate_state *s)); local block_state deflate_stored OF((deflate_state *s, int flush)); local block_state deflate_fast OF((deflate_state *s, int flush)); #ifndef FASTEST local block_state deflate_slow OF((deflate_state *s, int flush)); #endif local void lm_init OF((deflate_state *s)); local void putShortMSB OF((deflate_state *s, uInt b)); local void flush_pending OF((z_streamp strm)); local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); #ifndef FASTEST #ifdef ASMV void match_init OF((void)); /* asm code initialization */ uInt longest_match OF((deflate_state *s, IPos cur_match)); #else local uInt longest_match OF((deflate_state *s, IPos cur_match)); #endif #endif local uInt longest_match_fast OF((deflate_state *s, IPos cur_match)); #ifdef DEBUG local void check_match OF((deflate_state *s, IPos start, IPos match, int length)); #endif /* =========================================================================== * Local data */ #define NIL 0 /* Tail of hash chains */ #ifndef TOO_FAR # define TOO_FAR 4096 #endif /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. */ /* Values for max_lazy_match, good_match and max_chain_length, depending on * the desired pack level (0..9). The values given below have been tuned to * exclude worst case performance for pathological files. Better values may be * found for specific files. */ typedef struct config_s { ush good_length; /* reduce lazy search above this match length */ ush max_lazy; /* do not perform lazy search above this match length */ ush nice_length; /* quit search above this match length */ ush max_chain; compress_func func; } config; #ifdef FASTEST local const config configuration_table[2] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ /* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ #else local const config configuration_table[10] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ /* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ /* 2 */ {4, 5, 16, 8, deflate_fast}, /* 3 */ {4, 6, 32, 32, deflate_fast}, /* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ /* 5 */ {8, 16, 32, 32, deflate_slow}, /* 6 */ {8, 16, 128, 128, deflate_slow}, /* 7 */ {8, 32, 128, 256, deflate_slow}, /* 8 */ {32, 128, 258, 1024, deflate_slow}, /* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ #endif /* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 * For deflate_fast() (levels <= 3) good is ignored and lazy has a different * meaning. */ #define EQUAL 0 /* result of memcmp for equal strings */ #ifndef NO_DUMMY_DECL struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif /* =========================================================================== * Update a hash value with the given input byte * IN assertion: all calls to to UPDATE_HASH are made with consecutive * input characters, so that a running hash key can be computed from the * previous key instead of complete recalculation each time. */ #define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) /* =========================================================================== * Insert string str in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. * If this file is compiled with -DFASTEST, the compression level is forced * to 1, and no hash chains are maintained. * IN assertion: all calls to to INSERT_STRING are made with consecutive * input characters and the first MIN_MATCH bytes of str are valid * (except for the last MIN_MATCH-1 bytes of the input file). */ #ifdef FASTEST #define INSERT_STRING(s, str, match_head) \ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ match_head = s->head[s->ins_h], \ s->head[s->ins_h] = (Pos)(str)) #else #define INSERT_STRING(s, str, match_head) \ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ s->head[s->ins_h] = (Pos)(str)) #endif /* =========================================================================== * Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) \ s->head[s->hash_size-1] = NIL; \ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); /* ========================================================================= */ int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size) { deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; ushf *overlay; /* We overlay pending_buf and d_buf+l_buf. This works since the average * output size for (length,distance) codes is <= 24 bits. */ if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { return Z_VERSION_ERROR; } if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { strm->zalloc = zcalloc; strm->opaque = (voidpf)0; } if (strm->zfree == (free_func)0) strm->zfree = zcfree; #ifdef FASTEST if (level != 0) level = 1; #else if (level == Z_DEFAULT_COMPRESSION) level = 6; #endif if (windowBits < 0) { /* suppress zlib wrapper */ wrap = 0; windowBits = -windowBits; } #ifdef GZIP else if (windowBits > 15) { wrap = 2; /* write gzip wrapper instead */ windowBits -= 16; } #endif if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { return Z_STREAM_ERROR; } if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); if (s == Z_NULL) return Z_MEM_ERROR; strm->state = (struct internal_state FAR *)s; s->strm = strm; s->wrap = wrap; s->gzhead = Z_NULL; s->w_bits = windowBits; s->w_size = 1 << s->w_bits; s->w_mask = s->w_size - 1; s->hash_bits = memLevel + 7; s->hash_size = 1 << s->hash_bits; s->hash_mask = s->hash_size - 1; s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); s->pending_buf = (uchf *) overlay; s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L); if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { s->status = FINISH_STATE; strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); deflateEnd (strm); return Z_MEM_ERROR; } s->d_buf = overlay + s->lit_bufsize/sizeof(ush); s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; s->level = level; s->strategy = strategy; s->method = (Byte)method; return deflateReset(strm); } /* ========================================================================= */ int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength) { deflate_state *s; uInt length = dictLength; uInt n; IPos hash_head = 0; if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || strm->state->wrap == 2 || (strm->state->wrap == 1 && strm->state->status != INIT_STATE)) return Z_STREAM_ERROR; s = strm->state; if (s->wrap) strm->adler = adler32(strm->adler, dictionary, dictLength); if (length < MIN_MATCH) return Z_OK; if (length > MAX_DIST(s)) { length = MAX_DIST(s); dictionary += dictLength - length; /* use the tail of the dictionary */ } zmemcpy(s->window, dictionary, length); s->strstart = length; s->block_start = (long)length; /* Insert all strings in the hash table (except for the last two bytes). * s->lookahead stays null, so s->ins_h will be recomputed at the next * call of fill_window. */ s->ins_h = s->window[0]; UPDATE_HASH(s, s->ins_h, s->window[1]); for (n = 0; n <= length - MIN_MATCH; n++) { INSERT_STRING(s, n, hash_head); } if (hash_head) hash_head = 0; /* to make compiler happy */ return Z_OK; } /* ========================================================================= */ int ZEXPORT deflateReset (z_streamp strm) { deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { return Z_STREAM_ERROR; } strm->total_in = strm->total_out = 0; strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ strm->data_type = Z_UNKNOWN; s = (deflate_state *)strm->state; s->pending = 0; s->pending_out = s->pending_buf; if (s->wrap < 0) { s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ } s->status = s->wrap ? INIT_STATE : BUSY_STATE; strm->adler = #ifdef GZIP s->wrap == 2 ? crc32(0L, Z_NULL, 0) : #endif adler32(0L, Z_NULL, 0); s->last_flush = Z_NO_FLUSH; _tr_init(s); lm_init(s); return Z_OK; } /* ========================================================================= */ int ZEXPORT deflateSetHeader (z_streamp strm, gz_headerp head) { if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; if (strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; return Z_OK; } /* ========================================================================= */ int ZEXPORT deflatePrime (z_streamp strm, int bits, int value) { if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; strm->state->bi_valid = bits; strm->state->bi_buf = (ush)(value & ((1 << bits) - 1)); return Z_OK; } /* ========================================================================= */ int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; int err = Z_OK; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; s = strm->state; #ifdef FASTEST if (level != 0) level = 1; #else if (level == Z_DEFAULT_COMPRESSION) level = 6; #endif if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { return Z_STREAM_ERROR; } func = configuration_table[s->level].func; if (func != configuration_table[level].func && strm->total_in != 0) { /* Flush the last buffer: */ err = deflate(strm, Z_PARTIAL_FLUSH); } if (s->level != level) { s->level = level; s->max_lazy_match = configuration_table[level].max_lazy; s->good_match = configuration_table[level].good_length; s->nice_match = configuration_table[level].nice_length; s->max_chain_length = configuration_table[level].max_chain; } s->strategy = strategy; return err; } /* ========================================================================= */ int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, int nice_length, int max_chain) { deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; s = strm->state; s->good_match = good_length; s->max_lazy_match = max_lazy; s->nice_match = nice_length; s->max_chain_length = max_chain; return Z_OK; } /* ========================================================================= * For the default windowBits of 15 and memLevel of 8, this function returns * a close to exact, as well as small, upper bound on the compressed size. * They are coded as constants here for a reason--if the #define's are * changed, then this function needs to be changed as well. The return * value for 15 and 8 only works for those exact settings. * * For any setting other than those defaults for windowBits and memLevel, * the value returned is a conservative worst case for the maximum expansion * resulting from using fixed blocks instead of stored blocks, which deflate * can emit on compressed data for some combinations of the parameters. * * This function could be more sophisticated to provide closer upper bounds * for every combination of windowBits and memLevel, as well as wrap. * But even the conservative upper bound of about 14% expansion does not * seem onerous for output buffer allocation. */ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { deflate_state *s; uLong destLen; /* conservative upper bound */ destLen = sourceLen + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11; /* if can't get parameters, return conservative bound */ if (strm == Z_NULL || strm->state == Z_NULL) return destLen; /* if not default parameters, return conservative bound */ s = strm->state; if (s->w_bits != 15 || s->hash_bits != 8 + 7) return destLen; /* default settings: return tight bound for that case */ return 0; //return compressBound(sourceLen); } /* ========================================================================= * Put a short in the pending buffer. The 16-bit value is put in MSB order. * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ local void putShortMSB (deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); } /* ========================================================================= * Flush as much pending output as possible. All deflate() output goes * through this function so some applications may wish to modify it * to avoid allocating a large strm->next_out buffer and copying into it. * (See also read_buf()). */ local void flush_pending(z_streamp strm) { unsigned len = strm->state->pending; if (len > strm->avail_out) len = strm->avail_out; if (len == 0) return; zmemcpy(strm->next_out, strm->state->pending_out, len); strm->next_out += len; strm->state->pending_out += len; strm->total_out += len; strm->avail_out -= len; strm->state->pending -= len; if (strm->state->pending == 0) { strm->state->pending_out = strm->state->pending_buf; } } /* ========================================================================= */ int ZEXPORT deflate (z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; if (strm == Z_NULL || strm->state == Z_NULL || flush > Z_FINISH || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0) || (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); s->strm = strm; /* just in case */ old_flush = s->last_flush; s->last_flush = flush; /* Write the header */ if (s->status == INIT_STATE) { #ifdef GZIP if (s->wrap == 2) { strm->adler = crc32(0L, Z_NULL, 0); put_byte(s, 31); put_byte(s, 139); put_byte(s, 8); if (s->gzhead == NULL) { put_byte(s, 0); put_byte(s, 0); put_byte(s, 0); put_byte(s, 0); put_byte(s, 0); put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); put_byte(s, OS_CODE); s->status = BUSY_STATE; } else { put_byte(s, (s->gzhead->text ? 1 : 0) + (s->gzhead->hcrc ? 2 : 0) + (s->gzhead->extra == Z_NULL ? 0 : 4) + (s->gzhead->name == Z_NULL ? 0 : 8) + (s->gzhead->comment == Z_NULL ? 0 : 16) ); put_byte(s, (Byte)(s->gzhead->time & 0xff)); put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); put_byte(s, s->level == 9 ? 2 : (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? 4 : 0)); put_byte(s, s->gzhead->os & 0xff); if (s->gzhead->extra != NULL) { put_byte(s, s->gzhead->extra_len & 0xff); put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); } if (s->gzhead->hcrc) strm->adler = crc32(strm->adler, s->pending_buf, s->pending); s->gzindex = 0; s->status = EXTRA_STATE; } } else #endif { uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; uInt level_flags; if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) level_flags = 0; else if (s->level < 6) level_flags = 1; else if (s->level == 6) level_flags = 2; else level_flags = 3; header |= (level_flags << 6); if (s->strstart != 0) header |= PRESET_DICT; header += 31 - (header % 31); s->status = BUSY_STATE; putShortMSB(s, header); /* Save the adler32 of the preset dictionary: */ if (s->strstart != 0) { putShortMSB(s, (uInt)(strm->adler >> 16)); putShortMSB(s, (uInt)(strm->adler & 0xffff)); } strm->adler = adler32(0L, Z_NULL, 0); } } #ifdef GZIP if (s->status == EXTRA_STATE) { if (s->gzhead->extra != NULL) { uInt beg = s->pending; /* start of bytes to update crc */ while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { if (s->pending == s->pending_buf_size) { if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); flush_pending(strm); beg = s->pending; if (s->pending == s->pending_buf_size) break; } put_byte(s, s->gzhead->extra[s->gzindex]); s->gzindex++; } if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); if (s->gzindex == s->gzhead->extra_len) { s->gzindex = 0; s->status = NAME_STATE; } } else s->status = NAME_STATE; } if (s->status == NAME_STATE) { if (s->gzhead->name != NULL) { uInt beg = s->pending; /* start of bytes to update crc */ int val; do { if (s->pending == s->pending_buf_size) { if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); flush_pending(strm); beg = s->pending; if (s->pending == s->pending_buf_size) { val = 1; break; } } val = s->gzhead->name[s->gzindex++]; put_byte(s, val); } while (val != 0); if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); if (val == 0) { s->gzindex = 0; s->status = COMMENT_STATE; } } else s->status = COMMENT_STATE; } if (s->status == COMMENT_STATE) { if (s->gzhead->comment != NULL) { uInt beg = s->pending; /* start of bytes to update crc */ int val; do { if (s->pending == s->pending_buf_size) { if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); flush_pending(strm); beg = s->pending; if (s->pending == s->pending_buf_size) { val = 1; break; } } val = s->gzhead->comment[s->gzindex++]; put_byte(s, val); } while (val != 0); if (s->gzhead->hcrc && s->pending > beg) strm->adler = crc32(strm->adler, s->pending_buf + beg, s->pending - beg); if (val == 0) s->status = HCRC_STATE; } else s->status = HCRC_STATE; } if (s->status == HCRC_STATE) { if (s->gzhead->hcrc) { if (s->pending + 2 > s->pending_buf_size) flush_pending(strm); if (s->pending + 2 <= s->pending_buf_size) { put_byte(s, (Byte)(strm->adler & 0xff)); put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); strm->adler = crc32(0L, Z_NULL, 0); s->status = BUSY_STATE; } } else s->status = BUSY_STATE; } #endif /* Flush as much pending output as possible */ if (s->pending != 0) { flush_pending(strm); if (strm->avail_out == 0) { /* Since avail_out is 0, deflate will be called again with * more output space, but possibly with both pending and * avail_in equal to zero. There won't be anything to do, * but this is not an error situation so make sure we * return OK instead of BUF_ERROR at next call of deflate: */ s->last_flush = -1; return Z_OK; } /* Make sure there is something to do and avoid duplicate consecutive * flushes. For repeated and useless calls with Z_FINISH, we keep * returning Z_STREAM_END instead of Z_BUF_ERROR. */ } else if (strm->avail_in == 0 && flush <= old_flush && flush != Z_FINISH) { ERR_RETURN(strm, Z_BUF_ERROR); } /* User must not provide more input after the first FINISH: */ if (s->status == FINISH_STATE && strm->avail_in != 0) { ERR_RETURN(strm, Z_BUF_ERROR); } /* Start a new block or continue the current one. */ if (strm->avail_in != 0 || s->lookahead != 0 || (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { block_state bstate; bstate = (*(configuration_table[s->level].func))(s, flush); if (bstate == finish_started || bstate == finish_done) { s->status = FINISH_STATE; } if (bstate == need_more || bstate == finish_started) { if (strm->avail_out == 0) { s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ } return Z_OK; /* If flush != Z_NO_FLUSH && avail_out == 0, the next call * of deflate should use the same flush parameter to make sure * that the flush is complete. So we don't have to output an * empty block here, this will be done at next call. This also * ensures that for a very small output buffer, we emit at most * one empty block. */ } if (bstate == block_done) { if (flush == Z_PARTIAL_FLUSH) { _tr_align(s); } else { /* FULL_FLUSH or SYNC_FLUSH */ _tr_stored_block(s, (char*)0, 0L, 0); /* For a full flush, this empty block will be recognized * as a special marker by inflate_sync(). */ if (flush == Z_FULL_FLUSH) { CLEAR_HASH(s); /* forget history */ } } flush_pending(strm); if (strm->avail_out == 0) { s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ return Z_OK; } } } Assert(strm->avail_out > 0, "bug2"); if (flush != Z_FINISH) return Z_OK; if (s->wrap <= 0) return Z_STREAM_END; /* Write the trailer */ #ifdef GZIP if (s->wrap == 2) { put_byte(s, (Byte)(strm->adler & 0xff)); put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); put_byte(s, (Byte)(strm->total_in & 0xff)); put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); } else #endif { putShortMSB(s, (uInt)(strm->adler >> 16)); putShortMSB(s, (uInt)(strm->adler & 0xffff)); } flush_pending(strm); /* If avail_out is zero, the application will call deflate again * to flush the rest. */ if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ return s->pending != 0 ? Z_OK : Z_STREAM_END; } /* ========================================================================= */ int ZEXPORT deflateEnd (z_streamp strm) { int status; if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; status = strm->state->status; if (status != INIT_STATE && status != EXTRA_STATE && status != NAME_STATE && status != COMMENT_STATE && status != HCRC_STATE && status != BUSY_STATE && status != FINISH_STATE) { return Z_STREAM_ERROR; } /* Deallocate in reverse order of allocations: */ TRY_FREE(strm, strm->state->pending_buf); TRY_FREE(strm, strm->state->head); TRY_FREE(strm, strm->state->prev); TRY_FREE(strm, strm->state->window); ZFREE(strm, strm->state); strm->state = Z_NULL; return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; } /* ========================================================================= * Copy the source state to the destination state. * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ int ZEXPORT deflateCopy (z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K return Z_STREAM_ERROR; #else deflate_state *ds; deflate_state *ss; ushf *overlay; if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { return Z_STREAM_ERROR; } ss = source->state; zmemcpy(dest, source, sizeof(z_stream)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); if (ds == Z_NULL) return Z_MEM_ERROR; dest->state = (struct internal_state FAR *) ds; zmemcpy(ds, ss, sizeof(deflate_state)); ds->strm = dest; ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2); ds->pending_buf = (uchf *) overlay; if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { deflateEnd (dest); return Z_MEM_ERROR; } /* following zmemcpy do not work for 16-bit MSDOS */ zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush); ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize; ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; ds->bl_desc.dyn_tree = ds->bl_tree; return Z_OK; #endif /* MAXSEG_64K */ } /* =========================================================================== * Read a new buffer from the current input stream, update the adler32 * and total number of bytes read. All deflate() input goes through * this function so some applications may wish to modify it to avoid * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ local int read_buf(z_streamp strm, Bytef *buf, unsigned size) { unsigned len = strm->avail_in; if (len > size) len = size; if (len == 0) return 0; strm->avail_in -= len; if (strm->state->wrap == 1) { strm->adler = adler32(strm->adler, strm->next_in, len); } #ifdef GZIP else if (strm->state->wrap == 2) { strm->adler = crc32(strm->adler, strm->next_in, len); } #endif zmemcpy(buf, strm->next_in, len); strm->next_in += len; strm->total_in += len; return (int)len; } /* =========================================================================== * Initialize the "longest match" routines for a new zlib stream */ local void lm_init (deflate_state *s) { s->window_size = (ulg)2L*s->w_size; CLEAR_HASH(s); /* Set the default configuration parameters: */ s->max_lazy_match = configuration_table[s->level].max_lazy; s->good_match = configuration_table[s->level].good_length; s->nice_match = configuration_table[s->level].nice_length; s->max_chain_length = configuration_table[s->level].max_chain; s->strstart = 0; s->block_start = 0L; s->lookahead = 0; s->match_length = s->prev_length = MIN_MATCH-1; s->match_available = 0; s->ins_h = 0; #ifndef FASTEST #ifdef ASMV match_init(); /* initialize the asm code */ #endif #endif } #ifndef FASTEST /* =========================================================================== * Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is * garbage. * IN assertions: cur_match is the head of the hash chain for the current * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 * OUT assertion: the match length is not greater than s->lookahead. */ #ifndef ASMV /* For 80x86 and 680x0, an optimized version will be provided in match.asm or * match.S. The code will be functionally equivalent. */ local uInt longest_match(deflate_state *s, IPos cur_match) /* current match */ { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ int best_len = s->prev_length; /* best match length so far */ int nice_match = s->nice_match; /* stop if match long enough */ IPos limit = s->strstart > (IPos)MAX_DIST(s) ? s->strstart - (IPos)MAX_DIST(s) : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0. */ Posf *prev = s->prev; uInt wmask = s->w_mask; #ifdef UNALIGNED_OK /* Compare two bytes at a time. Note: this is not always beneficial. * Try with and without -DUNALIGNED_OK to check. */ register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; register ush scan_start = *(ushf*)scan; register ush scan_end = *(ushf*)(scan+best_len-1); #else register Bytef *strend = s->window + s->strstart + MAX_MATCH; register Byte scan_end1 = scan[best_len-1]; register Byte scan_end = scan[best_len]; #endif /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); /* Do not waste too much time if we already have a good match: */ if (s->prev_length >= s->good_match) { chain_length >>= 2; } /* Do not look for matches beyond the end of the input. This is necessary * to make deflate deterministic. */ if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); do { Assert(cur_match < s->strstart, "no future"); match = s->window + cur_match; /* Skip to next match if the match length cannot increase * or if the match length is less than 2. Note that the checks below * for insufficient lookahead only occur occasionally for performance * reasons. Therefore uninitialized memory will be accessed, and * conditional jumps will be made that depend on those values. * However the length of the match is limited to the lookahead, so * the output of deflate is not affected by the uninitialized values. */ #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) /* This code assumes sizeof(unsigned short) == 2. Do not use * UNALIGNED_OK if your compiler uses a different size. */ if (*(ushf*)(match+best_len-1) != scan_end || *(ushf*)match != scan_start) continue; /* It is not necessary to compare scan[2] and match[2] since they are * always equal when the other bytes match, given that the hash keys * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at * strstart+3, +5, ... up to strstart+257. We check for insufficient * lookahead only every 4th comparison; the 128th check will be made * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is * necessary to put more guard bytes at the end of the window, or * to check more often for insufficient lookahead. */ Assert(scan[2] == match[2], "scan[2]?"); scan++, match++; do { } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && *(ushf*)(scan+=2) == *(ushf*)(match+=2) && *(ushf*)(scan+=2) == *(ushf*)(match+=2) && *(ushf*)(scan+=2) == *(ushf*)(match+=2) && scan < strend); /* The funny "do {}" generates better code on most compilers */ /* Here, scan <= window+strstart+257 */ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); if (*scan == *match) scan++; len = (MAX_MATCH - 1) - (int)(strend-scan); scan = strend - (MAX_MATCH-1); #else /* UNALIGNED_OK */ if (match[best_len] != scan_end || match[best_len-1] != scan_end1 || *match != *scan || *++match != scan[1]) continue; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match++; Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; #endif /* UNALIGNED_OK */ if (len > best_len) { s->match_start = cur_match; best_len = len; if (len >= nice_match) break; #ifdef UNALIGNED_OK scan_end = *(ushf*)(scan+best_len-1); #else scan_end1 = scan[best_len-1]; scan_end = scan[best_len]; #endif } } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0); if ((uInt)best_len <= s->lookahead) return (uInt)best_len; return s->lookahead; } #endif /* ASMV */ #endif /* FASTEST */ /* --------------------------------------------------------------------------- * Optimized version for level == 1 or strategy == Z_RLE only */ local uInt longest_match_fast(deflate_state *s, IPos cur_match) /* current match */ { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ register Bytef *strend = s->window + s->strstart + MAX_MATCH; /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); Assert(cur_match < s->strstart, "no future"); match = s->window + cur_match; /* Return failure if the match length is less than 2: */ if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; /* The check at best_len-1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match += 2; Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart+258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); if (len < MIN_MATCH) return MIN_MATCH - 1; s->match_start = cur_match; return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; } #ifdef DEBUG /* =========================================================================== * Check that the match at match_start is indeed a match. */ local void check_match(s, start, match, length) deflate_state *s; IPos start, match; int length; { /* check that the match is indeed a match */ if (zmemcmp(s->window + match, s->window + start, length) != EQUAL) { fprintf(stderr, " start %u, match %u, length %d\n", start, match, length); do { fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); } while (--length != 0); z_error("invalid match"); } if (z_verbose > 1) { fprintf(stderr,"\\[%d,%d]", start-match, length); do { putc(s->window[start++], stderr); } while (--length != 0); } } #else # define check_match(s, start, match, length) #endif /* DEBUG */ /* =========================================================================== * Fill the window when the lookahead becomes insufficient. * Updates strstart and lookahead. * * IN assertion: lookahead < MIN_LOOKAHEAD * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD * At least one byte has been read, or avail_in == 0; reads are * performed for at least two bytes (required for the zip translate_eol * option -- not supported here). */ local void fill_window(deflate_state *s) { register unsigned n, m; register Posf *p; unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; do { more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); /* Deal with !@#$% 64K limit: */ if (sizeof(int) <= 2) { if (more == 0 && s->strstart == 0 && s->lookahead == 0) { more = wsize; } else if (more == (unsigned)(-1)) { /* Very unlikely, but possible on 16 bit machine if * strstart == 0 && lookahead == 1 (input done a byte at time) */ more--; } } /* If the window is almost full and there is insufficient lookahead, * move the upper half to the lower one to make room in the upper half. */ if (s->strstart >= wsize+MAX_DIST(s)) { zmemcpy(s->window, s->window+wsize, (unsigned)wsize); s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; /* Slide the hash table (could be avoided with 32 bit values at the expense of memory usage). We slide even when level == 0 to keep the hash table consistent if we switch back to level > 0 later. (Using level 0 permanently is not an optimal usage of zlib, so we don't care about this pathological case.) */ /* %%% avoid this when Z_RLE */ n = s->hash_size; p = &s->head[n]; do { m = *--p; *p = (Pos)(m >= wsize ? m-wsize : NIL); } while (--n); n = wsize; #ifndef FASTEST p = &s->prev[n]; do { m = *--p; *p = (Pos)(m >= wsize ? m-wsize : NIL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } while (--n); #endif more += wsize; } if (s->strm->avail_in == 0) return; /* If there was no sliding: * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && * more == window_size - lookahead - strstart * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) * => more >= window_size - 2*WSIZE + 2 * In the BIG_MEM or MMAP case (not yet supported), * window_size == input_size + MIN_LOOKAHEAD && * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. * Otherwise, window_size == 2*WSIZE so more >= 2. * If there was sliding, more >= WSIZE. So in all cases, more >= 2. */ Assert(more >= 2, "more < 2"); n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); s->lookahead += n; /* Initialize the hash value now that we have some input: */ if (s->lookahead >= MIN_MATCH) { s->ins_h = s->window[s->strstart]; UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); #if MIN_MATCH != 3 Call UPDATE_HASH() MIN_MATCH-3 more times #endif } /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, * but this is not important since only literal bytes will be emitted. */ } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); } /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK_ONLY(s, eof) { \ _tr_flush_block(s, (s->block_start >= 0L ? \ (charf *)&s->window[(unsigned)s->block_start] : \ (charf *)Z_NULL), \ (ulg)((long)s->strstart - s->block_start), \ (eof)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ Tracev((stderr,"[FLUSH]")); \ } /* Same but force premature exit if necessary. */ #define FLUSH_BLOCK(s, eof) { \ FLUSH_BLOCK_ONLY(s, eof); \ if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ } /* =========================================================================== * Copy without compression as much as possible from the input stream, return * the current block state. * This function does not insert new strings in the dictionary since * uncompressible data is probably not useful. This function is used * only for the level=0 compression option. * NOTE: this function should be optimized to avoid extra copying from * window to pending_buf. */ local block_state deflate_stored(deflate_state *s, int flush) { /* Stored blocks are limited to 0xffff bytes, pending_buf is limited * to pending_buf_size, and each stored block has a 5 byte header: */ ulg max_block_size = 0xffff; ulg max_start; if (max_block_size > s->pending_buf_size - 5) { max_block_size = s->pending_buf_size - 5; } /* Copy as much as possible from input to output: */ for (;;) { /* Fill the window as much as possible: */ if (s->lookahead <= 1) { Assert(s->strstart < s->w_size+MAX_DIST(s) || s->block_start >= (long)s->w_size, "slide too late"); fill_window(s); if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; if (s->lookahead == 0) break; /* flush the current block */ } Assert(s->block_start >= 0L, "block gone"); s->strstart += s->lookahead; s->lookahead = 0; /* Emit a stored block if pending_buf will be full: */ max_start = s->block_start + max_block_size; if (s->strstart == 0 || (ulg)s->strstart >= max_start) { /* strstart == 0 is possible when wraparound on 16-bit machine */ s->lookahead = (uInt)(s->strstart - max_start); s->strstart = (uInt)max_start; FLUSH_BLOCK(s, 0); } /* Flush if we may have to slide, otherwise block_start may become * negative and the data will be gone: */ if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { FLUSH_BLOCK(s, 0); } } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } /* =========================================================================== * Compress as much as possible from the input stream, return the current * block state. * This function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head = NIL; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (s->lookahead >= MIN_MATCH) { INSERT_STRING(s, s->strstart, hash_head); } /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ #ifdef FASTEST if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) || (s->strategy == Z_RLE && s->strstart - hash_head == 1)) { s->match_length = longest_match_fast (s, hash_head); } #else if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { s->match_length = longest_match (s, hash_head); } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { s->match_length = longest_match_fast (s, hash_head); } #endif /* longest_match() or longest_match_fast() sets match_start */ } if (s->match_length >= MIN_MATCH) { check_match(s, s->strstart, s->match_start, s->match_length); _tr_tally_dist(s, s->strstart - s->match_start, s->match_length - MIN_MATCH, bflush); s->lookahead -= s->match_length; /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ #ifndef FASTEST if (s->match_length <= s->max_insert_length && s->lookahead >= MIN_MATCH) { s->match_length--; /* string at strstart already in table */ do { s->strstart++; INSERT_STRING(s, s->strstart, hash_head); /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. */ } while (--s->match_length != 0); s->strstart++; } else #endif { s->strstart += s->match_length; s->match_length = 0; s->ins_h = s->window[s->strstart]; UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); #if MIN_MATCH != 3 Call UPDATE_HASH() MIN_MATCH-3 more times #endif /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not * matter since it will be recomputed at next deflate call. */ } } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } #ifndef FASTEST /* =========================================================================== * Same as above, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head = NIL; /* head of hash chain */ int bflush; /* set if current block must be flushed */ /* Process the input block. */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ if (s->lookahead >= MIN_MATCH) { INSERT_STRING(s, s->strstart, hash_head); } /* Find the longest match, discarding those <= prev_length. */ s->prev_length = s->match_length, s->prev_match = s->match_start; s->match_length = MIN_MATCH-1; if (hash_head != NIL && s->prev_length < s->max_lazy_match && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string * of window index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) { s->match_length = longest_match (s, hash_head); } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) { s->match_length = longest_match_fast (s, hash_head); } /* longest_match() or longest_match_fast() sets match_start */ if (s->match_length <= 5 && (s->strategy == Z_FILTERED #if TOO_FAR <= 32767 || (s->match_length == MIN_MATCH && s->strstart - s->match_start > TOO_FAR) #endif )) { /* If prev_match is also MIN_MATCH, match_start is garbage * but we will ignore the current match anyway. */ s->match_length = MIN_MATCH-1; } } /* If there was a match at the previous step and the current * match is not better, output the previous match: */ if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; /* Do not insert strings in hash table beyond this. */ check_match(s, s->strstart-1, s->prev_match, s->prev_length); _tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - MIN_MATCH, bflush); /* Insert in hash table all strings up to the end of the match. * strstart-1 and strstart are already inserted. If there is not * enough lookahead, the last two strings are not inserted in * the hash table. */ s->lookahead -= s->prev_length-1; s->prev_length -= 2; do { if (++s->strstart <= max_insert) { INSERT_STRING(s, s->strstart, hash_head); } } while (--s->prev_length != 0); s->match_available = 0; s->match_length = MIN_MATCH-1; s->strstart++; if (bflush) FLUSH_BLOCK(s, 0); } else if (s->match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ Tracevv((stderr,"%c", s->window[s->strstart-1])); _tr_tally_lit(s, s->window[s->strstart-1], bflush); if (bflush) { FLUSH_BLOCK_ONLY(s, 0); } s->strstart++; s->lookahead--; if (s->strm->avail_out == 0) return need_more; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ s->match_available = 1; s->strstart++; s->lookahead--; } } Assert (flush != Z_NO_FLUSH, "no flush?"); if (s->match_available) { Tracevv((stderr,"%c", s->window[s->strstart-1])); _tr_tally_lit(s, s->window[s->strstart-1], bflush); s->match_available = 0; } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } #endif /* FASTEST */ #if 0 /* =========================================================================== * For Z_RLE, simply look for runs of bytes, generate matches only of distance * one. Do not maintain a hash table. (It will be regenerated if this run of * deflate switches away from Z_RLE.) */ local block_state deflate_rle(s, flush) deflate_state *s; int flush; { int bflush; /* set if current block must be flushed */ uInt run; /* length of run */ uInt max; /* maximum length of run */ uInt prev; /* byte at distance one to match */ Bytef *scan; /* scan for end of run */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the longest encodable run. */ if (s->lookahead < MAX_MATCH) { fill_window(s); if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* See how many times the previous byte repeats */ run = 0; if (s->strstart > 0) { /* if there is a previous byte, that is */ max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; scan = s->window + s->strstart - 1; prev = *scan++; do { if (*scan++ != prev) break; } while (++run < max); } /* Emit match if have run of MIN_MATCH or longer, else emit literal */ if (run >= MIN_MATCH) { check_match(s, s->strstart, s->strstart - 1, run); _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); s->lookahead -= run; s->strstart += run; } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit (s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } FLUSH_BLOCK(s, flush == Z_FINISH); return flush == Z_FINISH ? finish_done : block_done; } #endif wgd-3.1/src/resources_base/zlib/crc32.cpp0000644000175000001440000003263610755642352015251 00000000000000/* crc32.c -- compute the CRC-32 of a data stream * Copyright (C) 1995-2005 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Thanks to Rodney Brown for his contribution of faster * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing * tables for updating the shift register in one step with three exclusive-ors * instead of four steps with four exclusive-ors. This results in about a * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. */ /* @(#) $Id$ */ /* Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection on the static variables used to control the first-use generation of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should first call get_crc_table() to initialize the tables before allowing more than one thread to use crc32(). */ #ifdef MAKECRCH # include # ifndef DYNAMIC_CRC_TABLE # define DYNAMIC_CRC_TABLE # endif /* !DYNAMIC_CRC_TABLE */ #endif /* MAKECRCH */ #include /* for STDC and FAR definitions */ #define local static /* Find a four-byte integer type for crc32_little() and crc32_big(). */ #ifndef NOBYFOUR # ifdef STDC /* need ANSI C limits.h to determine sizes */ # include # define BYFOUR # if (UINT_MAX == 0xffffffffUL) typedef unsigned int u4; # else # if (ULONG_MAX == 0xffffffffUL) typedef unsigned long u4; # else # if (USHRT_MAX == 0xffffffffUL) typedef unsigned short u4; # else # undef BYFOUR /* can't find a four-byte integer type! */ # endif # endif # endif # endif /* STDC */ #endif /* !NOBYFOUR */ /* Definitions for doing the crc four data bytes at a time. */ #ifdef BYFOUR # define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long, const unsigned char FAR *, unsigned)); local unsigned long crc32_big OF((unsigned long, const unsigned char FAR *, unsigned)); # define TBLS 8 #else # define TBLS 1 #endif /* BYFOUR */ /* Local functions for crc concatenation */ local unsigned long gf2_matrix_times OF((unsigned long *mat, unsigned long vec)); local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); #ifdef DYNAMIC_CRC_TABLE local volatile int crc_table_empty = 1; local unsigned long FAR crc_table[TBLS][256]; local void make_crc_table OF((void)); #ifdef MAKECRCH local void write_table OF((FILE *, const unsigned long FAR *)); #endif /* MAKECRCH */ /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b. This calculation is done using the shift-register method of multiplying and taking the remainder. The register is initialized to zero, and for each incoming bit, x^32 is added mod p to the register if the bit is a one (where x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x (which is shifting right by one and adding x^32 mod p if the bit shifted out is a one). We start with the highest power (least significant bit) of q and repeat for all eight bits of q. The first table is simply the CRC of all possible eight bit values. This is all the information needed to generate CRCs on data a byte at a time for all combinations of CRC register values and incoming bytes. The remaining tables allow for word-at-a-time CRC calculation for both big-endian and little- endian machines, where a word is four bytes. */ local void make_crc_table() { unsigned long c; int n, k; unsigned long poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ static volatile int first = 1; /* flag to limit concurrent making */ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; /* See if another task is already doing this (not thread-safe, but better than nothing -- significantly reduces duration of vulnerability in case the advice about DYNAMIC_CRC_TABLE is ignored) */ if (first) { first = 0; /* make exclusive-or pattern from polynomial (0xedb88320UL) */ poly = 0UL; for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) poly |= 1UL << (31 - p[n]); /* generate a crc for every 8-bit value */ for (n = 0; n < 256; n++) { c = (unsigned long)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[0][n] = c; } #ifdef BYFOUR /* generate crc for each value followed by one, two, and three zeros, and then the byte reversal of those as well as the first table */ for (n = 0; n < 256; n++) { c = crc_table[0][n]; crc_table[4][n] = REV(c); for (k = 1; k < 4; k++) { c = crc_table[0][c & 0xff] ^ (c >> 8); crc_table[k][n] = c; crc_table[k + 4][n] = REV(c); } } #endif /* BYFOUR */ crc_table_empty = 0; } else { /* not first */ /* wait for the other guy to finish (not efficient, but rare) */ while (crc_table_empty) ; } #ifdef MAKECRCH /* write out CRC tables to crc32.h */ { FILE *out; out = fopen("crc32.h", "w"); if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); fprintf(out, "local const unsigned long FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); # ifdef BYFOUR fprintf(out, "#ifdef BYFOUR\n"); for (k = 1; k < 8; k++) { fprintf(out, " },\n {\n"); write_table(out, crc_table[k]); } fprintf(out, "#endif\n"); # endif /* BYFOUR */ fprintf(out, " }\n};\n"); fclose(out); } #endif /* MAKECRCH */ } #ifdef MAKECRCH local void write_table(out, table) FILE *out; const unsigned long FAR *table; { int n; for (n = 0; n < 256; n++) fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); } #endif /* MAKECRCH */ #else /* !DYNAMIC_CRC_TABLE */ /* ======================================================================== * Tables of CRC-32s of all single-byte values, made by make_crc_table(). */ #include #endif /* DYNAMIC_CRC_TABLE */ /* ========================================================================= * This function can be used by asm versions of crc32() */ const unsigned long FAR * ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ return (const unsigned long FAR *)crc_table; } /* ========================================================================= */ #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 /* ========================================================================= */ unsigned long ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len) //unsigned long ZEXPORT crc32(crc, buf, len) // unsigned long crc; // const unsigned char FAR *buf; // unsigned len; { if (buf == Z_NULL) return 0UL; #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ #ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { u4 endian; endian = 1; if (*((unsigned char *)(&endian))) return crc32_little(crc, buf, len); else return crc32_big(crc, buf, len); } #endif /* BYFOUR */ crc = crc ^ 0xffffffffUL; while (len >= 8) { DO8; len -= 8; } if (len) do { DO1; } while (--len); return crc ^ 0xffffffffUL; } #ifdef BYFOUR /* ========================================================================= */ #define DOLIT4 c ^= *buf4++; \ c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] #define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 /* ========================================================================= */ local unsigned long crc32_little (unsigned long crc, const unsigned char FAR *buf, unsigned len) //local unsigned long crc32_little(crc, buf, len) // unsigned long crc; // const unsigned char FAR *buf; // unsigned len; { register u4 c; register const u4 FAR *buf4; c = (u4)crc; c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); len--; } buf4 = (const u4 FAR *)(const void FAR *)buf; while (len >= 32) { DOLIT32; len -= 32; } while (len >= 4) { DOLIT4; len -= 4; } buf = (const unsigned char FAR *)buf4; if (len) do { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); } while (--len); c = ~c; return (unsigned long)c; } /* ========================================================================= */ #define DOBIG4 c ^= *++buf4; \ c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 /* ========================================================================= */ local unsigned long crc32_big(unsigned long crc, const unsigned char FAR *buf, unsigned len) //local unsigned long crc32_big(crc, buf, len) // unsigned long crc; // const unsigned char FAR *buf; // unsigned len; { register u4 c; register const u4 FAR *buf4; c = REV((u4)crc); c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); len--; } buf4 = (const u4 FAR *)(const void FAR *)buf; buf4--; while (len >= 32) { DOBIG32; len -= 32; } while (len >= 4) { DOBIG4; len -= 4; } buf4++; buf = (const unsigned char FAR *)buf4; if (len) do { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); } while (--len); c = ~c; return (unsigned long)(REV(c)); } #endif /* BYFOUR */ #define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ /* ========================================================================= */ local unsigned long gf2_matrix_times(unsigned long *mat, unsigned long vec) //local unsigned long gf2_matrix_times(mat, vec) // unsigned long *mat; // unsigned long vec; { unsigned long sum; sum = 0; while (vec) { if (vec & 1) sum ^= *mat; vec >>= 1; mat++; } return sum; } /* ========================================================================= */ local void gf2_matrix_square(unsigned long *square, unsigned long *mat) //local void gf2_matrix_square(square, mat) // unsigned long *square; // unsigned long *mat; { int n; for (n = 0; n < GF2_DIM; n++) square[n] = gf2_matrix_times(mat, mat[n]); } /* ========================================================================= */ uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) //uLong ZEXPORT crc32_combine(crc1, crc2, len2) // uLong crc1; // uLong crc2; // z_off_t len2; { int n; unsigned long row; unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ /* degenerate case */ if (len2 == 0) return crc1; /* put operator for one zero bit in odd */ odd[0] = 0xedb88320L; /* CRC-32 polynomial */ row = 1; for (n = 1; n < GF2_DIM; n++) { odd[n] = row; row <<= 1; } /* put operator for two zero bits in even */ gf2_matrix_square(even, odd); /* put operator for four zero bits in odd */ gf2_matrix_square(odd, even); /* apply len2 zeros to crc1 (first square will put the operator for one zero byte, eight zero bits, in even) */ do { /* apply zeros operator for this bit of len2 */ gf2_matrix_square(even, odd); if (len2 & 1) crc1 = gf2_matrix_times(even, crc1); len2 >>= 1; /* if no more bits set, then done */ if (len2 == 0) break; /* another iteration of the loop with odd and even swapped */ gf2_matrix_square(odd, even); if (len2 & 1) crc1 = gf2_matrix_times(odd, crc1); len2 >>= 1; /* if no more bits set, then done */ } while (len2 != 0); /* return combined crc */ crc1 ^= crc2; return crc1; } wgd-3.1/src/widgets/0000777000175000001440000000000011265576313011405 500000000000000wgd-3.1/src/widgets/widgets.cpp0000644000175000001440000003527011233311614013464 00000000000000#include #include #include #include #include #include #include #include #undef False using namespace wgd; using namespace doste; using namespace doste::dvm; wgd::OID WidgetManager::s_focus; bool WidgetManager::s_rebuild; Widget *Widget::s_prevmouse = 0; namespace wgd { OnEvent(WidgetManager, evt_mouse) { if (get(ix::root) == Null) return; int mx = wgd::mouse->x(); int my = wgd::mouse->y(); Widget *root = get(ix::root); if (root != 0) root->mouse(mx,my); set("over", s_focus, true); } OnEvent(WidgetManager, evt_focus) { if(get(ix::focus)!=Null) { Widget *cw = get(ix::focus); if(cw) cw->setfocus(); } } IMPLEMENT_EVENTS(WidgetManager, Agent); }; wgd::WidgetManager::WidgetManager(const OID &o) : Agent(o) { s_focus = Null; s_rebuild=true; Object::registerType(); Object::registerType(); registerEvents(); //std::cout << "Made widget manager\n"; } wgd::WidgetManager::~WidgetManager() { } void wgd::WidgetManager::draw() { //Prevent the changing of the depth buffer. glDepthMask(0); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glEnable(GL_SCISSOR_TEST); glScissor(0,0,wgd::window->width(),wgd::window->height()); glMatrixMode(GL_PROJECTION); glPushMatrix(); // Store The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(0,wgd::window->width(),0,wgd::window->height(),-1,1); // Set Up An Ortho Screen glMatrixMode(GL_MODELVIEW); glPushMatrix(); //create clip rect ClipRect r; r.top=0; r.left=0; r.right = window->width(); r.bottom = window->height(); //Draw widgets if (get(ix::root) != Null) { Widget *root = getObject("root"); if (root != 0) { root->draw(r); } } glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); // Restore The Old Projection Matrix glMatrixMode(GL_MODELVIEW); //Lighting::enabled(lightstate); glEnable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); //Allow depth buffer to be changed again glDepthMask(1); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// wgd::Widget::Widget(const doste::dvm::OID &id) : Agent(id) { m_remake = true; m_vertices = NULL; m_indices = NULL; m_nIndices=0; m_nVertices=0; //add screen position to database _DASM( this screenx is { if(this parent == null) { this x } else { this parent screenx add (this x) } } ); _DASM( this screeny is { if(this parent == null) { this y } else { this parent screeny add (this y) } } ); //mouseover _DASM( this mouseover is {this == (@root widgets over) } ); //Register Triggers registerEvents(); } wgd::Widget::~Widget() { if(m_vertices!=NULL) delete [] m_vertices; if(m_indices!=NULL) delete [] m_indices; } void wgd::Widget::event(const doste::dvm::OID& type){ //cause any triggers to fire property(type, true); property(type, false); } void wgd::Widget::make(int x, int y, int w, int h){ property(ix::x, x); property(ix::y, y); width(w); height(h); } extern WidgetManager *wm; void wgd::Widget::update(){ } namespace wgd { OnEvent(Widget, evt_changed) { m_remake = true; } OnEvent(Widget, evt_frame) { m_remake = true; } OnEvent(Widget, evt_text) { resizeText(); } OnEvent(Widget, evt_child) { //Could mean that an object changed or //was deleted, but for now assume it was added //NOTE: THIS IS A BUG THAT CAN OCCUR IF A SCRIPT IS RUN MULTIPLE TIMES. Widget *child; OID children = get(ix::children); m_focus.clear(); //Check for all existing children for (OID::iterator i=children.begin(); i!=children.end(); i++) { if ((*i) == Parent) continue; child = (Widget*) children.get(*i); if (child != 0){ child->set(ix::parent, *this, true); int z = child->get(ix::z); addFocus(child); //m_focus.push_front(child); } } } IMPLEMENT_EVENTS(Widget, Agent); }; void wgd::Widget::addFocus(Widget *w) { int z = w->get(ix::z); for (std::list::iterator i=m_focus.begin(); i!=m_focus.end(); i++) { int wz = (*i)->get(ix::z); if(z >= wz) { m_focus.insert(i, w); return; } } //stick it on the end if not added m_focus.push_back(w); } void wgd::Widget::resizeText() { if (get(ix::font) == Null) return; Font *fnt = font(); if (fnt == 0) return; int twidth=0; int theight=0; doste::dstring t = caption(); int len = t.size(); for(int i=0; iCharWidth(t[i]); theight+=fnt->CharHeight(t[i]); } if (len > 0) theight/=len; set("textwidth", twidth, true); set("textheight", theight, true); } bool wgd::Widget::mouse(int mx, int my) { vector2d pos = screenPosition(); if ((pos.x <= mx) && ((pos.x+width()) >= mx) && (pos.y <= my) && ((pos.y+height()) >= my)) { //OID children = get(ix::children); bool found = false; if (m_focus.size()) { Widget *child; //For each child. //for (OID::iterator i=children.begin(); i!=children.end(); i++) { for (std::list::iterator i=m_focus.begin(); i!=m_focus.end(); i++) { child = *i; if (child->visible()) { if (child->mouse(mx,my)) { found = true; break; } } } } if (!found) { //if (s_prevmouse != this) { //if (s_prevmouse != 0) s_prevmouse->set("mouseover", false); //std::cout << "Changing mouseover\n"; //set("mouseover", true); //s_prevmouse = this; WidgetManager::s_focus = *this; //} } return true; } //else { //Set all children to mouseover false. //set("mouseover", false); //} return false; } void wgd::Widget::setfocus() { //recursively make focus if(get(ix::parent)!=Null){ Widget *parent = get(ix::parent); if(parent) { //set this widget as the fucused widget parent->makefocus(this); //recursively focus parent widget parent->setfocus(); } } } void wgd::Widget::makefocus(Widget *w) { if (m_focus.front() == w) return; for (std::list::iterator i=m_focus.begin(); i!=m_focus.end(); i++) { if ((*i) == w) { m_focus.erase(i); break; } } //bring as far forward as it can go addFocus(w); } void wgd::Widget::draw(const ClipRect &rect){ int glerr; if ((glerr = glGetError()) != 0) { DMsg msg(DMsg::ERROR); msg << "OpenGL Error: " << glerr << "\n"; } //build vertex array if(m_remake && get(ix::sprite) != Null){ clearFrame(); addFrame(0, 0, width(), height(), frame(), border()); } if (get(ix::sprite) != Null) drawSprite(); if (get(ix::caption) != Null && get(ix::font) != Null) { if(get("textcolour")!=Null){ colour col = textColour(); glColor4f(col.r,col.g,col.b,col.a); } else { glColor4f(0.0f,0.0f,0.0f,1.0f); } drawText(textX(), textY(), caption(), font()); glColor4f(1.0f,1.0f,1.0f,1.0f); } if (m_remake) m_remake = false; drawChildren(rect); } void wgd::Widget::drawChildren(const ClipRect &rect) { OID children = get(ix::children); if (children == Null) return; Widget *child; ClipRect r, rchild; r.top = (int)get(ix::screeny); r.left = (int)get(ix::screenx); r.right = r.left + width(); r.bottom = r.top + height(); for (std::list::reverse_iterator i=m_focus.rbegin(); i!=m_focus.rend(); i++) { child = *i; if (child != 0 && child->visible()) { //scissor text to clip drawing to the widget //glScissor(x,wh-y,w,h); rchild = clip(rect, r); child->draw(rchild); } } } ClipRect wgd::Widget::clip(const ClipRect &base, const ClipRect &r) { ClipRect c; //Intersect rectangles c.top = max(base.top, r.top); c.left = max(base.left, r.left); c.right = min(base.right, r.right); c.bottom = min(base.bottom, r.bottom); //make sure width and height are positive if(c.right < c.left) c.right = c.left; if(c.bottom < c.top) c.bottom = c.top; //do scissor test glScissor(c.left, window->height() - c.bottom, c.right-c.left, c.bottom-c.top); return c; } void wgd::Widget::clearFrame(){ if(m_vertices!=NULL) delete [] m_vertices; if(m_indices!=NULL) delete [] m_indices; m_vertices=NULL; m_indices=NULL; m_nVertices = 0; m_nIndices = 0; } void wgd::Widget::addFrame(int x, int y, int cw, int ch, int cframe, int cborder) { Sprite *spr = sprite(); //Does the sprite need flipping? bool fx = false; bool fy = false; if(spr!=0){ fx = spr->fliph(); fy = !spr->flipv(); //Get sprite texture coordinates //m_tw = ((float)spr->width() / (float)spr->texture()->width()) / (float)spr->columns(); //m_th = -((float)spr->height() / (float)spr->texture()->height()) / (float)spr->rows(); m_tw = 1.0f / (float)spr->columns(); m_th = -1.0f / (float)spr->rows(); m_tx = m_tw * (float)(cframe % spr->columns()); m_ty = m_th * (float)(cframe / spr->columns()); } //calculate offset float ox = (float)x + (float)cw/2.0f; float oy = - (float)y - (float)ch/2.0f; float w = (float)cw/2.0f; float h = (float)ch/2.0f; //If w and h are not defined - take them from the sprite if(spr!=0){ if(w<1.0) w = (float)spr->width() / 2; if(h<1.0) h = (float)spr->height() / 2; } //Build vertex array if(cborder<=0 || spr==0 || spr->texture()==0){ //Single polygon version //resize vertex array int j = m_nVertices; vertex* tmpv = new vertex[m_nVertices + 4]; memcpy(tmpv, m_vertices, m_nVertices * sizeof(vertex)); if(m_vertices)delete [] m_vertices; m_vertices = tmpv; m_nVertices+=4; //add new vertices for(int i=0; i<4; i++){ m_vertices[i+j].x = ox + (i<2? w: -w); m_vertices[i+j].y = oy + (i%2? h: -h); m_vertices[i+j].u = ((i<2 && !fx) || (!(i<2) && fx) )? m_tx+m_tw : m_tx; m_vertices[i+j].v = ((i%2 && !fy) || (!(i%2) && fy) )? m_ty+m_th : m_ty; } unsigned char tIndices[] = {0, 1, 3, 2}; //Resize Index array unsigned char* tmpi = new unsigned char[m_nIndices + 4]; memcpy(tmpi, m_indices, m_nIndices); if(m_indices)delete [] m_indices; m_indices = tmpi; //copy data for(int i=0; i<4; i++) m_indices[m_nIndices + i] = tIndices[i] + j; m_nIndices+=4; } else { //edges are separate (texture must exist) float b = (float)cborder; //Border (in pixels) spr->texture()->load(); float tbx = b / ((float)spr->texture()->width()); //Border (texture units u) float tby = -b / ((float)spr->texture()->height()); //Border (texture units v) //std::cout << "Adding frame: " << spr->texture()->width() << "\n"; //resize vertex array int j = m_nVertices; vertex* tmpv = new vertex[m_nVertices + 16]; memcpy(tmpv, m_vertices, m_nVertices * sizeof(vertex)); if(m_vertices)delete [] m_vertices; m_vertices = tmpv; m_nVertices+=16; //Add new vertices for(int i=0; i<4; i++){ m_vertices[j+i ].y = oy + h; m_vertices[j+i+ 4].y = oy + h-b; m_vertices[j+i+ 8].y = oy + b-h; m_vertices[j+i+12].y = oy + -h; m_vertices[j+i*4 ].x = ox + -w; m_vertices[j+i*4+1].x = ox + b-w; m_vertices[j+i*4+2].x = ox + w-b; m_vertices[j+i*4+3].x = ox + w; //UVs m_vertices[j+i ].v = (fy ? m_ty : m_ty+m_th); m_vertices[j+i+ 4].v = (fy ? m_ty+tby : m_ty+m_th-tby); m_vertices[j+i+ 8].v = (fy ? m_ty+m_th-tby : m_ty+tby); m_vertices[j+i+12].v = (fy ? m_ty+m_th : m_ty); m_vertices[j+i*4 ].u = (!fx ? m_tx : m_tx+m_tw); m_vertices[j+i*4+1].u = (!fx ? m_tx+tbx : m_tx+m_tw-tbx); m_vertices[j+i*4+2].u = (!fx ? m_tx+m_tw-tbx : m_tx+tbx); m_vertices[j+i*4+3].u = (!fx ? m_tx+m_tw : m_tx); } //Create indices unsigned char tIndices[] = { 0,4,5,1, 1,5,6,2, 2,6,7,3, 4,8,9,5, 5,9,10,6, 6,10,11,7, 8,12,13,9, 9,13,14,10, 10,14,15,11}; //Resize Index array unsigned char* tmpi = new unsigned char[m_nIndices + 9*4]; memcpy(tmpi, m_indices, m_nIndices); if(m_indices)delete [] m_indices; m_indices = tmpi; //copy data for(int i=0; i<9*4; i++) m_indices[m_nIndices + i] = tIndices[i] + j; m_nIndices+=9*4; } } void wgd::Widget::drawSprite(){ Sprite *spr = sprite(); if(spr!=0 && spr->texture() != 0) spr->texture()->bind(); else return; //translate to position glLoadIdentity(); glRasterPos2f(0.0,0.0); vector2d pos = screenPosition(); pos.y = wgd::window->height() - pos.y; glTranslatef(pos.x, pos.y, 0.0); //std::cout << "Widget: " << pos.x << "," << pos.y << "\n"; //Tint - if it exists if (get(ix::tint) != Null) { colour tin = tint(); glColor4f(tin.r, tin.g, tin.b, tin.a); } //Draw the vertex array glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); float* pointer = &m_vertices[0].x; glVertexPointer (2, GL_FLOAT, sizeof(vertex), pointer); glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), pointer+6); glDrawElements(GL_QUADS, m_nIndices, GL_UNSIGNED_BYTE, m_indices); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glColor4f(1.0f,1.0f,1.0f,1.0f); if(spr!=0) spr->texture()->unbind(); } void wgd::Widget::drawText(int ox, int oy, const char* t, Font* fnt){ if (fnt == 0) return; //Length of string to draw int len = strlen(t); if(len==0) return; //no point continuing with no string //This will start at the top left corner, and will truncate. glLoadIdentity(); glRasterPos2f(0.0,0.0); vector2d pos = screenPosition(); float posX = pos.x + ox; float posY = wgd::window->height() - pos.y - oy; glTranslatef((float)(int)posX, (float)(int)posY, 0); //std::cout << "Draw text: " << posX << "," << posY << "\n"; fnt->bind(); if (m_remake) resizeText(); //get font //if(fnt==NULL) fnt = Resource::convert(WGD[ix::console][ix::font]); //if (fnt->texture() == 0) return; float tx,ty,tw,th; int cw,ch; int x = 0; float texw = (float)fnt->texture()->width(); float texh = (float)fnt->texture()->height(); //float texw = 256.0f; //float texh = 256.0f; for (int i=0; iCharX(t[i]) / texw; ty = (float)fnt->CharY(t[i]) / texh; cw = fnt->CharWidth(t[i]); ch = fnt->CharHeight(t[i]); tw = (float)cw / texw; th = (float)ch / texh; //ch may be negative if(ch<0) ch = -ch; //clip text //if(!centered && x+cw > width() - ox) break; if(x>=0){ glBegin(GL_QUADS); glTexCoord2f(tx, ty+th); glVertex2i(x, -ch); glTexCoord2f(tx+tw, ty+th); glVertex2i(x+cw, -ch); glTexCoord2f(tx+tw, ty); glVertex2i(x+cw, 0); glTexCoord2f(tx, ty); glVertex2i(x, 0); glEnd(); } x += cw; } fnt->unbind(); } WidgetManager *wm; extern "C" void WIDIMPORT initialise(const doste::dvm::OID &base) { Object::registerType(); wm = base; } extern "C" void WIDIMPORT update() { wm->draw(); } extern "C" void WIDIMPORT finalise() { //delete wm; } wgd-3.1/src/widgets/Makefile.am0000644000175000001440000000046411021713643013346 00000000000000bindir=$(datadir)/@PACKAGE@/modules bin_PROGRAMS=libwgd_widgets.so libwgd_widgets_so_SOURCES=widgets.cpp wviewport.cpp AM_CPPFLAGS=-fPIC AM_LDFLAGS=-L../base -L../resources_base -shared -lGL -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base INCLUDES=-I@top_srcdir@/include -I@top_builddir@/include wgd-3.1/src/widgets/Makefile.in0000644000175000001440000003027311265575055013375 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = libwgd_widgets.so$(EXEEXT) subdir = src/widgets DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_libwgd_widgets_so_OBJECTS = widgets.$(OBJEXT) wviewport.$(OBJEXT) libwgd_widgets_so_OBJECTS = $(am_libwgd_widgets_so_OBJECTS) libwgd_widgets_so_LDADD = $(LDADD) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = am__depfiles_maybe = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libwgd_widgets_so_SOURCES) DIST_SOURCES = $(libwgd_widgets_so_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = $(datadir)/@PACKAGE@/modules build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ libwgd_widgets_so_SOURCES = widgets.cpp wviewport.cpp AM_CPPFLAGS = -fPIC AM_LDFLAGS = -L../base -L../resources_base -shared -lGL -lX11 -lXxf86vm -ldoste -lwgd_base -lwgd_resources_base INCLUDES = -I@top_srcdir@/include -I@top_builddir@/include all: all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/widgets/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps src/widgets/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) libwgd_widgets.so$(EXEEXT): $(libwgd_widgets_so_OBJECTS) $(libwgd_widgets_so_DEPENDENCIES) @rm -f libwgd_widgets.so$(EXEEXT) $(CXXLINK) $(libwgd_widgets_so_OBJECTS) $(libwgd_widgets_so_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c .cpp.o: $(CXXCOMPILE) -c -o $@ $< .cpp.obj: $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-exec-am: install-binPROGRAMS install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/src/widgets/wviewport.cpp0000644000175000001440000000712011233311614014055 00000000000000#include #include #include #include using namespace wgd; using namespace doste; using namespace doste::dvm; WViewport::WViewport(const doste::dvm::OID &id) : Widget(id) { } WViewport::~WViewport() { } void WViewport::draw(const ClipRect &rect) { if (get(ix::source) == Null) { //Use camera and scene Camera *cam = camera(); Scene *sc = scene(); if (cam == 0 || sc == 0) return; if (Extensions::hasColourClamp()) { WGDglClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_FALSE); WGDglClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FALSE); } vector2d pos = screenPosition(); int w = width(); int h = height(); int wh = wgd::window->height() - h; //clip window ClipRect r; r.top = (int)pos.y; r.left = (int)pos.x; r.right = r.left + w; r.bottom = r.top + h; clip(rect, r); cam->size(w, h); //glScissor((int)pos.x,wh-(int)pos.y,w,h); glViewport((int)pos.x,wh-(int)pos.y,w,h); glEnable(GL_DEPTH_TEST); glDepthMask(1); cam->bind(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glShadeModel(GL_SMOOTH); glDisable(GL_TEXTURE_2D); //glEnable(GL_BLEND); float poss[] = {0.0, 1.0f, 1.0f, 0.0}; glLightfv(GL_LIGHT0, GL_POSITION, poss); float amb[] = {0.3f, 0.3f, 0.3f, 1.0f}; glLightfv(GL_LIGHT0, GL_AMBIENT, amb); float diff[] = {1.0f, 1.0f, 1.0f, 1.0f}; glLightfv(GL_LIGHT0, GL_DIFFUSE, diff); float spec[] = {0.5f, 0.5f, 0.5f, 1.0f}; glLightfv(GL_LIGHT0, GL_SPECULAR, spec); //clear colour - would be cool to do some stencil stuff so we can draw to an arbitrary shape if(get("clear")!=Null) { colour c = get("clear"); if(c.a > 0.0f) { glClearColor(c.r, c.g, c.b, c.a); glClear(GL_COLOR_BUFFER_BIT); } } sc->draw(cam); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); cam->unbind(); if (Extensions::hasColourClamp()) { WGDglClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, GL_TRUE); WGDglClampColorARB(GL_CLAMP_FRAGMENT_COLOR_ARB, GL_FIXED_ONLY_ARB); } glDepthMask(0); glDisable(GL_DEPTH_TEST); glViewport(0,0,wgd::window->width(),wgd::window->height()); } else { RenderTarget *src = source(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); src->draw(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); vector2d pos = screenPosition(); int w = width(); int h = height(); int wh = wgd::window->height() - h; glScissor((int)pos.x,wh-(int)pos.y,w,h); glViewport((int)pos.x,wh-(int)pos.y,w,h); glMatrixMode(GL_PROJECTION); glPushMatrix(); // Store The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(0,w,0,h,-1,1); // Set Up An Ortho Screen glMatrixMode(GL_MODELVIEW); glPushMatrix(); // Store The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix //Reset raster position glRasterPos2f(0.0,0.0); glTranslatef(0.0, 0.0, -1.0); //glEnable(GL_DEPTH_TEST); //glDepthMask(1); //Use rendertarget. src->bind(); glColor4f(1.0,1.0,1.0,1.0); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(0.0, 0.0, 0.0); glTexCoord2f(1.0, 0.0); glVertex3f((float)w, 0.0, 0.0); glTexCoord2f(1.0, 1.0); glVertex3f((float)w, (float)h, 0.0); glTexCoord2f(0.0, 1.0); glVertex3f(0.0, (float)h, 0.0); glEnd(); src->unbind(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glViewport(0,0,wgd::window->width(),wgd::window->height()); } drawChildren(rect); } wgd-3.1/scripts/0000777000175000001440000000000011265576315010641 500000000000000wgd-3.1/scripts/themes/0000777000175000001440000000000011265576315012126 500000000000000wgd-3.1/scripts/themes/Makefile.am0000644000175000001440000000014711000437021014051 00000000000000scriptdir = $(datadir)/@PACKAGE@/scripts/themes script_DATA=simple_dark.dasm EXTRA_DIST=$(script_DATA) wgd-3.1/scripts/themes/Makefile.in0000644000175000001440000002257411265575054014120 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scripts/themes DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(scriptdir)" scriptDATA_INSTALL = $(INSTALL_DATA) DATA = $(script_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ scriptdir = $(datadir)/@PACKAGE@/scripts/themes script_DATA = simple_dark.dasm EXTRA_DIST = $(script_DATA) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps scripts/themes/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps scripts/themes/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-scriptDATA: $(script_DATA) @$(NORMAL_INSTALL) test -z "$(scriptdir)" || $(MKDIR_P) "$(DESTDIR)$(scriptdir)" @list='$(script_DATA)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(scriptDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(scriptdir)/$$f'"; \ $(scriptDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(scriptdir)/$$f"; \ done uninstall-scriptDATA: @$(NORMAL_UNINSTALL) @list='$(script_DATA)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(scriptdir)/$$f'"; \ rm -f "$(DESTDIR)$(scriptdir)/$$f"; \ done tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(scriptdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-scriptDATA install-dvi: install-dvi-am install-exec-am: install-html: install-html-am install-info: install-info-am install-man: install-pdf: install-pdf-am install-ps: install-ps-am installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-scriptDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-scriptDATA install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ uninstall-am uninstall-scriptDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/scripts/themes/simple_dark.dasm0000644000175000001440000000275611064133263015200 00000000000000#Simpel_dark theme script. this widgets sprite = (new type = Sprite texture = (new type = Texture file = (new type = LocalFile base = (this datadir) filename = "./data/simple_dark.png" ) compress = false mipmap = false nearest = true ) columns = 4 rows = 4 frames = 16 border = 6 ); this widgets tint = (new r=1.0 g=1.0 b=1.0 a=1.0); this widgets font = (new type = Font size = 12 name = "helvetica" bold = false ); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/widget.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/button.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/window.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/colours.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/trackbar1.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/label.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/scrollbar.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/editbox.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/listbox.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/textbox.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/popup.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/themes/simple_dark/treeview.dasm"); wgd-3.1/scripts/Makefile.am0000644000175000001440000000015111013000002012544 00000000000000scriptdir = $(datadir)/@PACKAGE@/scripts script_DATA=linux.dasm EXTRA_DIST=$(script_DATA) SUBDIRS=themes wgd-3.1/scripts/Makefile.in0000644000175000001440000003556611265575054012640 00000000000000# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = scripts DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = depcomp = am__depfiles_maybe = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(scriptdir)" scriptDATA_INSTALL = $(INSTALL_DATA) DATA = $(script_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__leading_dot = @am__leading_dot@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ scriptdir = $(datadir)/@PACKAGE@/scripts script_DATA = linux.dasm EXTRA_DIST = $(script_DATA) SUBDIRS = themes all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps scripts/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --gnu --ignore-deps scripts/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh install-scriptDATA: $(script_DATA) @$(NORMAL_INSTALL) test -z "$(scriptdir)" || $(MKDIR_P) "$(DESTDIR)$(scriptdir)" @list='$(script_DATA)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f=$(am__strip_dir) \ echo " $(scriptDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(scriptdir)/$$f'"; \ $(scriptDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(scriptdir)/$$f"; \ done uninstall-scriptDATA: @$(NORMAL_UNINSTALL) @list='$(script_DATA)'; for p in $$list; do \ f=$(am__strip_dir) \ echo " rm -f '$(DESTDIR)$(scriptdir)/$$f'"; \ rm -f "$(DESTDIR)$(scriptdir)/$$f"; \ done # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(DATA) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(scriptdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-scriptDATA install-dvi: install-dvi-recursive install-exec-am: install-html: install-html-recursive install-info: install-info-recursive install-man: install-pdf: install-pdf-recursive install-ps: install-ps-recursive installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-scriptDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic ctags \ ctags-recursive distclean distclean-generic distclean-tags \ distdir dvi dvi-am html html-am info info-am install \ install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-scriptDATA install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-scriptDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: wgd-3.1/scripts/linux.dasm0000644000175000001440000000032111026710112012532 00000000000000@dasm run = (new type=LocalFile filename = "./scripts/wgd.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/modules-linux.dasm"); @dasm run = (new type=LocalFile filename = "./scripts/load.dasm"); wgd-3.1/ChangeLog0000755000175000001440000000000010750154243010617 00000000000000