Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trunk: gl_multi_texture check in the material. This should resolve the Material::select() bug

File size: 2.6 KB
Line 
1/*!
2 * @file texture.h
3 * @brief Contains the texture class, that handles the reading of Images into Texture-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{
22  ObjectListDeclaration(Texture);
23public:
24  Texture();
25  Texture(const Texture& texture);
26  Texture(GLenum target, unsigned int width, unsigned int height, unsigned int channels, GLenum type);
27  Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
28  Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
29
30  Texture& operator=(const Texture& texture);
31  Texture& operator=(const TextureData::Pointer& textureDataPointer);
32  void acquireData(const TextureData::Pointer& textureDataPointer) { this->data = textureDataPointer; };
33  const TextureData::Pointer& dataPointer() const { return data; }
34
35  virtual ~Texture();
36
37  bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
38  bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
39  virtual bool rebuild();
40
41  /** @returns The textureID of this texture.  */
42  inline GLuint getTexture() const { return this->data->getTexture(); };
43  /** @returns true if texture has alpha, false otherwise */
44  inline bool hasAlpha() const  { return this->data->hasAlpha(); }
45  /** @returns the stored image of this Texture */
46  const SDL_Surface* const getStoredImage() const { return this->data->getStoredImage(); };
47
48
49
50  static void setTextureEnableState(bool texturesEnabled);
51  /** @returns true if Textures are enabled */
52  static bool getTextureEnableState() { return Texture::texturesEnabled; };
53  // Utility functionality:
54  static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha);
55  static GLuint loadTexToGL (const SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
56
57protected:
58  bool setSurface(SDL_Surface* newSurface) { return this->data->setSurface(newSurface); };
59  bool setAlpha(bool hasAlpha) { return this->data->setAlpha(hasAlpha); };
60  bool setTexture(GLuint texture) { return this->data->setTexture(texture); };
61
62private:
63  void init();
64  static void generateTexture(GLuint& texture, GLenum target);
65
66private:
67  TextureData::Pointer          data;               //!< The TextureData
68  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
69
70  static bool                   texturesEnabled;    //!< If the Textures are enabled.
71};
72
73#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.