Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/resources/src/lib/graphics/importer/texture.h @ 7914

Last change on this file since 7914 was 7229, checked in by bensch, 19 years ago

resources: some minor implementations

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