Texture.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. public:
  27. //! Constructor
  28. DLLEXPORT Texture(TextureDirection dir);
  29. //! Destructor
  30. DLLEXPORT virtual ~Texture();
  31. //! Sets a pointer to the image that contains the texture
  32. //! \param b The pointer to the image
  33. DLLEXPORT void setImageZ(Image* b);
  34. //! Sets the image that contains the texture by copying it
  35. //! \param b The image to copy
  36. DLLEXPORT void setImage(Image* b);
  37. //! Updates the texture. The pixels of the current image are copied
  38. //! to graphics memory
  39. DLLEXPORT virtual bool updateTextur() = 0;
  40. //! Returns true if updateTextur needs to be called
  41. DLLEXPORT virtual bool needsUpdate() const = 0;
  42. //! Returns a pointer to the image
  43. DLLEXPORT Image* getImage() const;
  44. //! Returns a pointer to the image without increased reference counter
  45. DLLEXPORT Image* zImage() const;
  46. //! Returns the id of the texture if it was registered in a TextureList.
  47. //! (see Framework::zTextureRegister())
  48. DLLEXPORT int getId() const;
  49. //! Returns the direction of the texture
  50. DLLEXPORT TextureDirection getDirection() const;
  51. friend TextureList;
  52. };
  53. } // namespace Framework