Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9882 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
RevLine 
[3341]1/*!
[5768]2 * @file texture.h
[9869]3 * @brief Contains the texture class, that handles the reading of Images into Texture-files.
[5768]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{
[9869]22  ObjectListDeclaration(Texture);
[7785]23public:
[7790]24  Texture();
[7788]25  Texture(const Texture& texture);
[8312]26  Texture(GLenum target, unsigned int width, unsigned int height, unsigned int channels, GLenum type);
[7785]27  Texture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
28  Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
[5753]29
[8376]30  Texture& operator=(const Texture& texture);
[9869]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; }
[8376]34
[7785]35  virtual ~Texture();
[3341]36
[7785]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();
[5856]40
[7785]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(); };
[5856]47
[5857]48
[5858]49
[7785]50  static void setTextureEnableState(bool texturesEnabled);
51  /** @returns true if Textures are enabled */
[9882]52  static bool getTextureEnableState() { return Texture::texturesEnabled; };
[7785]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);
[4466]56
[7785]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); };
[5857]61
[7785]62private:
63  void init();
64  static void generateTexture(GLuint& texture, GLenum target);
[5768]65
[7785]66private:
[9869]67  TextureData::Pointer          data;               //!< The TextureData
[7785]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
[3341]73#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.