| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #pragma once
- #include "Point.h"
- #include "ReferenceCounter.h"
- struct ID3D11Texture2D;
- struct ID3D11ShaderResourceView;
- struct ID3D11Device;
- struct ID3D11DeviceContext;
- namespace Framework
- {
- class Image; //! 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:
- Image* 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 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 brauchtUpdate() 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 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(Image* zB);
- };
- } // namespace Framework
|