Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
StudyDx
Commits
71916660
Commit
71916660
authored
Dec 17, 2022
by
Administrator
Browse files
move main logic into App.cpp
parent
44715f35
Changes
5
Hide whitespace changes
Inline
Side-by-side
StudyDx/App.cpp
0 → 100644
View file @
71916660
#include "App.h"
App
::
App
()
:
wnd
(
800
,
600
,
"Oasis Demo"
)
{}
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
StudyDx/App.h
0 → 100644
View file @
71916660
#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
StudyDx/StudyDx.vcxproj
View file @
71916660
...
...
@@ -137,6 +137,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"App.cpp"
/>
<ClCompile
Include=
"ChiliException.cpp"
/>
<ClCompile
Include=
"Keyboard.cpp"
/>
<ClCompile
Include=
"Mouse.cpp"
/>
...
...
@@ -145,6 +146,7 @@
<ClCompile
Include=
"WinMain.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"App.h"
/>
<ClInclude
Include=
"ChiliException.h"
/>
<ClInclude
Include=
"ChiliWin.h"
/>
<ClInclude
Include=
"Keyboard.h"
/>
...
...
StudyDx/StudyDx.vcxproj.filters
View file @
71916660
...
...
@@ -27,6 +27,15 @@
<ClCompile
Include=
"WindowsMessageMap.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"Keyboard.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"Mouse.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"App.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"ChiliException.h"
>
...
...
@@ -44,6 +53,15 @@
<ClInclude
Include=
"resource.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"Keyboard.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"Mouse.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"App.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile
Include=
"StudyDx.rc"
>
...
...
StudyDx/WinMain.cpp
View file @
71916660
...
...
@@ -18,7 +18,7 @@
* along with The Chili Direct3D Engine. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#include "Window.h"
#include
<sstream>
#include
"App.h"
int
CALLBACK
WinMain
(
HINSTANCE
hInstance
,
...
...
@@ -28,62 +28,7 @@ int CALLBACK WinMain(
{
try
{
Window
wnd
(
800
,
600
,
"Oasis Demo"
);
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
);
// if (wnd.kbd.KeyIsPressed(VK_SPACE) || wnd.kbd.KeyIsPressed(VK_MENU))
// {
// MessageBox(nullptr, "Something happens!", "Space key was pressed", MB_OK | MB_ICONEXCLAMATION);
// }
while
(
!
wnd
.
mouse
.
IsEmpty
())
{
const
auto
e
=
wnd
.
mouse
.
Read
();
static
int
i
=
0
;
switch
(
e
.
GetType
())
{
case
Mouse
::
Event
::
Type
::
Move
:
{
std
::
ostringstream
oss
;
oss
<<
"Mouse Position: ("
<<
e
.
GetPosX
()
<<
","
<<
e
.
GetPosY
()
<<
"), "
<<
"Mouse Press Status: ("
<<
wnd
.
mouse
.
LeftIsPressed
()
<<
","
<<
wnd
.
mouse
.
RightIsPressed
()
<<
")"
;
wnd
.
SetTitle
(
oss
.
str
());
break
;
}
case
Mouse
::
Event
::
Type
::
WheelUp
:
{
i
++
;
std
::
ostringstream
oss
;
oss
<<
"Up: "
<<
i
;
wnd
.
SetTitle
(
oss
.
str
());
break
;
}
case
Mouse
::
Event
::
Type
::
WheelDown
:
{
i
--
;
std
::
ostringstream
oss
;
oss
<<
"Down: "
<<
i
;
wnd
.
SetTitle
(
oss
.
str
());
break
;
}
}
}
}
// check if GetMessage call itself borked
if
(
gResult
==
-
1
)
{
return
-
1
;
}
// wParam here is the value passed to PostQuitMessage
return
msg
.
wParam
;
return
App
().
Go
();
}
catch
(
const
ChiliException
&
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment