From 07800559cce4308a857a7d8e97bcf76689a67c99 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 25 Jun 2019 23:40:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DGeometryCreater=E7=BC=93?= =?UTF-8?q?=E5=86=B2=E5=8C=BA=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/Vulkan/VulkanAppFramework.h | 2 ++ inc/hgl/graph/InlineGeometry.h | 4 ++-- src/SceneGraph/InlineGeometry.cpp | 18 ++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/Vulkan/VulkanAppFramework.h b/example/Vulkan/VulkanAppFramework.h index 5aacd93b..115531b9 100644 --- a/example/Vulkan/VulkanAppFramework.h +++ b/example/Vulkan/VulkanAppFramework.h @@ -231,6 +231,8 @@ public: { int index=AcquireNextImage(); + if(index<0||index>swap_chain_count)return; + SubmitDraw(index); } diff --git a/inc/hgl/graph/InlineGeometry.h b/inc/hgl/graph/InlineGeometry.h index a258120d..9dd5843a 100644 --- a/inc/hgl/graph/InlineGeometry.h +++ b/inc/hgl/graph/InlineGeometry.h @@ -22,7 +22,7 @@ namespace hgl vulkan::Renderable *CreateRenderableRectangle(SceneDB *db,vulkan::Material *mtl,const RectangleCreateInfo *rci); /** - * 圆角矩形创建信息(扇形) + * 圆角矩形创建信息(扇形/线圈) */ struct RoundRectangleCreateInfo:public RectangleCreateInfo { @@ -43,7 +43,7 @@ namespace hgl };//struct CircleCreateInfo /** - * 创建一个2D圆形(扇形) + * 创建一个2D圆形(扇形/线圈) */ vulkan::Renderable *CreateRenderableCircle(SceneDB *db,vulkan::Material *mtl,const CircleCreateInfo *rci); diff --git a/src/SceneGraph/InlineGeometry.cpp b/src/SceneGraph/InlineGeometry.cpp index 8671800d..d506c434 100644 --- a/src/SceneGraph/InlineGeometry.cpp +++ b/src/SceneGraph/InlineGeometry.cpp @@ -18,7 +18,7 @@ namespace hgl const vulkan::VertexShaderModule *vsm=nullptr; vulkan::Renderable *render_obj=nullptr; - + int vertex_binding =-1; int color_binding =-1; int normal_binding =-1; @@ -74,11 +74,11 @@ namespace hgl void WriteTangent (const float *v){if(tangent )tangent ->BufferData(v);} void WriteTexCoord (const float *v){if(tex_coord )tex_coord ->BufferData(v);} - VERTEX_VB_FORMAT * GetVertex (){return vertex; } - VB4f * GetColor (){return color; } - VB3f * GetNormal (){return normal; } - VB3f * GetTangent (){return tangent; } - VB2f * GetTexCoord (){return tex_coord; } + VERTEX_VB_FORMAT * GetVertex (){if(!vertex)return nullptr;vertex->Begin();return vertex; } + VB4f * GetColor (){if(!color)return nullptr;color->Begin();return color; } + VB3f * GetNormal (){if(!normal)return nullptr;normal->Begin();return normal; } + VB3f * GetTangent (){if(!tangent)return nullptr;tangent->Begin();return tangent; } + VB2f * GetTexCoord (){if(!tex_coord)return nullptr;tex_coord->Begin();return tex_coord; } float *GetVertexPointer (){return vertex ?(float *)vertex ->Begin():nullptr;} float *GetColorPointer (){return color ?(float *)color ->Begin():nullptr;} @@ -231,14 +231,12 @@ namespace hgl { GeometryCreater2D gc(db,mtl); - if(!gc.Init(cci->field_count+2)) + if(!gc.Init(cci->field_count)) return(nullptr); VB2f *vertex=gc.GetVertex(); - vertex->Write(cci->center.x,cci->center.y); - - for(uint i=0;i<=cci->field_count;i++) + for(uint i=0;ifield_count;i++) { float ang=float(i)/float(cci->field_count)*360.0f;