| [3341] | 1 | /*! | 
|---|
 | 2 |   \file texture.h | 
|---|
 | 3 |   \brief Contains the texture class, that handles the reading of Images into Texutre-files. | 
|---|
 | 4 |  | 
|---|
 | 5 |   \todo free SDL-surface when deleting Material. | 
|---|
 | 6 |   \todo delete imgNameWithPath after use creation. | 
|---|
 | 7 | */ | 
|---|
 | 8 |  | 
|---|
 | 9 | #ifndef _TEXTURE_H | 
|---|
 | 10 | #define _TEXTURE_H | 
|---|
 | 11 |  | 
|---|
 | 12 | #include "../stdincl.h" | 
|---|
 | 13 | #ifdef HAVE_SDL_SDL_IMAGE_H | 
|---|
 | 14 | #include <SDL/SDL_image.h> | 
|---|
 | 15 | #else | 
|---|
 | 16 | // IMAGE LIBS // | 
|---|
 | 17 | #ifdef HAVE_JPEGLIB_H | 
|---|
 | 18 | extern "C"{         // This has to be done, because not a c++ lib | 
|---|
 | 19 | #include <jpeglib.h> | 
|---|
 | 20 | } | 
|---|
 | 21 | #endif /* HAVE_JPEGLIB_H */ | 
|---|
 | 22 | #ifdef HAVE_PNG_H | 
|---|
 | 23 | #include <png.h> | 
|---|
 | 24 | #endif /* HAVE_PNG_H */ | 
|---|
 | 25 | #endif /* HAVE_SDL_SDL_IMAGE_H */ | 
|---|
 | 26 |  | 
|---|
 | 27 |  | 
|---|
 | 28 |  | 
|---|
 | 29 | //! Class to handle lists of paths. | 
|---|
 | 30 | /** | 
|---|
 | 31 |    \todo Ability to return Paths by itself. | 
|---|
 | 32 |  | 
|---|
 | 33 |    It is simple to use, and good, for all PathList you want. | 
|---|
 | 34 |    just create a new Pathlist, and add Paths. | 
|---|
 | 35 | */ | 
|---|
 | 36 | class PathList | 
|---|
 | 37 | { | 
|---|
 | 38 |  private: | 
|---|
 | 39 |   PathList(); | 
|---|
 | 40 |   static PathList* firstPath; //!< A static Pointer to the first PathList in the List. | 
|---|
 | 41 |  public: | 
|---|
 | 42 |   PathList(char* pName); | 
|---|
 | 43 |   ~PathList(); | 
|---|
 | 44 |   static PathList* getInstance(void); | 
|---|
 | 45 |    | 
|---|
 | 46 |   void addPath (char* pName); | 
|---|
 | 47 |   char* pathName;              //!< The Name of the current Path. | 
|---|
 | 48 |   PathList* next;              //!< Pointer to the next Pathlist. | 
|---|
 | 49 | }; | 
|---|
 | 50 |  | 
|---|
 | 51 | //! A Class, that reads in Textures from different fileformats. | 
|---|
 | 52 | class Texture | 
|---|
 | 53 | { | 
|---|
 | 54 |  private: | 
|---|
 | 55 |   //! Struct to handle Infos about an Image | 
|---|
 | 56 |   struct Image | 
|---|
 | 57 |   { | 
|---|
 | 58 |     int rowSpan;    //!< The count of the rows this Image has. | 
|---|
 | 59 |     GLuint width;   //!< The width of the Image. | 
|---|
 | 60 |     GLuint height;  //!< The height of the Image. | 
|---|
| [3343] | 61 |     GLuint bpp;     //!< BytesPerPixel | 
|---|
| [3347] | 62 |     GLenum format;  //!< The Format of the PixelData | 
|---|
| [3341] | 63 |     GLuint type;    //!< Type of the Image. | 
|---|
 | 64 |     GLubyte *data;  //!< The Image Data comes here! DANGER: uncompressed data. | 
|---|
 | 65 |   }; | 
|---|
| [3454] | 66 |   Image* pImage;    //!< The data of an Image | 
|---|
 | 67 |   GLuint texture;   //!< The Texture-ID of opengl from this Texture. | 
|---|
 | 68 |   SDL_Surface* map; //!< The map SDL initializes for this element. | 
|---|
| [3341] | 69 |   char* searchTextureInPaths(char* texName) const; | 
|---|
| [3343] | 70 |   inline void swap(unsigned char &a, unsigned char &b); | 
|---|
| [3341] | 71 |  public: | 
|---|
| [3344] | 72 |   Texture(void); | 
|---|
 | 73 |   ~Texture(void); | 
|---|
| [3454] | 74 |   /** \returns The textureID of this texture.  */ | 
|---|
 | 75 |   inline GLuint getTexture(void) {return this->texture;}  | 
|---|
| [3344] | 76 |   bool loadTexToGL (Image* pImage); | 
|---|
| [3341] | 77 |  | 
|---|
| [3344] | 78 |   bool loadImage(char* imageName); | 
|---|
| [3341] | 79 | #ifndef HAVE_SDL_SDL_IMAGE_H | 
|---|
 | 80 |  | 
|---|
| [3344] | 81 |   bool loadBMP (char* bmpName); | 
|---|
| [3341] | 82 |  | 
|---|
| [3344] | 83 |   bool loadJPG (char* jpgName); | 
|---|
| [3341] | 84 |  | 
|---|
 | 85 |   /// TGA /// | 
|---|
 | 86 |  | 
|---|
| [3344] | 87 |   bool loadTGA(const char * tgaName); | 
|---|
 | 88 |   bool loadUncompressedTGA(const char * filename, FILE * fTGA); | 
|---|
 | 89 |   bool loadCompressedTGA(const char * filename, FILE * fTGA); | 
|---|
| [3341] | 90 |  | 
|---|
| [3454] | 91 |   bool loadPNG(const char* pngName); | 
|---|
| [3341] | 92 | #endif | 
|---|
 | 93 |  | 
|---|
 | 94 |  | 
|---|
 | 95 | }; | 
|---|
 | 96 |  | 
|---|
 | 97 |  | 
|---|
 | 98 |  | 
|---|
 | 99 | #endif /* _TEXTURE_H */ | 
|---|