#pragma once #include "Point.h" #include "ReferenceCounter.h" #include "Text.h" namespace Framework { class Image; //! Image.h class TextureList; //! TextureList.h enum TextureDirection { RAM_TO_GPU = 0, //! The texture is copied from an Image to GPU and then //! used in shaders GPU_TO_RAM = 1, //! The texture is created by a shader and then copied //! to an Image }; //! Converts an image to a texture that can be passed to the graphics //! card for rendering class Texture : public virtual ReferenceCounter { protected: Image* bild; bool changed; Point lastGr; int id; TextureDirection direction; bool bufferChanged; Text name; public: //! Constructor DLLEXPORT Texture(TextureDirection dir); //! Destructor DLLEXPORT virtual ~Texture(); //! Sets a pointer to the image that contains the texture //! \param b The pointer to the image DLLEXPORT void setImageZ(Image* b); //! Sets the image that contains the texture by copying it //! \param b The image to copy DLLEXPORT void setImage(Image* b); //! Updates the texture. The pixels of the current image are copied //! to graphics memory DLLEXPORT virtual bool updateTextur() = 0; //! Returns true if updateTextur needs to be called DLLEXPORT virtual bool needsUpdate() const = 0; //! Returns a pointer to the image DLLEXPORT Image* getImage() const; //! Returns a pointer to the image without increased reference counter DLLEXPORT Image* zImage() const; //! Returns the id of the texture if it was registered in a TextureList. //! (see Framework::zTextureRegister()) DLLEXPORT int getId() const; //! Returns the direction of the texture DLLEXPORT TextureDirection getDirection() const; //! Returns true if the texture has changed since the last update DLLEXPORT bool hasBufferChanged() const; // Sets whether the texture has changed since the last update DLLEXPORT void setBufferChanged(bool changed); // Sets the name of the texture. This name also acociated with the // underlying direct x recource and can be used for debugging purposes. DLLEXPORT void setName(const char* name); friend TextureList; }; } // namespace Framework