Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7785 in orxonox.OLD for trunk/src/lib/graphics/importer/texture.h


Ignore:
Timestamp:
May 24, 2006, 3:17:19 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the Changes from the water branche back to the trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/texture.h

    r7727 r7785  
    1010
    1111#include "glincl.h"
     12#include "count_pointer.h"
    1213
    1314/* Forward Declaration */
    1415struct SDL_Surface;
    1516
    16 //! A Class, that reads in Textures from different fileformats.
    17   class Texture : public BaseObject
    18   {
    19     public:
    20       Texture(const std::string& imageName = "", GLenum target = GL_TEXTURE_2D);
    21   //  Texture(TEXTURE_TYPE type, int resolution);
    22       virtual ~Texture();
    2317
    24       bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
    25       virtual bool rebuild();
     18class TextureData
     19{
     20  public:
     21    TextureData();
     22    ~TextureData();
    2623
    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);
    3331
    3432
    3533
    36       static void setTextureEnableState(bool texturesEnabled);
    37       /** @returns true if Textures are enabled */
    38       inline static bool getTextureEnableState() { return Texture::texturesEnabled; };
     34    bool rebuild();
    3935
    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);
    4339
    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};
    4845
    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)
    5446
    55       static bool      texturesEnabled;    //!< If the Textures are enabled.
    56   };
     47//! A Class, that reads in Textures from different fileformats.
     48class Texture : public BaseObject
     49{
     50public:
     51
     52public:
     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
     79protected:
     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
     84private:
     85  void init();
     86  static void generateTexture(GLuint& texture, GLenum target);
     87
     88private:
     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};
    5794
    5895#endif /* _TEXTURE_H */
Note: See TracChangeset for help on using the changeset viewer.