Texture.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "Critical.h"
  3. #include "Point.h"
  4. #include "ReferenceCounter.h"
  5. namespace Framework
  6. {
  7. class Image; //! Image.h
  8. class TextureList; //! TextureList.h
  9. enum TextureDirection
  10. {
  11. RAM_TO_GPU = 0, //! The texture is copied from an Image to GPU and then
  12. //! used in shaders
  13. GPU_TO_RAM = 1, //! The texture is created by a shader and then copied
  14. //! to an Image
  15. };
  16. //! Converts an image to a texture that can be passed to the graphics
  17. //! card for rendering
  18. class Texture : public virtual ReferenceCounter
  19. {
  20. protected:
  21. Image* bild;
  22. bool changed;
  23. Point lastGr;
  24. int id;
  25. TextureDirection direction;
  26. bool bufferChanged;
  27. public:
  28. //! Constructor
  29. DLLEXPORT Texture(TextureDirection dir);
  30. //! Destructor
  31. DLLEXPORT virtual ~Texture();
  32. //! Sets a pointer to the image that contains the texture
  33. //! \param b The pointer to the image
  34. DLLEXPORT void setImageZ(Image* b);
  35. //! Sets the image that contains the texture by copying it
  36. //! \param b The image to copy
  37. DLLEXPORT void setImage(Image* b);
  38. //! Updates the texture. The pixels of the current image are copied
  39. //! to graphics memory
  40. DLLEXPORT virtual bool updateTextur() = 0;
  41. //! Returns true if updateTextur needs to be called
  42. DLLEXPORT virtual bool needsUpdate() const = 0;
  43. //! Returns a pointer to the image
  44. DLLEXPORT Image* getImage() const;
  45. //! Returns a pointer to the image without increased reference counter
  46. DLLEXPORT Image* zImage() const;
  47. //! Returns the id of the texture if it was registered in a TextureList.
  48. //! (see Framework::zTextureRegister())
  49. DLLEXPORT int getId() const;
  50. //! Returns the direction of the texture
  51. DLLEXPORT TextureDirection getDirection() const;
  52. //! Returns true if the texture has changed since the last update
  53. DLLEXPORT bool hasBufferChanged() const;
  54. // Sets whether the texture has changed since the last update
  55. DLLEXPORT void setBufferChanged(bool changed);
  56. friend TextureList;
  57. };
  58. } // namespace Framework