#pragma once #include "Array.h" #include "Critical.h" namespace Framework { class DXBuffer; enum ShaderType { UNBEKANNT, VERTEX, PIXEL }; //! A Shader class that manages all constant buffers of a shader class Shader : public virtual ReferenceCounter { protected: ShaderType type; RCArray* constBuffers; public: //! Constructor DLLEXPORT Shader(); //! Destructor DLLEXPORT virtual ~Shader(); //! 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 virtual bool setCompiledByteArray(unsigned char* bytes, int length) = 0; //! After calling this function, this shader is used as a pixel shader //! zD3d11Context: The context object with which the shader should //! be used virtual void useShader() = 0; //! 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. virtual bool createConstBuffer(int size, int index) = 0; //! Deletes a constant buffer //! \param index The index of the buffer to delete. Buffer 0 cannot //! be deleted while buffer 1 still exists, etc. DLLEXPORT bool removeConstBuffer(int index); //! Copies data into a constant buffer //! zD3d11Context: The context object to use for copying //! \param data A pointer to a byte array of the buffer's size //! \param index The index of the buffer //! \param len The length of the data in bytes (-1 for the maximum //! buffer size) DLLEXPORT bool fillConstBuffer(char* data, int index, int len = -1); //! Returns the length of a constant buffer //! \param index The index of the buffer DLLEXPORT int getConstBufferLaenge(int index) const; //! Returns the shader type DLLEXPORT ShaderType getType() const; //! Returns the index of the first uninitialized buffer DLLEXPORT int getFirstUninitializedBufferIndex() const; }; } // namespace Framework