Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7687 was 7687, checked in by stefalie, 18 years ago

branches/water: activate/deactivate reflection/refraction functions added

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