Commit 83156329 authored by chili's avatar chili
Browse files

basic app class

parent 380f88b3
#include "App.h"
App::App()
:
wnd( 800,600,"The Donkey Fart Box")
{}
int App::Go()
{
MSG msg;
BOOL gResult;
while( (gResult = GetMessage( &msg,nullptr,0,0 )) > 0 )
{
// TranslateMessage will post auxilliary WM_CHAR messages from key msgs
TranslateMessage( &msg );
DispatchMessage( &msg );
DoFrame();
}
// check if GetMessage call itself borked
if( gResult == -1 )
{
throw CHWND_LAST_EXCEPT();
}
// wParam here is the value passed to PostQuitMessage
return msg.wParam;
}
void App::DoFrame()
{
}
\ No newline at end of file
#pragma once
#include "Window.h"
class App
{
public:
App();
// master frame / message loop
int Go();
private:
void DoFrame();
private:
Window wnd;
};
\ No newline at end of file
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License * * You should have received a copy of the GNU General Public License *
* along with The Chili Direct3D Engine. If not, see <http://www.gnu.org/licenses/>. * * along with The Chili Direct3D Engine. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/ ******************************************************************************************/
#include "Window.h" #include "App.h"
int CALLBACK WinMain( int CALLBACK WinMain(
...@@ -28,25 +28,7 @@ int CALLBACK WinMain( ...@@ -28,25 +28,7 @@ int CALLBACK WinMain(
{ {
try try
{ {
Window wnd( 800,300,"Donkey Fart Box" ); return App{}.Go();
MSG msg;
BOOL gResult;
while( (gResult = GetMessage( &msg,nullptr,0,0 )) > 0 )
{
// TranslateMessage will post auxilliary WM_CHAR messages from key msgs
TranslateMessage( &msg );
DispatchMessage( &msg );
}
// check if GetMessage call itself borked
if( gResult == -1 )
{
throw CHWND_LAST_EXCEPT();
}
// wParam here is the value passed to PostQuitMessage
return msg.wParam;
} }
catch( const ChiliException& e ) catch( const ChiliException& e )
{ {
......
...@@ -145,6 +145,7 @@ ...@@ -145,6 +145,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="App.cpp" />
<ClCompile Include="ChiliException.cpp" /> <ClCompile Include="ChiliException.cpp" />
<ClCompile Include="Keyboard.cpp" /> <ClCompile Include="Keyboard.cpp" />
<ClCompile Include="Mouse.cpp" /> <ClCompile Include="Mouse.cpp" />
...@@ -153,6 +154,7 @@ ...@@ -153,6 +154,7 @@
<ClCompile Include="WinMain.cpp" /> <ClCompile Include="WinMain.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="App.h" />
<ClInclude Include="ChiliException.h" /> <ClInclude Include="ChiliException.h" />
<ClInclude Include="ChiliWin.h" /> <ClInclude Include="ChiliWin.h" />
<ClInclude Include="Keyboard.h" /> <ClInclude Include="Keyboard.h" />
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
<ClCompile Include="Mouse.cpp"> <ClCompile Include="Mouse.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="App.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="WindowsMessageMap.h"> <ClInclude Include="WindowsMessageMap.h">
...@@ -56,6 +59,9 @@ ...@@ -56,6 +59,9 @@
<ClInclude Include="Mouse.h"> <ClInclude Include="Mouse.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="App.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="hw3d.rc"> <ResourceCompile Include="hw3d.rc">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment