Changeset 3086 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 4, 2004, 6:05:54 PM (20 years ago)
- Location:
- orxonox/branches/images
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/images/config.h.in
r3084 r3086 12 12 /* Define to 1 if you have the <inttypes.h> header file. */ 13 13 #undef HAVE_INTTYPES_H 14 15 /* Define to 1 if you have the <jpeglib.h> header file. */ 16 #undef HAVE_JPEGLIB_H 14 17 15 18 /* Define to 1 if you have the `m' library (-lm). */ -
orxonox/branches/images/configure
r3084 r3086 5797 5797 5798 5798 5799 5799 ## checking for libjpeg 5800 5801 for ac_header in jpeglib.h 5802 do 5803 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` 5804 if eval "test \"\${$as_ac_Header+set}\" = set"; then 5805 echo "$as_me:$LINENO: checking for $ac_header" >&5 5806 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 5807 if eval "test \"\${$as_ac_Header+set}\" = set"; then 5808 echo $ECHO_N "(cached) $ECHO_C" >&6 5809 fi 5810 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 5811 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 5812 else 5813 # Is the header compilable? 5814 echo "$as_me:$LINENO: checking $ac_header usability" >&5 5815 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 5816 cat >conftest.$ac_ext <<_ACEOF 5817 /* confdefs.h. */ 5818 _ACEOF 5819 cat confdefs.h >>conftest.$ac_ext 5820 cat >>conftest.$ac_ext <<_ACEOF 5821 /* end confdefs.h. */ 5822 $ac_includes_default 5823 #include <$ac_header> 5824 _ACEOF 5825 rm -f conftest.$ac_objext 5826 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 5827 (eval $ac_compile) 2>conftest.er1 5828 ac_status=$? 5829 grep -v '^ *+' conftest.er1 >conftest.err 5830 rm -f conftest.er1 5831 cat conftest.err >&5 5832 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5833 (exit $ac_status); } && 5834 { ac_try='test -z "$ac_c_werror_flag" 5835 || test ! -s conftest.err' 5836 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 5837 (eval $ac_try) 2>&5 5838 ac_status=$? 5839 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5840 (exit $ac_status); }; } && 5841 { ac_try='test -s conftest.$ac_objext' 5842 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 5843 (eval $ac_try) 2>&5 5844 ac_status=$? 5845 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5846 (exit $ac_status); }; }; then 5847 ac_header_compiler=yes 5848 else 5849 echo "$as_me: failed program was:" >&5 5850 sed 's/^/| /' conftest.$ac_ext >&5 5851 5852 ac_header_compiler=no 5853 fi 5854 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext 5855 echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 5856 echo "${ECHO_T}$ac_header_compiler" >&6 5857 5858 # Is the header present? 5859 echo "$as_me:$LINENO: checking $ac_header presence" >&5 5860 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 5861 cat >conftest.$ac_ext <<_ACEOF 5862 /* confdefs.h. */ 5863 _ACEOF 5864 cat confdefs.h >>conftest.$ac_ext 5865 cat >>conftest.$ac_ext <<_ACEOF 5866 /* end confdefs.h. */ 5867 #include <$ac_header> 5868 _ACEOF 5869 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 5870 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 5871 ac_status=$? 5872 grep -v '^ *+' conftest.er1 >conftest.err 5873 rm -f conftest.er1 5874 cat conftest.err >&5 5875 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5876 (exit $ac_status); } >/dev/null; then 5877 if test -s conftest.err; then 5878 ac_cpp_err=$ac_c_preproc_warn_flag 5879 ac_cpp_err=$ac_cpp_err$ac_c_werror_flag 5880 else 5881 ac_cpp_err= 5882 fi 5883 else 5884 ac_cpp_err=yes 5885 fi 5886 if test -z "$ac_cpp_err"; then 5887 ac_header_preproc=yes 5888 else 5889 echo "$as_me: failed program was:" >&5 5890 sed 's/^/| /' conftest.$ac_ext >&5 5891 5892 ac_header_preproc=no 5893 fi 5894 rm -f conftest.err conftest.$ac_ext 5895 echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 5896 echo "${ECHO_T}$ac_header_preproc" >&6 5897 5898 # So? What about this header? 5899 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in 5900 yes:no: ) 5901 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 5902 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} 5903 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 5904 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} 5905 ac_header_preproc=yes 5906 ;; 5907 no:yes:* ) 5908 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 5909 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} 5910 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 5911 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} 5912 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 5913 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} 5914 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 5915 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} 5916 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 5917 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} 5918 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 5919 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} 5920 ( 5921 cat <<\_ASBOX 5922 ## ------------------------------------------- ## 5923 ## Report this to orxonox-dev@mail.datacore.ch ## 5924 ## ------------------------------------------- ## 5925 _ASBOX 5926 ) | 5927 sed "s/^/$as_me: WARNING: /" >&2 5928 ;; 5929 esac 5930 echo "$as_me:$LINENO: checking for $ac_header" >&5 5931 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 5932 if eval "test \"\${$as_ac_Header+set}\" = set"; then 5933 echo $ECHO_N "(cached) $ECHO_C" >&6 5934 else 5935 eval "$as_ac_Header=\$ac_header_preproc" 5936 fi 5937 echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 5938 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 5939 5940 fi 5941 if test `eval echo '${'$as_ac_Header'}'` = yes; then 5942 cat >>confdefs.h <<_ACEOF 5943 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 5944 _ACEOF 5945 5946 else 5947 { { echo "$as_me:$LINENO: error: cannot find jpeg headers" >&5 5948 echo "$as_me: error: cannot find jpeg headers" >&2;} 5949 { (exit 1); exit 1; }; } 5950 fi 5951 5952 done 5953 5954 5955 echo "$as_me:$LINENO: checking for main in -ljpeg" >&5 5956 echo $ECHO_N "checking for main in -ljpeg... $ECHO_C" >&6 5957 if test "${ac_cv_lib_jpeg_main+set}" = set; then 5958 echo $ECHO_N "(cached) $ECHO_C" >&6 5959 else 5960 ac_check_lib_save_LIBS=$LIBS 5961 LIBS="-ljpeg $LIBS" 5962 cat >conftest.$ac_ext <<_ACEOF 5963 /* confdefs.h. */ 5964 _ACEOF 5965 cat confdefs.h >>conftest.$ac_ext 5966 cat >>conftest.$ac_ext <<_ACEOF 5967 /* end confdefs.h. */ 5968 5969 5970 int 5971 main () 5972 { 5973 main (); 5974 ; 5975 return 0; 5976 } 5977 _ACEOF 5978 rm -f conftest.$ac_objext conftest$ac_exeext 5979 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 5980 (eval $ac_link) 2>conftest.er1 5981 ac_status=$? 5982 grep -v '^ *+' conftest.er1 >conftest.err 5983 rm -f conftest.er1 5984 cat conftest.err >&5 5985 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5986 (exit $ac_status); } && 5987 { ac_try='test -z "$ac_c_werror_flag" 5988 || test ! -s conftest.err' 5989 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 5990 (eval $ac_try) 2>&5 5991 ac_status=$? 5992 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5993 (exit $ac_status); }; } && 5994 { ac_try='test -s conftest$ac_exeext' 5995 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 5996 (eval $ac_try) 2>&5 5997 ac_status=$? 5998 echo "$as_me:$LINENO: \$? = $ac_status" >&5 5999 (exit $ac_status); }; }; then 6000 ac_cv_lib_jpeg_main=yes 6001 else 6002 echo "$as_me: failed program was:" >&5 6003 sed 's/^/| /' conftest.$ac_ext >&5 6004 6005 ac_cv_lib_jpeg_main=no 6006 fi 6007 rm -f conftest.err conftest.$ac_objext \ 6008 conftest$ac_exeext conftest.$ac_ext 6009 LIBS=$ac_check_lib_save_LIBS 6010 fi 6011 echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_main" >&5 6012 echo "${ECHO_T}$ac_cv_lib_jpeg_main" >&6 6013 if test $ac_cv_lib_jpeg_main = yes; then 6014 FOUND_jpeg=yes 6015 fi 6016 6017 if test "$FOUND_jpeg" = "yes" ; then 6018 LIBS="$LIBS -ljpeg" 6019 else 6020 echo "------------------" 6021 echo "jpeg library not found." 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 5800 6026 5801 6027 -
orxonox/branches/images/configure.ac
r3084 r3086 203 203 AC_SUBST(MSBITFIELDS) 204 204 205 205 ## checking for libjpeg 206 AC_CHECK_HEADERS(jpeglib.h ,, 207 [AC_MSG_ERROR([cannot find jpeg headers]) ]) 208 209 AC_CHECK_LIB([jpeg], [main], FOUND_jpeg=yes) 210 if test "$FOUND_jpeg" = "yes" ; then 211 LIBS="$LIBS -ljpeg" 212 else 213 echo "------------------" 214 echo "jpeg library not found." 215 echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org" 216 echo "------------------" 217 exit -1 218 fi 206 219 207 220 -
orxonox/branches/images/console/Makefile.in
r2991 r3086 425 425 426 426 427 # uncomment the following if bencoderrequires the math library427 # uncomment the following if orxonox requires the math library 428 428 #gui_LDADD=-lm 429 429 -
orxonox/branches/images/gui/Makefile.in
r2991 r3086 178 178 noinst_HEADERS = orxonox_gui.h orxonox_gui_video.h orxonox_gui_audio.h orxonox_gui_exec.h orxonox_gui_flags.h orxonox_gui_banner.h orxonox_gui_keys.h 179 179 180 # uncomment the following if bencoderrequires the math library180 # uncomment the following if orxonox requires the math library 181 181 #gui_LDADD=-lm 182 182 -
orxonox/branches/images/importer/material.cc
r3085 r3086 319 319 printf ("setting Diffuse Map %s\n", dMap); 320 320 321 diffuseTextureSet = loadBMP(dMap, &diffuseTexture); 321 // diffuseTextureSet = loadBMP(dMap, &diffuseTexture); 322 diffuseTextureSet = loadJPG(dMap, &diffuseTexture); 322 323 323 324 } … … 384 385 } 385 386 386 387 388 387 bool Material::loadJPG (char* jpgName, GLuint* texture) 388 { 389 struct jpeg_decompress_struct cinfo; 390 tImageJPG *pImage = NULL; 391 FILE *pFile; 392 393 // Open a file pointer to the jpeg file and check if it was found and opened 394 if((pFile = fopen(jpgName, "rb")) == NULL) 395 { 396 // Display an error message saying the file was not found, then return NULL 397 printf("Unable to load JPG File %s.\n", jpgName); 398 return false; 399 } 400 401 // Create an error handler 402 jpeg_error_mgr jerr; 403 404 // Have our compression info object point to the error handler address 405 cinfo.err = jpeg_std_error(&jerr); 406 407 // Initialize the decompression object 408 jpeg_create_decompress(&cinfo); 409 410 // Specify the data source (Our file pointer) 411 jpeg_stdio_src(&cinfo, pFile); 412 413 // Allocate the structure that will hold our eventual jpeg data (must free it!) 414 pImage = (tImageJPG*)malloc(sizeof(tImageJPG)); 415 416 // Decode the jpeg file and fill in the image data structure to pass back 417 decodeJPG(&cinfo, pImage); 418 419 // This releases all the stored memory for reading and decoding the jpeg 420 jpeg_destroy_decompress(&cinfo); 421 422 // Close the file pointer that opened the file 423 fclose(pFile); 424 425 426 if(pImage == NULL) // If we can't load the file, quit! 427 exit(0); 428 429 // Generate a texture with the associative texture ID stored in the array 430 glGenTextures(1, texture); 431 432 // Bind the texture to the texture arrays index and init the texture 433 glBindTexture(GL_TEXTURE_2D, *texture); 434 435 // Build Mipmaps (builds different versions of the picture for distances - looks better) 436 gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->sizeX, pImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pImage->data); 437 438 // Lastly, we need to tell OpenGL the quality of our texture map. GL_LINEAR_MIPMAP_LINEAR 439 // is the smoothest. GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR, 440 // but looks blochy and pixilated. Good for slower computers though. 441 442 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); 443 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR); 444 445 446 // Now we need to free the image data that we loaded since OpenGL stored it as a texture 447 448 if (pImage) // If we loaded the image 449 { 450 if (pImage->data) // If there is texture data 451 { 452 free(pImage->data); // Free the texture data, we don't need it anymore 453 } 454 455 free(pImage); // Free the image structure 456 } 457 458 } 459 460 void Material::decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData) 461 { 462 // Read in the header of the jpeg file 463 jpeg_read_header(cinfo, TRUE); 464 465 // Start to decompress the jpeg file with our compression info 466 jpeg_start_decompress(cinfo); 467 468 // Get the image dimensions and row span to read in the pixel data 469 pImageData->rowSpan = cinfo->image_width * cinfo->num_components; 470 pImageData->sizeX = cinfo->image_width; 471 pImageData->sizeY = cinfo->image_height; 472 473 // Allocate memory for the pixel buffer 474 pImageData->data = new unsigned char[pImageData->rowSpan * pImageData->sizeY]; 475 476 // Here we use the library's state variable cinfo.output_scanline as the 477 // loop counter, so that we don't have to keep track ourselves. 478 479 // Create an array of row pointers 480 unsigned char** rowPtr = new unsigned char*[pImageData->sizeY]; 481 for (int i = 0; i < pImageData->sizeY; i++) 482 rowPtr[i] = &(pImageData->data[i*pImageData->rowSpan]); 483 484 // Now comes the juice of our work, here we extract all the pixel data 485 int rowsRead = 0; 486 while (cinfo->output_scanline < cinfo->output_height) 487 { 488 // Read in the current row of pixels and increase the rowsRead count 489 rowsRead += jpeg_read_scanlines(cinfo, &rowPtr[rowsRead], cinfo->output_height - rowsRead); 490 } 491 492 // Delete the temporary row pointers 493 delete [] rowPtr; 494 495 // Finish decompressing the data 496 jpeg_finish_decompress(cinfo); 497 } 498 -
orxonox/branches/images/importer/material.h
r3085 r3086 16 16 17 17 // IMAGE LIBS // 18 extern "C"{ // This has to be done, because not a c++ lib 18 19 #include <jpeglib.h> 19 20 } 20 21 //! Class to handle Materials. 21 22 class Material … … 63 64 void setBump(char* bump); 64 65 65 // TEXTURING66 bool loadBMP (char* bmpName, GLuint* texture);67 66 68 67 private: 68 struct tImageJPG 69 { 70 int rowSpan; 71 int sizeX; 72 int sizeY; 73 unsigned char *data; 74 }; 75 76 69 77 char* name; 70 78 int illumModel; … … 76 84 Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists. 77 85 86 // TEXTURING 87 bool loadBMP (char* bmpName, GLuint* texture); 88 bool loadJPG (char* jpgName, GLuint* texture); 89 void decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData); 78 90 }; 79 91 #endif
Note: See TracChangeset
for help on using the changeset viewer.