Index: /orxonox/branches/images/config.h.in
===================================================================
--- /orxonox/branches/images/config.h.in	(revision 3085)
+++ /orxonox/branches/images/config.h.in	(revision 3086)
@@ -12,4 +12,7 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <jpeglib.h> header file. */
+#undef HAVE_JPEGLIB_H
 
 /* Define to 1 if you have the `m' library (-lm). */
Index: /orxonox/branches/images/configure
===================================================================
--- /orxonox/branches/images/configure	(revision 3085)
+++ /orxonox/branches/images/configure	(revision 3086)
@@ -5797,5 +5797,231 @@
 
 
-
+## checking for libjpeg
+
+for ac_header in jpeglib.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------------- ##
+## Report this to orxonox-dev@mail.datacore.ch ##
+## ------------------------------------------- ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+  { { echo "$as_me:$LINENO: error: cannot find jpeg headers" >&5
+echo "$as_me: error: cannot find jpeg headers" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+done
+
+
+echo "$as_me:$LINENO: checking for main in -ljpeg" >&5
+echo $ECHO_N "checking for main in -ljpeg... $ECHO_C" >&6
+if test "${ac_cv_lib_jpeg_main+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ljpeg  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+main ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_jpeg_main=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_jpeg_main=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_main" >&5
+echo "${ECHO_T}$ac_cv_lib_jpeg_main" >&6
+if test $ac_cv_lib_jpeg_main = yes; then
+  FOUND_jpeg=yes
+fi
+
+    if test "$FOUND_jpeg" = "yes" ; then
+      LIBS="$LIBS -ljpeg"
+    else
+	 echo "------------------"
+	 echo "jpeg library not found."
+	 echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org"
+	 echo "------------------"
+	 exit -1
+    fi
 
 
Index: /orxonox/branches/images/configure.ac
===================================================================
--- /orxonox/branches/images/configure.ac	(revision 3085)
+++ /orxonox/branches/images/configure.ac	(revision 3086)
@@ -203,5 +203,18 @@
 AC_SUBST(MSBITFIELDS)
 
-
+## checking for libjpeg
+AC_CHECK_HEADERS(jpeglib.h ,,
+        [AC_MSG_ERROR([cannot find jpeg headers]) ])
+
+AC_CHECK_LIB([jpeg], [main], FOUND_jpeg=yes)
+    if test "$FOUND_jpeg" = "yes" ; then
+      LIBS="$LIBS -ljpeg"
+    else
+	 echo "------------------"
+	 echo "jpeg library not found."
+	 echo "please install the jpeg library from the Independent JPEG Group, which can be found at http://www.ijg.org"
+	 echo "------------------"
+	 exit -1
+    fi   
 
 
Index: /orxonox/branches/images/console/Makefile.in
===================================================================
--- /orxonox/branches/images/console/Makefile.in	(revision 3085)
+++ /orxonox/branches/images/console/Makefile.in	(revision 3086)
@@ -425,5 +425,5 @@
 
 
-#  uncomment the following if bencoder requires the math library
+#  uncomment the following if orxonox requires the math library
 #gui_LDADD=-lm
 
Index: /orxonox/branches/images/gui/Makefile.in
===================================================================
--- /orxonox/branches/images/gui/Makefile.in	(revision 3085)
+++ /orxonox/branches/images/gui/Makefile.in	(revision 3086)
@@ -178,5 +178,5 @@
 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
 
-#  uncomment the following if bencoder requires the math library
+#  uncomment the following if orxonox requires the math library
 #gui_LDADD=-lm
 
Index: /orxonox/branches/images/importer/material.cc
===================================================================
--- /orxonox/branches/images/importer/material.cc	(revision 3085)
+++ /orxonox/branches/images/importer/material.cc	(revision 3086)
@@ -319,5 +319,6 @@
     printf ("setting Diffuse Map %s\n", dMap);
 
-  diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
+  //  diffuseTextureSet = loadBMP(dMap, &diffuseTexture);
+  diffuseTextureSet = loadJPG(dMap, &diffuseTexture);
 
 }
@@ -384,5 +385,114 @@
 }
 
-
-
-
+bool Material::loadJPG (char* jpgName, GLuint* texture)
+{
+  struct jpeg_decompress_struct cinfo;
+  tImageJPG *pImage = NULL;
+  FILE *pFile;
+  
+  // Open a file pointer to the jpeg file and check if it was found and opened 
+  if((pFile = fopen(jpgName, "rb")) == NULL) 
+    {
+      // Display an error message saying the file was not found, then return NULL
+      printf("Unable to load JPG File %s.\n", jpgName);
+      return false;
+    }
+  
+  // Create an error handler
+  jpeg_error_mgr jerr;
+  
+  // Have our compression info object point to the error handler address
+  cinfo.err = jpeg_std_error(&jerr);
+  
+  // Initialize the decompression object
+  jpeg_create_decompress(&cinfo);
+  
+  // Specify the data source (Our file pointer)	
+  jpeg_stdio_src(&cinfo, pFile);
+  
+  // Allocate the structure that will hold our eventual jpeg data (must free it!)
+  pImage = (tImageJPG*)malloc(sizeof(tImageJPG));
+  
+  // Decode the jpeg file and fill in the image data structure to pass back
+  decodeJPG(&cinfo, pImage);
+  
+  // This releases all the stored memory for reading and decoding the jpeg
+  jpeg_destroy_decompress(&cinfo);
+  
+  // Close the file pointer that opened the file
+  fclose(pFile);
+  
+
+  if(pImage == NULL)									// If we can't load the file, quit!
+    exit(0);
+
+  // Generate a texture with the associative texture ID stored in the array
+  glGenTextures(1, texture);
+  
+  // Bind the texture to the texture arrays index and init the texture
+  glBindTexture(GL_TEXTURE_2D, *texture);
+  
+  // Build Mipmaps (builds different versions of the picture for distances - looks better)
+  gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->sizeX, pImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pImage->data);
+  
+  // Lastly, we need to tell OpenGL the quality of our texture map.  GL_LINEAR_MIPMAP_LINEAR
+  // is the smoothest.  GL_LINEAR_MIPMAP_NEAREST is faster than GL_LINEAR_MIPMAP_LINEAR, 
+  // but looks blochy and pixilated.  Good for slower computers though. 
+  
+  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
+  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);	
+  
+
+  // Now we need to free the image data that we loaded since OpenGL stored it as a texture
+  
+  if (pImage)										// If we loaded the image
+    {
+      if (pImage->data)							// If there is texture data
+	{
+	  free(pImage->data);						// Free the texture data, we don't need it anymore
+	}
+      
+      free(pImage);								// Free the image structure
+    }
+
+}
+
+void Material::decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData)
+{
+  // Read in the header of the jpeg file
+  jpeg_read_header(cinfo, TRUE);
+  
+  // Start to decompress the jpeg file with our compression info
+  jpeg_start_decompress(cinfo);
+  
+  // Get the image dimensions and row span to read in the pixel data
+  pImageData->rowSpan = cinfo->image_width * cinfo->num_components;
+  pImageData->sizeX   = cinfo->image_width;
+  pImageData->sizeY   = cinfo->image_height;
+  
+  // Allocate memory for the pixel buffer
+  pImageData->data = new unsigned char[pImageData->rowSpan * pImageData->sizeY];
+  
+  // Here we use the library's state variable cinfo.output_scanline as the
+  // loop counter, so that we don't have to keep track ourselves.
+  
+  // Create an array of row pointers
+  unsigned char** rowPtr = new unsigned char*[pImageData->sizeY];
+  for (int i = 0; i < pImageData->sizeY; i++)
+    rowPtr[i] = &(pImageData->data[i*pImageData->rowSpan]);
+  
+  // Now comes the juice of our work, here we extract all the pixel data
+  int rowsRead = 0;
+  while (cinfo->output_scanline < cinfo->output_height) 
+    {
+      // Read in the current row of pixels and increase the rowsRead count
+      rowsRead += jpeg_read_scanlines(cinfo, &rowPtr[rowsRead], cinfo->output_height - rowsRead);
+    }
+  
+  // Delete the temporary row pointers
+  delete [] rowPtr;
+  
+  // Finish decompressing the data
+  jpeg_finish_decompress(cinfo);
+}
+
Index: /orxonox/branches/images/importer/material.h
===================================================================
--- /orxonox/branches/images/importer/material.h	(revision 3085)
+++ /orxonox/branches/images/importer/material.h	(revision 3086)
@@ -16,6 +16,7 @@
 
 // IMAGE LIBS //
+extern "C"{         // This has to be done, because not a c++ lib
 #include <jpeglib.h>
-
+}
 //! Class to handle Materials.
 class Material
@@ -63,8 +64,15 @@
   void setBump(char* bump);
 
-  // TEXTURING
-  bool loadBMP (char* bmpName, GLuint* texture);
 
  private:
+  struct tImageJPG
+  {
+    int rowSpan;
+    int sizeX;
+    int sizeY;
+    unsigned char *data;
+  };
+
+
   char* name;
   int illumModel;
@@ -76,4 +84,8 @@
   Material* nextMat; //!< pointer to the Next Material of the List. NULL if no next exists.
 
+  // TEXTURING
+  bool loadBMP (char* bmpName, GLuint* texture);
+  bool loadJPG (char* jpgName, GLuint* texture);
+  void decodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData);
 };
 #endif
