TerraForge3D  2.3.1
3D Terrain And Landscape Generator
EntryPoint.cpp
1#pragma once
2#include "Base/EntryPoint.h"
3#include "Base/SplashScreen.h"
4#include "Base/Logging/Logger.h"
5
6#include <iostream>
7#include <string>
8
9#ifdef TERR3D_WIN32
10#include <shellapi.h>
11#include <windows.h>
12
13static void AllocateConsole()
14{
15 AllocConsole();
16 freopen_s((FILE **)stdout, "CONOUT$", "w", stdout);
17 freopen_s((FILE **)stdin, "CONIN$", "r", stdin);
18}
19static std::string ParseArgs(PWSTR pCmdLine)
20{
21 LPWSTR *szArgList;
22 int argCount;
23 szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
24
25 if (szArgList == NULL)
26 {
27 MessageBox(NULL, L"Unable to load file from command line argument! Opening blank project.", L"Error", MB_OK);
28 return std::string("");
29 }
30
31 if (argCount == 2)
32 {
33 std::wstring ws(szArgList[1]);
34 return std::string(ws.begin(), ws.end());
35 }
36
37 return std::string("");
38 LocalFree(szArgList);
39}
40
41int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
42{
43 AllocateConsole();
44 Application *app = CreateApplication();
45 app->OnPreload();
46 Logger logger(app->logsDir);
47 app->Init();
48 {
49 SplashScreen::Init(hInstance);
50 app->OnStart(ParseArgs(pCmdLine));
51 SplashScreen::Destory();
52 }
53 app->Run();
54 delete app;
55}
56
57#else
58
59int main(int argc, char **argv)
60{
61 Application *app = CreateApplication();
62 app->OnPreload();
63 Logger logger(app->logsDir);
64 app->Init();
65 {
66 std::string args = "";
67
68 if (argc == 2)
69 {
70 args = std::string(argv[1]);
71 }
72
73 app->OnStart(args);
74 }
75 app->Run();
76 delete app;
77}
78
79#endif
Definition: Logger.h:5