Engine
Frameworkcreatedbymeusableforthecreationofsimplegames.CurrentlysupportsOpenGL(Verysimple)andVulkan.
main.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <ThirdParty/EASTL-master/include/EASTL/vector.h>
3 #include <functional>
4 #include "Engine/engine.hpp"
6 #include "Game/ImGui/ImGuiRenderer.hpp"
9 
10 #if defined(_WIN32) && defined(UNICODE)
11 #include <utf8.h>
12 #include <direct.h>
13 #endif
14 
15 #if defined(_WIN32) && defined(UNICODE)
16 extern "C" void wParseArguments(int argumentCount, wchar_t *wideArguments[]);
17 
18 extern "C" void wParseArguments(int argumentCount, wchar_t *wideArguments[])
19 #else
20 void ParseArguments(int argumentCount, char *inArguments[])
21 #endif
22 {
23  // Vector of strings to parse the arguments
24  eastl::vector<eastl::string> arguments;
25 
26  // Allocate beforehand to get no reallocations
27  arguments.reserve(static_cast<size_t>(argumentCount));
28 
29 #if defined(_WIN32) && defined(UNICODE)
30  // Convert arguments from UCS-2 to UTF-8 strings
31  // (support for every language ever) on Windows
32  for (eastl::string::size_type i = 0;
33  i < static_cast<eastl::string::size_type>(argumentCount); ++i)
34  {
35  size_t length = wcslen(wideArguments[i]);
36  arguments.emplace_back(eastl::string());
37  utf8::utf16to8(wideArguments[i], wideArguments[i] + length, std::back_inserter(arguments[i]));
38  std::cout << arguments[i].c_str() << std::endl;
39  }
40  // --
41 #else
42  // Convert arguments to strings (without converting to UTF-8 on Windows)
43  // Mostly used on platforms like not-Windows.
44  for (eastl::string::size_type i = 0;
45  i < static_cast<eastl::string::size_type>(argumentCount); ++i)
46  {
47  arguments.emplace_back(eastl::string(inArguments[i]));
48  }
49  // --
50 #endif
51 }
52 
53 #if defined(_WIN32) && defined(UNICODE)
54 extern "C" int wmain(int argumentCount, wchar_t *wideArguments[]);
55 
56 extern "C" int wmain(int argumentCount, wchar_t *wideArguments[])
57 #else
58 int main(int argumentCount, char *inArguments[])
59 #endif
60 {
61 #if defined(_WIN32) && defined(UNICODE)
62  wParseArguments(argumentCount, wideArguments);
63 #else
64  ParseArguments(argumentCount, inArguments);
65 #endif
66  Engine::Engine::GetEngine().lock()->SetIsPlaying(false);
67 
69 
70  // ImGuiRenderer handles the main menu menu's. It works standalone, but has to be cleared in the correct order.
71  eastl::unique_ptr<ImGuiRenderer> imGuiRenderer = eastl::make_unique<ImGuiRenderer>();
72  Engine::Engine::GetEngine().lock()->GetCamera().lock()->SetPostionAndRotation(glm::vec3(0, 30, -75), glm::vec3(-44.15f, 9.43f, 1));
73  eastl::weak_ptr<Engine::EntitySystem> entitySystem = Engine::Engine::GetEngine().lock()->GetEntitySystem();
74  eastl::weak_ptr<Engine::Entity> entity = entitySystem.lock()->CreateEntity("Amazing Entity");
75  entity.lock()->AddComponent<Engine::TransformComponent>();
76  entity.lock()->AddComponent<Engine::ModelComponent>("jeep1.fbx");
77  entity.lock()->AddComponent<Engine::LightComponent>("light", LIGHT_POINT_LIGHT, glm::vec3(0, 50, 0), glm::vec3(), glm::vec3(1, 1, 1), 3000, 100, 10, 10);
78 
79  while (!Engine::Engine::GetEngine().lock()->GetWindow().lock()->ShouldClose())
80  {
81  Engine::Engine::GetEngine().lock()->Update();
82  }
83  imGuiRenderer.reset();
84  Engine::Engine::GetEngine().lock()->Destroy();
85 
86  return 0;
87 }
This component is used to keep track of the meshes and textures to render. NOTE: only the Entity clas...
void ParseArguments(int argumentCount, char *inArguments[])
Definition: main.cpp:20
int main(int argumentCount, char *inArguments[])
Definition: main.cpp:58
LIGHT_POINT_LIGHT
Definition: Light.hpp:10
static eastl::weak_ptr< Engine > GetEngine() noexcept
This method allows you to get the instance of the Engine. This method will automatically initialize t...
Definition: engine.cpp:130
eastl::weak_ptr< ComponentType > AddComponent(Args &&...args)
Allows you to create a component of the given type.
Definition: Component.hpp:163