Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

some texture attributes, camera target fix

File size: 2.7 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
[10460]57  float getHeight() { return this->data->getHeight(); }
58  float getWidth() { return this->data->getWidth(); }
59
[7785]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); };
[5857]64
[7785]65private:
66  void init();
67  static void generateTexture(GLuint& texture, GLenum target);
[5768]68
[7785]69private:
[9869]70  TextureData::Pointer          data;               //!< The TextureData
[7785]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
[3341]76#endif /* _TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.