#ifndef XNA_GRAPHICS_EFFECT_HPP #define XNA_GRAPHICS_EFFECT_HPP #include "../common/numerics.hpp" #include "../default.hpp" #include "gresource.hpp" namespace xna { //Represents an annotation to an EffectParameter. class EffectAnnotation { public: Int ColumCount() const; String Name() const; EffectParameterClass ParameterClass() const; Int RowCount() const; String Semantic() const; bool GetValueBoolean() const; Int GetValueInt32() const; Matrix GetValueMatrix() const; float GetValueSingle() const; String GetValueString() const; Vector2 GetValueVector2() const; Vector3 GetValueVector3() const; Vector4 GetValueVector4() const; public: struct PlatformImplementation; uptr impl; public: EffectAnnotation(); }; using PEffectAnnotation = sptr; class EffectAnnotationCollection { public: EffectAnnotationCollection() {} EffectAnnotationCollection(std::vector const& data) : data(data) { } constexpr size_t Count() const { return data.size(); } PEffectAnnotation operator[](size_t index) { if (index >= data.size()) return nullptr; return data[index]; } PEffectAnnotation operator[](String const& name) { for (size_t i = 0; i < data.size(); ++i) { const auto& p = data[i]; if (p->Name() == name) return p; } return nullptr; } public: std::vector data; }; using PEffectAnnotationCollection = sptr; class EffectPass { public: //Gets the name of this pass. String Name() const; //The EffectAnnotationCollection containing EffectAnnotation objects for this EffectPass. PEffectAnnotationCollection Annotations() const; //Begins this pass. void Apply(); public: struct PlatformImplementation; uptr impl; public: EffectPass(); }; using PEffectPass = sptr; class EffectPassCollection { public: EffectPassCollection() {} EffectPassCollection(std::vector const& data) : data(data) { } constexpr size_t Count() const { return data.size(); } PEffectPass operator[](size_t index) { if (index >= data.size()) return nullptr; return data[index]; } PEffectPass operator[](String const& name) { for (size_t i = 0; i < data.size(); ++i) { const auto& p = data[i]; if (p->Name() == name) return p; } return nullptr; } public: std::vector data; }; using PEffectPassCollection = sptr; class EffectTechnique { public: PEffectAnnotationCollection Annotations() const; String Name() const; PEffectPassCollection Passes() const; public: struct PlatformImplementation; uptr impl; public: EffectTechnique(); }; using PEffectTechnique = sptr; class EffectParameterCollection; class EffectParameter { public: //Gets the collection of EffectAnnotation objects for this parameter. PEffectAnnotationCollection Annotations() const; //Gets the number of columns in the parameter description. Int ColumnCount() const; //Gets the number of rows in the parameter description. Int RowCount() const; //Gets the semantic meaning, or usage, of the parameter. String Semantic() const; //Gets the type of the parameter. EffectParameterType ParameterType() const; //Gets the class of the parameter. EffectParameterClass ParameterClass() const; //Gets the name of the parameter. String Name() const; //Gets the collection of effect parameters. sptr Elements() const; //Gets the collection of structure members. sptr StructureMembers() const; bool GetValueBoolean() const; std::vector GetValueBooleanArray(size_t count) const; Int GetValueInt32() const; std::vector GetValueInt32Array(size_t count) const; Matrix GetValueMatrix() const; std::vector GetValueMatrixArray(size_t count) const; Matrix GetValueMatrixTranspose() const; std::vector GetValueMatrixTransposeArray(size_t count) const; Quaternion GetValueQuaternion() const; std::vector GetValueQuaternionArray() const; float GetValueSingle() const; std::vector GetValueSingleArray() const; String GetValueString() const; sptr GetValueTexture2D() const; sptr GetValueTexture3D() const; sptr GetValueTextureCube() const; Vector2 GetValueVector2() const; std::vector GetValueVector2Array() const; Vector3 GetValueVector3() const; std::vector GetValueVector3Array() const; Vector4 GetValueVector4() const; std::vector GetValueVector4Array() const; void SetValue(bool value); void SetValue(std::vector const& value); void SetValue(Int value); void SetValue(std::vector const& value); void SetValue(float value); void SetValue(std::vector const& value); void SetValue(Matrix const& value); void SetValue(std::vector const& value); void SetValue(Quaternion const& value); void SetValue(std::vector const& value); void SetValue(Vector2 const& value); void SetValue(std::vector const& value); void SetValue(Vector3 const& value); void SetValue(std::vector const& value); void SetValue(Vector4 const& value); void SetValue(std::vector const& value); void SetValue(String const& value); void SetValue(sptr const& value); void SetValueTranspose(Matrix const& value); void SetValueTranspose(std::vector const& value); public: struct PlatformImplementation; uptr impl; public: EffectParameter(); }; using PEffectParameter = sptr; class EffectParameterCollection { public: EffectParameterCollection() {} EffectParameterCollection(std::vector const& data) : data(data) { } constexpr size_t Count() const { return data.size(); } PEffectParameter operator[](size_t index) { if (index >= data.size()) return nullptr; return data[index]; } PEffectParameter operator[](String const& name) { for (size_t i = 0; i < data.size(); ++i) { const auto& p = data[i]; if (p->Name() == name) return p; } return nullptr; } public: std::vector data; }; using PEffectPassCollection = sptr; class Effect : public GraphicsResource { Effect(sptr const& device, std::vector const& effectCode); PEffectTechnique CurrentTechnique() const; public: struct PlatformImplementation; uptr impl; }; class IEffectMatrices { virtual Matrix World() const = 0; virtual Matrix View() const = 0; virtual Matrix Projection() const = 0; virtual void World(Matrix const& value) = 0; virtual void View(Matrix const& value) = 0; virtual void Projection(Matrix const& value) = 0; }; class DirectionalLight; class IEffectLights { virtual DirectionalLight DirectionalLight0() const = 0; virtual DirectionalLight DirectionalLight1() const = 0; virtual DirectionalLight DirectionalLight2() const = 0; virtual Vector3 AmbientLightColor() const = 0; virtual void AmbientLightColor(Vector3 const& value) = 0; virtual bool LightingEnabled() const = 0; virtual void LightingEnabled(bool value) = 0; virtual void EnableDefaultLighting() = 0; }; class IEffectFog { virtual bool FogEnabled() const = 0; virtual float FogStart() const = 0; virtual float FogEnd() const = 0; virtual Vector3 FogColor() const = 0; virtual void FogEnabled(bool value) const = 0; virtual void FogStart(float value) const = 0; virtual void FogEnd(float value) const = 0; virtual void FogColor(Vector3 const& value) const = 0; }; } #endif