Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2006, 2:49:58 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: image-data splitted out of Texture

File:
1 edited

Legend:

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

    r7700 r7783  
    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(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();
    2417
    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();
     18class TextureData
     19{
     20  public:
     21    TextureData();
     22    ~TextureData();
    2823
    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);
    3531
    3632
    3733
    38       static void setTextureEnableState(bool texturesEnabled);
    39       /** @returns true if Textures are enabled */
    40       inline static bool getTextureEnableState() { return Texture::texturesEnabled; };
     34    bool rebuild();
    4135
    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);
    4539
    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};
    5045
    51     private:
    52       void init();
    53       static void generateTexture(GLuint& texture, GLenum target);
    5446
    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.
     48class Texture : public BaseObject
     49{
     50public:
    6051
    61       static bool      texturesEnabled;    //!< If the Textures are enabled.
    62   };
     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
     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
     81protected:
     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
     86private:
     87  void init();
     88  static void generateTexture(GLuint& texture, GLenum target);
     89
     90private:
     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};
    6396
    6497#endif /* _TEXTURE_H */
Note: See TracChangeset for help on using the changeset viewer.