/*! \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" #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; //!< The data of an Image GLuint texture; //!< The Texture-ID of opengl from this Texture. SDL_Surface* map; //!< The map SDL initializes for this element. char* searchTextureInPaths(char* texName) const; inline void swap(unsigned char &a, unsigned char &b); public: Texture(void); ~Texture(void); /** \returns The textureID of this texture. */ inline GLuint getTexture(void) {return 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); #endif }; #endif /* _TEXTURE_H */