Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/lib/graphics/importer/texture.h @ 9142

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

merged the new Font-Implementation back here
merged with svn merge https://svn.orxonox.net/orxonox/branches/fontdata . -r8752:HEAD
no conflicts, naturally

File size: 2.4 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  Texture& operator=(const Texture& texture);
30  Texture& operator=(const TextureDataPointer& textureDataPointer);
31
32  virtual ~Texture();
33
34  bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
35  bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
36  virtual bool rebuild();
37
38  /** @returns The textureID of this texture.  */
39  inline GLuint getTexture() const { return this->data->getTexture(); };
40  /** @returns true if texture has alpha, false otherwise */
41  inline bool hasAlpha() const  { return this->data->hasAlpha(); }
42  /** @returns the stored image of this Texture */
43  const SDL_Surface* const getStoredImage() const { return this->data->getStoredImage(); };
44
45
46
47  static void setTextureEnableState(bool texturesEnabled);
48  /** @returns true if Textures are enabled */
49  inline static bool getTextureEnableState() { return Texture::texturesEnabled; };
50  // Utility functionality:
51  static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha);
52  static GLuint loadTexToGL (const SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
53
54protected:
55  bool setSurface(SDL_Surface* newSurface) { return this->data->setSurface(newSurface); };
56  bool setAlpha(bool hasAlpha) { return this->data->setAlpha(hasAlpha); };
57  bool setTexture(GLuint texture) { return this->data->setTexture(texture); };
58
59private:
60  void init();
61  static void generateTexture(GLuint& texture, GLenum target);
62
63private:
64  TextureDataPointer            data;               //!< The TextureData
65  GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
66
67  static bool                   texturesEnabled;    //!< If the Textures are enabled.
68};
69
70#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.