| 87 | } |
| 88 | |
| 89 | int ApplicationMain(int argc, char* argv[]) |
| 90 | { |
| 91 | using namespace Nuake; |
| 92 | |
| 93 | const auto& arguments = ParseArguments(argc, argv); |
| 94 | LaunchSettings launchSettings = ParseLaunchSettings(arguments); |
| 95 | |
| 96 | Engine::Init(); |
| 97 | |
| 98 | auto window = Nuake::Engine::GetCurrentWindow(); |
| 99 | |
| 100 | std::string projectPath; |
| 101 | if (launchSettings.projectPath.empty()) |
| 102 | { |
| 103 | projectPath = "./game.project"; |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | projectPath = launchSettings.projectPath; |
| 108 | } |
| 109 | |
| 110 | FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath)); |
| 111 | |
| 112 | Ref<Nuake::Project> project = Nuake::Project::New(); |
| 113 | project->FullPath = projectPath; |
| 114 | |
| 115 | if (!FileSystem::FileExists(projectPath)) |
| 116 | { |
| 117 | Logger::Log("game.project not found", "runtime", CRITICAL); |
| 118 | return -1; |
| 119 | } |
| 120 | |
| 121 | const std::string& projectfileContent = FileSystem::ReadFile(projectPath, true); |
| 122 | if (projectfileContent.empty()) |
| 123 | { |
| 124 | Logger::Log("game.project was empty", "runtime", CRITICAL); |
| 125 | return -1; |
| 126 | } |
| 127 | |
| 128 | project->Deserialize(json::parse(projectfileContent)); |
| 129 | |
| 130 | window->ShowTitleBar(true); |
| 131 | window->SetDecorated(true); |
| 132 | window->SetTitle(project->Name); |
| 133 | |
| 134 | Nuake::Engine::LoadProject(project); |
| 135 | Nuake::Engine::EnterPlayMode(); |
| 136 | window->SetVSync(false); |
| 137 | |
| 138 | while (!window->ShouldClose()) |
| 139 | { |
| 140 | Nuake::Engine::Tick(); |
| 141 | Engine::Draw(); |
| 142 | |
| 143 | const auto& WindowSize = window->GetSize(); |
| 144 | //glViewport(0, 0, WindowSize.x, WindowSize.y); |
| 145 | Nuake::Renderer2D::BeginDraw(WindowSize); |
| 146 |
no test coverage detected