From ac64f28e2f4e59a6f5295c3142d7397693d37038 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 9 Jan 2020 18:22:18 +0800 Subject: [PATCH] add DataSource of material --- inc/hgl/graph/material/ComboMaterial.h | 13 +++ inc/hgl/graph/material/Component.h | 17 ++++ inc/hgl/graph/material/DataSource.h | 120 +++++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 inc/hgl/graph/material/DataSource.h diff --git a/inc/hgl/graph/material/ComboMaterial.h b/inc/hgl/graph/material/ComboMaterial.h index 1c26ab9f..54676b83 100644 --- a/inc/hgl/graph/material/ComboMaterial.h +++ b/inc/hgl/graph/material/ComboMaterial.h @@ -1,3 +1,16 @@ #ifndef HGL_GRAPH_COMBO_MATERIAL_INCLUDE #define HGL_GRAPH_COMBO_MATERIAL_INCLUDE + +#include + +BEGIN_MATERIAL_NAMESPACE +/** + * 简易组合材质
+ * 提供最简单的材质定义方案 + */ +class ComboMaterial +{ + +};//class ComboMaterial +END_MATERIAL_NAMESPACE #endif//HGL_GRAPH_COMBO_MATERIAL_INCLUDE diff --git a/inc/hgl/graph/material/Component.h b/inc/hgl/graph/material/Component.h index bd0cd714..cbaf279b 100644 --- a/inc/hgl/graph/material/Component.h +++ b/inc/hgl/graph/material/Component.h @@ -70,6 +70,23 @@ BEGIN_MATERIAL_NAMESPACE Uint, };// + enum class DataFormat + { + NONE=0, + + #define MATERIAL_DATA_FORMAT_DEFINE(long_name,short_name,type) long_name =((uint(ComponentDataType)<<4)|1), \ + vec##short_name##1 =((uint(ComponentDataType)<<4)|2), \ + vec##short_name##2 =((uint(ComponentDataType)<<4)|3), \ + vec##short_name##3 =((uint(ComponentDataType)<<4)|4), + + MATERIAL_DATA_FORMAT_DEFINE(boolean,b,Bool ), + MATERIAL_DATA_FORMAT_DEFINE(float, f,Float ), + MATERIAL_DATA_FORMAT_DEFINE(int, i,Int ), + MATERIAL_DATA_FORMAT_DEFINE(uint, u,Uint ), + + #undef MATERIAL_DATA_FORMAT_DEFINE + }; + using ComponentBitsConfig=uint32; constexpr ComponentBitsConfig MCC_PureColor =uint32(ComponentBit::Color); diff --git a/inc/hgl/graph/material/DataSource.h b/inc/hgl/graph/material/DataSource.h new file mode 100644 index 00000000..b3ee8b26 --- /dev/null +++ b/inc/hgl/graph/material/DataSource.h @@ -0,0 +1,120 @@ +#ifndef HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE +#define HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE + +#include +#include + +BEGIN_MATERIAL_NAMESPACE + +/** + * 数据源 + */ +class DataSource +{ + DataFormat format; + +public: + + DataSource() + { + format=DataFormat::NONE; + } + + DataSource(const DataFormat &df) + { + format=df; + } + + virtual ~DataSource()=default; + + virtual bool SetX(UTF8String &,const UTF8String &)const{return false;} + virtual bool SetY(UTF8String &,const UTF8String &)const{return false;} + virtual bool SetZ(UTF8String &,const UTF8String &)const{return false;} + virtual bool SetW(UTF8String &,const UTF8String &)const{return false;} + + virtual bool SetXY(UTF8String &,const UTF8String &)const{return false;} + virtual bool SetYZ(UTF8String &,const UTF8String &)const{return false;} + virtual bool SetZW(UTF8String &,const UTF8String &)const{return false;} + + virtual bool SetXYZ(UTF8String &,const UTF8String &)const{return false;} + virtual bool SetXYZW(UTF8String &,const UTF8String &)const{return false;} + + bool SetR(UTF8String &result,const UTF8String &str)const{return this->SetX(result,str);} + bool SetG(UTF8String &result,const UTF8String &str)const{return this->SetY(result,str);} + bool SetB(UTF8String &result,const UTF8String &str)const{return this->SetZ(result,str);} + bool SetA(UTF8String &result,const UTF8String &str)const{return this->SetW(result,str);} + + bool SetRG(UTF8String &result,const UTF8String &str)const{return this->SetXY(result,str);} + bool SetGB(UTF8String &result,const UTF8String &str)const{return this->SetYZ(result,str);} + bool SetBA(UTF8String &result,const UTF8String &str)const{return this->SetZW(result,str);} + + bool SetRGB(UTF8String &result,const UTF8String &str)const{return this->SetXYZ(result,str);} + bool SetRGBA(UTF8String &result,const UTF8String &str)const{return this->SetXYZW(result,str);} + + virtual bool GetX(UTF8String &)const{return false;} + virtual bool GetY(UTF8String &)const{return false;} + virtual bool GetZ(UTF8String &)const{return false;} + virtual bool GetW(UTF8String &)const{return false;} + + virtual bool GetXY(UTF8String &)const{return false;} + virtual bool GetYZ(UTF8String &)const{return false;} + virtual bool GetZW(UTF8String &)const{return false;} + + virtual bool GetXYZ(UTF8String &)const{return false;} + virtual bool GetXYZW(UTF8String &)const{return false;} + + bool GetR(UTF8String &result)const{return this->GetX(result);} + bool GetG(UTF8String &result)const{return this->GetY(result);} + bool GetB(UTF8String &result)const{return this->GetZ(result);} + bool GetA(UTF8String &result)const{return this->GetW(result);} + + bool GetRG(UTF8String &result)const{return this->GetXY(result);} + bool GetGB(UTF8String &result)const{return this->GetYZ(result);} + bool GetBA(UTF8String &result)const{return this->GetZW(result);} + + bool GetRGB(UTF8String &result)const{return this->GetXYZ(result);} + bool GetRGBA(UTF8String &result)const{return this->GetXYZW(result);} +};//class DataSource + +/** + * 固定值数据源 + */ +class DataSourceConst:public DataSource +{ +};//class DataSourceConst:public DataSource + +/** + * Uniform数据源 + */ +class DataSourceUniform:public DataSource +{ +};//class DataSourceUniform:public DataSource + +/** + * 纹理数据源 + */ +class DataSourceTexture:public DataSource +{ +};//class DataSourceTexture:public DataSource + +class DataSourceTexture1D:public DataSourceTexture +{ +};//class DataSourceTexture1D:public DataSourceTexture + +class DataSourceTexture2D:public DataSourceTexture +{ +};//class DataSourceTexture2D:public DataSourceTexture + +class DataSourceTexture2DArrays:public DataSourceTexture +{ +};//class DataSourceTexture2DArrays:public DataSourceTexture + +class DataSourceTextureCubemap:public DataSourceTexture +{ +};//class DataSourceTextureCubemap:public DataSourceTexture + +class DataSourceTextureCubemapArrays:public DataSourceTexture +{ +};//class DataSourceTextureCubemapArrays:public DataSourceTexture +END_MATERIAL_NAMESPACE +#endif//HGL_GRAPH_MATERIAL_DATA_SOURCE_INCLUDE