VBO,VAO等全部将本体和数据生成器分离,建立起独立的Maker类。 以方便数据对象可以有不同的操作类,或是有不同的操作模式

This commit is contained in:
hyzboy 2019-03-16 15:08:03 +08:00
parent b65d4d86d2
commit 4e167b5353
3 changed files with 46 additions and 20 deletions

View File

@ -21,11 +21,13 @@ namespace hgl
ObjectList<VertexBufferBase> vertex_buffer_list; ///<顶点数据缓冲区
int vertex_compoment; ///<顶点属性格式
PixelCompoment color_compoment; ///<颜色属性格式
VertexBufferBase *element_buffer;
VertexBufferBase *vertex_buffer;
VertexBufferBase *position_buffer;
int position_compoment; ///<位置属性格式
List<Pair<VertexBufferBase *,PixelCompoment>> color_buffer;
PixelCompoment color_compoment; ///<颜色属性格式
VertexBufferBase *color_buffer;
public:
@ -48,11 +50,12 @@ namespace hgl
public: //特殊缓冲区独立设置函数
bool SetElementBuffer (VertexBufferBase *eb); ///<设置索引缓冲区数据
bool SetVertexBuffer (int shader_location,VertexBufferBase *vb); ///<设置顶点缓冲区数据
bool SetColorBuffer (int shader_location,VertexBufferBase *vb,PixelCompoment cf); ///<设置颜色缓冲区数据
bool SetPositionBuffer (int shader_location,VertexBufferBase *vb); ///<设置位置缓冲区数据
int GetVertexCompoment ()const{return vertex_compoment;} ///<取得顶点数据成分数量
PixelCompoment GetColorCompoment ()const{return color_compoment;} ///<取得顶点颜色格式
bool AddColorBuffer (int shader_location,VertexBufferBase *vb,PixelCompoment cf); ///<设置颜色缓冲区数据
int GetPositionCompoment()const{return position_compoment;} ///<取得位置数据成分数量
PixelCompoment GetColorCompoment ()const{return color_compoment;} ///<取得颜色数据成份格式
public:
@ -60,9 +63,9 @@ namespace hgl
bool Draw(); ///<绘制
};//class VertexArray
GIT上退回到上一版本
1.ColorBuffer可能存在多个SetColorBuffer可能要考虑多个的情况
2.VertexArray类拆分成独立的VAO类和VAOCreater类VAO相关的全部放到VAOCreater类中VAO对象
//新设计内容如碰到此处编译失败请在GIT上退回到上一版本
//1.ColorBuffer可能存在多个所以上面的SetColorBuffer可能要考虑多个的情况
//2.将VertexArray类拆分成独立的VAO类和VAOCreater类所有创建VAO相关的全部放到VAOCreater类中创建完删除自身并返回VAO对象
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_VERTEX_ARRAY_INCLUDE

View File

@ -886,7 +886,23 @@ namespace hgl
using EB16=ElementBuffer<uint16,GL_UNSIGNED_SHORT >;
using EB32=ElementBuffer<uint32,GL_UNSIGNED_INT >;
#define USING_VB1234(type,gl_type,short_name) using VB1##short_name=VertexBuffer1<type,gl_type>; \
template<typename BASE>
class ColorBufferBase:public BASE
{
protected:
PixelCompoment color_compoment;
public:
const PixelCompoment GetColorCompoment()const{return color_compoment;}
public:
ColorBuferBase(const PixelCompoment &pc):color_compoment(pc){}
};//
#define USING_VB1234(type,gl_type,short_name) using VB1##short_name=VertexBuffer1<type,gl_type>;using CB1##short_name=ColorBufferBase<VB1##short_name>; \
using VB2##short_name=VertexBuffer2<type,gl_type>; \
using VB3##short_name=VertexBuffer3<type,gl_type>; \
using VB4##short_name=VertexBuffer4<type,gl_type>;
@ -898,15 +914,19 @@ namespace hgl
USING_VB1234(int32, GL_INT, i32)
USING_VB1234(int32, GL_INT, i)
USING_VB1234(int8, GL_UNSIGNED_BYTE, u8)
USING_VB1234(int8, GL_UNSIGNED_BYTE, ub)
USING_VB1234(int16, GL_UNSIGNED_SHORT, u16)
USING_VB1234(int16, GL_UNSIGNED_SHORT, us)
USING_VB1234(int32, GL_UNSIGNED_INT, u32)
USING_VB1234(int32, GL_UNSIGNED_INT, ui)
USING_VB1234(uint8, GL_UNSIGNED_BYTE, u8)
USING_VB1234(uint8, GL_UNSIGNED_BYTE, ub)
USING_VB1234(uint16,GL_UNSIGNED_SHORT, u16)
USING_VB1234(uint16,GL_UNSIGNED_SHORT, us)
USING_VB1234(uint32,GL_UNSIGNED_INT, u32)
USING_VB1234(uint32,GL_UNSIGNED_INT, ui)
USING_VB1234(uint16,GL_HALF_FLOAT, hf)
USING_VB1234(uint16,GL_HALF_FLOAT, f16)
USING_VB1234(float, GL_FLOAT, f)
USING_VB1234(float, GL_FLOAT, f32)
USING_VB1234(double,GL_DOUBLE, d)
USING_VB1234(double,GL_DOUBLE, f64)
#undef USING_VB1234

View File

@ -66,6 +66,9 @@ namespace hgl
//void BindVertexBuffer();
int GetBufferIndex()const; ///<取得缓冲区索引
};//class VertexBufferBase
using VBB=VertexBufferBase;
using VBBPointer=VBB *;
}//namespace graph
}//namespace hgl
#endif//HGL_VERTEX_BUFFER_BASE_INCLUDE