diff --git a/example/Vulkan/fourth_triangle.cpp b/example/Vulkan/fourth_triangle.cpp index 794a7aad..c64966a8 100644 --- a/example/Vulkan/fourth_triangle.cpp +++ b/example/Vulkan/fourth_triangle.cpp @@ -40,8 +40,8 @@ private: SceneNode render_root; RenderList * render_list =nullptr; - MaterialInstance * material_instance[6]={nullptr,nullptr,nullptr,nullptr,nullptr,nullptr}; - Renderable * render_obj[6] ={nullptr,nullptr,nullptr,nullptr,nullptr,nullptr}; + MaterialInstance * material_instance[6]{}; + Renderable * render_obj[6] {}; Pipeline * pipeline =nullptr; diff --git a/example/Vulkan/third_triangle.cpp b/example/Vulkan/third_triangle.cpp index a1ac45c7..0ac27494 100644 --- a/example/Vulkan/third_triangle.cpp +++ b/example/Vulkan/third_triangle.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -23,10 +24,10 @@ constexpr float position_data[VERTEX_COUNT*2]= 0.1, 0.9 }; -constexpr float color_data[VERTEX_COUNT][4]= -{ {1,0,0,1}, - {0,1,0,1}, - {0,0,1,1} +constexpr uint8 color_data[VERTEX_COUNT][4]= +{ {255,0,0,255}, + {0,255,0,255}, + {0,0,255,255} }; class TestApp:public VulkanApplicationFramework @@ -53,15 +54,19 @@ private: AutoDelete mci=mtl::CreateVertexColor2D(&cfg); - material_instance=db->CreateMaterialInstance(mci); + VILConfig vil_config; + + vil_config.Add(VAN::Color,VF_V4UN8); + + material_instance=db->CreateMaterialInstance(mci,&vil_config); } if(!material_instance) return(false); - + // pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d")); pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target - + return pipeline; } @@ -69,8 +74,8 @@ private: { RenderablePrimitiveCreater rpc(db,VERTEX_COUNT); - if(!rpc.SetVBO(VAN::Position, VF_V2F, position_data))return(false); - if(!rpc.SetVBO(VAN::Color, VF_V4F, color_data ))return(false); + if(!rpc.SetVBO(VAN::Position, VF_V2F, position_data))return(false); + if(!rpc.SetVBO(VAN::Color, VF_V4UN8, color_data ))return(false); render_obj=rpc.Create(material_instance,pipeline); diff --git a/inc/hgl/graph/mtl/2d/Material2DCreateConfig.h b/inc/hgl/graph/mtl/2d/Material2DCreateConfig.h index 5d8c7aaa..c6d017a6 100644 --- a/inc/hgl/graph/mtl/2d/Material2DCreateConfig.h +++ b/inc/hgl/graph/mtl/2d/Material2DCreateConfig.h @@ -11,8 +11,6 @@ struct Material2DCreateConfig:public MaterialCreateConfig bool local_to_world; ///<包含LocalToWorld矩阵 - bool use_8bit_color; ///<使用rgba8格式颜色(默认使用rgba32f) - public: Material2DCreateConfig(const GPUDeviceAttribute *da,const AnsiString &name):MaterialCreateConfig(da,name)