Symphony Of Empires
main.cpp
Go to the documentation of this file.
1 // Eng3D - General purpouse game engine
2 // Copyright (C) 2021, Eng3D contributors
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16 //
17 // ----------------------------------------------------------------------------
18 // Name:
19 // main.cpp
20 //
21 // Abstract:
22 // Code glue for entry points of the game on various platforms.
23 // ----------------------------------------------------------------------------
24 
25 #include <cstring>
26 #include <stdexcept>
27 #include "eng3d/log.hpp"
28 #include "eng3d/utils.hpp"
29 #ifdef E3D_TARGET_WINDOWS
30 # include <windows.h>
31 #endif
32 
33 #ifdef E3D_TARGET_ANDROID
34 # include <android_native_app_glue.h>
35 # define APPNAME "baseapp"
36 void android_main(struct android_app* state)
37 {
38  main(0, { NULL });
39  ANativeActivity_finish(state->activity);
40 }
41 #elif defined E3D_TARGET_SWITCH
47 extern "C" long pathconf(const char *pathname, int varcode) {
48  if(pathname == NULL)
49  return 0;
50  switch(varcode) {
51  case _PC_LINK_MAX:
52  return 1;
53  case _PC_MAX_CANON:
54  return 512;
55  case _PC_MAX_INPUT:
56  return 512;
57  case _PC_NAME_MAX:
58  return 512;
59  case _PC_PATH_MAX:
60  return 512;
61  case _PC_PIPE_BUF:
62  return 512;
63  case _PC_CHOWN_RESTRICTED:
64  return 1;
65  case _PC_NO_TRUNC:
66  return 1;
67  case _PC_VDISABLE:
68  return 1;
69  }
70  return 0;
71 }
72 
73 extern "C" long sysconf(int) {
74  return 0;
75 }
76 #elif defined E3D_TARGET_WINDOWS
77 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
78  switch(fdwReason) {
79  case DLL_PROCESS_ATTACH:
80 // auto game_main = (MainFn)GetProcAddress(GetModuleHandle(nullptr), "game_main");
81 // if(game_main == nullptr)
82 // CXX_THROW(std::runtime_error, translate("No game_main found!"));
83 // game_main(__argc, __argv);
84  break;
85  case DLL_THREAD_ATTACH:
86  break;
87  case DLL_THREAD_DETACH:
88  break;
89  case DLL_PROCESS_DETACH:
90  if(lpvReserved != nullptr) break;
91  break;
92  }
93  return TRUE;
94 }
95 #endif
int main(int argc, char **argv)
Definition: game_state.cpp:444
#define TRUE
Definition: stb_vorbis.c:652