Changeset 3098 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 5, 2004, 4:05:57 AM (20 years ago)
- Location:
- orxonox/branches/images
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/images/configure
r3086 r3098 6021 6021 echo "jpeg library not found." 6022 6022 echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org" 6023 echo "------------------" 6024 exit -1 6025 fi 6026 6027 6028 ## checking for libpng 6029 6030 for ac_header in png.h 6031 do 6032 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 6033 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6034 echo "$as_me:$LINENO: checking for $ac_header" >&5 6035 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 6036 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6037 echo $ECHO_N "(cached) $ECHO_C" >&6 6038 fi 6039 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 6040 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 6041 else 6042 # Is the header compilable? 6043 echo "$as_me:$LINENO: checking $ac_header usability" >&5 6044 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 6045 cat >conftest.$ac_ext <<_ACEOF 6046 /* confdefs.h. */ 6047 _ACEOF 6048 cat confdefs.h >>conftest.$ac_ext 6049 cat >>conftest.$ac_ext <<_ACEOF 6050 /* end confdefs.h. */ 6051 $ac_includes_default 6052 #include <$ac_header> 6053 _ACEOF 6054 rm -f conftest.$ac_objext 6055 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 6056 (eval $ac_compile) 2>conftest.er1 6057 ac_status=$? 6058 grep -v '^ *+' conftest.er1 >conftest.err 6059 rm -f conftest.er1 6060 cat conftest.err >&5 6061 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6062 (exit $ac_status); } && 6063 { ac_try='test -z "$ac_c_werror_flag" 6064 || test ! -s conftest.err' 6065 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 6066 (eval $ac_try) 2>&5 6067 ac_status=$? 6068 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6069 (exit $ac_status); }; } && 6070 { ac_try='test -s conftest.$ac_objext' 6071 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 6072 (eval $ac_try) 2>&5 6073 ac_status=$? 6074 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6075 (exit $ac_status); }; }; then 6076 ac_header_compiler=yes 6077 else 6078 echo "$as_me: failed program was:" >&5 6079 sed 's/^/| /' conftest.$ac_ext >&5 6080 6081 ac_header_compiler=no 6082 fi 6083 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 6084 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 6085 echo "${ECHO_T}$ac_header_compiler" >&6 6086 6087 # Is the header present? 6088 echo "$as_me:$LINENO: checking $ac_header presence" >&5 6089 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 6090 cat >conftest.$ac_ext <<_ACEOF 6091 /* confdefs.h. */ 6092 _ACEOF 6093 cat confdefs.h >>conftest.$ac_ext 6094 cat >>conftest.$ac_ext <<_ACEOF 6095 /* end confdefs.h. */ 6096 #include <$ac_header> 6097 _ACEOF 6098 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 6099 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 6100 ac_status=$? 6101 grep -v '^ *+' conftest.er1 >conftest.err 6102 rm -f conftest.er1 6103 cat conftest.err >&5 6104 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6105 (exit $ac_status); } >/dev/null; then 6106 if test -s conftest.err; then 6107 ac_cpp_err=$ac_c_preproc_warn_flag 6108 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag 6109 else 6110 ac_cpp_err= 6111 fi 6112 else 6113 ac_cpp_err=yes 6114 fi 6115 if test -z "$ac_cpp_err"; then 6116 ac_header_preproc=yes 6117 else 6118 echo "$as_me: failed program was:" >&5 6119 sed 's/^/| /' conftest.$ac_ext >&5 6120 6121 ac_header_preproc=no 6122 fi 6123 rm -f conftest.err conftest.$ac_ext 6124 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 6125 echo "${ECHO_T}$ac_header_preproc" >&6 6126 6127 # So? What about this header? 6128 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 6129 yes:no: ) 6130 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 6131 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 6132 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 6133 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 6134 ac_header_preproc=yes 6135 ;; 6136 no:yes:* ) 6137 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 6138 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 6139 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 6140 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 6141 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 6142 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 6143 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 6144 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} 6145 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 6146 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 6147 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 6148 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 6149 ( 6150 cat <<\_ASBOX 6151 ## ------------------------------------------- ## 6152 ## Report this to orxonox-dev@mail.datacore.ch ## 6153 ## ------------------------------------------- ## 6154 _ASBOX 6155 ) | 6156 sed "s/^/$as_me: WARNING: /" >&2 6157 ;; 6158 esac 6159 echo "$as_me:$LINENO: checking for $ac_header" >&5 6160 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 6161 if eval "test \"\${$as_ac_Header+set}\" = set"; then 6162 echo $ECHO_N "(cached) $ECHO_C" >&6 6163 else 6164 eval "$as_ac_Header=\$ac_header_preproc" 6165 fi 6166 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 6167 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 6168 6169 fi 6170 if test `eval echo '${'$as_ac_Header'}'` = yes; then 6171 cat >>confdefs.h <<_ACEOF 6172 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 6173 _ACEOF 6174 6175 else 6176 { { echo "$as_me:$LINENO: error: cannot find jpeg headers" >&5 6177 echo "$as_me: error: cannot find jpeg headers" >&2;} 6178 { (exit 1); exit 1; }; } 6179 fi 6180 6181 done 6182 6183 6184 echo "$as_me:$LINENO: checking for main in -lpng" >&5 6185 echo $ECHO_N "checking for main in -lpng... $ECHO_C" >&6 6186 if test "${ac_cv_lib_png_main+set}" = set; then 6187 echo $ECHO_N "(cached) $ECHO_C" >&6 6188 else 6189 ac_check_lib_save_LIBS=$LIBS 6190 LIBS="-lpng $LIBS" 6191 cat >conftest.$ac_ext <<_ACEOF 6192 /* confdefs.h. */ 6193 _ACEOF 6194 cat confdefs.h >>conftest.$ac_ext 6195 cat >>conftest.$ac_ext <<_ACEOF 6196 /* end confdefs.h. */ 6197 6198 6199 int 6200 main () 6201 { 6202 main (); 6203 ; 6204 return 0; 6205 } 6206 _ACEOF 6207 rm -f conftest.$ac_objext conftest$ac_exeext 6208 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 6209 (eval $ac_link) 2>conftest.er1 6210 ac_status=$? 6211 grep -v '^ *+' conftest.er1 >conftest.err 6212 rm -f conftest.er1 6213 cat conftest.err >&5 6214 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6215 (exit $ac_status); } && 6216 { ac_try='test -z "$ac_c_werror_flag" 6217 || test ! -s conftest.err' 6218 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 6219 (eval $ac_try) 2>&5 6220 ac_status=$? 6221 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6222 (exit $ac_status); }; } && 6223 { ac_try='test -s conftest$ac_exeext' 6224 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 6225 (eval $ac_try) 2>&5 6226 ac_status=$? 6227 echo "$as_me:$LINENO: \$? = $ac_status" >&5 6228 (exit $ac_status); }; }; then 6229 ac_cv_lib_png_main=yes 6230 else 6231 echo "$as_me: failed program was:" >&5 6232 sed 's/^/| /' conftest.$ac_ext >&5 6233 6234 ac_cv_lib_png_main=no 6235 fi 6236 rm -f conftest.err conftest.$ac_objext \ 6237 conftest$ac_exeext conftest.$ac_ext 6238 LIBS=$ac_check_lib_save_LIBS 6239 fi 6240 echo "$as_me:$LINENO: result: $ac_cv_lib_png_main" >&5 6241 echo "${ECHO_T}$ac_cv_lib_png_main" >&6 6242 if test $ac_cv_lib_png_main = yes; then 6243 FOUND_png=yes 6244 fi 6245 6246 if test "$FOUND_png" = "yes" ; then 6247 LIBS="$LIBS -lpng" 6248 else 6249 echo "------------------" 6250 echo "png library not found." 6251 echo "please install the png library, which can be found at http://libpng.org/pub/png/libpng.html" 6023 6252 echo "------------------" 6024 6253 exit -1 -
orxonox/branches/images/configure.ac
r3086 r3098 219 219 220 220 221 ## checking for libpng 222 AC_CHECK_HEADERS(png.h ,, 223 [AC_MSG_ERROR([cannot find jpeg headers]) ]) 224 225 AC_CHECK_LIB([png], [main], FOUND_png=yes) 226 if test "$FOUND_png" = "yes" ; then 227 LIBS="$LIBS -lpng" 228 else 229 echo "------------------" 230 echo "png library not found." 231 echo "please install the png library, which can be found at http://libpng.org/pub/png/libpng.html" 232 echo "------------------" 233 exit -1 234 fi 235 236 221 237 ## checking for GTK 222 238 PKG_CHECK_MODULES(GTK2, gtk+-2.0 >= 2.0.3 gthread-2.0 >= 2.0.3, have_gtk2=yes, have_gtk2=no) -
orxonox/branches/images/importer/material.cc
r3097 r3098 17 17 18 18 #include "material.h" 19 19 20 20 21 /** … … 401 402 printf ("Requested tga-image. Trying to Import\n"); 402 403 return loadTGA(imageName, texture); 404 } 405 else if (!strncmp(imageName+strlen(imageName)-4, ".png", 4)) 406 { 407 if (verbose >=2) 408 printf ("Requested png-image. Trying to Import\n"); 409 return loadPNG(imageName, texture); 403 410 } 404 411 else … … 933 940 } 934 941 942 943 /* 944 static int ST_is_power_of_two(unsigned int number) 945 { 946 return (number & (number - 1)) == 0; 947 } 948 */ 949 950 /** 951 \brief reads in a png-file 952 \param pngName the Name of the Image to load 953 \param texture a reference to the Texture to write the image to 954 */ 955 bool Material::loadPNG(const char* pngName, GLuint* texture) 956 { 957 Image* pImage = new Image; 958 959 FILE *PNG_file = fopen(pngName, "rb"); 960 if (PNG_file == NULL) 961 { 962 return 0; 963 } 964 965 GLubyte PNG_header[8]; 966 967 fread(PNG_header, 1, 8, PNG_file); 968 if (png_sig_cmp(PNG_header, 0, 8) != 0) 969 { 970 if (verbose >=2) 971 printf ("Not Recognized as a pngFile\n"); 972 fclose (PNG_file); 973 return 0; 974 } 975 976 png_structp PNG_reader = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 977 if (PNG_reader == NULL) 978 { 979 fclose(PNG_file); 980 return 0; 981 } 982 983 png_infop PNG_info = png_create_info_struct(PNG_reader); 984 if (PNG_info == NULL) 985 { 986 png_destroy_read_struct(&PNG_reader, NULL, NULL); 987 fclose(PNG_file); 988 return 0; 989 } 990 991 png_infop PNG_end_info = png_create_info_struct(PNG_reader); 992 if (PNG_end_info == NULL) 993 { 994 png_destroy_read_struct(&PNG_reader, &PNG_info, NULL); 995 fclose(PNG_file); 996 return 0; 997 } 998 999 if (setjmp(png_jmpbuf(PNG_reader))) 1000 { 1001 png_destroy_read_struct(&PNG_reader, &PNG_info, &PNG_end_info); 1002 fclose(PNG_file); 1003 return (0); 1004 } 1005 1006 png_init_io(PNG_reader, PNG_file); 1007 png_set_sig_bytes(PNG_reader, 8); 1008 1009 png_read_info(PNG_reader, PNG_info); 1010 1011 pImage->width = png_get_image_width(PNG_reader, PNG_info); 1012 pImage->height = png_get_image_height(PNG_reader, PNG_info); 1013 1014 png_uint_32 bit_depth, color_type; 1015 bit_depth = png_get_bit_depth(PNG_reader, PNG_info); 1016 color_type = png_get_color_type(PNG_reader, PNG_info); 1017 1018 if (color_type == PNG_COLOR_TYPE_PALETTE) 1019 { 1020 png_set_palette_to_rgb(PNG_reader); 1021 } 1022 1023 if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) 1024 { 1025 png_set_gray_1_2_4_to_8(PNG_reader); 1026 } 1027 1028 if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 1029 { 1030 png_set_gray_to_rgb(PNG_reader); 1031 } 1032 1033 if (png_get_valid(PNG_reader, PNG_info, PNG_INFO_tRNS)) 1034 { 1035 png_set_tRNS_to_alpha(PNG_reader); 1036 } 1037 else 1038 { 1039 png_set_filler(PNG_reader, 0xff, PNG_FILLER_AFTER); 1040 } 1041 1042 if (bit_depth == 16) 1043 { 1044 png_set_strip_16(PNG_reader); 1045 } 1046 1047 png_read_update_info(PNG_reader, PNG_info); 1048 1049 pImage->data = (png_byte*)malloc(4 * pImage->width * pImage->height); 1050 png_byte** PNG_rows = (png_byte**)malloc(pImage->height * sizeof(png_byte*)); 1051 1052 unsigned int row; 1053 for (row = 0; row < pImage->height; ++row) 1054 { 1055 PNG_rows[pImage->height - 1 - row] = pImage->data + (row * 4 * pImage->width); 1056 } 1057 1058 png_read_image(PNG_reader, PNG_rows); 1059 1060 free(PNG_rows); 1061 1062 png_destroy_read_struct(&PNG_reader, &PNG_info, &PNG_end_info); 1063 fclose(PNG_file); 1064 1065 /* if (!ST_is_power_of_two(pImage->width) || !ST_is_power_of_two(pImage->height)) 1066 { 1067 free(pImage->data); 1068 return 0; 1069 } 1070 */ 1071 loadTexToGL (pImage, texture); 1072 1073 free(pImage->data); 1074 1075 return true; 1076 } -
orxonox/branches/images/importer/material.h
r3096 r3098 19 19 #include <jpeglib.h> 20 20 } 21 #include <png.h> 21 22 //! Class to handle Materials. 22 23 class Material … … 102 103 bool loadCompressedTGA(const char * filename, FILE * fTGA, GLuint* texture); 103 104 105 bool loadPNG(const char* pngName, GLuint* texture); 104 106 }; 105 107 #endif
Note: See TracChangeset
for help on using the changeset viewer.