Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/water/src/lib/graphics/importer/texture.h @ 7749

Last change on this file since 7749 was 7700, checked in by stefalie, 19 years ago

branches/water: first attempt to realise reflection

File size: 2.3 KB
Line 
1/*!
2 * @file texture.h
3 * @brief Contains the texture class, that handles the reading of Images into Texutre-files.
4 */
5
6#ifndef _TEXTURE_H
7#define _TEXTURE_H
8
9#include "base_object.h"
10
11#include "glincl.h"
12
13/* Forward Declaration */
14struct SDL_Surface;
15
16//! A Class, that reads in Textures from different fileformats.
17  class Texture : public BaseObject
18  {
19    public:
20      Texture(GLenum target = GL_TEXTURE_2D);
21      Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
22      Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
23      virtual ~Texture();
24
25      bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
26      bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
27      virtual bool rebuild();
28
29      /** @returns The textureID of this texture.  */
30      inline GLuint getTexture() const { return this->texture; };
31      /** @returns true if texture has alpha, false otherwise */
32      inline bool hasAlpha() const  {return bAlpha; }
33      /** @returns the stored image of this Texture */
34      const SDL_Surface* const getStoredImage() const { return this->image; };
35
36
37
38      static void setTextureEnableState(bool texturesEnabled);
39      /** @returns true if Textures are enabled */
40      inline static bool getTextureEnableState() { return Texture::texturesEnabled; };
41
42      // Utility functionality:
43      SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha) const;
44      GLuint loadTexToGL (const SDL_Surface* surface, GLenum target = GL_TEXTURE_2D) const;
45
46    protected:
47      bool setSurface(SDL_Surface* newSurface);
48      bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; };
49      bool setTexture(GLuint texture) { this->texture = texture; };
50
51    private:
52      void init();
53      static void generateTexture(GLuint& texture, GLenum target);
54
55    private:
56      GLuint           texture;            //!< The Texture-ID of opengl from this Texture.
57      bool             bAlpha;             //!< if the texture has an alpha channel.
58      SDL_Surface*     image;              //!< The SDL_Surfce that stores the Texture on it.
59      GLclampf         priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
60
61      static bool      texturesEnabled;    //!< If the Textures are enabled.
62  };
63
64#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.