The entry point main.cpp file is the entry point to your application. It’s automatically generated by the
UVKBuildTool under the Generated folder. It looks like this:
// This is an autogenerated file, touching it is not recommended
#include <Framework.hpp>
#include "../Source/Instance.hpp"
#include <Global.hpp>
#include <Renderer.hpp>
int main(int argc, char** argv)
{
UIMGUI_START(true);
#ifdef __EMSCRIPTEN__
auto* inst = new {{ name }}::Instance{};
#else
{{ name }}::Instance instance{};
auto* inst = &instance;
#endif
UImGui::FrameworkMain::setupGlobal(&UImGui::Global::get(), &UImGui::AllocatorFuncs::get(), &LoggerInternal::get());
UImGui::FrameworkMain::parseArguments(inst, argc, argv);
// Cannot be moved into a function because of emscripten quirks
#ifdef __EMSCRIPTEN__
auto* renderer = new UImGui::RendererInternal{};
renderer->start();
renderer->stop();
#else
UImGui::RendererInternal renderer;
renderer.start();
renderer.stop();
#endif
}
{{ name }} is replaced with the project name from uvproj.yaml when UVKBuildTool runs.
First, it calls the startup macro, then instantiates the application’s Instance (heap-allocated on Emscripten so it
outlives the JS event loop, stack-allocated otherwise). Next, FrameworkMain::setupGlobal wires the framework’s
Global, allocator function table and logger context together so plugins can later share them. After that,
FrameworkMain::parseArguments populates the instance’s CLI argument fields. Finally, the RendererInternal is
created and the main loop runs inside renderer.start() until exit.