Changeset 3140 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 10, 2004, 7:44:36 PM (20 years ago)
- Location:
- orxonox/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/config.h.in
r3101 r3140 16 16 #undef HAVE_INTTYPES_H 17 17 18 /* Define to 1 if you have the <jpeglib.h> header file. */ 19 #undef HAVE_JPEGLIB_H 20 18 21 /* Define to 1 if you have the `m' library (-lm). */ 19 22 #undef HAVE_LIBM … … 32 35 #undef HAVE_OPENGL_GL_H 33 36 37 /* Define to 1 if you have the <png.h> header file. */ 38 #undef HAVE_PNG_H 39 34 40 /* Define to 1 if you have the <SDL/SDL.h> header file. */ 35 41 #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 36 45 37 46 /* Define to 1 if you have the `sqrt' function. */ -
orxonox/trunk/configure
r3101 r3140 866 866 --enable-dependency-tracking do not reject slow dependency extractors 867 867 --disable-gtk Prevents GTK from being loaded 868 --disabel-sdl-image Prevents SDL_image from being loaded 868 869 869 870 Some influential environment variables: … … 3831 3832 3832 3833 3833 3834 3834 ### CHECKING OPTIONAT ARGUMENTS 3835 3835 ## GTK-disabled … … 3848 3848 echo "no" 3849 3849 fi 3850 3851 3850 ### SDL_image-disable 3851 def_sdl_image=yes 3852 echo "$as_me:$LINENO: checking if SDL_image should be enabled" >&5 3853 echo $ECHO_N "checking if SDL_image should be enabled... $ECHO_C" >&6 3854 # Check whether --enable-sdl_image or --disable-sdl_image was given. 3855 if test "${enable_sdl_image+set}" = set; then 3856 enableval="$enable_sdl_image" 3857 def_sdl_image=no 3858 fi; 3859 if test "$def_sdl_image" = yes; then 3860 echo "yes" 3861 fi 3862 if test "$def_sdl_image" = no; then 3863 echo "no" 3864 fi 3852 3865 3853 3866 ### CHECKING FOR SYSTEM ### … … 4765 4778 fi 4766 4779 4767 4768 4780 ;; 4769 4781 … … 5393 5405 5394 5406 5395 # checking for SDL-lib s5407 # checking for SDL-lib 5396 5408 echo "$as_me:$LINENO: checking for main in -lSDL" >&5 5397 5409 echo $ECHO_N "checking for main in -lSDL... $ECHO_C" >&6 … … 5466 5478 fi 5467 5479 5480 5468 5481 ## checking for SDL 5469 5482 # SDL_VERSION=1.2.7 … … 5482 5495 osX="yes" 5483 5496 5497 CPPFLAGS="-I/sw/include $CPPFLAGS" 5484 5498 # checking gl header 5485 5499 … … 5810 5824 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" 5811 5825 LIBS="$LIBS $SDL_LIBS" 5826 5812 5827 ;; 5813 5828 … … 5818 5833 5819 5834 5820 5821 5835 ## check for SDL_Image 5836 if test "$def_sdl_image" = "yes"; then 5837 # checking for SDL_image-headers 5838 5839 for ac_header in SDL/SDL_image.h 5840 do 5841 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 5842 if eval "test \"\${$as_ac_Header+set}\" = set"; then 5843 echo "$as_me:$LINENO: checking for $ac_header" >&5 5844 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 5845 if eval "test \"\${$as_ac_Header+set}\" = set"; then 5846 echo $ECHO_N "(cached) $ECHO_C" >&6 5847 fi 5848 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 5849 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 5850 else 5851 # Is the header compilable? 5852 echo "$as_me:$LINENO: checking $ac_header usability" >&5 5853 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 5854 cat >conftest.$ac_ext <<_ACEOF 5855 /* confdefs.h. */ 5856 _ACEOF 5857 cat confdefs.h >>conftest.$ac_ext 5858 cat >>conftest.$ac_ext <<_ACEOF 5859 /* end confdefs.h. */ 5860 $ac_includes_default 5861 #include <$ac_header> 5862 _ACEOF 5863 rm -f conftest.$ac_objext 5864 if { (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 5886 else 5887 echo "$as_me: failed program was:" >&5 5888 sed 's/^/| /' conftest.$ac_ext >&5 5889 5890 ac_header_compiler=no 5891 fi 5892 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 5893 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 5894 echo "${ECHO_T}$ac_header_compiler" >&6 5895 5896 # Is the header present? 5897 echo "$as_me:$LINENO: checking $ac_header presence" >&5 5898 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 5899 cat >conftest.$ac_ext <<_ACEOF 5900 /* confdefs.h. */ 5901 _ACEOF 5902 cat confdefs.h >>conftest.$ac_ext 5903 cat >>conftest.$ac_ext <<_ACEOF 5904 /* end confdefs.h. */ 5905 #include <$ac_header> 5906 _ACEOF 5907 if { (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 5921 else 5922 ac_cpp_err=yes 5923 fi 5924 if test -z "$ac_cpp_err"; then 5925 ac_header_preproc=yes 5926 else 5927 echo "$as_me: failed program was:" >&5 5928 sed 's/^/| /' conftest.$ac_ext >&5 5929 5930 ac_header_preproc=no 5931 fi 5932 rm -f conftest.err conftest.$ac_ext 5933 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 5934 echo "${ECHO_T}$ac_header_preproc" >&6 5935 5936 # So? What about this header? 5937 case $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 5940 echo "$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 5942 echo "$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 5947 echo "$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 5949 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 5950 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 5951 echo "$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 5953 echo "$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 5955 echo "$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 5957 echo "$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 ;; 5967 esac 5968 echo "$as_me:$LINENO: checking for $ac_header" >&5 5969 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 5970 if eval "test \"\${$as_ac_Header+set}\" = set"; then 5971 echo $ECHO_N "(cached) $ECHO_C" >&6 5972 else 5973 eval "$as_ac_Header=\$ac_header_preproc" 5974 fi 5975 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 5976 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 5977 5978 fi 5979 if 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 5984 else 5985 echo "sdl_image not found. falling back to other options"; def_sdl_image=no 5986 fi 5987 5988 done 5989 5990 fi 5991 if test "$def_sdl_image" = "yes"; then 5992 # checking for SDL_image-lib 5993 echo "$as_me:$LINENO: checking for main in -lSDL_image" >&5 5994 echo $ECHO_N "checking for main in -lSDL_image... $ECHO_C" >&6 5995 if test "${ac_cv_lib_SDL_image_main+set}" = set; then 5996 echo $ECHO_N "(cached) $ECHO_C" >&6 5997 else 5998 ac_check_lib_save_LIBS=$LIBS 5999 LIBS="-lSDL_image $LIBS" 6000 cat >conftest.$ac_ext <<_ACEOF 6001 /* confdefs.h. */ 6002 _ACEOF 6003 cat confdefs.h >>conftest.$ac_ext 6004 cat >>conftest.$ac_ext <<_ACEOF 6005 /* end confdefs.h. */ 6006 6007 6008 int 6009 main () 6010 { 6011 main (); 6012 ; 6013 return 0; 6014 } 6015 _ACEOF 6016 rm -f conftest.$ac_objext conftest$ac_exeext 6017 if { (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 6039 else 6040 echo "$as_me: failed program was:" >&5 6041 sed 's/^/| /' conftest.$ac_ext >&5 6042 6043 ac_cv_lib_SDL_image_main=no 6044 fi 6045 rm -f conftest.err conftest.$ac_objext \ 6046 conftest$ac_exeext conftest.$ac_ext 6047 LIBS=$ac_check_lib_save_LIBS 6048 fi 6049 echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_image_main" >&5 6050 echo "${ECHO_T}$ac_cv_lib_SDL_image_main" >&6 6051 if test $ac_cv_lib_SDL_image_main = yes; then 6052 FOUND_SDL_image=yes 6053 fi 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 6064 fi 6065 6066 6067 if test "$def_sdl_image" = "no"; then 6068 ## checking for libjpeg 6069 6070 for ac_header in jpeglib.h 6071 do 6072 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 6073 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6074 echo "$as_me:$LINENO: checking for $ac_header" >&5 6075 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 6076 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6077 echo $ECHO_N "(cached) $ECHO_C" >&6 6078 fi 6079 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 6080 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 6081 else 6082 # Is the header compilable? 6083 echo "$as_me:$LINENO: checking $ac_header usability" >&5 6084 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 6085 cat >conftest.$ac_ext <<_ACEOF 6086 /* confdefs.h. */ 6087 _ACEOF 6088 cat confdefs.h >>conftest.$ac_ext 6089 cat >>conftest.$ac_ext <<_ACEOF 6090 /* end confdefs.h. */ 6091 $ac_includes_default 6092 #include <$ac_header> 6093 _ACEOF 6094 rm -f conftest.$ac_objext 6095 if { (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 6117 else 6118 echo "$as_me: failed program was:" >&5 6119 sed 's/^/| /' conftest.$ac_ext >&5 6120 6121 ac_header_compiler=no 6122 fi 6123 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 6124 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 6125 echo "${ECHO_T}$ac_header_compiler" >&6 6126 6127 # Is the header present? 6128 echo "$as_me:$LINENO: checking $ac_header presence" >&5 6129 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 6130 cat >conftest.$ac_ext <<_ACEOF 6131 /* confdefs.h. */ 6132 _ACEOF 6133 cat confdefs.h >>conftest.$ac_ext 6134 cat >>conftest.$ac_ext <<_ACEOF 6135 /* end confdefs.h. */ 6136 #include <$ac_header> 6137 _ACEOF 6138 if { (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 6152 else 6153 ac_cpp_err=yes 6154 fi 6155 if test -z "$ac_cpp_err"; then 6156 ac_header_preproc=yes 6157 else 6158 echo "$as_me: failed program was:" >&5 6159 sed 's/^/| /' conftest.$ac_ext >&5 6160 6161 ac_header_preproc=no 6162 fi 6163 rm -f conftest.err conftest.$ac_ext 6164 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 6165 echo "${ECHO_T}$ac_header_preproc" >&6 6166 6167 # So? What about this header? 6168 case $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 6171 echo "$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 6173 echo "$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 6178 echo "$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 6180 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 6181 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 6182 echo "$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 6184 echo "$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 6186 echo "$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 6188 echo "$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 ;; 6198 esac 6199 echo "$as_me:$LINENO: checking for $ac_header" >&5 6200 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 6201 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6202 echo $ECHO_N "(cached) $ECHO_C" >&6 6203 else 6204 eval "$as_ac_Header=\$ac_header_preproc" 6205 fi 6206 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 6207 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 6208 6209 fi 6210 if 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" 6215 else 6216 jpegHeader="no" 6217 fi 6218 6219 done 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 6225 echo $ECHO_N "checking for main in -ljpeg... $ECHO_C" >&6 6226 if test "${ac_cv_lib_jpeg_main+set}" = set; then 6227 echo $ECHO_N "(cached) $ECHO_C" >&6 6228 else 6229 ac_check_lib_save_LIBS=$LIBS 6230 LIBS="-ljpeg $LIBS" 6231 cat >conftest.$ac_ext <<_ACEOF 6232 /* confdefs.h. */ 6233 _ACEOF 6234 cat confdefs.h >>conftest.$ac_ext 6235 cat >>conftest.$ac_ext <<_ACEOF 6236 /* end confdefs.h. */ 6237 6238 6239 int 6240 main () 6241 { 6242 main (); 6243 ; 6244 return 0; 6245 } 6246 _ACEOF 6247 rm -f conftest.$ac_objext conftest$ac_exeext 6248 if { (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 6270 else 6271 echo "$as_me: failed program was:" >&5 6272 sed 's/^/| /' conftest.$ac_ext >&5 6273 6274 ac_cv_lib_jpeg_main=no 6275 fi 6276 rm -f conftest.err conftest.$ac_objext \ 6277 conftest$ac_exeext conftest.$ac_ext 6278 LIBS=$ac_check_lib_save_LIBS 6279 fi 6280 echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_main" >&5 6281 echo "${ECHO_T}$ac_cv_lib_jpeg_main" >&6 6282 if test $ac_cv_lib_jpeg_main = yes; then 6283 FOUND_jpeg=yes 6284 fi 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 6299 for ac_header in png.h 6300 do 6301 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 6302 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6303 echo "$as_me:$LINENO: checking for $ac_header" >&5 6304 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 6305 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6306 echo $ECHO_N "(cached) $ECHO_C" >&6 6307 fi 6308 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 6309 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 6310 else 6311 # Is the header compilable? 6312 echo "$as_me:$LINENO: checking $ac_header usability" >&5 6313 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 6314 cat >conftest.$ac_ext <<_ACEOF 6315 /* confdefs.h. */ 6316 _ACEOF 6317 cat confdefs.h >>conftest.$ac_ext 6318 cat >>conftest.$ac_ext <<_ACEOF 6319 /* end confdefs.h. */ 6320 $ac_includes_default 6321 #include <$ac_header> 6322 _ACEOF 6323 rm -f conftest.$ac_objext 6324 if { (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 6346 else 6347 echo "$as_me: failed program was:" >&5 6348 sed 's/^/| /' conftest.$ac_ext >&5 6349 6350 ac_header_compiler=no 6351 fi 6352 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 6353 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 6354 echo "${ECHO_T}$ac_header_compiler" >&6 6355 6356 # Is the header present? 6357 echo "$as_me:$LINENO: checking $ac_header presence" >&5 6358 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 6359 cat >conftest.$ac_ext <<_ACEOF 6360 /* confdefs.h. */ 6361 _ACEOF 6362 cat confdefs.h >>conftest.$ac_ext 6363 cat >>conftest.$ac_ext <<_ACEOF 6364 /* end confdefs.h. */ 6365 #include <$ac_header> 6366 _ACEOF 6367 if { (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 6381 else 6382 ac_cpp_err=yes 6383 fi 6384 if test -z "$ac_cpp_err"; then 6385 ac_header_preproc=yes 6386 else 6387 echo "$as_me: failed program was:" >&5 6388 sed 's/^/| /' conftest.$ac_ext >&5 6389 6390 ac_header_preproc=no 6391 fi 6392 rm -f conftest.err conftest.$ac_ext 6393 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 6394 echo "${ECHO_T}$ac_header_preproc" >&6 6395 6396 # So? What about this header? 6397 case $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 6400 echo "$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 6402 echo "$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 6407 echo "$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 6409 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 6410 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 6411 echo "$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 6413 echo "$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 6415 echo "$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 6417 echo "$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 ;; 6427 esac 6428 echo "$as_me:$LINENO: checking for $ac_header" >&5 6429 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 6430 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6431 echo $ECHO_N "(cached) $ECHO_C" >&6 6432 else 6433 eval "$as_ac_Header=\$ac_header_preproc" 6434 fi 6435 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 6436 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 6437 6438 fi 6439 if 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" 6444 else 6445 pngHeader="no" 6446 fi 6447 6448 done 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 6454 echo $ECHO_N "checking for main in -lpng... $ECHO_C" >&6 6455 if test "${ac_cv_lib_png_main+set}" = set; then 6456 echo $ECHO_N "(cached) $ECHO_C" >&6 6457 else 6458 ac_check_lib_save_LIBS=$LIBS 6459 LIBS="-lpng $LIBS" 6460 cat >conftest.$ac_ext <<_ACEOF 6461 /* confdefs.h. */ 6462 _ACEOF 6463 cat confdefs.h >>conftest.$ac_ext 6464 cat >>conftest.$ac_ext <<_ACEOF 6465 /* end confdefs.h. */ 6466 6467 6468 int 6469 main () 6470 { 6471 main (); 6472 ; 6473 return 0; 6474 } 6475 _ACEOF 6476 rm -f conftest.$ac_objext conftest$ac_exeext 6477 if { (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 6499 else 6500 echo "$as_me: failed program was:" >&5 6501 sed 's/^/| /' conftest.$ac_ext >&5 6502 6503 ac_cv_lib_png_main=no 6504 fi 6505 rm -f conftest.err conftest.$ac_objext \ 6506 conftest$ac_exeext conftest.$ac_ext 6507 LIBS=$ac_check_lib_save_LIBS 6508 fi 6509 echo "$as_me:$LINENO: result: $ac_cv_lib_png_main" >&5 6510 echo "${ECHO_T}$ac_cv_lib_png_main" >&6 6511 if test $ac_cv_lib_png_main = yes; then 6512 FOUND_png=yes 6513 fi 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 6525 fi 5822 6526 5823 6527 ## checking for GTK -
orxonox/trunk/configure.ac
r3101 r3140 20 20 AC_PROG_CXX 21 21 AC_HEADER_STDC 22 23 22 24 23 ### CHECKING OPTIONAT ARGUMENTS … … 35 34 echo "no" 36 35 fi 37 38 36 ### SDL_image-disable 37 def_sdl_image=yes 38 AC_MSG_CHECKING([if SDL_image should be enabled]) 39 AC_ARG_ENABLE([sdl_image], 40 AC_HELP_STRING( [--disabel-sdl-image], 41 [Prevents SDL_image from being loaded]), [def_sdl_image=no]) 42 if test "$def_sdl_image" = yes; then 43 echo "yes" 44 fi 45 if test "$def_sdl_image" = no; then 46 echo "no" 47 fi 39 48 40 49 ### CHECKING FOR SYSTEM ### … … 116 125 fi 117 126 118 119 127 ;; 120 128 … … 160 168 [AC_MSG_ERROR([cannot find SDL headers]) ]) 161 169 162 # checking for SDL-lib s170 # checking for SDL-lib 163 171 AC_CHECK_LIB([SDL], [main], FOUND_SDL=yes) 164 172 if test "$FOUND_SDL" = "yes" ; then … … 171 179 exit -1 172 180 fi 181 173 182 174 183 ## checking for SDL … … 188 197 osX="yes" 189 198 199 CPPFLAGS="-I/sw/include $CPPFLAGS" 190 200 # checking gl header 191 201 AC_CHECK_HEADERS(OpenGL/gl.h ,, … … 212 222 CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" 213 223 LIBS="$LIBS $SDL_LIBS" 224 214 225 ;; 215 226 … … 220 231 AC_SUBST(MSBITFIELDS) 221 232 222 223 233 ## check for SDL_Image 234 if 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 ]) 238 fi 239 if 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 251 fi 252 253 254 if 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 290 fi 224 291 225 292 ## checking for GTK -
orxonox/trunk/importer/array.cc
r3064 r3140 33 33 printf("deleting array\n"); 34 34 Entry* walker = firstEntry; 35 Entry* last;36 while (walker != NULL)35 Entry* previous; 36 while (walker) 37 37 { 38 last= walker;38 previous = walker; 39 39 walker = walker->next; 40 delete last;40 delete previous; 41 41 } 42 42 if (finalized) 43 delete [] 43 delete []array; 44 44 } 45 45 -
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 1 16 #include "framework.h" 2 17 3 int verbose = 1;18 int verbose = 2; 4 19 5 20 void DrawGLScene() … … 43 58 // Create a new OpenGL window with the title "Cone3D Basecode" at 44 59 // 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) 46 61 { 47 62 // 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 12 12 main-programmer: Benjamin Grauer 13 13 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. 14 20 */ 15 21 16 22 #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 31 using namespace std; 32 33 34 PathList::PathList() 35 { 36 pathName = NULL; 37 next = NULL; 38 } 39 PathList::PathList(char* pName) 40 { 41 pathName = new char [strlen(pName)+1]; 42 strcpy (pathName, pName); 43 next = NULL; 44 } 45 46 PathList::~PathList() 47 { 48 if (pathName) 49 delete []pathName; 50 if (next) 51 delete next; 52 } 53 54 void 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 } 17 88 18 89 /** … … 43 114 Material::~Material() 44 115 { 116 if (verbose >= 2) 117 printf ("delete Material %s.\n", name); 45 118 if (name) 46 119 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) 50 123 delete nextMat; 51 124 } … … 60 133 if (verbose >=2) 61 134 printf ("adding Material %s.\n", mtlName); 62 Material* newMat = new Material(mtlName); 63 Material* tmpMat = this; 135 Material* tmpMat = this; 64 136 while (tmpMat->nextMat != NULL) 65 137 { 66 138 tmpMat = tmpMat->nextMat; 67 139 } 68 tmpMat->nextMat = new Mat;69 return newMat;140 tmpMat->nextMat = new Material(mtlName); 141 return tmpMat->nextMat; 70 142 71 143 } … … 79 151 printf ("initializing new Material.\n"); 80 152 nextMat = NULL; 81 153 name =""; 82 154 setIllum(1); 83 155 setDiffuse(0,0,0); 84 156 setAmbient(0,0,0); 85 setSpecular( 0,0,0);157 setSpecular(.5,.5,.5); 86 158 setShininess(2.0); 87 159 setTransparency(0.0); 160 161 if (!pathList) 162 pathList = new PathList(""); 163 88 164 89 165 diffuseTextureSet = false; … … 93 169 94 170 } 171 172 PathList *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 */ 179 Material* 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 */ 204 bool 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 95 232 96 233 /** … … 100 237 void Material::setName (char* mtlName) 101 238 { 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]; 105 240 strcpy(name, mtlName); 241 if (verbose >= 3) 242 printf("setting Material Name to %s.\n", name); 243 106 244 // printf ("adding new Material: %s, %p\n", this->getName(), this); 107 245 … … 122 260 { 123 261 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); 125 263 illumModel = illum; 126 264 // printf ("setting illumModel to: %i\n", illumModel); … … 156 294 void Material::setDiffuse (char* rgb) 157 295 { 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); 161 299 } 162 300 … … 182 320 void Material::setAmbient (char* rgb) 183 321 { 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); 187 325 } 188 326 … … 208 346 void Material::setSpecular (char* rgb) 209 347 { 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); 213 351 } 214 352 … … 246 384 void Material::setTransparency (char* trans) 247 385 { 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 */ 393 void 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 */ 403 char* 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 252 432 253 433 // MAPPING // … … 262 442 printf ("setting Diffuse Map %s\n", dMap); 263 443 264 diffuseTextureSet = loadBMP(dMap, &diffuseTexture); 444 // diffuseTextureSet = loadBMP(dMap, &diffuseTexture); 445 diffuseTextureSet = loadImage(dMap, &diffuseTexture); 265 446 266 447 } … … 293 474 { 294 475 476 } 477 478 bool 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 497 bool 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 */ 537 bool 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 } 295 580 } 296 581 … … 302 587 bool Material::loadBMP (char* bmpName, GLuint* texture) 303 588 { 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 } 311 690 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 */ 701 bool 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 } 316 785 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 */ 802 bool 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); 324 842 } 325 843 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 */ 859 bool 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 */ 934 bool 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 /* 1113 static 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 */ 1124 bool 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 12 12 #include <GL/glu.h> 13 13 #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 24 extern "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 33 class 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 16 45 17 46 //! Class to handle Materials. … … 22 51 Material (char* mtlName); 23 52 Material* addMaterial(char* mtlName); 53 ~Material (); 54 void init(void); 24 55 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); 35 58 36 59 void setName (char* mtlName); … … 49 72 void setTransparency (char* trans); 50 73 51 // MAPPING // 74 75 76 void addTexturePath(char* pathName); 77 char* searchTextureInPaths(char* texName) const; 78 // MAPPING // 52 79 void setDiffuseMap(char* dMap); 53 80 void setAmbientMap(char* aMap); … … 55 82 void setBump(char* bump); 56 83 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 }; 58 94 59 95 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:67 96 char* name; 68 97 int illumModel; … … 73 102 float transparency; 74 103 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 75 134 }; 76 135 #endif -
orxonox/trunk/importer/object.cc
r3083 r3140 15 15 16 16 #include "object.h" 17 using namespace std; 17 18 18 19 /** … … 78 79 walker = walker->next; 79 80 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; 81 94 } 82 95 … … 184 197 185 198 initGroup (firstGroup); 186 mtlFileName = ""; 199 objPath = NULL; 200 objFileName = NULL; 201 mtlFileName = NULL; 187 202 scaleFactor = 1; 188 203 material = new Material(); … … 244 259 delete normals; 245 260 246 if (material != NULL)247 delete material;248 249 261 cleanupGroup(firstGroup); 250 262 return true; … … 316 328 { 317 329 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 (); 321 364 return true; 322 365 } … … 325 368 \brief Reads in the .obj File and sets all the Values. 326 369 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 */ 371 bool 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()) 333 381 { 334 382 if (verbose >=1) 335 383 printf ("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName); 336 384 BoxObject(); 385 delete []fileName; 337 386 return false; 338 387 } 339 objFileName = fileName; 388 if (verbose >=2) 389 printf ("Reading from opened file %s\n", fileName); 340 390 char Buffer[10000]; 341 391 while(!OBJ_FILE->eof()) … … 391 441 } 392 442 OBJ_FILE->close(); 443 delete []fileName; 393 444 return true; 394 445 … … 403 454 bool Object::readGroup (char* groupString) 404 455 { 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); 411 458 if (groupCount != 0 && currentGroup->faceCount>0) 412 459 { … … 415 462 initGroup(currentGroup); 416 463 } 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 } 418 470 ++groupCount; 419 471 … … 541 593 bool Object::readMtlLib (char* mtlFile) 542 594 { 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()) 545 607 { 546 608 if (verbose >= 1) 547 printf ("unable to open file: %s\n", mtlFile); 609 printf ("unable to open file: %s\n", fileName); 610 delete []fileName; 548 611 return false; 549 612 } 550 mtlFileName = mtlFile;551 if (verbose >=2)552 printf ("Opening mtlFile: %s\n", mtlFileName);553 613 char Buffer[500]; 554 614 Material* tmpMat = material; … … 621 681 622 682 } 683 delete []fileName; 623 684 return true; 624 685 } … … 630 691 bool Object::readUseMtl (char* matString) 631 692 { 632 if (! strcmp (mtlFileName, ""))693 if (!mtlFileName) 633 694 { 634 695 if (verbose >= 1) … … 641 702 initFace (currentGroup->currentFace); 642 703 643 currentGroup->currentFace->materialString = new char[strlen(matString) ];704 currentGroup->currentFace->materialString = new char[strlen(matString)+1]; 644 705 strcpy (currentGroup->currentFace->materialString, matString); 645 706 -
orxonox/trunk/importer/object.h
r3075 r3140 87 87 char* objFileName; 88 88 char* mtlFileName; 89 ifstream* OBJ_FILE;90 ifstream* MTL_FILE;91 89 92 90 bool initialize (void); … … 100 98 ///// readin /// 101 99 bool importFile (char* fileName); 102 bool readFromObjFile ( char* fileName);100 bool readFromObjFile (void); 103 101 104 102 bool readGroup (char* groupString); -
orxonox/trunk/importer/windowHandler.cc
r2936 r3140 1 /* 2 orxonox - the future of 3D-vertical-scrollers 1 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 */ 2 15 3 16 #include "windowHandler.h"
Note: See TracChangeset
for help on using the changeset viewer.