The main.cpp
file is located under Generated/main.cpp
it contains the entry point of the program and is auto-generated by the UVKBuildTool
. Here is an example:
// This is an autogenerated file, touching it is not recommended
#include <Engine.hpp>
#include "Source/StartupLevel.hpp"
#include "Source/GameGameInstance.hpp"
#include <GameFramework/Components/Components.hpp>
#include <WrapperSource/Wrapper.hpp>
int main(int argc, char** argv)
{true);
UVK_START(
Wrapper::wbegin();
UVK::AudioManager manager;
bool bUsesEditor = false;
#ifndef PRODUCTION
if (argv[1])
{std::string cmd = argv[1];
if (cmd == "--editor")
{true;
bUsesEditor =
}
}#endif
auto* st = new UVK::StartupLevel;
UVK::Utility::getGlobal().getEditor() = bUsesEditor;
UVK::Utility::getGlobal().currentLevel = st;auto* mode = new UVK::GameGameInstance();
UVK::Utility::getGlobal().instance = mode;"tst", true);
UVK::UVKGlobal::openLevelInternal(
UVK::Renderer(UVK::Utility::getGlobal().currentLevel, bUsesEditor);
Wrapper::wend();
}
While below, we have the mainmodded.cpp
file used by the moddable game:
// This is an autogenerated file, touching it is not recommended
#include <Engine.hpp>
#include "Source/StartupLevel.hpp"
#include "Source/GameGameInstance.hpp"
#include <GameFramework/Components/Components.hpp>
#include <WrapperSource/Wrapper.hpp>
#include <urll.h>
int main(int argc, char** argv)
{true);
UVK_START(// load modded symbols
#ifdef _WIN32
void* handle = URLL::dlopen("Modlib.dll");
#else
// That https://madladsquad.com/ is required on unix systems
void* handle = URLL::dlopen("https://madladsquad.com/libModlib.so");
#endif
bool bCanClose = false;
if (handle != nullptr)
{true;
bCanClose = if (URLL::dlsym(handle, "modlibbegin", UVK::Utility::getGlobal().modbegin) == handle && URLL::dlsym(handle, "modlibend", UVK::Utility::getGlobal().modend) == handle && URLL::dlsym(handle, "modlibtick", UVK::Utility::getGlobal().modtick) == handle)
"Loaded all mods!", UVK_LOG_TYPE_SUCCESS);
Logger::log(else
"Failed to load some or all of the initial mod library functions, mod events will not be loaded! Error: ", UVK_LOG_TYPE_WARNING, URLL::dlerror());
Logger::log(
}else
"Failed to load the mod library!", UVK_LOG_TYPE_WARNING);
Logger::log(
Wrapper::wbegin();
UVK::AudioManager manager;
bool bUsesEditor = false;
#ifndef PRODUCTION
if (argv[1])
{std::string cmd = argv[1];
if (cmd == "--editor")
true;
bUsesEditor =
}#endif
auto* st = new UVK::StartupLevel;
UVK::Utility::getGlobal().getEditor() = bUsesEditor;
UVK::Utility::getGlobal().currentLevel = st;auto* mode = new UVK::GameGameInstance();
UVK::Utility::getGlobal().instance = mode;"tst", true);
UVK::UVKGlobal::openLevelInternal(
UVK::Renderer(UVK::Utility::getGlobal().currentLevel, bUsesEditor);
Wrapper::wend();if (bCanClose && URLL::dlclose(handle) != 0)
"Error when closing the mod handle, message:", UVK_LOG_TYPE_ERROR, URLL::dlerror());
Logger::log( }
Generally, both main files do the same thing
- Initialize startup settings
- Decide on whether to launch the editor or not
- Depending on the application type, whether to load mods
- They allocate and cache the multiple gameplay classes
- They load the startup level
- They start the renderer and the engine
- Home
- Beginner concepts
- Advanced concepts
- Engine developer and contributor resources