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();
}
virtual void Draw()=0;
bool Run()
{
win->MessageProc();
return !win->IsClose();
if(!win->Update())return(false);
if(win->IsVisible())
{
AcquireNextFrame();
Draw();
}
return(true);
}
};//class VulkanApplicationFramework

View File

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

View File

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

View File

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

View File

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