#pragma once #include "Shader.h" struct ID3D10Blob; struct ID3D11PixelShader; struct ID3D11VertexShader; struct ID3D11Device; struct ID3D11DeviceContext; struct D3D11_INPUT_ELEMENT_DESC; struct ID3D11Buffer; struct ID3D11InputLayout; namespace Framework { class DX11Shader : public Shader { protected: ID3D11Device* device; ID3D11DeviceContext* context; Critical& deviceLock; public: DLLEXPORT DX11Shader(ID3D11Device* device, ID3D11DeviceContext* context, Critical& deviceLock); DLLEXPORT virtual ~DX11Shader(); //! Creates a constant buffer that passes constant data to the shader. //! A maximum of 14 buffers can be created. //! zD3d11Device: The device with which the buffer should be created //! \param size The size of the buffer in bytes //! \param index The position of the buffer in the buffer array. An //! existing buffer will be replaced. Buffer 1 cannot be created //! if buffer 0 has not been created yet, etc. DLLEXPORT virtual bool createConstBuffer(int size, int index) override; }; //! Manages a pixel shader class DX11PixelShader : public DX11Shader { private: ID3D11PixelShader* pixelShader; public: //! Constructor DLLEXPORT DX11PixelShader(ID3D11Device* device, ID3D11DeviceContext* context, Critical& deviceLock); //! Destructor DLLEXPORT ~DX11PixelShader(); //! Sets the compiled shader //! zD3d11Device: The device with which the shader should be created //! \param bytes The bytes of the compiled code //! \param length The length of the byte array //! \return true if bytes is valid, false otherwise DLLEXPORT bool setCompiledByteArray( unsigned char* bytes, int length) override; //! After calling this function, this shader is used as a pixel shader //! zD3d11Context: The context object with which the shader should //! be used DLLEXPORT void useShader() override; }; //! Manages a vertex shader class DX11VertexShader : public DX11Shader { private: ID3D11VertexShader* vertexShader; ID3D11InputLayout* inputLayout; unsigned char* shaderByteBuffer; int byteBufferSize; public: //! Constructor DLLEXPORT DX11VertexShader(ID3D11Device* device, ID3D11DeviceContext* context, Critical& deviceLock); //! Destructor DLLEXPORT ~DX11VertexShader(); //! Sets the compiled shader //! zD3d11Device: The device with which the shader should be created //! \param bytes The bytes of the compiled code //! \param length The length of the byte array //! \return true if bytes is valid, false otherwise DLLEXPORT bool setCompiledByteArray( unsigned char* bytes, int length) override; //! Creates an input layout for the shader. //! May only be called after compile. //! zD3d11Device: The device with which the layout should be created //! \param descArray An array with initialization data //! \param anz The number of elements in the array DLLEXPORT bool createInputLayout( D3D11_INPUT_ELEMENT_DESC* descArray, int anz); //! After calling this function, this shader is used as a vertex shader //! zD3d11Context: The context object with which the shader should //! be used DLLEXPORT void useShader() override; }; } // namespace Framework