/*! \file texture.h \brief Contains the texture class, that handles the reading of Images into Texutre-files. \todo free SDL-surface when deleting Material. \todo delete imgNameWithPath after use creation. */ #ifndef _TEXTURE_H #define _TEXTURE_H #include "../stdincl.h" extern int verbose; #ifdef HAVE_SDL_SDL_IMAGE_H #include #else // IMAGE LIBS // #ifdef HAVE_JPEGLIB_H extern "C"{ // This has to be done, because not a c++ lib #include } #endif /* HAVE_JPEGLIB_H */ #ifdef HAVE_PNG_H #include #endif /* HAVE_PNG_H */ #endif /* HAVE_SDL_SDL_IMAGE_H */ //! Class to handle lists of paths. /** \todo Ability to return Paths by itself. It is simple to use, and good, for all PathList you want. just create a new Pathlist, and add Paths. */ class PathList { private: PathList(); static PathList* firstPath; //!< A static Pointer to the first PathList in the List. public: PathList(char* pName); ~PathList(); static PathList* getInstance(void); void addPath (char* pName); char* pathName; //!< The Name of the current Path. PathList* next; //!< Pointer to the next Pathlist. }; //! A Class, that reads in Textures from different fileformats. class Texture { private: //! Struct to handle Infos about an Image struct Image { int rowSpan; //!< The count of the rows this Image has. GLuint width; //!< The width of the Image. GLuint height; //!< The height of the Image. GLuint bpp; //!< BytesPerPixel GLenum format; //!< The Format of the PixelData GLuint type; //!< Type of the Image. GLubyte *data; //!< The Image Data comes here! DANGER: uncompressed data. }; Image* pImage; GLuint texture; SDL_Surface* map; char* searchTextureInPaths(char* texName) const; inline void swap(unsigned char &a, unsigned char &b); public: Texture(void); ~Texture(void); inline GLuint getTexture(void) {return this->texture;} //!< \returns The textureID of this texture. bool loadTexToGL (Image* pImage); bool loadImage(char* imageName); #ifndef HAVE_SDL_SDL_IMAGE_H bool loadBMP (char* bmpName); bool loadJPG (char* jpgName); /// TGA /// bool loadTGA(const char * tgaName); bool loadUncompressedTGA(const char * filename, FILE * fTGA); bool loadCompressedTGA(const char * filename, FILE * fTGA); bool loadPNG(const char* pngName, GLuint* texture); #endif }; #endif /* _TEXTURE_H */