Plasma Engine  2.0
Loading...
Searching...
No Matches
ApplicationEntryPoint_uwp.h
1
2#pragma once
3
5
6#include <Foundation/Logging/Log.h>
7#include <Foundation/Memory/MemoryTracker.h>
8
9// Disable C++/CX adds.
10#pragma warning(disable : 4447)
11
12class plApplication;
13extern PL_FOUNDATION_DLL plResult plUWPRun(plApplication* pApp);
14
15namespace plApplicationDetails
16{
17 PL_FOUNDATION_DLL plResult InitializeWinrt();
18 PL_FOUNDATION_DLL void UninitializeWinrt();
19
20 template <typename AppClass, typename... Args>
21 int EntryFunc(Args&&... arguments)
22 {
23 alignas(PL_ALIGNMENT_OF(AppClass)) static char appBuffer[sizeof(AppClass)]; // Not on the stack to cope with smaller stacks.
24
25 if (InitializeWinrt().Failed())
26 {
27 return 1;
28 }
29
30 AppClass* pApp = new (appBuffer) AppClass(std::forward<Args>(arguments)...);
31
32 plUWPRun(pApp).IgnoreResult();
33
34 const int iReturnCode = pApp->GetReturnCode();
35 if (iReturnCode != 0)
36 {
37 std::string text = pApp->TranslateReturnCode();
38 if (!text.empty())
39 printf("Return Code: '%s'\n", text.c_str());
40 }
41
42 UninitializeWinrt();
43
44 return iReturnCode;
45 }
46} // namespace plApplicationDetails
47
49#define PL_CONSOLEAPP_ENTRY_POINT(AppClass, ...) \
50 alignas(PL_ALIGNMENT_OF(AppClass)) static char appBuffer[sizeof(AppClass)]; /* Not on the stack to cope with smaller stacks */ \
51 \
52 PL_APPLICATION_ENTRY_POINT_CODE_INJECTION \
53 int main(int argc, const char** argv) \
54 { \
55 return ::plApplicationDetails::EntryFunc<AppClass>(__VA_ARGS__); \
56 }
57
62#define PL_APPLICATION_ENTRY_POINT(AppClass, ...) \
63 PL_APPLICATION_ENTRY_POINT_CODE_INJECTION \
64 int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) \
65 { \
66 return ::plApplicationDetails::EntryFunc<AppClass>(__VA_ARGS__); \
67 }
Base class to be used by applications based on plEngine.
Definition Application.h:66
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
PL_ALWAYS_INLINE void IgnoreResult()
Used to silence compiler warnings, when success or failure doesn't matter.
Definition Types.h:69