1.win平台增加WaitMessage实现和调用

2.Window类增加IsVisible函数用于返回当前是否需要显示
3.WIndow类增加Update函数,用于处理是否绘制的问题
This commit is contained in:
hyzboy 2019-05-04 16:52:44 +08:00
parent be0d2dcd2c
commit 61fcd72a31
6 changed files with 38 additions and 7 deletions

View File

@ -82,9 +82,18 @@ public:
device->QueuePresent(); device->QueuePresent();
} }
virtual void Draw()=0;
bool Run() bool Run()
{ {
win->MessageProc(); if(!win->Update())return(false);
return !win->IsClose();
if(win->IsVisible())
{
AcquireNextFrame();
Draw();
}
return(true);
} }
};//class VulkanApplicationFramework };//class VulkanApplicationFramework

View File

@ -157,9 +157,8 @@ public:
return(true); return(true);
} }
void Draw() void Draw() override
{ {
AcquireNextFrame();
Submit(cmd_buf[device->GetCurrentFrameIndices()]); Submit(cmd_buf[device->GetCurrentFrameIndices()]);
} }
};//class TestApp:public VulkanApplicationFramework };//class TestApp:public VulkanApplicationFramework
@ -176,8 +175,7 @@ int main(int,char **)
if(!app.Init()) if(!app.Init())
return(-1); return(-1);
while(app.Run()) while(app.Run());
app.Draw();
return 0; return 0;
} }

View File

@ -19,6 +19,11 @@ namespace hgl
bool key_push[kbRangeSize]; bool key_push[kbRangeSize];
protected:
virtual bool MessageProc()=0;
virtual bool WaitMessage()=0;
public: public:
uint GetWidth()const{return width;} uint GetWidth()const{return width;}
@ -64,6 +69,7 @@ namespace hgl
virtual void Close()=0; virtual void Close()=0;
bool IsClose()const{return is_close;} bool IsClose()const{return is_close;}
bool IsVisible()const{return (!is_close)&&width&&height;}
virtual void SetCaption(const OSString &)=0; virtual void SetCaption(const OSString &)=0;
@ -75,7 +81,7 @@ namespace hgl
virtual void SetSystemCursor(bool){} virtual void SetSystemCursor(bool){}
virtual bool MessageProc()=0; virtual bool Update();
};//class Window };//class Window
Window *CreateRenderWindow(const OSString &win_name); Window *CreateRenderWindow(const OSString &win_name);

View File

@ -192,6 +192,11 @@ namespace hgl
} }
} }
bool WinWindow::WaitMessage()
{
return ::WaitMessage();
}
Window *CreateRenderWindow(const WideString& win_name) Window *CreateRenderWindow(const WideString& win_name)
{ {
return(new WinWindow(win_name)); return(new WinWindow(win_name));

View File

@ -46,5 +46,6 @@ namespace hgl
void SetSystemCursor(bool visible) override; void SetSystemCursor(bool visible) override;
bool MessageProc() override; bool MessageProc() override;
bool WaitMessage() override;
};//class WinWindow :public Window };//class WinWindow :public Window
}//namespace win }//namespace win

View File

@ -17,4 +17,16 @@ namespace hgl
OnKeyUp(kb); OnKeyUp(kb);
key_push[kb]=false; key_push[kb]=false;
} }
bool Window::Update()
{
while(MessageProc())
{
}
if(!active||width==0||height==0)
this->WaitMessage();
return(!is_close);
}
}//namespace hgl }//namespace hgl