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::wbegin();
Wrapper::AudioManager manager;
UVK
bool bUsesEditor = false;
#ifndef PRODUCTION
if (argv[1])
{
std::string cmd = argv[1];
if (cmd == "--editor")
{
= true;
bUsesEditor }
}
#endif
auto* st = new UVK::StartupLevel;
::Utility::getGlobal().getEditor() = bUsesEditor;
UVK::Utility::getGlobal().currentLevel = st;
UVKauto* mode = new UVK::GameGameInstance();
::Utility::getGlobal().instance = mode;
UVK::UVKGlobal::openLevelInternal("tst", true);
UVK::Renderer(UVK::Utility::getGlobal().currentLevel, bUsesEditor);
UVK::wend();
Wrapper}
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)
::log("Loaded all mods!", UVK_LOG_TYPE_SUCCESS);
Loggerelse
::log("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}
else
::log("Failed to load the mod library!", UVK_LOG_TYPE_WARNING);
Logger::wbegin();
Wrapper::AudioManager manager;
UVK
bool bUsesEditor = false;
#ifndef PRODUCTION
if (argv[1])
{
std::string cmd = argv[1];
if (cmd == "--editor")
= true;
bUsesEditor }
#endif
auto* st = new UVK::StartupLevel;
::Utility::getGlobal().getEditor() = bUsesEditor;
UVK::Utility::getGlobal().currentLevel = st;
UVKauto* mode = new UVK::GameGameInstance();
::Utility::getGlobal().instance = mode;
UVK::UVKGlobal::openLevelInternal("tst", true);
UVK::Renderer(UVK::Utility::getGlobal().currentLevel, bUsesEditor);
UVK::wend();
Wrapperif (bCanClose && URLL::dlclose(handle) != 0)
::log("Error when closing the mod handle, message:", UVK_LOG_TYPE_ERROR, URLL::dlerror());
Logger}
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