/* * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** @file main.cu * @author Thomas Müller, NVIDIA */ #include #include #include #include using namespace args; using namespace ngp; using namespace std; namespace ngp { int main_func(const std::vector& arguments) { ArgumentParser parser{ "Gen3C GUI" "Version " NGP_VERSION, "", }; HelpFlag help_flag{ parser, "HELP", "Display this help menu.", {'h', "help"}, }; Flag vr_flag{parser, "VR", "Enables VR", {"vr"}}; ValueFlag snapshot_flag{ parser, "SNAPSHOT", "Optional snapshot to load upon startup.", {"snapshot", "load_snapshot"}, }; ValueFlag width_flag{ parser, "WIDTH", "Resolution width of the GUI.", {"width"}, }; ValueFlag height_flag{ parser, "HEIGHT", "Resolution height of the GUI.", {"height"}, }; Flag version_flag{ parser, "VERSION", "Display the version of Gen3C GUI.", {'v', "version"}, }; PositionalList files{ parser, "files", "Files to be loaded. Can be a scene, network config, snapshot, camera path, or a combination of those.", }; // Parse command line arguments and react to parsing // errors using exceptions. try { if (arguments.empty()) { tlog::error() << "Number of arguments must be bigger than 0."; return -3; } parser.Prog(arguments.front()); parser.ParseArgs(begin(arguments) + 1, end(arguments)); } catch (const Help&) { cout << parser; return 0; } catch (const ParseError& e) { cerr << e.what() << endl; cerr << parser; return -1; } catch (const ValidationError& e) { cerr << e.what() << endl; cerr << parser; return -2; } if (version_flag) { tlog::none() << "Gen3C GUI v" NGP_VERSION; return 0; } Testbed testbed{ETestbedMode::Gen3c}; for (auto file : get(files)) { testbed.load_file(file); } #ifdef NGP_GUI bool gui = true; #else bool gui = false; #endif if (gui) { testbed.init_window(width_flag ? get(width_flag) : 1920, height_flag ? get(height_flag) : 1080); } if (vr_flag) { testbed.init_vr(); } // Render loop while (testbed.frame()) {} return 0; } } // namespace ngp #ifdef _WIN32 int wmain(int argc, wchar_t* argv[]) { SetConsoleOutputCP(CP_UTF8); #else int main(int argc, char* argv[]) { #endif try { std::vector arguments; for (int i = 0; i < argc; ++i) { #ifdef _WIN32 arguments.emplace_back(ngp::utf16_to_utf8(argv[i])); #else arguments.emplace_back(argv[i]); #endif } return ngp::main_func(arguments); } catch (const exception& e) { tlog::error() << fmt::format("Uncaught exception: {}", e.what()); return 1; } }