From 382584a81e0e19dbfd829b652e633f30939988fc Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 30 Nov 2018 19:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86VertexArray=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/hgl/graph/VertexArray.h | 67 ++------------------ src/RenderDriver/CMakeLists.txt | 3 +- src/RenderDriver/VertexArray.cpp | 32 ++++++++++ src/RenderDriver/VertexBufferControlBind.cpp | 2 +- 4 files changed, 41 insertions(+), 63 deletions(-) diff --git a/inc/hgl/graph/VertexArray.h b/inc/hgl/graph/VertexArray.h index f2fd8dcd..cf51a953 100644 --- a/inc/hgl/graph/VertexArray.h +++ b/inc/hgl/graph/VertexArray.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace hgl { namespace graph @@ -20,9 +19,6 @@ namespace hgl ObjectList vertex_buffer_list; ///<顶点数据缓冲区 - AABB aabb; ///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: diff --git a/src/RenderDriver/CMakeLists.txt b/src/RenderDriver/CMakeLists.txt index 8f6bd35a..67a6cc4a 100644 --- a/src/RenderDriver/CMakeLists.txt +++ b/src/RenderDriver/CMakeLists.txt @@ -3,5 +3,6 @@ Shader.cpp VertexArray.cpp VertexBuffer.cpp - VertexBufferControlDSA.cpp) + VertexBufferControlDSA.cpp + VertexBufferControlBind.cpp) diff --git a/src/RenderDriver/VertexArray.cpp b/src/RenderDriver/VertexArray.cpp index a53b66d6..c42367df 100644 --- a/src/RenderDriver/VertexArray.cpp +++ b/src/RenderDriver/VertexArray.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 可绘制数量数量 diff --git a/src/RenderDriver/VertexBufferControlBind.cpp b/src/RenderDriver/VertexBufferControlBind.cpp index 1bddf3a5..f3b94ce6 100644 --- a/src/RenderDriver/VertexBufferControlBind.cpp +++ b/src/RenderDriver/VertexBufferControlBind.cpp @@ -1,4 +1,4 @@ -#include"VertexBufferControl.h" +#include"VertexBufferControl.h" #include namespace hgl