改进CameraAppFramework中对相机矩阵数据的管理,使之可以绑定到多个材质。
因此修正Geometry3D接收输入无效的问题
This commit is contained in:
parent
4cf5b0dce3
commit
7828468547
@ -10,8 +10,8 @@
|
|||||||
using namespace hgl;
|
using namespace hgl;
|
||||||
using namespace hgl::graph;
|
using namespace hgl::graph;
|
||||||
|
|
||||||
constexpr uint32_t SCREEN_WIDTH=128;
|
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||||
constexpr uint32_t SCREEN_HEIGHT=128;
|
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||||
|
|
||||||
class TestApp:public CameraAppFramework
|
class TestApp:public CameraAppFramework
|
||||||
{
|
{
|
||||||
@ -52,7 +52,7 @@ private:
|
|||||||
|
|
||||||
bool InitUBO(MDP *mdp)
|
bool InitUBO(MDP *mdp)
|
||||||
{
|
{
|
||||||
if(!InitCameraUBO(mdp->material_instance,"world"))
|
if(!mdp->material_instance->BindUBO("world",GetCameraMatrixBuffer()))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
mdp->material_instance->Update();
|
mdp->material_instance->Update();
|
||||||
@ -150,12 +150,12 @@ public:
|
|||||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMDP(&m3d,PRIM_LINES,OS_TEXT("res/shader/PositionColor3D.vert.spv"),
|
if(!InitMDP(&m3d,PRIM_LINES,OS_TEXT("res/shader/PositionColor3D.vert"),
|
||||||
OS_TEXT("res/shader/VertexColor.frag.spv")))
|
OS_TEXT("res/shader/VertexColor.frag")))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMDP(&m2d,PRIM_TRIANGLE_FAN, OS_TEXT("res/shader/OnlyPosition.vert.spv"),
|
if(!InitMDP(&m2d,PRIM_TRIANGLE_FAN, OS_TEXT("res/shader/OnlyPosition.vert"),
|
||||||
OS_TEXT("res/shader/FlatColor.frag.spv")))
|
OS_TEXT("res/shader/FlatColor.frag")))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -112,7 +112,7 @@ public:
|
|||||||
cili.khronos.validation = true;
|
cili.khronos.validation = true;
|
||||||
cili.RenderDoc.Capture = true;
|
cili.RenderDoc.Capture = true;
|
||||||
|
|
||||||
inst=vulkan::CreateInstance(U8_TEXT("VulkanTest"));
|
inst=vulkan::CreateInstance(U8_TEXT("VulkanTest"),nullptr,&cili);
|
||||||
|
|
||||||
if(!inst)
|
if(!inst)
|
||||||
return(false);
|
return(false);
|
||||||
@ -304,12 +304,16 @@ public:
|
|||||||
camera.type=CameraType::Perspective;
|
camera.type=CameraType::Perspective;
|
||||||
camera.width=w;
|
camera.width=w;
|
||||||
camera.height=h;
|
camera.height=h;
|
||||||
|
camera.vp_width=w;
|
||||||
|
camera.vp_height=h;
|
||||||
camera.center.Set(0,0,0,1);
|
camera.center.Set(0,0,0,1);
|
||||||
camera.eye.Set(100,100,100,1); //xyz三个值不要一样,以方便调试
|
camera.eye.Set(100,100,100,1); //xyz三个值不要一样,以方便调试
|
||||||
camera.znear=16;
|
camera.znear=16;
|
||||||
camera.zfar=256;
|
camera.zfar=256;
|
||||||
|
|
||||||
camera.Refresh(); //更新矩阵计算
|
camera.Refresh(); //更新矩阵计算
|
||||||
|
|
||||||
|
ubo_world_matrix=db->CreateUBO(sizeof(WorldMatrix),&camera.matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Resize(int w,int h)override
|
void Resize(int w,int h)override
|
||||||
@ -318,14 +322,9 @@ public:
|
|||||||
camera.height=h;
|
camera.height=h;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitCameraUBO(vulkan::MaterialInstance *mi,const UTF8String &node_name)
|
vulkan::Buffer *GetCameraMatrixBuffer()
|
||||||
{
|
{
|
||||||
ubo_world_matrix=db->CreateUBO(sizeof(WorldMatrix),&camera.matrix);
|
return ubo_world_matrix;
|
||||||
|
|
||||||
if(!ubo_world_matrix)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return mi->BindUBO(node_name,ubo_world_matrix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void BuildCommandBuffer(uint32_t index)=0;
|
virtual void BuildCommandBuffer(uint32_t index)=0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user