修正没有正常RESIZE的问题
This commit is contained in:
parent
ad200efa71
commit
7e3b14ce17
@ -30,12 +30,6 @@ private:
|
|||||||
Window * win =nullptr;
|
Window * win =nullptr;
|
||||||
vulkan::Instance * inst =nullptr;
|
vulkan::Instance * inst =nullptr;
|
||||||
|
|
||||||
void OnResize(int w,int h)
|
|
||||||
{
|
|
||||||
InitCommandBuffer();
|
|
||||||
Resize(w,h);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnKeyDown (KeyboardButton kb){key_status[kb]=true;}
|
void OnKeyDown (KeyboardButton kb){key_status[kb]=true;}
|
||||||
void OnKeyUp (KeyboardButton kb){key_status[kb]=false;}
|
void OnKeyUp (KeyboardButton kb){key_status[kb]=false;}
|
||||||
void OnKeyPress (KeyboardButton kb){KeyPress(kb);}
|
void OnKeyPress (KeyboardButton kb){KeyPress(kb);}
|
||||||
@ -60,7 +54,7 @@ protected:
|
|||||||
|
|
||||||
vulkan::ShaderModuleManage * shader_manage =nullptr;
|
vulkan::ShaderModuleManage * shader_manage =nullptr;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
|
||||||
uint32_t swap_chain_count=0;
|
uint32_t swap_chain_count=0;
|
||||||
|
|
||||||
@ -115,7 +109,6 @@ public:
|
|||||||
if(!device)
|
if(!device)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
sc_render_target=device->GetSwapchainRT();
|
|
||||||
present_complete_semaphore =device->CreateSem();
|
present_complete_semaphore =device->CreateSem();
|
||||||
render_complete_semaphore =device->CreateSem();
|
render_complete_semaphore =device->CreateSem();
|
||||||
|
|
||||||
@ -143,11 +136,19 @@ public:
|
|||||||
virtual void MouseUp(uint){}
|
virtual void MouseUp(uint){}
|
||||||
virtual void MouseMove(){}
|
virtual void MouseMove(){}
|
||||||
virtual void MouseWheel(int,int,uint){}
|
virtual void MouseWheel(int,int,uint){}
|
||||||
|
|
||||||
|
void OnResize(int w,int h)
|
||||||
|
{
|
||||||
|
InitCommandBuffer();
|
||||||
|
Resize(w,h);
|
||||||
|
}
|
||||||
|
|
||||||
void InitCommandBuffer()
|
void InitCommandBuffer()
|
||||||
{
|
{
|
||||||
if(cmd_buf)
|
if(cmd_buf)
|
||||||
SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count);
|
SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count);
|
||||||
|
|
||||||
|
sc_render_target=device->GetSwapchainRT();
|
||||||
|
|
||||||
swap_chain_count=sc_render_target->GetImageCount();
|
swap_chain_count=sc_render_target->GetImageCount();
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,7 @@ bool Device::Resize(const VkExtent2D &extent)
|
|||||||
SAFE_CLEAR(textureSQ);
|
SAFE_CLEAR(textureSQ);
|
||||||
SAFE_CLEAR(texture_cmd_buf);
|
SAFE_CLEAR(texture_cmd_buf);
|
||||||
|
|
||||||
|
attr->Refresh();
|
||||||
swapchain=CreateSwapchain(attr,extent);
|
swapchain=CreateSwapchain(attr,extent);
|
||||||
|
|
||||||
texture_cmd_buf=CreateCommandBuffer(extent,0);
|
texture_cmd_buf=CreateCommandBuffer(extent,0);
|
||||||
|
@ -21,19 +21,12 @@ namespace
|
|||||||
{
|
{
|
||||||
VkExtent2D SwapchainExtentClamp(const VkSurfaceCapabilitiesKHR &surface_caps,const VkExtent2D &acquire_extent)
|
VkExtent2D SwapchainExtentClamp(const VkSurfaceCapabilitiesKHR &surface_caps,const VkExtent2D &acquire_extent)
|
||||||
{
|
{
|
||||||
if(surface_caps.currentExtent.width==UINT32_MAX)
|
VkExtent2D swapchain_extent;
|
||||||
{
|
|
||||||
VkExtent2D swapchain_extent;
|
|
||||||
|
|
||||||
swapchain_extent.width =hgl_clamp(acquire_extent.width, surface_caps.minImageExtent.width, surface_caps.maxImageExtent.width );
|
swapchain_extent.width =hgl_clamp(acquire_extent.width, surface_caps.minImageExtent.width, surface_caps.maxImageExtent.width );
|
||||||
swapchain_extent.height =hgl_clamp(acquire_extent.height, surface_caps.minImageExtent.height, surface_caps.maxImageExtent.height );
|
swapchain_extent.height =hgl_clamp(acquire_extent.height, surface_caps.minImageExtent.height, surface_caps.maxImageExtent.height );
|
||||||
|
|
||||||
return swapchain_extent;
|
return swapchain_extent;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return surface_caps.currentExtent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSwapchainKHR CreateSwapChain(const DeviceAttribute *dev_attr,const VkExtent2D &extent)
|
VkSwapchainKHR CreateSwapChain(const DeviceAttribute *dev_attr,const VkExtent2D &extent)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user