refresh 2dVector/line example.

This commit is contained in:
hyzboy 2021-12-01 15:17:30 +08:00
parent 0852b379a2
commit 926802619f
4 changed files with 31 additions and 18 deletions

@ -1 +1 @@
Subproject commit 3031a9e4e4881060352475686cb6b9b6b84e9b24 Subproject commit c22c92c64779b91745103c1f552d78e8c9784a85

View File

@ -35,9 +35,9 @@ private:
Camera cam; Camera cam;
MaterialParameters * material_instance =nullptr; MaterialInstance * material_instance =nullptr;
RenderableInstance *render_instance =nullptr; RenderableInstance *render_instance =nullptr;
GPUBuffer * ubo_camera_info =nullptr; GPUBuffer * ubo_camera_info =nullptr;
GPUBuffer * ubo_color_material =nullptr; GPUBuffer * ubo_color_material =nullptr;
GPUBuffer * ubo_line_config =nullptr; GPUBuffer * ubo_line_config =nullptr;
@ -69,13 +69,6 @@ private:
if(!ubo) if(!ubo)
return(nullptr); return(nullptr);
if(!material_instance->BindUBO(name,ubo))
{
std::cerr<<"Bind UBO<"<<name.c_str()<<"> to material failed!"<<std::endl;
SAFE_CLEAR(ubo);
return(nullptr);
}
return ubo; return ubo;
} }
@ -87,12 +80,34 @@ private:
cam.height=extent.height; cam.height=extent.height;
cam.Refresh(); cam.Refresh();
ubo_camera_info =CreateUBO("camera", sizeof(CameraInfo), &cam.info);
ubo_color_material =CreateUBO("color_material",sizeof(Vector4f), &color);
ubo_line_config =CreateUBO("line2d_config", sizeof(Line2DConfig), &line_2d_config);
material_instance->Update(); {
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global)
return(false);
ubo_camera_info =db->CreateUBO(sizeof(CameraInfo), &cam.info);
mp_global->BindUBO("g_camera",ubo_camera_info);
mp_global->Update();
}
{
MaterialParameters *mp_value=material_instance->GetMP(DescriptorSetsType::Value);
if(!mp_value)
return(false);
ubo_color_material =db->CreateUBO(sizeof(Vector4f), &color);
ubo_line_config =db->CreateUBO(sizeof(Line2DConfig), &line_2d_config);
mp_value->BindUBO("color_material",ubo_color_material);
mp_value->BindUBO("line2d_config",ubo_line_config);
mp_value->Update();
}
return(true); return(true);
} }

View File

@ -56,8 +56,6 @@ private:
bool InitUBO() bool InitUBO()
{ {
MVPMatrix *mvp=new MVPMatrix;
const VkExtent2D extent=sc_render_target->GetExtent(); const VkExtent2D extent=sc_render_target->GetExtent();
cam.width=extent.width; cam.width=extent.width;

2
res

@ -1 +1 @@
Subproject commit cff431d24a2e511112e26b6d75b74286cf697dfd Subproject commit bb3e05f43bcbc2e2cafa1e1e639a8d626e0af738