Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/graphics/importer/texture.h @ 9718

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

more thoughts on Resources, and soon going to adapt… i think i've got a clue :)

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