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