Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/texture.h @ 8363

Last change on this file since 8363 was 8363, checked in by bensch, 18 years ago

trunk: splitted Texture and TextureData into two files.
Also fixed the Creator-Function for Textures with empty textures with size

File size: 2.3 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
11#include "glincl.h"
12#include "count_pointer.h"
13#include "texture_data.h"
14
15
16/* Forward Declaration */
17struct SDL_Surface;
18
19//! A Class, that reads in Textures from different fileformats.
20class Texture : public BaseObject
21{
22public:
23  Texture();
24  Texture(const Texture& texture);
25  Texture(GLenum target, unsigned int width, unsigned int height, unsigned int channels, GLenum type);
26  Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
27  Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
28
29  virtual ~Texture();
30
31  bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
32  bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
33  virtual bool rebuild();
34
35  /** @returns The textureID of this texture.  */
36  inline GLuint getTexture() const { return this->data->getTexture(); };
37  /** @returns true if texture has alpha, false otherwise */
38  inline bool hasAlpha() const  { return this->data->hasAlpha(); }
39  /** @returns the stored image of this Texture */
40  const SDL_Surface* const getStoredImage() const { return this->data->getStoredImage(); };
41
42
43
44  static void setTextureEnableState(bool texturesEnabled);
45  /** @returns true if Textures are enabled */
46  inline static bool getTextureEnableState() { return Texture::texturesEnabled; };
47  // Utility functionality:
48  static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha);
49  static GLuint loadTexToGL (const SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
50
51protected:
52  bool setSurface(SDL_Surface* newSurface) { return this->data->setSurface(newSurface); };
53  bool setAlpha(bool hasAlpha) { return this->data->setAlpha(hasAlpha); };
54  bool setTexture(GLuint texture) { return this->data->setTexture(texture); };
55
56private:
57  void init();
58  static void generateTexture(GLuint& texture, GLenum target);
59
60private:
61  CountPointer<TextureData>     data;               //!< The TextureData
62  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
63
64  static bool                   texturesEnabled;    //!< If the Textures are enabled.
65};
66
67#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.