Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9452 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
RevLine 
[3341]1/*!
[5768]2 * @file texture.h
3 * @brief Contains the texture class, that handles the reading of Images into Texutre-files.
4 */
[3341]5
6#ifndef _TEXTURE_H
7#define _TEXTURE_H
8
[5304]9#include "base_object.h"
[3548]10
[5768]11#include "glincl.h"
[7785]12#include "count_pointer.h"
[8363]13#include "texture_data.h"
[3548]14
[8363]15
[5768]16/* Forward Declaration */
[5239]17struct SDL_Surface;
18
[3341]19//! A Class, that reads in Textures from different fileformats.
[7785]20class Texture : public BaseObject
21{
22public:
[7790]23  Texture();
[7788]24  Texture(const Texture& texture);
[8312]25  Texture(GLenum target, unsigned int width, unsigned int height, unsigned int channels, GLenum type);
[7785]26  Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
27  Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
[5753]28
[8376]29  Texture& operator=(const Texture& texture);
[8761]30  Texture& operator=(const TextureDataPointer& textureDataPointer);
[8376]31
[7785]32  virtual ~Texture();
[3341]33
[7785]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();
[5856]37
[7785]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(); };
[5856]44
[5857]45
[5858]46
[7785]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);
[4466]53
[7785]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); };
[5857]58
[7785]59private:
60  void init();
61  static void generateTexture(GLuint& texture, GLenum target);
[5768]62
[7785]63private:
[8761]64  TextureDataPointer            data;               //!< The TextureData
[7785]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
[3341]70#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.