完成窗口事件回调机制,并实现窗口缩放后VULKAN各种属性重建
This commit is contained in:
parent
1f389efda1
commit
aa43932fc7
@ -166,6 +166,11 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(&render_list);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
|
@ -168,6 +168,11 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(&render_list);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
|
@ -267,6 +267,11 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(&render_list);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -187,6 +187,11 @@ public:
|
||||
|
||||
BuildCommandBuffer(&render_list);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(&render_list);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
|
@ -86,9 +86,19 @@ public:
|
||||
|
||||
InitCommandBuffer();
|
||||
|
||||
SetEventCall(win->OnResize,this,VulkanApplicationFramework,OnResize);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
virtual void Resize(int,int)=0;
|
||||
|
||||
void OnResize(int w,int h)
|
||||
{
|
||||
InitCommandBuffer();
|
||||
Resize(w,h);
|
||||
}
|
||||
|
||||
void InitCommandBuffer()
|
||||
{
|
||||
if(cmd_buf)
|
||||
|
@ -140,6 +140,11 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(pipeline,descriptor_sets,render_obj);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
|
@ -154,6 +154,11 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(pipeline,descriptor_sets,render_obj);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
|
@ -177,6 +177,11 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int,int)override
|
||||
{
|
||||
BuildCommandBuffer(pipeline,descriptor_sets,render_obj);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
|
@ -30,6 +30,29 @@ namespace hgl
|
||||
virtual bool MessageProc()=0;
|
||||
virtual bool WaitMessage()=0;
|
||||
|
||||
public:
|
||||
|
||||
virtual void ProcMouseMove (int x,int y) {SafeCallEvent(OnMouseMove, (x,y));}
|
||||
virtual void ProcMouseWheel (int x,int y, int v,int h) {SafeCallEvent(OnMouseWheel, (x,y,v,h));}
|
||||
virtual void ProcMouseDown (int x,int y,uint mb) {SafeCallEvent(OnMouseDown, (x,y,mb));}
|
||||
virtual void ProcMouseUp (int x,int y,uint mb) {SafeCallEvent(OnMouseUp, (x,y,mb));}
|
||||
virtual void ProcMouseDblClick (int x,int y,uint mb) {SafeCallEvent(OnMouseDblClick, (x,y,mb));}
|
||||
|
||||
//virtual void ProcJoystickDown (uint);
|
||||
//virtual void ProcJoystickPress (uint);
|
||||
//virtual void ProcJoystickUp (uint);
|
||||
|
||||
virtual void ProcKeyDown (KeyboardButton);
|
||||
virtual void ProcKeyPress (KeyboardButton kb){SafeCallEvent(OnKeyPress,(kb));}
|
||||
virtual void ProcKeyUp (KeyboardButton);
|
||||
|
||||
virtual void ProcChar (os_char ch){SafeCallEvent(OnChar,(ch));}
|
||||
|
||||
virtual void ProcResize (uint,uint);
|
||||
|
||||
virtual void ProcActive (bool);
|
||||
virtual void ProcClose ();
|
||||
|
||||
public:
|
||||
|
||||
uint GetWidth()const{return width;}
|
||||
@ -37,26 +60,26 @@ namespace hgl
|
||||
|
||||
public:
|
||||
|
||||
virtual void OnMouseMove (int,int){}
|
||||
virtual void OnMouseWheel (int,int, int){}
|
||||
virtual void OnMouseDown (int,int,uint){}
|
||||
virtual void OnMouseUp (int,int,uint){}
|
||||
virtual void OnMouseDoubleClick (int,int,uint){}
|
||||
DefEvent(void,OnMouseMove ,(int,int));
|
||||
DefEvent(void,OnMouseWheel ,(int,int, int,int));
|
||||
DefEvent(void,OnMouseDown ,(int,int,uint));
|
||||
DefEvent(void,OnMouseUp ,(int,int,uint));
|
||||
DefEvent(void,OnMouseDblClick ,(int,int,uint));
|
||||
|
||||
//virtual void OnJoystickDown (uint){}
|
||||
//virtual void OnJoystickPress (uint){}
|
||||
//virtual void OnJoystickUp (uint){}
|
||||
//DefEvent(void,OnJoystickDown ,(uint));
|
||||
//DefEvent(void,OnJoystickPress ,(uint));
|
||||
//DefEvent(void,OnJoystickUp ,(uint));
|
||||
|
||||
virtual void OnKeyDown (KeyboardButton);
|
||||
virtual void OnKeyPress (KeyboardButton){}
|
||||
virtual void OnKeyUp (KeyboardButton);
|
||||
DefEvent(void,OnKeyDown ,(KeyboardButton));
|
||||
DefEvent(void,OnKeyPress,(KeyboardButton));
|
||||
DefEvent(void,OnKeyUp ,(KeyboardButton));
|
||||
|
||||
virtual void OnChar (os_char){}
|
||||
DefEvent(void,OnChar ,(os_char));
|
||||
|
||||
virtual void OnResize (uint,uint);
|
||||
DefEvent(void,OnResize ,(uint,uint));
|
||||
|
||||
virtual void OnActive (bool a){active=a;}
|
||||
virtual void OnClose (){is_close=true;}
|
||||
DefEvent(void,OnActive ,(bool));
|
||||
DefEvent(void,OnClose ,());
|
||||
|
||||
public:
|
||||
|
||||
|
@ -191,7 +191,7 @@ namespace hgl
|
||||
|
||||
void WMProcDestroy(WinWindow *win,uint32,uint32)
|
||||
{
|
||||
win->OnClose();
|
||||
win->ProcClose();
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
@ -200,25 +200,25 @@ namespace hgl
|
||||
const int x=LOWORD(lParam); \
|
||||
const int y=HIWORD(lParam); \
|
||||
\
|
||||
win->OnMouseMove(x,y); \
|
||||
win->OnMouse##action(x,y,mb##button|GetMouseKeyFlags(wParam)); \
|
||||
win->ProcMouseMove(x,y); \
|
||||
win->ProcMouse##action(x,y,mb##button|GetMouseKeyFlags(wParam)); \
|
||||
}
|
||||
|
||||
WMEF_MOUSE(Left,Down);
|
||||
WMEF_MOUSE(Left,Up);
|
||||
WMEF_MOUSE(Left,DoubleClick);
|
||||
WMEF_MOUSE(Left,DblClick);
|
||||
|
||||
WMEF_MOUSE(Mid,Down);
|
||||
WMEF_MOUSE(Mid,Up);
|
||||
WMEF_MOUSE(Mid,DoubleClick);
|
||||
WMEF_MOUSE(Mid,DblClick);
|
||||
|
||||
WMEF_MOUSE(Right,Down);
|
||||
WMEF_MOUSE(Right,Up);
|
||||
WMEF_MOUSE(Right,DoubleClick);
|
||||
WMEF_MOUSE(Right,DblClick);
|
||||
|
||||
void WMProcMouseMove(WinWindow *win,uint32 wParam,uint32 lParam)
|
||||
{
|
||||
win->OnMouseMove(LOWORD(lParam),HIWORD(lParam));
|
||||
win->ProcMouseMove(LOWORD(lParam),HIWORD(lParam));
|
||||
}
|
||||
#undef WMEF_MOUSE
|
||||
|
||||
@ -228,30 +228,39 @@ namespace hgl
|
||||
const int x=LOWORD(lParam);
|
||||
const int y=HIWORD(lParam);
|
||||
|
||||
win->OnMouseMove(x,y);
|
||||
win->OnMouseWheel(x,y,(short)HIWORD(wParam));
|
||||
win->ProcMouseMove(x,y);
|
||||
win->ProcMouseWheel(x,y,HIWORD(wParam),0);
|
||||
}
|
||||
|
||||
WMEF2(WMProcMouseHWheel)
|
||||
{
|
||||
const int x=LOWORD(lParam);
|
||||
const int y=HIWORD(lParam);
|
||||
|
||||
win->ProcMouseMove(x,y);
|
||||
win->ProcMouseWheel(x,y,0,HIWORD(wParam));
|
||||
}
|
||||
|
||||
WMEF2(WMProcSize)
|
||||
{
|
||||
win->OnResize(LOWORD(lParam),HIWORD(lParam));
|
||||
win->ProcResize(LOWORD(lParam),HIWORD(lParam));
|
||||
}
|
||||
#undef WMEF2
|
||||
|
||||
#define WMEF1(name) void name(WinWindow *win,uint32 wParam,uint32)
|
||||
WMEF1(WMProcKeyDown)
|
||||
{
|
||||
win->OnKeyDown(ConvertOSKey(wParam));
|
||||
win->ProcKeyDown(ConvertOSKey(wParam));
|
||||
}
|
||||
|
||||
WMEF1(WMProcKeyUp)
|
||||
{
|
||||
win->OnKeyUp(ConvertOSKey(wParam));
|
||||
win->ProcKeyUp(ConvertOSKey(wParam));
|
||||
}
|
||||
|
||||
WMEF1(WMProcChar)
|
||||
{
|
||||
win->OnChar((wchar_t)wParam);
|
||||
win->ProcChar((wchar_t)wParam);
|
||||
}
|
||||
|
||||
WMEF1(WMProcActive)
|
||||
@ -259,7 +268,7 @@ namespace hgl
|
||||
//if(JoyPlugIn)
|
||||
// JoyInterface.SetInputActive(wParam);
|
||||
|
||||
win->OnActive(wParam);
|
||||
win->ProcActive(wParam);
|
||||
}
|
||||
#undef WMEF1
|
||||
}//namespace
|
||||
@ -277,14 +286,15 @@ namespace hgl
|
||||
WM_MAP(WM_CLOSE ,WMProcDestroy);
|
||||
WM_MAP(WM_LBUTTONDOWN ,WMProcMouseLeftDown);
|
||||
WM_MAP(WM_LBUTTONUP ,WMProcMouseLeftUp);
|
||||
WM_MAP(WM_LBUTTONDBLCLK ,WMProcMouseLeftDoubleClick);
|
||||
WM_MAP(WM_LBUTTONDBLCLK ,WMProcMouseLeftDblClick);
|
||||
WM_MAP(WM_MBUTTONDOWN ,WMProcMouseMidDown);
|
||||
WM_MAP(WM_MBUTTONUP ,WMProcMouseMidUp);
|
||||
WM_MAP(WM_MBUTTONDBLCLK ,WMProcMouseMidDoubleClick);
|
||||
WM_MAP(WM_MBUTTONDBLCLK ,WMProcMouseMidDblClick);
|
||||
WM_MAP(WM_RBUTTONDOWN ,WMProcMouseRightDown);
|
||||
WM_MAP(WM_RBUTTONUP ,WMProcMouseRightUp);
|
||||
WM_MAP(WM_RBUTTONDBLCLK ,WMProcMouseRightDoubleClick);
|
||||
WM_MAP(WM_RBUTTONDBLCLK ,WMProcMouseRightDblClick);
|
||||
WM_MAP(WM_MOUSEWHEEL ,WMProcMouseWheel);
|
||||
WM_MAP(WM_MOUSEHWHEEL ,WMProcMouseHWheel);
|
||||
WM_MAP(WM_MOUSEMOVE ,WMProcMouseMove);
|
||||
WM_MAP(WM_KEYDOWN ,WMProcKeyDown);
|
||||
WM_MAP(WM_KEYUP ,WMProcKeyUp);
|
||||
|
@ -186,7 +186,7 @@ namespace hgl
|
||||
DispatchMessage(&win_msg);
|
||||
|
||||
if(win_msg.message==WM_QUIT)
|
||||
OnClose();
|
||||
ProcClose();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
@ -52,24 +52,31 @@ namespace hgl
|
||||
SAFE_CLEAR(device);
|
||||
}
|
||||
|
||||
void Window::OnKeyDown(KeyboardButton kb)
|
||||
void Window::ProcKeyDown(KeyboardButton kb)
|
||||
{
|
||||
if(key_push[kb])
|
||||
OnKeyPress(kb);
|
||||
ProcKeyPress(kb);
|
||||
else
|
||||
key_push[kb]=true;
|
||||
|
||||
SafeCallEvent(OnKeyDown,(kb));
|
||||
}
|
||||
|
||||
void Window::OnKeyUp(KeyboardButton kb)
|
||||
void Window::ProcKeyUp(KeyboardButton kb)
|
||||
{
|
||||
key_push[kb]=false;
|
||||
|
||||
SafeCallEvent(OnKeyUp,(kb));
|
||||
}
|
||||
|
||||
void Window::OnResize(uint w,uint h)
|
||||
void Window::ProcResize(uint w,uint h)
|
||||
{
|
||||
if(w==width&&height==h)
|
||||
return;
|
||||
|
||||
width=w;
|
||||
height=h;
|
||||
|
||||
if(w==0||h==0)
|
||||
{
|
||||
is_min=true;
|
||||
@ -77,12 +84,24 @@ namespace hgl
|
||||
else
|
||||
{
|
||||
is_min=false;
|
||||
width=w;
|
||||
height=h;
|
||||
|
||||
if(device)
|
||||
device->Resize(width,height);
|
||||
}
|
||||
|
||||
SafeCallEvent(OnResize,(w,h));
|
||||
}
|
||||
|
||||
void Window::ProcActive(bool a)
|
||||
{
|
||||
active=a;
|
||||
SafeCallEvent(OnActive,(a));
|
||||
}
|
||||
|
||||
void Window::ProcClose()
|
||||
{
|
||||
is_close=true;
|
||||
SafeCallEvent(OnClose,());
|
||||
}
|
||||
|
||||
bool Window::Update()
|
||||
|
@ -66,11 +66,19 @@ void Device::CreateMainFramebuffer()
|
||||
bool Device::Resize(uint width,uint height)
|
||||
{
|
||||
main_fb.Clear();
|
||||
delete main_rp;
|
||||
|
||||
delete texture_cmd_buf;
|
||||
|
||||
if(!ResizeRenderDevice(attr,width,height))
|
||||
return(false);
|
||||
|
||||
main_rp=CreateRenderPass(attr->sc_image_views[0]->GetFormat(),attr->depth.view->GetFormat());
|
||||
|
||||
CreateMainFramebuffer();
|
||||
|
||||
texture_cmd_buf=CreateCommandBuffer();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user