Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10727 was 10460, checked in by patrick, 18 years ago

some texture attributes, camera target fix

File size: 2.7 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
57  float getHeight() { return this->data->getHeight(); }
58  float getWidth() { return this->data->getWidth(); }
59
60protected:
61  bool setSurface(SDL_Surface* newSurface) { return this->data->setSurface(newSurface); };
62  bool setAlpha(bool hasAlpha) { return this->data->setAlpha(hasAlpha); };
63  bool setTexture(GLuint texture) { return this->data->setTexture(texture); };
64
65private:
66  void init();
67  static void generateTexture(GLuint& texture, GLenum target);
68
69private:
70  TextureData::Pointer          data;               //!< The TextureData
71  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
72
73  static bool                   texturesEnabled;    //!< If the Textures are enabled.
74};
75
76#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.