home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / Texture.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-12-18  |  2.3 KB  |  59 lines

  1. #ifndef __Texture_h__
  2. #define __Texture_h__
  3.  
  4. /*!
  5. \file texture.h
  6. \author Karsten Schwenk
  7.  
  8. \brief This file contains the the classes #Texture and #TextureHandler, which are used *surprise* for texture handling.
  9.  
  10. Whenever you need to load textures you just have to call #TextureHandler::getTexture(filename). If it returns a valid pointer to #Texture object you can bind it in OpenGL via \c Texture->texName. If #TextureHandler::getTexture() returns \c NULL the file couldn't be opened or the format is not known. To avoid the first you can set/change the #TetureHandler::searchPath.
  11.  
  12. The following image formats are supported: BMP, PNM (PPM/PGM/PBM), XPM, LBM, PCX, GIF, JPEG, PNG, TGA, TIFF and RGB/RGBA (SGI). RGB is supported through my own loader in rgbloader.h, all other formats are loaded by SDL_image routines (see imageloader.h).
  13. */
  14.  
  15. #ifdef WIN32
  16. #include <windows.h>
  17. #endif
  18. #include <GL/gl.h>
  19. #include <GL/glu.h>
  20.  
  21. #include "ImageLoader.h"
  22.  
  23. //! wraps an OpenGL texture
  24. /*!
  25. Since the constructors automatically generate an OpenGL texture object, an OpenGL context MUST be present, when you construct an object of this class.
  26. */
  27. class Texture{
  28. public:
  29.     int width;        //!< width of the texture
  30.     int height;        //!< height of the texture
  31.     bool hasAlpha;        //!< does the texture have an alpha channel?
  32.     char* filename;        //!< filename of the image file
  33.  
  34.     GLuint texName;        //!< the OpenGL texture object name
  35.     GLuint texType;        //!< the OpenGL texture type (RGB, RGB, LUMINANCE, ...)
  36.     GLclampf priority;    //!< the OpenGL texture priority
  37.  
  38.     Texture(const char* filename);                //!< constructor
  39.     Texture(const char* filename, GLclampf priority);    //!< constructor
  40.     Texture(image_t* image);        //!< generates a Texture object from an image_s struct
  41.     ~Texture();                        //!< destructor
  42.  
  43.     void reload();        //!< reloads the texture
  44.  
  45.     // THINKABOUTME: wirklich static??
  46.     static char* findImageFile(const char* filename);    //!< searches for an image file
  47.  
  48. protected:    
  49.     image_t* image;                //!< the #image_s struct for loading
  50.  
  51.     bool setAttribs();            //!< sets attributes like hasAlpha, texType, etc.
  52.     GLuint generateTextureObject();        //!< returns a new OpenGL texture object id
  53.     void freeTextureObject();        //!< tells OpenGL to free the texture object associated with this object
  54.     void freeImage();            //!< frees the #image struct
  55. };
  56.  
  57.  
  58. #endif    /* __Texture_h__ */
  59.