整理VertexArray代码
This commit is contained in:
parent
6394ad8b74
commit
382584a81e
@ -4,7 +4,6 @@
|
||||
#include<hgl/type/List.h>
|
||||
#include<hgl/graph/VertexBuffer.h>
|
||||
#include<hgl/graph/PixelCompoment.h>
|
||||
#include<hgl/math/Math.h>
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
@ -20,9 +19,6 @@ namespace hgl
|
||||
|
||||
ObjectList<VertexBufferBase> vertex_buffer_list; ///<顶点数据缓冲区
|
||||
|
||||
AABB aabb; ///<AABB绑定盒
|
||||
OBB obb; ///<OBB绑定盒
|
||||
|
||||
int vertex_compoment; ///<顶点属性格式
|
||||
PixelCompoment color_compoment; ///<颜色属性格式
|
||||
|
||||
@ -49,65 +45,14 @@ namespace hgl
|
||||
bool ClearVertexAttribBuffer (int index){return vertex_buffer_list.Delete(index);} ///<清除顶点缓冲区数据
|
||||
void ClearVertexAttribBuffers (){vertex_buffer_list.Clear();} ///<清除所有顶点缓冲区数据
|
||||
|
||||
public: //索引缓冲区设置
|
||||
public: //特殊缓冲区独立设置函数
|
||||
|
||||
bool SetElementBuffer(VertexBufferBase *vb)
|
||||
{
|
||||
if(!vb)return(false);
|
||||
element_buffer=vb;
|
||||
return(true);
|
||||
}
|
||||
bool SetElementBuffer (VertexBufferBase *vb); ///<设置索引缓冲区数据
|
||||
bool SetVertexBuffer (VertexBufferBase *vb); ///<设置顶点缓冲区数据
|
||||
bool SetColorBuffer (VertexBufferBase *vb,PixelCompoment cf); ///<设置颜色缓冲区数据
|
||||
|
||||
public: //顶点格式相关
|
||||
|
||||
bool SetVertexBuffer(VertexBufferBase *vb)
|
||||
{
|
||||
if(!vb)return(false);
|
||||
|
||||
vertex_compoment=vb->GetComponent();
|
||||
|
||||
return(AddVertexAttribBuffer(vb)>=0);
|
||||
}
|
||||
|
||||
int GetVertexCompoment()const{return vertex_compoment;} ///<取得顶点数据成分数量
|
||||
|
||||
public: //颜色格式相关
|
||||
|
||||
PixelCompoment GetColorCompoment()const{return color_compoment;} ///<取得顶点颜色格式
|
||||
|
||||
bool SetColor(VertexBufferBase *vb,PixelCompoment cf)
|
||||
{
|
||||
if(!vb)return(false);
|
||||
if(cf<=HGL_PC_NONE||cf>=HGL_PC_END)return(false);
|
||||
|
||||
color_compoment=cf;
|
||||
|
||||
return(AddVertexAttribBuffer(vb)>=0);
|
||||
}
|
||||
|
||||
public: //绑定盒相关
|
||||
|
||||
void SetBoundingBox (const Vector3f &min_v,Vector3f &max_v)
|
||||
{
|
||||
aabb.minPoint=POINT_VEC(min_v);
|
||||
aabb.maxPoint=POINT_VEC(max_v);
|
||||
|
||||
obb.SetFrom(aabb);
|
||||
}
|
||||
|
||||
const AABB & GetAABB ()const{return aabb;} ///<取得AABB绑定盒
|
||||
const OBB & GetOBB ()const{return obb;} ///<取得OBB绑定盒
|
||||
|
||||
const Vector3f GetCenter ()const ///<取得中心点
|
||||
{
|
||||
return POINT_TO_FLOAT3(obb.CenterPoint());
|
||||
}
|
||||
|
||||
void GetBoundingBox (Vector3f &min_v,Vector3f &max_v) ///<取得最小顶点和最大顶点
|
||||
{
|
||||
min_v=POINT_TO_FLOAT3(aabb.minPoint);
|
||||
max_v=POINT_TO_FLOAT3(aabb.maxPoint);
|
||||
}
|
||||
int GetVertexCompoment ()const{return vertex_compoment;} ///<取得顶点数据成分数量
|
||||
PixelCompoment GetColorCompoment ()const{return color_compoment;} ///<取得顶点颜色格式
|
||||
|
||||
public:
|
||||
|
||||
|
@ -3,5 +3,6 @@
|
||||
Shader.cpp
|
||||
VertexArray.cpp
|
||||
VertexBuffer.cpp
|
||||
VertexBufferControlDSA.cpp)
|
||||
VertexBufferControlDSA.cpp
|
||||
VertexBufferControlBind.cpp)
|
||||
|
||||
|
@ -33,6 +33,38 @@ namespace hgl
|
||||
return(index);
|
||||
}
|
||||
|
||||
bool VertexArray::SetElementBuffer(VertexBufferBase *vb)
|
||||
{
|
||||
if(!vb)return(false);
|
||||
element_buffer=vb;
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool VertexArray::SetVertexBuffer(VertexBufferBase *vb)
|
||||
{
|
||||
if(!vb)return(false);
|
||||
|
||||
if(!AddVertexAttribBuffer(vb)<0)
|
||||
return(false);
|
||||
|
||||
vertex_compoment=vb->GetComponent();
|
||||
vertex_buffer=vb;
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool VertexArray::SetColorBuffer(VertexBufferBase *vb,PixelCompoment cf)
|
||||
{
|
||||
if(!vb)return(false);
|
||||
if(cf<=HGL_PC_NONE||cf>=HGL_PC_END)return(false);
|
||||
|
||||
if(AddVertexAttribBuffer(vb)<0)
|
||||
return(false);
|
||||
|
||||
color_compoment=cf;
|
||||
color_buffer=vb;
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得可绘制数据数量
|
||||
* @return 可绘制数量数量
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include"VertexBufferControl.h"
|
||||
#include"VertexBufferControl.h"
|
||||
#include<GLEWCore/glew.h>
|
||||
|
||||
namespace hgl
|
||||
|
Loading…
x
Reference in New Issue
Block a user