Texture.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include "Point.h"
  3. #include "ReferenceCounter.h"
  4. #include "Text.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. Text name;
  28. public:
  29. //! Constructor
  30. DLLEXPORT Texture(TextureDirection dir);
  31. //! Destructor
  32. DLLEXPORT virtual ~Texture();
  33. //! Sets a pointer to the image that contains the texture
  34. //! \param b The pointer to the image
  35. DLLEXPORT void setImageZ(Image* b);
  36. //! Sets the image that contains the texture by copying it
  37. //! \param b The image to copy
  38. DLLEXPORT void setImage(Image* b);
  39. //! Updates the texture. The pixels of the current image are copied
  40. //! to graphics memory
  41. DLLEXPORT virtual bool updateTextur() = 0;
  42. //! Returns true if updateTextur needs to be called
  43. DLLEXPORT virtual bool needsUpdate() const = 0;
  44. //! Returns a pointer to the image
  45. DLLEXPORT Image* getImage() const;
  46. //! Returns a pointer to the image without increased reference counter
  47. DLLEXPORT Image* zImage() const;
  48. //! Returns the id of the texture if it was registered in a TextureList.
  49. //! (see Framework::zTextureRegister())
  50. DLLEXPORT int getId() const;
  51. //! Returns the direction of the texture
  52. DLLEXPORT TextureDirection getDirection() const;
  53. //! Returns true if the texture has changed since the last update
  54. DLLEXPORT bool hasBufferChanged() const;
  55. // Sets whether the texture has changed since the last update
  56. DLLEXPORT void setBufferChanged(bool changed);
  57. // Sets the name of the texture. This name also acociated with the
  58. // underlying direct x recource and can be used for debugging purposes.
  59. DLLEXPORT void setName(const char* name);
  60. friend TextureList;
  61. };
  62. } // namespace Framework