#pragma once #include "Point.h" #include "ReferenceCounter.h" struct ID3D11Texture2D; struct ID3D11ShaderResourceView; struct ID3D11Device; struct ID3D11DeviceContext; namespace Framework { class Bild; //! Image.h class Render3D; //! Render3D.h class TexturList; //! TextureList.h class DX12CopyCommandQueue; class DX12DirectCommandQueue; //! Converts an image to a texture that can be passed to the graphics //! card for rendering class Textur : public virtual ReferenceCounter { protected: Bild* bild; bool changed; Punkt lastGr; int id; public: //! Constructor DLLEXPORT Textur(); //! Destructor DLLEXPORT virtual ~Textur(); //! Sets a pointer to the image that contains the texture //! \param b The pointer to the image DLLEXPORT void setBildZ(Bild* b); //! Sets the image that contains the texture by copying it //! \param b The image to copy DLLEXPORT void setBild(Bild* 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 brauchtUpdate() const = 0; //! Returns a pointer to the image DLLEXPORT Bild* getBild() const; //! Returns a pointer to the image without increased reference counter DLLEXPORT Bild* zBild() const; //! Returns the id of the texture if it was registered in a TexturList. //! (see Framework::zTexturRegister()) DLLEXPORT int getId() const; friend TexturList; }; //! Converts an image to a texture that can be passed to the graphics //! card for rendering class DX9Textur : public Textur { public: //! Updates the texture. The pixels of the current image are copied //! to graphics memory DLLEXPORT virtual bool updateTextur() override; //! Returns true if updateTextur needs to be called DLLEXPORT virtual bool brauchtUpdate() const override; }; class DX11Textur : public Textur { private: ID3D11Texture2D* txt; ID3D11ShaderResourceView* view; ID3D11Device* device; ID3D11DeviceContext* context; bool renderTarget; bool useMips; public: DLLEXPORT DX11Textur( ID3D11Device* device, ID3D11DeviceContext* context); DLLEXPORT ~DX11Textur(); //! Updates the texture. The pixels of the current image are copied //! to graphics memory DLLEXPORT bool updateTextur() override; //! Returns true if updateTextur needs to be called DLLEXPORT bool brauchtUpdate() const override; //! Returns the used shader resource view DLLEXPORT operator ID3D11ShaderResourceView*() const; //! Returns the used texture DLLEXPORT operator ID3D11Texture2D*() const; //! specifies that this texture is used as a render target DLLEXPORT void setRenderTarget(bool rt); //! specifies if a mip map should be generated DLLEXPORT void setUseMips(bool useMips); //! copy the texture to an image DLLEXPORT void copyToImage(Bild* zB); }; } // namespace Framework