Changeset 7783 in orxonox.OLD for branches/water/src/lib/graphics/importer/texture.h
- Timestamp:
- May 24, 2006, 2:49:58 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/water/src/lib/graphics/importer/texture.h
r7700 r7783 10 10 11 11 #include "glincl.h" 12 #include "count_pointer.h" 12 13 13 14 /* Forward Declaration */ 14 15 struct SDL_Surface; 15 16 16 //! A Class, that reads in Textures from different fileformats.17 class Texture : public BaseObject18 {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 17 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(); 18 class TextureData 19 { 20 public: 21 TextureData(); 22 ~TextureData(); 28 23 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; }; 24 inline GLuint getTexture() const { return this->texture; }; 25 /** @returns true if texture has alpha, false otherwise */ 26 inline bool hasAlpha() const {return this->bAlpha; } 27 /** @returns the stored image of this Texture */ 28 const SDL_Surface* const getStoredImage() const { return this->image; }; 29 30 bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D); 35 31 36 32 37 33 38 static void setTextureEnableState(bool texturesEnabled); 39 /** @returns true if Textures are enabled */ 40 inline static bool getTextureEnableState() { return Texture::texturesEnabled; }; 34 bool rebuild(); 41 35 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;36 bool setSurface(SDL_Surface* newSurface); 37 bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; }; 38 bool setTexture(GLuint texture); 45 39 46 protected: 47 bool setSurface(SDL_Surface* newSurface); 48 bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; }; 49 bool setTexture(GLuint texture) { this->texture = texture; }; 40 private: 41 GLuint texture; //!< The Texture-ID of opengl from this Texture. 42 bool bAlpha; //!< if the texture has an alpha channel. 43 SDL_Surface* image; //!< The SDL_Surfce that stores the Texture on it. 44 }; 50 45 51 private:52 void init();53 static void generateTexture(GLuint& texture, GLenum target);54 46 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) 47 //! A Class, that reads in Textures from different fileformats. 48 class Texture : public BaseObject 49 { 50 public: 60 51 61 static bool texturesEnabled; //!< If the Textures are enabled. 62 }; 52 public: 53 Texture(GLenum target = GL_TEXTURE_2D); 54 Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D); 55 Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D); 56 57 virtual ~Texture(); 58 59 bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D); 60 bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D); 61 virtual bool rebuild(); 62 63 /** @returns The textureID of this texture. */ 64 inline GLuint getTexture() const { return this->data->getTexture(); }; 65 /** @returns true if texture has alpha, false otherwise */ 66 inline bool hasAlpha() const { return this->data->hasAlpha(); } 67 /** @returns the stored image of this Texture */ 68 const SDL_Surface* const getStoredImage() const { return this->data->getStoredImage(); }; 69 70 71 72 static void setTextureEnableState(bool texturesEnabled); 73 /** @returns true if Textures are enabled */ 74 inline static bool getTextureEnableState() { return Texture::texturesEnabled; }; 75 76 // Utility functionality: 77 static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha); 78 static GLuint loadTexToGL (const SDL_Surface* surface, GLenum target = GL_TEXTURE_2D); 79 80 81 protected: 82 bool setSurface(SDL_Surface* newSurface) { return this->data->setSurface(newSurface); }; 83 bool setAlpha(bool hasAlpha) { return this->data->setAlpha(hasAlpha); }; 84 bool setTexture(GLuint texture) { return this->data->setTexture(texture); }; 85 86 private: 87 void init(); 88 static void generateTexture(GLuint& texture, GLenum target); 89 90 private: 91 CountPointer<TextureData> data; //!< The TextureData 92 GLclampf priority; //!< the priority of the current texture (used for garphics cards with limited mem) 93 94 static bool texturesEnabled; //!< If the Textures are enabled. 95 }; 63 96 64 97 #endif /* _TEXTURE_H */
Note: See TracChangeset
for help on using the changeset viewer.