Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3140 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Dec 10, 2004, 7:44:36 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: merged branches/images back into the trunk.
merged with command: svn merge bensches/images/ trunk/ -r 3084:HEAD

Conflicts in configure/.ac

resolved in favor of branches/images (newer)

Mayor differences:

  1. Image-Importing capability.
  2. configure remade for usage with sdl-image/jpeglib and so on.
  3. Absolutely no change in the trunk/src
Location:
orxonox/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/config.h.in

    r3101 r3140  
    1616#undef HAVE_INTTYPES_H
    1717
     18/* Define to 1 if you have the <jpeglib.h> header file. */
     19#undef HAVE_JPEGLIB_H
     20
    1821/* Define to 1 if you have the `m' library (-lm). */
    1922#undef HAVE_LIBM
     
    3235#undef HAVE_OPENGL_GL_H
    3336
     37/* Define to 1 if you have the <png.h> header file. */
     38#undef HAVE_PNG_H
     39
    3440/* Define to 1 if you have the <SDL/SDL.h> header file. */
    3541#undef HAVE_SDL_SDL_H
     42
     43/* Define to 1 if you have the <SDL/SDL_image.h> header file. */
     44#undef HAVE_SDL_SDL_IMAGE_H
    3645
    3746/* Define to 1 if you have the `sqrt' function. */
  • orxonox/trunk/configure

    r3101 r3140  
    866866  --enable-dependency-tracking   do not reject slow dependency extractors
    867867  --disable-gtk           Prevents GTK from being loaded
     868  --disabel-sdl-image     Prevents SDL_image from being loaded
    868869
    869870Some influential environment variables:
     
    38313832
    38323833
    3833 
    38343834### CHECKING  OPTIONAT ARGUMENTS
    38353835## GTK-disabled
     
    38483848  echo "no"
    38493849fi
    3850 
    3851 
     3850### SDL_image-disable
     3851def_sdl_image=yes
     3852echo "$as_me:$LINENO: checking if SDL_image should be enabled" >&5
     3853echo $ECHO_N "checking if SDL_image should be enabled... $ECHO_C" >&6
     3854# Check whether --enable-sdl_image or --disable-sdl_image was given.
     3855if test "${enable_sdl_image+set}" = set; then
     3856  enableval="$enable_sdl_image"
     3857  def_sdl_image=no
     3858fi;
     3859if test "$def_sdl_image" = yes; then
     3860  echo "yes"
     3861fi
     3862if test "$def_sdl_image" = no; then
     3863  echo "no"
     3864fi
    38523865
    38533866### CHECKING FOR SYSTEM ###
     
    47654778    fi
    47664779
    4767 
    47684780    ;;
    47694781
     
    53935405
    53945406
    5395 # checking for SDL-libs
     5407# checking for SDL-lib
    53965408    echo "$as_me:$LINENO: checking for main in -lSDL" >&5
    53975409echo $ECHO_N "checking for main in -lSDL... $ECHO_C" >&6
     
    54665478     fi
    54675479
     5480
    54685481## checking for SDL
    54695482#    SDL_VERSION=1.2.7
     
    54825495 osX="yes"
    54835496
     5497 CPPFLAGS="-I/sw/include $CPPFLAGS"
    54845498# checking gl header
    54855499
     
    58105824       CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
    58115825       LIBS="$LIBS $SDL_LIBS"
     5826
    58125827    ;;
    58135828
     
    58185833
    58195834
    5820 
    5821 
     5835## check for SDL_Image
     5836if test "$def_sdl_image" = "yes"; then
     5837# checking for SDL_image-headers
     5838
     5839for ac_header in SDL/SDL_image.h
     5840do
     5841as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
     5842if eval "test \"\${$as_ac_Header+set}\" = set"; then
     5843  echo "$as_me:$LINENO: checking for $ac_header" >&5
     5844echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     5845if eval "test \"\${$as_ac_Header+set}\" = set"; then
     5846  echo $ECHO_N "(cached) $ECHO_C" >&6
     5847fi
     5848echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     5849echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     5850else
     5851  # Is the header compilable?
     5852echo "$as_me:$LINENO: checking $ac_header usability" >&5
     5853echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
     5854cat >conftest.$ac_ext <<_ACEOF
     5855/* confdefs.h.  */
     5856_ACEOF
     5857cat confdefs.h >>conftest.$ac_ext
     5858cat >>conftest.$ac_ext <<_ACEOF
     5859/* end confdefs.h.  */
     5860$ac_includes_default
     5861#include <$ac_header>
     5862_ACEOF
     5863rm -f conftest.$ac_objext
     5864if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     5865  (eval $ac_compile) 2>conftest.er1
     5866  ac_status=$?
     5867  grep -v '^ *+' conftest.er1 >conftest.err
     5868  rm -f conftest.er1
     5869  cat conftest.err >&5
     5870  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     5871  (exit $ac_status); } &&
     5872         { ac_try='test -z "$ac_c_werror_flag"
     5873                         || test ! -s conftest.err'
     5874  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     5875  (eval $ac_try) 2>&5
     5876  ac_status=$?
     5877  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     5878  (exit $ac_status); }; } &&
     5879         { ac_try='test -s conftest.$ac_objext'
     5880  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     5881  (eval $ac_try) 2>&5
     5882  ac_status=$?
     5883  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     5884  (exit $ac_status); }; }; then
     5885  ac_header_compiler=yes
     5886else
     5887  echo "$as_me: failed program was:" >&5
     5888sed 's/^/| /' conftest.$ac_ext >&5
     5889
     5890ac_header_compiler=no
     5891fi
     5892rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     5893echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
     5894echo "${ECHO_T}$ac_header_compiler" >&6
     5895
     5896# Is the header present?
     5897echo "$as_me:$LINENO: checking $ac_header presence" >&5
     5898echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
     5899cat >conftest.$ac_ext <<_ACEOF
     5900/* confdefs.h.  */
     5901_ACEOF
     5902cat confdefs.h >>conftest.$ac_ext
     5903cat >>conftest.$ac_ext <<_ACEOF
     5904/* end confdefs.h.  */
     5905#include <$ac_header>
     5906_ACEOF
     5907if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
     5908  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
     5909  ac_status=$?
     5910  grep -v '^ *+' conftest.er1 >conftest.err
     5911  rm -f conftest.er1
     5912  cat conftest.err >&5
     5913  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     5914  (exit $ac_status); } >/dev/null; then
     5915  if test -s conftest.err; then
     5916    ac_cpp_err=$ac_c_preproc_warn_flag
     5917    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
     5918  else
     5919    ac_cpp_err=
     5920  fi
     5921else
     5922  ac_cpp_err=yes
     5923fi
     5924if test -z "$ac_cpp_err"; then
     5925  ac_header_preproc=yes
     5926else
     5927  echo "$as_me: failed program was:" >&5
     5928sed 's/^/| /' conftest.$ac_ext >&5
     5929
     5930  ac_header_preproc=no
     5931fi
     5932rm -f conftest.err conftest.$ac_ext
     5933echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
     5934echo "${ECHO_T}$ac_header_preproc" >&6
     5935
     5936# So?  What about this header?
     5937case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
     5938  yes:no: )
     5939    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
     5940echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
     5941    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
     5942echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
     5943    ac_header_preproc=yes
     5944    ;;
     5945  no:yes:* )
     5946    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
     5947echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
     5948    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
     5949echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
     5950    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
     5951echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
     5952    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
     5953echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
     5954    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
     5955echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
     5956    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
     5957echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
     5958    (
     5959      cat <<\_ASBOX
     5960## ------------------------------------------- ##
     5961## Report this to orxonox-dev@mail.datacore.ch ##
     5962## ------------------------------------------- ##
     5963_ASBOX
     5964    ) |
     5965      sed "s/^/$as_me: WARNING:     /" >&2
     5966    ;;
     5967esac
     5968echo "$as_me:$LINENO: checking for $ac_header" >&5
     5969echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     5970if eval "test \"\${$as_ac_Header+set}\" = set"; then
     5971  echo $ECHO_N "(cached) $ECHO_C" >&6
     5972else
     5973  eval "$as_ac_Header=\$ac_header_preproc"
     5974fi
     5975echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     5976echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     5977
     5978fi
     5979if test `eval echo '${'$as_ac_Header'}'` = yes; then
     5980  cat >>confdefs.h <<_ACEOF
     5981#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
     5982_ACEOF
     5983
     5984else
     5985  echo "sdl_image not found. falling back to other options"; def_sdl_image=no
     5986fi
     5987
     5988done
     5989
     5990fi
     5991if test "$def_sdl_image" = "yes"; then
     5992# checking for SDL_image-lib
     5993  echo "$as_me:$LINENO: checking for main in -lSDL_image" >&5
     5994echo $ECHO_N "checking for main in -lSDL_image... $ECHO_C" >&6
     5995if test "${ac_cv_lib_SDL_image_main+set}" = set; then
     5996  echo $ECHO_N "(cached) $ECHO_C" >&6
     5997else
     5998  ac_check_lib_save_LIBS=$LIBS
     5999LIBS="-lSDL_image  $LIBS"
     6000cat >conftest.$ac_ext <<_ACEOF
     6001/* confdefs.h.  */
     6002_ACEOF
     6003cat confdefs.h >>conftest.$ac_ext
     6004cat >>conftest.$ac_ext <<_ACEOF
     6005/* end confdefs.h.  */
     6006
     6007
     6008int
     6009main ()
     6010{
     6011main ();
     6012  ;
     6013  return 0;
     6014}
     6015_ACEOF
     6016rm -f conftest.$ac_objext conftest$ac_exeext
     6017if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     6018  (eval $ac_link) 2>conftest.er1
     6019  ac_status=$?
     6020  grep -v '^ *+' conftest.er1 >conftest.err
     6021  rm -f conftest.er1
     6022  cat conftest.err >&5
     6023  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6024  (exit $ac_status); } &&
     6025         { ac_try='test -z "$ac_c_werror_flag"
     6026                         || test ! -s conftest.err'
     6027  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6028  (eval $ac_try) 2>&5
     6029  ac_status=$?
     6030  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6031  (exit $ac_status); }; } &&
     6032         { ac_try='test -s conftest$ac_exeext'
     6033  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6034  (eval $ac_try) 2>&5
     6035  ac_status=$?
     6036  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6037  (exit $ac_status); }; }; then
     6038  ac_cv_lib_SDL_image_main=yes
     6039else
     6040  echo "$as_me: failed program was:" >&5
     6041sed 's/^/| /' conftest.$ac_ext >&5
     6042
     6043ac_cv_lib_SDL_image_main=no
     6044fi
     6045rm -f conftest.err conftest.$ac_objext \
     6046      conftest$ac_exeext conftest.$ac_ext
     6047LIBS=$ac_check_lib_save_LIBS
     6048fi
     6049echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_image_main" >&5
     6050echo "${ECHO_T}$ac_cv_lib_SDL_image_main" >&6
     6051if test $ac_cv_lib_SDL_image_main = yes; then
     6052  FOUND_SDL_image=yes
     6053fi
     6054
     6055     if test "$FOUND_SDL_image" = "yes" ; then
     6056       LIBS="$LIBS -lSDL_image"
     6057     else
     6058        echo "------------------"
     6059        echo "SDL_image library not found."
     6060        echo "please install the SDL_image library, which can be found at http://www.libsdl.org/projects/SDL_image/"
     6061        echo "------------------"
     6062        exit -1
     6063     fi
     6064fi
     6065
     6066
     6067if test "$def_sdl_image" = "no"; then
     6068 ## checking for libjpeg
     6069
     6070for ac_header in jpeglib.h
     6071do
     6072as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
     6073if eval "test \"\${$as_ac_Header+set}\" = set"; then
     6074  echo "$as_me:$LINENO: checking for $ac_header" >&5
     6075echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     6076if eval "test \"\${$as_ac_Header+set}\" = set"; then
     6077  echo $ECHO_N "(cached) $ECHO_C" >&6
     6078fi
     6079echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     6080echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     6081else
     6082  # Is the header compilable?
     6083echo "$as_me:$LINENO: checking $ac_header usability" >&5
     6084echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
     6085cat >conftest.$ac_ext <<_ACEOF
     6086/* confdefs.h.  */
     6087_ACEOF
     6088cat confdefs.h >>conftest.$ac_ext
     6089cat >>conftest.$ac_ext <<_ACEOF
     6090/* end confdefs.h.  */
     6091$ac_includes_default
     6092#include <$ac_header>
     6093_ACEOF
     6094rm -f conftest.$ac_objext
     6095if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     6096  (eval $ac_compile) 2>conftest.er1
     6097  ac_status=$?
     6098  grep -v '^ *+' conftest.er1 >conftest.err
     6099  rm -f conftest.er1
     6100  cat conftest.err >&5
     6101  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6102  (exit $ac_status); } &&
     6103         { ac_try='test -z "$ac_c_werror_flag"
     6104                         || test ! -s conftest.err'
     6105  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6106  (eval $ac_try) 2>&5
     6107  ac_status=$?
     6108  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6109  (exit $ac_status); }; } &&
     6110         { ac_try='test -s conftest.$ac_objext'
     6111  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6112  (eval $ac_try) 2>&5
     6113  ac_status=$?
     6114  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6115  (exit $ac_status); }; }; then
     6116  ac_header_compiler=yes
     6117else
     6118  echo "$as_me: failed program was:" >&5
     6119sed 's/^/| /' conftest.$ac_ext >&5
     6120
     6121ac_header_compiler=no
     6122fi
     6123rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     6124echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
     6125echo "${ECHO_T}$ac_header_compiler" >&6
     6126
     6127# Is the header present?
     6128echo "$as_me:$LINENO: checking $ac_header presence" >&5
     6129echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
     6130cat >conftest.$ac_ext <<_ACEOF
     6131/* confdefs.h.  */
     6132_ACEOF
     6133cat confdefs.h >>conftest.$ac_ext
     6134cat >>conftest.$ac_ext <<_ACEOF
     6135/* end confdefs.h.  */
     6136#include <$ac_header>
     6137_ACEOF
     6138if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
     6139  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
     6140  ac_status=$?
     6141  grep -v '^ *+' conftest.er1 >conftest.err
     6142  rm -f conftest.er1
     6143  cat conftest.err >&5
     6144  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6145  (exit $ac_status); } >/dev/null; then
     6146  if test -s conftest.err; then
     6147    ac_cpp_err=$ac_c_preproc_warn_flag
     6148    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
     6149  else
     6150    ac_cpp_err=
     6151  fi
     6152else
     6153  ac_cpp_err=yes
     6154fi
     6155if test -z "$ac_cpp_err"; then
     6156  ac_header_preproc=yes
     6157else
     6158  echo "$as_me: failed program was:" >&5
     6159sed 's/^/| /' conftest.$ac_ext >&5
     6160
     6161  ac_header_preproc=no
     6162fi
     6163rm -f conftest.err conftest.$ac_ext
     6164echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
     6165echo "${ECHO_T}$ac_header_preproc" >&6
     6166
     6167# So?  What about this header?
     6168case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
     6169  yes:no: )
     6170    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
     6171echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
     6172    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
     6173echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
     6174    ac_header_preproc=yes
     6175    ;;
     6176  no:yes:* )
     6177    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
     6178echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
     6179    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
     6180echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
     6181    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
     6182echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
     6183    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
     6184echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
     6185    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
     6186echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
     6187    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
     6188echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
     6189    (
     6190      cat <<\_ASBOX
     6191## ------------------------------------------- ##
     6192## Report this to orxonox-dev@mail.datacore.ch ##
     6193## ------------------------------------------- ##
     6194_ASBOX
     6195    ) |
     6196      sed "s/^/$as_me: WARNING:     /" >&2
     6197    ;;
     6198esac
     6199echo "$as_me:$LINENO: checking for $ac_header" >&5
     6200echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     6201if eval "test \"\${$as_ac_Header+set}\" = set"; then
     6202  echo $ECHO_N "(cached) $ECHO_C" >&6
     6203else
     6204  eval "$as_ac_Header=\$ac_header_preproc"
     6205fi
     6206echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     6207echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     6208
     6209fi
     6210if test `eval echo '${'$as_ac_Header'}'` = yes; then
     6211  cat >>confdefs.h <<_ACEOF
     6212#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
     6213_ACEOF
     6214 jpegHeader="yes"
     6215else
     6216  jpegHeader="no"
     6217fi
     6218
     6219done
     6220
     6221 if test $jpegHeader = "no"; then
     6222        echo " not including jpeg."
     6223 else
     6224  echo "$as_me:$LINENO: checking for main in -ljpeg" >&5
     6225echo $ECHO_N "checking for main in -ljpeg... $ECHO_C" >&6
     6226if test "${ac_cv_lib_jpeg_main+set}" = set; then
     6227  echo $ECHO_N "(cached) $ECHO_C" >&6
     6228else
     6229  ac_check_lib_save_LIBS=$LIBS
     6230LIBS="-ljpeg  $LIBS"
     6231cat >conftest.$ac_ext <<_ACEOF
     6232/* confdefs.h.  */
     6233_ACEOF
     6234cat confdefs.h >>conftest.$ac_ext
     6235cat >>conftest.$ac_ext <<_ACEOF
     6236/* end confdefs.h.  */
     6237
     6238
     6239int
     6240main ()
     6241{
     6242main ();
     6243  ;
     6244  return 0;
     6245}
     6246_ACEOF
     6247rm -f conftest.$ac_objext conftest$ac_exeext
     6248if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     6249  (eval $ac_link) 2>conftest.er1
     6250  ac_status=$?
     6251  grep -v '^ *+' conftest.er1 >conftest.err
     6252  rm -f conftest.er1
     6253  cat conftest.err >&5
     6254  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6255  (exit $ac_status); } &&
     6256         { ac_try='test -z "$ac_c_werror_flag"
     6257                         || test ! -s conftest.err'
     6258  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6259  (eval $ac_try) 2>&5
     6260  ac_status=$?
     6261  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6262  (exit $ac_status); }; } &&
     6263         { ac_try='test -s conftest$ac_exeext'
     6264  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6265  (eval $ac_try) 2>&5
     6266  ac_status=$?
     6267  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6268  (exit $ac_status); }; }; then
     6269  ac_cv_lib_jpeg_main=yes
     6270else
     6271  echo "$as_me: failed program was:" >&5
     6272sed 's/^/| /' conftest.$ac_ext >&5
     6273
     6274ac_cv_lib_jpeg_main=no
     6275fi
     6276rm -f conftest.err conftest.$ac_objext \
     6277      conftest$ac_exeext conftest.$ac_ext
     6278LIBS=$ac_check_lib_save_LIBS
     6279fi
     6280echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_main" >&5
     6281echo "${ECHO_T}$ac_cv_lib_jpeg_main" >&6
     6282if test $ac_cv_lib_jpeg_main = yes; then
     6283  FOUND_jpeg=yes
     6284fi
     6285
     6286    if test "$FOUND_jpeg" = "yes" ; then
     6287      LIBS="$LIBS -ljpeg"
     6288    else
     6289         echo "------------------"
     6290         echo "jpeg library not found."
     6291         echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org"
     6292         echo "------------------"
     6293         exit -1
     6294    fi
     6295 fi
     6296
     6297 ## checking for libpng
     6298
     6299for ac_header in png.h
     6300do
     6301as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
     6302if eval "test \"\${$as_ac_Header+set}\" = set"; then
     6303  echo "$as_me:$LINENO: checking for $ac_header" >&5
     6304echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     6305if eval "test \"\${$as_ac_Header+set}\" = set"; then
     6306  echo $ECHO_N "(cached) $ECHO_C" >&6
     6307fi
     6308echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     6309echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     6310else
     6311  # Is the header compilable?
     6312echo "$as_me:$LINENO: checking $ac_header usability" >&5
     6313echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
     6314cat >conftest.$ac_ext <<_ACEOF
     6315/* confdefs.h.  */
     6316_ACEOF
     6317cat confdefs.h >>conftest.$ac_ext
     6318cat >>conftest.$ac_ext <<_ACEOF
     6319/* end confdefs.h.  */
     6320$ac_includes_default
     6321#include <$ac_header>
     6322_ACEOF
     6323rm -f conftest.$ac_objext
     6324if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     6325  (eval $ac_compile) 2>conftest.er1
     6326  ac_status=$?
     6327  grep -v '^ *+' conftest.er1 >conftest.err
     6328  rm -f conftest.er1
     6329  cat conftest.err >&5
     6330  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6331  (exit $ac_status); } &&
     6332         { ac_try='test -z "$ac_c_werror_flag"
     6333                         || test ! -s conftest.err'
     6334  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6335  (eval $ac_try) 2>&5
     6336  ac_status=$?
     6337  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6338  (exit $ac_status); }; } &&
     6339         { ac_try='test -s conftest.$ac_objext'
     6340  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6341  (eval $ac_try) 2>&5
     6342  ac_status=$?
     6343  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6344  (exit $ac_status); }; }; then
     6345  ac_header_compiler=yes
     6346else
     6347  echo "$as_me: failed program was:" >&5
     6348sed 's/^/| /' conftest.$ac_ext >&5
     6349
     6350ac_header_compiler=no
     6351fi
     6352rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
     6353echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
     6354echo "${ECHO_T}$ac_header_compiler" >&6
     6355
     6356# Is the header present?
     6357echo "$as_me:$LINENO: checking $ac_header presence" >&5
     6358echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
     6359cat >conftest.$ac_ext <<_ACEOF
     6360/* confdefs.h.  */
     6361_ACEOF
     6362cat confdefs.h >>conftest.$ac_ext
     6363cat >>conftest.$ac_ext <<_ACEOF
     6364/* end confdefs.h.  */
     6365#include <$ac_header>
     6366_ACEOF
     6367if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
     6368  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
     6369  ac_status=$?
     6370  grep -v '^ *+' conftest.er1 >conftest.err
     6371  rm -f conftest.er1
     6372  cat conftest.err >&5
     6373  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6374  (exit $ac_status); } >/dev/null; then
     6375  if test -s conftest.err; then
     6376    ac_cpp_err=$ac_c_preproc_warn_flag
     6377    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
     6378  else
     6379    ac_cpp_err=
     6380  fi
     6381else
     6382  ac_cpp_err=yes
     6383fi
     6384if test -z "$ac_cpp_err"; then
     6385  ac_header_preproc=yes
     6386else
     6387  echo "$as_me: failed program was:" >&5
     6388sed 's/^/| /' conftest.$ac_ext >&5
     6389
     6390  ac_header_preproc=no
     6391fi
     6392rm -f conftest.err conftest.$ac_ext
     6393echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
     6394echo "${ECHO_T}$ac_header_preproc" >&6
     6395
     6396# So?  What about this header?
     6397case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
     6398  yes:no: )
     6399    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
     6400echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
     6401    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
     6402echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
     6403    ac_header_preproc=yes
     6404    ;;
     6405  no:yes:* )
     6406    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
     6407echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
     6408    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
     6409echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
     6410    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
     6411echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
     6412    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
     6413echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
     6414    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
     6415echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
     6416    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
     6417echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
     6418    (
     6419      cat <<\_ASBOX
     6420## ------------------------------------------- ##
     6421## Report this to orxonox-dev@mail.datacore.ch ##
     6422## ------------------------------------------- ##
     6423_ASBOX
     6424    ) |
     6425      sed "s/^/$as_me: WARNING:     /" >&2
     6426    ;;
     6427esac
     6428echo "$as_me:$LINENO: checking for $ac_header" >&5
     6429echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
     6430if eval "test \"\${$as_ac_Header+set}\" = set"; then
     6431  echo $ECHO_N "(cached) $ECHO_C" >&6
     6432else
     6433  eval "$as_ac_Header=\$ac_header_preproc"
     6434fi
     6435echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
     6436echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
     6437
     6438fi
     6439if test `eval echo '${'$as_ac_Header'}'` = yes; then
     6440  cat >>confdefs.h <<_ACEOF
     6441#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
     6442_ACEOF
     6443 pngHeader="yes"
     6444else
     6445  pngHeader="no"
     6446fi
     6447
     6448done
     6449
     6450 if test $pngHeader = "no"; then
     6451        echo " not including png."
     6452 else
     6453  echo "$as_me:$LINENO: checking for main in -lpng" >&5
     6454echo $ECHO_N "checking for main in -lpng... $ECHO_C" >&6
     6455if test "${ac_cv_lib_png_main+set}" = set; then
     6456  echo $ECHO_N "(cached) $ECHO_C" >&6
     6457else
     6458  ac_check_lib_save_LIBS=$LIBS
     6459LIBS="-lpng  $LIBS"
     6460cat >conftest.$ac_ext <<_ACEOF
     6461/* confdefs.h.  */
     6462_ACEOF
     6463cat confdefs.h >>conftest.$ac_ext
     6464cat >>conftest.$ac_ext <<_ACEOF
     6465/* end confdefs.h.  */
     6466
     6467
     6468int
     6469main ()
     6470{
     6471main ();
     6472  ;
     6473  return 0;
     6474}
     6475_ACEOF
     6476rm -f conftest.$ac_objext conftest$ac_exeext
     6477if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
     6478  (eval $ac_link) 2>conftest.er1
     6479  ac_status=$?
     6480  grep -v '^ *+' conftest.er1 >conftest.err
     6481  rm -f conftest.er1
     6482  cat conftest.err >&5
     6483  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6484  (exit $ac_status); } &&
     6485         { ac_try='test -z "$ac_c_werror_flag"
     6486                         || test ! -s conftest.err'
     6487  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6488  (eval $ac_try) 2>&5
     6489  ac_status=$?
     6490  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6491  (exit $ac_status); }; } &&
     6492         { ac_try='test -s conftest$ac_exeext'
     6493  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
     6494  (eval $ac_try) 2>&5
     6495  ac_status=$?
     6496  echo "$as_me:$LINENO: \$? = $ac_status" >&5
     6497  (exit $ac_status); }; }; then
     6498  ac_cv_lib_png_main=yes
     6499else
     6500  echo "$as_me: failed program was:" >&5
     6501sed 's/^/| /' conftest.$ac_ext >&5
     6502
     6503ac_cv_lib_png_main=no
     6504fi
     6505rm -f conftest.err conftest.$ac_objext \
     6506      conftest$ac_exeext conftest.$ac_ext
     6507LIBS=$ac_check_lib_save_LIBS
     6508fi
     6509echo "$as_me:$LINENO: result: $ac_cv_lib_png_main" >&5
     6510echo "${ECHO_T}$ac_cv_lib_png_main" >&6
     6511if test $ac_cv_lib_png_main = yes; then
     6512  FOUND_png=yes
     6513fi
     6514
     6515    if test "$FOUND_png" = "yes" ; then
     6516      LIBS="$LIBS -lpng"
     6517    else
     6518         echo "------------------"
     6519         echo "png library not found."
     6520         echo "please install the png library, which can be found at http://libpng.org/pub/png/libpng.html"
     6521         echo "------------------"
     6522         exit -1
     6523    fi
     6524 fi
     6525fi
    58226526
    58236527## checking for GTK
  • orxonox/trunk/configure.ac

    r3101 r3140  
    2020AC_PROG_CXX
    2121AC_HEADER_STDC
    22 
    2322
    2423### CHECKING  OPTIONAT ARGUMENTS
     
    3534  echo "no"
    3635fi
    37 
    38 
     36### SDL_image-disable
     37def_sdl_image=yes
     38AC_MSG_CHECKING([if SDL_image should be enabled])
     39AC_ARG_ENABLE([sdl_image],
     40        AC_HELP_STRING( [--disabel-sdl-image],
     41        [Prevents SDL_image from being loaded]), [def_sdl_image=no])
     42if test "$def_sdl_image" = yes; then
     43  echo "yes"
     44fi
     45if test "$def_sdl_image" = no; then
     46  echo "no"
     47fi
    3948
    4049### CHECKING FOR SYSTEM ###
     
    116125    fi
    117126
    118 
    119127    ;;
    120128
     
    160168      [AC_MSG_ERROR([cannot find SDL headers]) ])
    161169
    162 # checking for SDL-libs
     170# checking for SDL-lib
    163171    AC_CHECK_LIB([SDL], [main], FOUND_SDL=yes)
    164172     if test "$FOUND_SDL" = "yes" ; then
     
    171179        exit -1
    172180     fi   
     181
    173182
    174183## checking for SDL
     
    188197 osX="yes"
    189198
     199 CPPFLAGS="-I/sw/include $CPPFLAGS"
    190200# checking gl header
    191201   AC_CHECK_HEADERS(OpenGL/gl.h ,,
     
    212222       CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
    213223       LIBS="$LIBS $SDL_LIBS"
     224
    214225    ;;
    215226
     
    220231AC_SUBST(MSBITFIELDS)
    221232
    222 
    223 
     233## check for SDL_Image
     234if test "$def_sdl_image" = "yes"; then
     235# checking for SDL_image-headers
     236  AC_CHECK_HEADERS(SDL/SDL_image.h ,,
     237      [echo "sdl_image not found. falling back to other options"; def_sdl_image=no ])
     238fi
     239if test "$def_sdl_image" = "yes"; then
     240# checking for SDL_image-lib
     241  AC_CHECK_LIB([SDL_image], [main], FOUND_SDL_image=yes)
     242     if test "$FOUND_SDL_image" = "yes" ; then
     243       LIBS="$LIBS -lSDL_image"
     244     else
     245        echo "------------------"
     246        echo "SDL_image library not found."
     247        echo "please install the SDL_image library, which can be found at http://www.libsdl.org/projects/SDL_image/"
     248        echo "------------------"
     249        exit -1
     250     fi   
     251fi
     252
     253
     254if test "$def_sdl_image" = "no"; then
     255 ## checking for libjpeg
     256 AC_CHECK_HEADERS(jpeglib.h ,jpegHeader="yes",
     257        jpegHeader="no")
     258 if test $jpegHeader = "no"; then
     259        echo " not including jpeg."
     260 else
     261  AC_CHECK_LIB([jpeg], [main], FOUND_jpeg=yes)
     262    if test "$FOUND_jpeg" = "yes" ; then
     263      LIBS="$LIBS -ljpeg"
     264    else
     265         echo "------------------"
     266         echo "jpeg library not found."
     267         echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org"
     268         echo "------------------"
     269         exit -1
     270    fi   
     271 fi
     272
     273 ## checking for libpng
     274 AC_CHECK_HEADERS(png.h ,pngHeader="yes",
     275        pngHeader="no")
     276 if test $pngHeader = "no"; then
     277        echo " not including png."
     278 else
     279  AC_CHECK_LIB([png], [main], FOUND_png=yes)
     280    if test "$FOUND_png" = "yes" ; then
     281      LIBS="$LIBS -lpng"
     282    else
     283         echo "------------------"
     284         echo "png library not found."
     285         echo "please install the png library, which can be found at http://libpng.org/pub/png/libpng.html"
     286         echo "------------------"
     287         exit -1
     288    fi
     289 fi   
     290fi
    224291
    225292## checking for GTK
  • orxonox/trunk/importer/array.cc

    r3064 r3140  
    3333    printf("deleting array\n");
    3434  Entry* walker = firstEntry;
    35   Entry* last;
    36   while (walker != NULL)
     35  Entry* previous;
     36  while (walker)
    3737    {
    38       last = walker;
     38      previous = walker;
    3939      walker = walker->next;
    40       delete last;
     40      delete previous;
    4141    }
    4242  if (finalized)
    43     delete [] array;
     43    delete []array;
    4444}
    4545
  • orxonox/trunk/importer/framework.cc

    r3070 r3140  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11   ### File Specific:
     12   main-programmer: Benjamin Grauer
     13   co-programmer: ...
     14*/
     15
    116#include "framework.h"
    217
    3 int verbose = 1;
     18int verbose = 2;
    419
    520void DrawGLScene()
     
    4358  // Create a new OpenGL window with the title "Cone3D Basecode" at
    4459  // 640x480x32, fullscreen and check for errors along the way
    45   if(wHandler.CreateGLWindow("Whandler Basecode", 640, 480, 32, FALSE) == FALSE)
     60  if(wHandler.CreateGLWindow("Whandler Basecode", 800, 600, 32, FALSE) == FALSE)
    4661  {
    4762    // If an error is found, display a message, kill the GL and SDL screens (if they were created) and exit
  • orxonox/trunk/importer/material.cc

    r3080 r3140  
    1212   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
     14
     15   TGA-code: borrowed from nehe-Tutorials
     16
     17   ToDo:
     18   - free SDL-surface when deleting Material.
     19   - delete imgNameWithPath after use creation.
    1420*/
    1521
    1622#include "material.h"
     23
     24// headers only for PathList
     25#include <unistd.h>
     26#include <sys/types.h>
     27#include <sys/stat.h>
     28#include <stdlib.h>
     29#include <fstream>
     30
     31using namespace std;
     32
     33
     34PathList::PathList()
     35{
     36  pathName = NULL;
     37  next = NULL;
     38}
     39PathList::PathList(char* pName)
     40{
     41  pathName = new char [strlen(pName)+1];
     42  strcpy (pathName, pName);
     43  next = NULL;
     44}
     45
     46PathList::~PathList()
     47{
     48  if (pathName)
     49    delete []pathName;
     50  if (next)
     51    delete next;
     52}
     53
     54void PathList::addPath (char* pName)
     55{
     56  if (pName[0] == '\0')
     57    {
     58      if (verbose >=3)
     59        printf("not Adding empty Path to the List.\n");
     60      return;
     61    }
     62  char* tmpPName = new char[strlen(pName)];
     63  strncpy(tmpPName, pName, strlen(pName)-1);
     64  tmpPName[strlen(pName)-1] = '\0';
     65  printf ("%s\n",tmpPName);
     66  if (access (tmpPName, F_OK) == 0)
     67    {
     68      struct stat status;
     69      stat(tmpPName, &status);
     70      if (status.st_mode & S_IFDIR)
     71        {
     72          if (verbose >=2)
     73            printf ("Adding Path %s to the PathList.\n", pName);
     74          PathList* tmpPathList = this;
     75          while (tmpPathList->next)
     76            tmpPathList = tmpPathList->next;
     77          tmpPathList->next = new PathList(pName);
     78        }
     79      else
     80        if (verbose >=1)
     81          printf ("You tried to add non-folder %s to a PathList.\n", tmpPName);
     82    }
     83  else
     84    if (verbose >=1)
     85      printf ("You tried to add non-existing folder %s to a PathList.\n", tmpPName);
     86  delete []tmpPName;
     87}
    1788
    1889/**
     
    43114Material::~Material()
    44115{
     116  if (verbose >= 2)
     117    printf ("delete Material %s.\n", name);
    45118  if (name)
    46119    delete []name;
    47   if (verbose >= 2)
    48     printf ("delete Material %s.\n", name);
    49   if (nextMat != NULL)
     120  if (diffuseTextureSet)
     121    glDeleteTextures (1, &diffuseTexture);
     122  if (nextMat)
    50123    delete nextMat;
    51124}
     
    60133  if (verbose >=2)
    61134    printf ("adding Material %s.\n", mtlName);
    62   Material* newMat = new Material(mtlName);
    63   Material* tmpMat = this;
     135   Material* tmpMat = this;
    64136  while (tmpMat->nextMat != NULL)
    65137    {
    66138      tmpMat = tmpMat->nextMat;
    67139    }
    68   tmpMat->nextMat = newMat;
    69   return newMat;
     140  tmpMat->nextMat = new Material(mtlName);
     141  return tmpMat->nextMat;
    70142 
    71143}
     
    79151    printf ("initializing new Material.\n");
    80152  nextMat = NULL;
    81 
     153  name ="";
    82154  setIllum(1);
    83155  setDiffuse(0,0,0);
    84156  setAmbient(0,0,0);
    85   setSpecular(0,0,0);
     157  setSpecular(.5,.5,.5);
    86158  setShininess(2.0);
    87159  setTransparency(0.0);
     160
     161  if (!pathList)
     162    pathList = new PathList("");
     163
    88164
    89165  diffuseTextureSet = false;
     
    93169 
    94170}
     171
     172PathList *Material::pathList = NULL;
     173
     174/**
     175   \brief Search for a Material called mtlName
     176   \param mtlName the Name of the Material to search for
     177   \returns Material named mtlName if it is found. NULL otherwise.
     178*/
     179Material* Material::search (char* mtlName)
     180{
     181  if (verbose >=3)
     182    printf ("Searching for material %s", mtlName);
     183  Material* searcher = this;
     184  while (searcher != NULL)
     185    {
     186      if (verbose >= 3)
     187        printf (".");
     188      if (!strcmp (searcher->getName(), mtlName))
     189        {
     190          if (verbose >= 3)
     191            printf ("found.\n");
     192          return searcher;
     193        }
     194      searcher = searcher->nextMat;
     195    }
     196  if (verbose >=3)
     197    printf ("not found\n");
     198  return NULL;
     199}
     200
     201/**
     202   \brief sets the material with which the following Faces will be painted
     203*/
     204bool Material::select (void)
     205{
     206  // setting diffuse color
     207  //  glColor3f (diffuse[0], diffuse[1], diffuse[2]);
     208  glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
     209
     210  // setting ambient color
     211  glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
     212
     213  // setting up Sprecular
     214  glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
     215
     216  // setting up Shininess
     217  glMaterialf(GL_FRONT, GL_SHININESS, shininess);
     218 
     219  // setting illumination Model
     220  if (illumModel == 1)
     221    glShadeModel(GL_FLAT);
     222  else if (illumModel >= 2)
     223    glShadeModel(GL_SMOOTH);
     224
     225  if (diffuseTextureSet)
     226    glBindTexture(GL_TEXTURE_2D, diffuseTexture);
     227  else
     228    glBindTexture(GL_TEXTURE_2D, 0);
     229 
     230}
     231
    95232
    96233/**
     
    100237void Material::setName (char* mtlName)
    101238{
    102   //  if (verbose >= 3)
    103     printf("setting Material Name to %s.\n", mtlName);
    104   name = new char [strlen(mtlName)];
     239  name = new char [strlen(mtlName)+1];
    105240  strcpy(name, mtlName);
     241  if (verbose >= 3)
     242    printf("setting Material Name to %s.\n", name);
     243
    106244  //  printf ("adding new Material: %s, %p\n", this->getName(), this);
    107245
     
    122260{
    123261  if (verbose >= 3)
    124     printf("setting illumModel of Material %s to %i", name, illum);
     262    printf("setting illumModel of Material %s to %i\n", name, illum);
    125263  illumModel = illum;
    126264  //  printf ("setting illumModel to: %i\n", illumModel);
     
    156294void Material::setDiffuse (char* rgb)
    157295{
    158   char r[20],g[20],b[20];
    159   sscanf (rgb, "%s %s %s", r, g, b);
    160   setDiffuse (atof(r), atof(g), atof(b));
     296  float r,g,b;
     297  sscanf (rgb, "%f %f %f", &r, &g, &b);
     298  setDiffuse (r, g, b);
    161299}
    162300
     
    182320void Material::setAmbient (char* rgb)
    183321{
    184   char r[20],g[20],b[20];
    185   sscanf (rgb, "%s %s %s", r, g, b);
    186   setAmbient (atof(r), atof(g), atof(b));
     322  float r,g,b;
     323  sscanf (rgb, "%f %f %f", &r, &g, &b);
     324  setAmbient (r, g, b);
    187325}
    188326
     
    208346void Material::setSpecular (char* rgb)
    209347{
    210   char r[20],g[20],b[20];
    211   sscanf (rgb, "%s %s %s", r, g, b);
    212   setSpecular (atof(r), atof(g), atof(b));
     348  float r,g,b;
     349  sscanf (rgb, "%f %f %f", &r, &g, &b);
     350  setSpecular (r, g, b);
    213351}
    214352
     
    246384void Material::setTransparency (char* trans)
    247385{
    248   char tr[20];
    249   sscanf (trans, "%s", tr);
    250   setTransparency (atof(tr));
    251 }
     386  setTransparency (atof(trans));
     387}
     388
     389/**
     390   \brief Adds a Texture Path to the List of already existing Paths
     391   \param pathName The Path to add.
     392*/
     393void Material::addTexturePath(char* pathName)
     394{
     395  pathList->addPath (pathName);
     396}
     397
     398/**
     399   \brief Searches for a Texture inside one of the defined Paths
     400   \param texName The name of the texture o search for.
     401   \returns pathName+texName if texName was found in the pathList. NULL if the Texture is not found.
     402*/
     403char* Material::searchTextureInPaths(char* texName) const
     404{
     405  char* tmpName = NULL;
     406  PathList* pList = pathList;
     407  while (pList)
     408    {
     409      if (pList->pathName)
     410        {
     411          tmpName = new char [strlen(pList->pathName)+strlen(texName)+1];
     412          strcpy(tmpName, pList->pathName);
     413        }
     414      else
     415        {
     416          tmpName = new char [strlen(texName)+1];
     417          tmpName[0]='\0';
     418        }
     419      strcat(tmpName, texName);
     420      printf("%s\n", tmpName);
     421      if (access (tmpName, F_OK) == 0)
     422        return tmpName;
     423     
     424      if (tmpName)
     425        delete []tmpName;
     426      tmpName = NULL;
     427      pList = pList->next;
     428    }
     429  return NULL;
     430}
     431
    252432
    253433// MAPPING //
     
    262442    printf ("setting Diffuse Map %s\n", dMap);
    263443
    264   diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
     444  //  diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
     445  diffuseTextureSet = loadImage(dMap, &diffuseTexture);
    265446
    266447}
     
    293474{
    294475
     476}
     477
     478bool Material::loadTexToGL (Image* pImage, GLuint* texture)
     479{
     480  if (verbose >=3)
     481    printf ("Loading texture to OpenGL-Environment.\n");
     482  glGenTextures(1, texture);
     483  glBindTexture(GL_TEXTURE_2D, *texture);
     484  /* not Working, and not needed.
     485  glTexImage2D( GL_TEXTURE_2D, 0, 3, width,
     486                height, 0, GL_BGR,
     487                GL_UNSIGNED_BYTE, map->pixels );
     488  */
     489  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->width, pImage->height, GL_RGB, GL_UNSIGNED_BYTE, pImage->data);
     490 
     491  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
     492  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
     493}
     494
     495
     496#ifdef HAVE_SDL_SDL_IMAGE_H
     497bool Material::loadImage(char* imageName, GLuint* texture)
     498{
     499  char* imgNameWithPath = searchTextureInPaths(imageName);
     500  if (imgNameWithPath)
     501    {
     502      SDL_Surface* map;
     503      Image* pImage = new Image;
     504      map=IMG_Load(imgNameWithPath);
     505      if(!map)
     506        {
     507          printf("IMG_Load: %s\n", IMG_GetError());
     508          return false;
     509        }
     510      pImage->height = map->h;
     511      pImage->width  = map->w;
     512      pImage->data   = (GLubyte*)map->pixels;
     513      if( !IMG_isPNG(SDL_RWFromFile(imgNameWithPath, "rb")) && !IMG_isJPG(SDL_RWFromFile(imgNameWithPath, "rb")))
     514        for (int i=0;i<map->h * map->w *3;i+=3)
     515          {
     516            GLuint temp = pImage->data[i];
     517            pImage->data[i] = pImage->data[i+2];
     518            pImage->data[i+2] = temp;
     519          }
     520      loadTexToGL (pImage, texture);
     521    }
     522  else
     523    {
     524      if (verbose >=1)
     525        printf ("Image not Found: %s\n", imgNameWithPath);
     526      return false;
     527    }
     528}
     529
     530
     531#else /* HAVE_SDL_SDL_IMAGE_H */
     532/**
     533   \brief Makes the Programm ready to Read-in a texture-File
     534   1. Checks what type of Image should be imported
     535   2. ToDO: Checks where to find the Image
     536*/
     537bool Material::loadImage(char* imageName, GLuint* texture)
     538{
     539  char* imgNameWithPath = searchTextureInPaths(imageName);
     540  if (imgNameWithPath)
     541    {
     542      if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".bmp", 4))
     543        {
     544          if (verbose >=2)
     545            printf ("Requested bmp-image. Trying to Import.\n");
     546          return loadBMP(imgNameWithPath, texture);
     547        }
     548     
     549      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".jpg", 4) || !strncmp(imgNameWithPath+strlen(imgNameWithPath)-5, ".jpg", 5))
     550        {
     551          if (verbose >=2)
     552            printf ("Requested jpeg-image. Trying to Import\n");
     553          return loadJPG(imgNameWithPath, texture);
     554        }
     555      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".tga", 4))
     556        {
     557          if (verbose >=2)
     558            printf ("Requested tga-image. Trying to Import\n");
     559          return loadTGA(imgNameWithPath, texture);
     560        }
     561      else if (!strncmp(imgNameWithPath+strlen(imgNameWithPath)-4, ".png", 4))
     562        {
     563          if (verbose >=2)
     564            printf ("Requested png-image. Trying to Import\n");
     565          return loadPNG(imgNameWithPath, texture);
     566        }
     567      else
     568        {
     569          if (verbose >=1)
     570            printf ("Requested Image was not recognized in its type. (Maybe a type-Cast-error.)\n FileName: %s", imgNameWithPath);
     571          return false;
     572        }
     573    }
     574  else
     575    {
     576      if (verbose >=1)
     577        printf ("Image not Found: %s\n", imgNameWithPath);
     578      return false;
     579    }
    295580}
    296581
     
    302587bool Material::loadBMP (char* bmpName, GLuint* texture)
    303588{
    304   SDL_Surface* map;
    305   if (map = SDL_LoadBMP(bmpName))
    306     {
    307 
    308       glGenTextures( 1, texture );
    309       /* Typical Texture Generation Using Data From The Bitmap */
    310       glBindTexture( GL_TEXTURE_2D, *texture );
     589  Image* pImage = new Image;
     590  FILE *file;
     591  unsigned long size;                 // size of the image in bytes.
     592  unsigned long i;                    // standard counter.
     593  unsigned short int planes;          // number of planes in image (must be 1)
     594  unsigned short int bpp;             // number of bits per pixel (must be 24)
     595  GLuint temp;                          // temporary color storage for bgr-rgb conversion.
     596
     597  // make sure the file is there.
     598  if ((file = fopen(bmpName, "rb"))==NULL)
     599    {
     600      if (verbose >=1)
     601        printf("File Not Found : %s\n",bmpName);
     602      return false;
     603    }
     604  // seek through the bmp header, up to the width/height:
     605  fseek(file, 18, SEEK_CUR);
     606 
     607  // read the width
     608  if ((i = fread(&pImage->width, 4, 1, file)) != 1)
     609    {
     610      if (verbose >=1)
     611        printf("Error reading width from %s.\n", bmpName);
     612      return false;
     613    }
     614  // read the height
     615  if ((i = fread(&pImage->height, 4, 1, file)) != 1)
     616    {
     617      if (verbose>=1)
     618        printf("Error reading height from %s.\n", bmpName);
     619      return false;
     620    }
     621 
     622  // calculate the size (assuming 24 bits or 3 bytes per pixel).
     623  size = pImage->width * pImage->height * 3;
     624 
     625  // read the planes
     626  if ((fread(&planes, 2, 1, file)) != 1)
     627    {
     628      if (verbose>=1)
     629        printf("Error reading planes from %s.\n", bmpName);
     630      return false;
     631    }
     632  if (planes != 1)
     633    {
     634      if (verbose>=1)
     635        printf("Planes from %s is not 1: %u\n", bmpName, planes);
     636      return false;
     637    }
     638 
     639  // read the bpp
     640  if ((i = fread(&bpp, 2, 1, file)) != 1)
     641    {
     642      if (verbose>=1)
     643        printf("Error reading bpp from %s.\n", bmpName);
     644      return false;
     645    }
     646  if (bpp != 24)
     647    {
     648      if (verbose>=1)
     649        printf("Bpp from %s is not 24: %u\n", bmpName, bpp);
     650      return false;
     651    }
     652 
     653  // seek past the rest of the bitmap header.
     654  fseek(file, 24, SEEK_CUR);
     655 
     656  // read the data.
     657  pImage->data = (GLubyte *) malloc(size);
     658  if (pImage->data == NULL)
     659    {
     660      if (verbose>=1)
     661        printf("Error allocating memory for color-corrected image data");
     662      return false;     
     663    }
     664 
     665  if ((i = fread(pImage->data, size, 1, file)) != 1)
     666    {
     667      if (verbose>=1)
     668        printf("Error reading image data from %s.\n", bmpName);
     669      return false;
     670    }
     671  fclose(file);
     672
     673  // reverse all of the colors. (bgr -> rgb)
     674  for (i=0;i<size;i+=3)
     675    {
     676      temp = pImage->data[i];
     677      pImage->data[i] = pImage->data[i+2];
     678      pImage->data[i+2] = temp;
     679    }
     680  loadTexToGL (pImage, texture);
     681 
     682  return true;
     683
     684  if (pImage)
     685    {
     686      if (pImage->data)
     687        {
     688          free(pImage->data);
     689        }
    311690     
    312       /* Generate The Texture */
    313       glTexImage2D( GL_TEXTURE_2D, 0, 3, map->w,
    314                     map->h, 0, GL_BGR,
    315                     GL_UNSIGNED_BYTE, map->pixels );
     691      free(pImage);
     692    }
     693
     694}
     695
     696/**
     697   \brief reads in a jpg-file
     698   \param jpgName the Name of the Image to load
     699   \param texture a reference to the Texture to write the image to
     700*/
     701bool Material::loadJPG (char* jpgName, GLuint* texture)
     702{
     703#ifdef HAVE_JPEGLIB_H
     704  struct jpeg_decompress_struct cinfo;
     705  Image *pImage = NULL;
     706  FILE *pFile;
     707 
     708  // Open a file pointer to the jpeg file and check if it was found and opened
     709  if((pFile = fopen(jpgName, "rb")) == NULL)
     710    {
     711      // Display an error message saying the file was not found, then return NULL
     712      printf("Unable to load JPG File %s.\n", jpgName);
     713      return false;
     714    }
     715 
     716  // Create an error handler
     717  jpeg_error_mgr jerr;
     718 
     719  // Have our compression info object point to the error handler address
     720  cinfo.err = jpeg_std_error(&jerr);
     721 
     722  // Initialize the decompression object
     723  jpeg_create_decompress(&cinfo);
     724 
     725  // Specify the data source (Our file pointer)
     726  jpeg_stdio_src(&cinfo, pFile);
     727 
     728  // Allocate the structure that will hold our eventual jpeg data (must free it!)
     729  pImage = (Image*)malloc(sizeof(Image));
     730 
     731  // DECOFING
     732  // Read in the header of the jpeg file
     733  jpeg_read_header(&cinfo, TRUE);
     734 
     735  // Start to decompress the jpeg file with our compression info
     736  jpeg_start_decompress(&cinfo);
     737 
     738  // Get the image dimensions and row span to read in the pixel data
     739  pImage->rowSpan = cinfo.image_width * cinfo.num_components;
     740  pImage->width   = cinfo.image_width;
     741  pImage->height   = cinfo.image_height;
     742 
     743  // Allocate memory for the pixel buffer
     744  pImage->data = new unsigned char[pImage->rowSpan * pImage->height];
     745 
     746  // Here we use the library's state variable cinfo.output_scanline as the
     747  // loop counter, so that we don't have to keep track ourselves.
     748 
     749  // Create an array of row pointers
     750  unsigned char** rowPtr = new unsigned char*[pImage->height];
     751  for (int i = 0; i < pImage->height; i++)
     752    rowPtr[i] = &(pImage->data[i*pImage->rowSpan]);
     753 
     754  // Now comes the juice of our work, here we extract all the pixel data
     755  int rowsRead = 0;
     756  while (cinfo.output_scanline < cinfo.output_height)
     757    {
     758      // Read in the current row of pixels and increase the rowsRead count
     759      rowsRead += jpeg_read_scanlines(&cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead);
     760    }
     761 
     762  // Delete the temporary row pointers
     763  delete [] rowPtr;
     764 
     765  // Finish decompressing the data
     766  jpeg_finish_decompress(&cinfo);//  decodeJPG(&cinfo, pImage);
     767 
     768  // This releases all the stored memory for reading and decoding the jpeg
     769  jpeg_destroy_decompress(&cinfo);
     770 
     771  // Close the file pointer that opened the file
     772  fclose(pFile);
     773 
     774
     775  if(pImage == NULL)
     776    exit(0);
     777 
     778  loadTexToGL (pImage, texture);
     779  if (pImage)
     780    {
     781      if (pImage->data)
     782        {
     783          free(pImage->data);
     784        }
    316785     
    317       /* Linear Filtering */
    318       glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
    319       glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    320       if ( map )
    321         SDL_FreeSurface( map );
    322 
    323       return true;
     786      free(pImage);
     787    }
     788  return true;
     789#else /* HAVE_JPEGLIB_H */
     790  if (verbose >=1)
     791    printf ("sorry, but you did not compile with jpeg-support.\nEither install SDL_image or jpeglib, and recompile to see the image\n");
     792  return false;
     793#endif /* HAVE_JPEGLIB_H */
     794
     795}
     796
     797/**
     798   \brief reads in a tga-file
     799   \param tgaName the Name of the Image to load
     800   \param texture a reference to the Texture to write the image to
     801*/
     802bool Material::loadTGA(const char * tgaName, GLuint* texture)
     803{
     804  typedef struct
     805  {
     806    GLubyte Header[12];
     807  } TGAHeader;
     808  TGAHeader tgaHeader;                 
     809 
     810  GLubyte uTGAcompare[12] = {0,0,2, 0,0,0,0,0,0,0,0,0}; // Uncompressed TGA Header
     811  GLubyte cTGAcompare[12] = {0,0,10,0,0,0,0,0,0,0,0,0}; // Compressed TGA Header
     812  FILE * fTGA;
     813  fTGA = fopen(tgaName, "rb");
     814
     815  if(fTGA == NULL)
     816    {
     817      printf("Error could not open texture file: %s\n", tgaName);
     818      return false;
     819    }
     820 
     821  if(fread(&tgaHeader, sizeof(TGAHeader), 1, fTGA) == 0)
     822    {
     823      printf("Error could not read file header of %s\n", tgaName);
     824      if(fTGA != NULL)
     825        {
     826          fclose(fTGA);
     827        }
     828      return false;
     829    }
     830 
     831  if(memcmp(uTGAcompare, &tgaHeader, sizeof(TGAHeader)) == 0)
     832    {
     833      loadUncompressedTGA(tgaName, fTGA, texture);
     834      if (fTGA)
     835        fclose (fTGA);
     836    }
     837  else if(memcmp(cTGAcompare, &tgaHeader, sizeof(TGAHeader)) == 0)
     838    {
     839      loadCompressedTGA(tgaName, fTGA, texture);
     840        if (fTGA)
     841          fclose (fTGA);
    324842    }
    325843  else
    326     return false;
    327 }
    328 
    329 
    330 
    331 
    332 /**
    333    \brief Search for a Material called mtlName
    334    \param mtlName the Name of the Material to search for
    335    \returns Material named mtlName if it is found. NULL otherwise.
    336 */
    337 Material* Material::search (char* mtlName)
    338 {
    339   if (verbose >=3)
    340     printf ("Searching for material %s", mtlName);
    341   Material* searcher = this;
    342   while (searcher != NULL)
    343     {
    344       if (verbose >= 3)
    345         printf (".");
    346       if (!strcmp (searcher->getName(), mtlName))
    347         {
    348           if (verbose >= 3)
    349             printf ("found.\n");
    350           return searcher;
    351         }
    352       searcher = searcher->nextMat;
    353     }
    354   if (verbose >=3)
    355     printf ("not found\n");
    356   return NULL;
    357 }
    358 
    359 /**
    360    \brief sets the material with which the following Faces will be painted
    361 */
    362 bool Material::select (void)
    363 {
    364   // setting diffuse color
    365   //  glColor3f (diffuse[0], diffuse[1], diffuse[2]);
    366   glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
    367 
    368   // setting ambient color
    369   glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
    370 
    371   // setting up Sprecular
    372   glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
    373 
    374   // setting up Shininess
    375   glMaterialf(GL_FRONT, GL_SHININESS, shininess);
    376  
    377   // setting illumination Model
    378   if (illumModel == 1)
    379     glShadeModel(GL_FLAT);
    380   else if (illumModel >= 2)
    381     glShadeModel(GL_SMOOTH);
    382 
    383   if (diffuseTextureSet)
    384     glBindTexture(GL_TEXTURE_2D, diffuseTexture);
    385  
    386 }
     844    {
     845      printf("Error TGA file be type 2 or type 10\n");
     846      if (fTGA)
     847        fclose(fTGA);
     848      return false;
     849    }
     850  return true;
     851}
     852
     853/**
     854   \brief reads in an uncompressed tga-file
     855   \param filename the Name of the Image to load
     856   \param fTGA a Pointer to a File, that should be read
     857   \param texture a reference to the Texture to write the image to
     858*/
     859bool Material::loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture)
     860{
     861  GLubyte header[6];      // First 6 Useful Bytes From The Header
     862  GLuint  bytesPerPixel;  // Holds Number Of Bytes Per Pixel Used In The TGA File
     863  GLuint  imageSize;      // Used To Store The Image Size When Setting Aside Ram
     864  GLuint  temp;           // Temporary Variable
     865  GLuint  type;
     866  GLuint  Height;         // Height of Image
     867  GLuint  Width;          // Width of Image
     868  GLuint  Bpp;            // Bits Per Pixel
     869
     870  Image* pImage = new Image;
     871  GLuint cswap;
     872  if(fread(header, sizeof(header), 1, fTGA) == 0)
     873    {
     874      printf("Error could not read info header\n");
     875      return false;
     876    }
     877 
     878  Width = pImage->width  = header[1] * 256 + header[0];
     879  Height =  pImage->height = header[3] * 256 + header[2];
     880  Bpp = pImage->bpp = header[4];
     881  // Make sure all information is valid
     882  if((pImage->width <= 0) || (pImage->height <= 0) || ((pImage->bpp != 24) && (pImage->bpp !=32)))
     883    {
     884      printf("Error invalid texture information\n");
     885      return false;
     886    }
     887 
     888  if(pImage->bpp == 24)
     889    {
     890      pImage->type = GL_RGB;
     891    }
     892  else
     893    {
     894      pImage->type = GL_RGBA;
     895    }
     896 
     897  bytesPerPixel = (Bpp / 8);
     898  imageSize = (bytesPerPixel * Width * Height);
     899  pImage->data = (GLubyte*) malloc(imageSize);
     900 
     901  if(pImage->data == NULL)
     902    {
     903      printf("Error could not allocate memory for image\n");
     904      return false;
     905    }
     906 
     907  if(fread(pImage->data, 1, imageSize, fTGA) != imageSize)
     908    {
     909      printf("Error could not read image data\n");
     910      if(pImage->data != NULL)
     911        {
     912          free(pImage->data);
     913        }
     914      return false;
     915    }
     916 
     917  for(cswap = 0; cswap < (int)imageSize; cswap += bytesPerPixel)
     918    {
     919      pImage->data[cswap] ^= pImage->data[cswap+2] ^=
     920        pImage->data[cswap] ^= pImage->data[cswap+2];
     921    }
     922 
     923  loadTexToGL (pImage, texture);
     924
     925  return true;
     926}
     927
     928/**
     929   \brief reads in a compressed tga-file
     930   \param filename the Name of the Image to load
     931   \param fTGA a Pointer to a File, that should be read
     932   \param texture a reference to the Texture to write the image to
     933*/
     934bool Material::loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture)
     935{
     936  GLubyte header[6];      // First 6 Useful Bytes From The Header
     937  GLuint  bytesPerPixel;  // Holds Number Of Bytes Per Pixel Used In The TGA File
     938  GLuint  imageSize;      // Used To Store The Image Size When Setting Aside Ram
     939  GLuint  temp;           // Temporary Variable
     940  GLuint  type;
     941  GLuint  Height;         // Height of Image
     942  GLuint  Width;          // Width of Image
     943  GLuint  Bpp;            // Bits Per Pixel
     944
     945  Image* pImage = new Image;
     946
     947 
     948  if(fread(header, sizeof(header), 1, fTGA) == 0)
     949    {
     950      printf("Error could not read info header\n");
     951      return false;
     952    }
     953 
     954  Width = pImage->width  = header[1] * 256 + header[0];
     955  Height = pImage->height = header[3] * 256 + header[2];
     956  Bpp = pImage->bpp     = header[4];
     957
     958  GLuint pixelcount     = Height * Width;
     959  GLuint currentpixel   = 0;
     960  GLuint currentbyte    = 0;
     961  GLubyte * colorbuffer = (GLubyte *)malloc(bytesPerPixel);
     962
     963  //Make sure all pImage info is ok
     964  if((pImage->width <= 0) || (pImage->height <= 0) || ((pImage->bpp != 24) && (pImage->bpp !=32)))
     965    {
     966      printf("Error Invalid pImage information\n");
     967      return false;
     968    }
     969 
     970  bytesPerPixel = (Bpp / 8);
     971  imageSize             = (bytesPerPixel * Width * Height);
     972  pImage->data  = (GLubyte*) malloc(imageSize);
     973 
     974  if(pImage->data == NULL)
     975    {
     976      printf("Error could not allocate memory for image\n");
     977      return false;
     978    }
     979 
     980  do
     981    {
     982      GLubyte chunkheader = 0;
     983     
     984      if(fread(&chunkheader, sizeof(GLubyte), 1, fTGA) == 0)
     985        {
     986          printf("Error could not read RLE header\n");
     987          if(pImage->data != NULL)
     988            {
     989              free(pImage->data);
     990            }
     991          return false;
     992        }
     993      // If the ehader is < 128, it means the that is the number of RAW color packets minus 1
     994      if(chunkheader < 128)
     995        {
     996          short counter;
     997          chunkheader++;
     998          // Read RAW color values
     999          for(counter = 0; counter < chunkheader; counter++)
     1000            {
     1001              // Try to read 1 pixel
     1002              if(fread(colorbuffer, 1, bytesPerPixel, fTGA) != bytesPerPixel)
     1003                {
     1004                  printf("Error could not read image data\n");
     1005                  if(colorbuffer != NULL)
     1006                    {
     1007                      free(colorbuffer);
     1008                    }
     1009                 
     1010                  if(pImage->data != NULL)
     1011                    {
     1012                      free(pImage->data);
     1013                    }
     1014                 
     1015                  return false;
     1016                }
     1017              // write to memory
     1018              // Flip R and B vcolor values around in the process
     1019              pImage->data[currentbyte    ] = colorbuffer[2];                               
     1020              pImage->data[currentbyte + 1] = colorbuffer[1];
     1021              pImage->data[currentbyte + 2] = colorbuffer[0];
     1022             
     1023              if(bytesPerPixel == 4) // if its a 32 bpp image
     1024                {
     1025                  pImage->data[currentbyte + 3] = colorbuffer[3];// copy the 4th byte
     1026                }
     1027             
     1028              currentbyte += bytesPerPixel;
     1029              currentpixel++;
     1030
     1031              // Make sure we haven't read too many pixels
     1032              if(currentpixel > pixelcount)     
     1033                {
     1034                  printf("Error too many pixels read\n");
     1035                  if(colorbuffer != NULL)
     1036                    {
     1037                      free(colorbuffer);
     1038                    }
     1039                 
     1040                  if(pImage->data != NULL)
     1041                    {
     1042                      free(pImage->data);
     1043                    }
     1044                 
     1045                  return false;
     1046                }
     1047            }
     1048        }
     1049      // chunkheader > 128 RLE data, next color  reapeated chunkheader - 127 times
     1050      else
     1051        {
     1052          short counter;
     1053          chunkheader -= 127;   // Subteact 127 to get rid of the ID bit
     1054          if(fread(colorbuffer, 1, bytesPerPixel, fTGA) != bytesPerPixel) // Attempt to read following color values
     1055            {
     1056              printf("Error could not read from file");
     1057              if(colorbuffer != NULL)
     1058                {
     1059                  free(colorbuffer);
     1060                }
     1061             
     1062              if(pImage->data != NULL)
     1063                {
     1064                  free(pImage->data);
     1065                }
     1066             
     1067              return false;
     1068            }
     1069         
     1070          for(counter = 0; counter < chunkheader; counter++) //copy the color into the image data as many times as dictated
     1071            {                                                   
     1072              // switch R and B bytes areound while copying
     1073              pImage->data[currentbyte    ] = colorbuffer[2];
     1074              pImage->data[currentbyte + 1] = colorbuffer[1];
     1075              pImage->data[currentbyte + 2] = colorbuffer[0];
     1076             
     1077              if(bytesPerPixel == 4)
     1078                {
     1079                  pImage->data[currentbyte + 3] = colorbuffer[3];
     1080                }
     1081             
     1082              currentbyte += bytesPerPixel;
     1083              currentpixel++;
     1084             
     1085              if(currentpixel > pixelcount)
     1086                {
     1087                  printf("Error too many pixels read\n");
     1088                  if(colorbuffer != NULL)
     1089                    {
     1090                      free(colorbuffer);
     1091                    }
     1092                 
     1093                  if(pImage->data != NULL)
     1094                    {
     1095                      free(pImage->data);
     1096                    }
     1097                 
     1098                  return false;
     1099                }
     1100            }
     1101        }
     1102    }
     1103 
     1104  while(currentpixel < pixelcount);     // Loop while there are still pixels left
     1105
     1106  loadTexToGL (pImage, texture);
     1107
     1108  return true;
     1109}
     1110
     1111
     1112/*
     1113static int ST_is_power_of_two(unsigned int number)
     1114{
     1115  return (number & (number - 1)) == 0;
     1116}
     1117*/
     1118
     1119/**
     1120   \brief reads in a png-file
     1121   \param pngName the Name of the Image to load
     1122   \param texture a reference to the Texture to write the image to
     1123*/
     1124bool Material::loadPNG(const char* pngName, GLuint* texture)
     1125{
     1126#ifdef HAVE_PNG_H
     1127  Image* pImage = new Image;
     1128
     1129  FILE *PNG_file = fopen(pngName, "rb");
     1130  if (PNG_file == NULL)
     1131    {
     1132      return 0;
     1133    }
     1134 
     1135  GLubyte PNG_header[8];
     1136 
     1137  fread(PNG_header, 1, 8, PNG_file);
     1138  if (png_sig_cmp(PNG_header, 0, 8) != 0)
     1139    {
     1140      if (verbose >=2)
     1141        printf ("Not Recognized as a pngFile\n");
     1142      fclose (PNG_file);
     1143      return 0;
     1144    }
     1145 
     1146  png_structp PNG_reader = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
     1147  if (PNG_reader == NULL)
     1148    {
     1149      fclose(PNG_file);
     1150      return 0;
     1151    }
     1152 
     1153  png_infop PNG_info = png_create_info_struct(PNG_reader);
     1154  if (PNG_info == NULL)
     1155    {
     1156      png_destroy_read_struct(&PNG_reader, NULL, NULL);
     1157      fclose(PNG_file);
     1158      return 0;
     1159    }
     1160 
     1161  png_infop PNG_end_info = png_create_info_struct(PNG_reader);
     1162  if (PNG_end_info == NULL)
     1163    {
     1164      png_destroy_read_struct(&PNG_reader, &PNG_info, NULL);
     1165      fclose(PNG_file);
     1166      return 0;
     1167    }
     1168 
     1169  if (setjmp(png_jmpbuf(PNG_reader)))
     1170    {
     1171      png_destroy_read_struct(&PNG_reader, &PNG_info, &PNG_end_info);
     1172      fclose(PNG_file);
     1173      return (0);
     1174    }
     1175 
     1176  png_init_io(PNG_reader, PNG_file);
     1177  png_set_sig_bytes(PNG_reader, 8);
     1178 
     1179  png_read_info(PNG_reader, PNG_info);
     1180 
     1181  pImage->width = png_get_image_width(PNG_reader, PNG_info);
     1182  pImage->height = png_get_image_height(PNG_reader, PNG_info);
     1183 
     1184  png_uint_32 bit_depth, color_type;
     1185  bit_depth = png_get_bit_depth(PNG_reader, PNG_info);
     1186  color_type = png_get_color_type(PNG_reader, PNG_info);
     1187 
     1188  if (color_type == PNG_COLOR_TYPE_PALETTE)
     1189    {
     1190      png_set_palette_to_rgb(PNG_reader);
     1191    }
     1192 
     1193  if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
     1194    {
     1195      png_set_gray_1_2_4_to_8(PNG_reader);
     1196    }
     1197 
     1198  if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
     1199    {
     1200      png_set_gray_to_rgb(PNG_reader);
     1201    }
     1202 
     1203  if (png_get_valid(PNG_reader, PNG_info, PNG_INFO_tRNS))
     1204    {
     1205      png_set_tRNS_to_alpha(PNG_reader);
     1206    }
     1207  else
     1208    {
     1209      png_set_filler(PNG_reader, 0xff, PNG_FILLER_AFTER);
     1210    }
     1211 
     1212  if (bit_depth == 16)
     1213    {
     1214      png_set_strip_16(PNG_reader);
     1215    }
     1216 
     1217  png_read_update_info(PNG_reader, PNG_info);
     1218 
     1219  pImage->data = (png_byte*)malloc(4 * pImage->width * pImage->height);
     1220  png_byte** PNG_rows = (png_byte**)malloc(pImage->height * sizeof(png_byte*));
     1221 
     1222  unsigned int row;
     1223  for (row = 0; row < pImage->height; ++row)
     1224    {
     1225      PNG_rows[pImage->height - 1 - row] = pImage->data + (row * 4 * pImage->width);
     1226    }
     1227 
     1228  png_read_image(PNG_reader, PNG_rows);
     1229 
     1230  free(PNG_rows);
     1231 
     1232  png_destroy_read_struct(&PNG_reader, &PNG_info, &PNG_end_info);
     1233  fclose(PNG_file);
     1234 
     1235  /*  if (!ST_is_power_of_two(pImage->width) || !ST_is_power_of_two(pImage->height))
     1236    {
     1237      free(pImage->data);
     1238      return 0;
     1239    }
     1240  */
     1241  loadTexToGL (pImage, texture); 
     1242 
     1243  free(pImage->data);
     1244 
     1245  return true;
     1246#else /* HAVE_PNG_H */
     1247  if (verbose >=1)
     1248    printf ("sorry, but you did not compile with png-support.\nEither install SDL_image or libpng, and recompile to see the image\n");
     1249  return false;
     1250#endif /* HAVE_PNG_H */
     1251
     1252}
     1253
     1254#endif /* HAVE_SDL_SDL_IMAGE_H */
  • orxonox/trunk/importer/material.h

    r3070 r3140  
    1212#include <GL/glu.h>
    1313#include <SDL/SDL.h>
    14 #include <stdlib.h>
    15 #include <fstream>
     14
     15#if HAVE_CONFIG_H
     16#include <config.h>
     17#endif /* HAVE_CONFIG_H */
     18
     19#ifdef HAVE_SDL_SDL_IMAGE_H
     20#include <SDL/SDL_image.h>
     21#else
     22// IMAGE LIBS //
     23#ifdef HAVE_JPEGLIB_H
     24extern "C"{         // This has to be done, because not a c++ lib
     25#include <jpeglib.h>
     26}
     27#endif /* HAVE_JPEGLIB_H */
     28#ifdef HAVE_PNG_H
     29#include <png.h>
     30#endif /* HAVE_PNG_H */
     31#endif /* HAVE_SDL_SDL_IMAGE_H */
     32
     33class PathList
     34{
     35 public:
     36  PathList();
     37  PathList(char* pName);
     38
     39  ~PathList();
     40  void addPath (char* pName);
     41  char* pathName;
     42  PathList* next;
     43};
     44
    1645
    1746//! Class to handle Materials.
     
    2251  Material (char* mtlName);
    2352  Material* addMaterial(char* mtlName);
     53  ~Material ();
     54  void init(void);
    2455
    25   void init(void);
    26   ~Material ();
    27 
    28   GLuint diffuseTexture;
    29   GLuint ambientTexture;
    30   GLuint specularTexture;
    31  
    32   bool diffuseTextureSet;
    33   bool ambientTextureSet;
    34   bool specularTextureSet;
     56  Material* search (char* mtlName);
     57  bool select (void);
    3558
    3659  void setName (char* mtlName);
     
    4972  void setTransparency (char* trans);
    5073
    51   // MAPPING //
     74
     75 
     76  void addTexturePath(char* pathName);
     77  char* searchTextureInPaths(char* texName) const;
     78 // MAPPING //
    5279  void setDiffuseMap(char* dMap);
    5380  void setAmbientMap(char* aMap);
     
    5582  void setBump(char* bump);
    5683
    57   bool loadBMP (char* bmpName, GLuint* texture);
     84 private:
     85  struct Image
     86  {
     87    int rowSpan;
     88    GLuint width;
     89    GLuint height;
     90    GLuint bpp;
     91    GLuint type;
     92    GLubyte *data;
     93  };
    5894
    5995
    60   Material* search (char* mtlName);
    61 
    62   bool select (void);
    63 
    64   Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
    65 
    66  private:
    6796  char* name;
    6897  int illumModel;
     
    73102  float transparency;
    74103
     104  static PathList* pathList;
     105 
     106  GLuint diffuseTexture;
     107  GLuint ambientTexture;
     108  GLuint specularTexture;
     109 
     110  bool diffuseTextureSet;
     111  bool ambientTextureSet;
     112  bool specularTextureSet;
     113
     114  Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
     115
     116  // TEXTURING
     117  bool loadTexToGL (Image* pImage, GLuint* texture);
     118
     119  bool loadImage(char* imageName, GLuint* texture);
     120#ifndef HAVE_SDL_SDL_IMAGE_H
     121
     122  bool loadBMP (char* bmpName, GLuint* texture);
     123
     124  bool loadJPG (char* jpgName, GLuint* texture);
     125
     126  /// TGA ///
     127
     128  bool loadTGA(const char * tgaName, GLuint* texture);
     129  bool loadUncompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
     130  bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture);
     131
     132  bool loadPNG(const char* pngName, GLuint* texture);
     133#endif
    75134};
    76135#endif
  • orxonox/trunk/importer/object.cc

    r3083 r3140  
    1515
    1616#include "object.h"
     17using namespace std;
    1718
    1819/**
     
    7879      walker = walker->next;
    7980      delete delWalker;
    80     }
     81    }
     82
     83  if (objPath)
     84    delete []objPath;
     85  if (objFileName)
     86    delete []objFileName;
     87  if (mtlFileName)
     88    delete []mtlFileName;
     89
     90  if (verbose >=2)
     91    printf("Deleting Materials.\n");
     92  if (material)
     93    delete material;
    8194}
    8295
     
    184197 
    185198  initGroup (firstGroup);
    186   mtlFileName = "";
     199  objPath = NULL;
     200  objFileName = NULL;
     201  mtlFileName = NULL;
    187202  scaleFactor = 1;
    188203  material = new Material();
     
    244259    delete normals;
    245260
    246   if (material != NULL)
    247     delete material;
    248 
    249261  cleanupGroup(firstGroup);
    250262  return true;
     
    316328{
    317329  if (verbose >=3)
    318     printf("preparing to read in file: %s\n", fileName);   
    319   objFileName = fileName;
    320   this->readFromObjFile (fileName);
     330    printf("preparing to read in file: %s\n", fileName);
     331
     332
     333#ifdef __WIN32__
     334  // win32 path reading
     335  char pathSplitter= '\\';
     336#else /* __WIN32__ */
     337  // unix path reading
     338  char pathSplitter='/';
     339#endif /* __WIN32__ */
     340  char* tmpName = fileName;
     341  if (tmpName[0] == pathSplitter)
     342    tmpName++;
     343  char* name = tmpName;
     344  while (( tmpName = strchr (tmpName+1, pathSplitter)))
     345    {
     346      name = tmpName+1;
     347    }
     348  objPath = new char[name-fileName];
     349  strncpy(objPath, fileName, name-fileName);
     350  objPath[name-fileName] = '\0';
     351  if (verbose >=2)
     352    if (strlen(objPath)> 0)
     353      {
     354        printf("Resolved file %s to folder: %s.\n", name, objPath);
     355      }
     356    else
     357      printf("Resolved file %s.\n", name);
     358 
     359  if (material)
     360    material->addTexturePath(objPath);
     361  objFileName = new char[strlen(name)+1];
     362  strcpy (objFileName, name);
     363  this->readFromObjFile ();
    321364  return true;
    322365}
     
    325368   \brief Reads in the .obj File and sets all the Values.
    326369   This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks
    327    \param fileName the File that will be parsed (.obj-file)
    328 */
    329 bool Object::readFromObjFile (char* fileName)
    330 {
    331   OBJ_FILE = new ifstream(fileName);
    332   if (!OBJ_FILE->is_open())
     370*/
     371bool Object::readFromObjFile (void)
     372{
     373  char* fileName = new char [strlen(objPath)+strlen(objFileName)+1];
     374  if (objFileName != NULL && !strcmp(objFileName, ""))
     375    return false;
     376  strcpy(fileName, objPath);
     377  strcat(fileName, objFileName);
     378
     379  ifstream* OBJ_FILE = new ifstream(fileName);
     380  if (OBJ_FILE->fail())
    333381    {
    334382      if (verbose >=1)
    335383        printf ("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName);
    336384      BoxObject();
     385      delete []fileName;
    337386      return false;
    338387    }
    339   objFileName = fileName;
     388  if (verbose >=2)
     389    printf ("Reading from opened file %s\n", fileName);
    340390  char Buffer[10000];
    341391  while(!OBJ_FILE->eof())
     
    391441    }
    392442  OBJ_FILE->close();
     443  delete []fileName;
    393444  return true;
    394445
     
    403454bool Object::readGroup (char* groupString)
    404455{
    405   // setting the group name if not default.
    406   if (strcmp(currentGroup->name, "default"))
    407     {
    408       currentGroup->name = new char [strlen(groupString)];
    409       strcpy(currentGroup->name, groupString);
    410     }
     456  if (verbose >=3)
     457    printf ("Read Group: %s.\n", groupString);
    411458  if (groupCount != 0 && currentGroup->faceCount>0)
    412459    {
     
    415462      initGroup(currentGroup);
    416463    }
    417 
     464  // setting the group name if not default.
     465  if (strcmp(groupString, "default"))
     466    {
     467      currentGroup->name = new char [strlen(groupString)+1];
     468      strcpy(currentGroup->name, groupString);
     469    }
    418470  ++groupCount;
    419471
     
    541593bool Object::readMtlLib (char* mtlFile)
    542594{
    543   MTL_FILE = new ifstream (mtlFile);
    544   if (!MTL_FILE->is_open())
     595  mtlFileName = new char [strlen(mtlFile)+1];
     596  strcpy(mtlFileName, mtlFile);
     597  char* fileName = new char [strlen(objPath) + strlen(mtlFileName)+1];
     598  strcpy(fileName, objPath);
     599  strcat(fileName, mtlFileName);
     600 
     601
     602  if (verbose >=2)
     603    printf ("Opening mtlFile: %s\n", fileName);
     604
     605  ifstream* MTL_FILE = new ifstream (fileName);
     606  if (MTL_FILE->fail())
    545607    {
    546608      if (verbose >= 1)
    547         printf ("unable to open file: %s\n", mtlFile);
     609        printf ("unable to open file: %s\n", fileName);
     610      delete []fileName;
    548611      return false;
    549612    }
    550   mtlFileName = mtlFile;
    551   if (verbose >=2)
    552     printf ("Opening mtlFile: %s\n", mtlFileName);
    553613  char Buffer[500];
    554614  Material* tmpMat = material;
     
    621681
    622682    }
     683  delete []fileName;
    623684  return true;
    624685}
     
    630691bool Object::readUseMtl (char* matString)
    631692{
    632   if (!strcmp (mtlFileName, ""))
     693  if (!mtlFileName)
    633694    {
    634695      if (verbose >= 1)
     
    641702  initFace (currentGroup->currentFace);
    642703 
    643   currentGroup->currentFace->materialString = new char[strlen(matString)];
     704  currentGroup->currentFace->materialString = new char[strlen(matString)+1];
    644705  strcpy (currentGroup->currentFace->materialString, matString);
    645706 
  • orxonox/trunk/importer/object.h

    r3075 r3140  
    8787  char* objFileName;
    8888  char* mtlFileName;
    89   ifstream* OBJ_FILE;
    90   ifstream* MTL_FILE;
    9189
    9290  bool initialize (void);
     
    10098  ///// readin ///
    10199  bool importFile (char* fileName);
    102   bool readFromObjFile (char* fileName);
     100  bool readFromObjFile (void);
    103101 
    104102  bool readGroup (char* groupString);
  • orxonox/trunk/importer/windowHandler.cc

    r2936 r3140  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
    13
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11   ### File Specific:
     12   main-programmer: Benjamin Grauer
     13   co-programmer: ...
     14*/
    215
    316#include "windowHandler.h"
Note: See TracChangeset for help on using the changeset viewer.