#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "Levels/MainMenu.h" #include "Levels/TestLevel.h" ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer) { *appName = "TechDemo"; *appVerId = "Release"; *appVer = {1, 0, 0}; ehs::File configFile("Config.json", ehs::Mode::READ_WRITE, ehs::Disposition::OPEN_PERSISTENT); if (!configFile.Size()) { ehs::JsonObj root; ehs::JsonObj server; server.AddVar({"identifier", ""}); server.AddVar({"address", ""}); server.AddVar({"port", 7840}); server.AddVar({"maxPlayers", 0}); root.AddVar({"server", server}); ehs::JsonObj client; client.AddVar({"username", ""}); client.AddVar({"connectAddress", ""}); client.AddVar({"connectPort", 7840}); root.AddVar({"client", client}); ehs::JsonObj server_client; server_client.AddVar({"timeout", 5}); server_client.AddVar({"resendRate", 0.5f}); root.AddVar({"server_client", server_client}); ehs::JsonObj engine; engine.AddVar({"threadCount", 0}); engine.AddVar({"timeLocked", true}); engine.AddVar({"maxTPS", 60}); root.AddVar({"engine", engine}); ehs::Json config(root); configFile.WriteStr_8(config.ToStr(false)); configFile.Release(); return 0; } ehs::Json config(configFile.ReadStr_8(configFile.Size()), 0); configFile.Release(); ehs::Vector args = ehs::Console::GetArgs_8(); if (args.Size() > 1 && ehs::Str_8::Cmp(args[1], "-server")) { ehs::Console::Attach(); ehs::Console::SetTitle_8("TechDemo"); EHS_LOG("Info", 0, "Initializing server, standby."); lwe::GameLoop gl((ehs::UInt_8)*(ehs::JsonNum*)config.RetrieveValue("engine.threadCount"), 0); gl.EnableTimeLock(*(ehs::JsonBool*)config.RetrieveValue("engine.timeLocked")); gl.SetMaxTPS((ehs::UInt_32)*(ehs::JsonNum*)config.RetrieveValue("engine.maxTPS")); gl.AddLevel(new MainMenu("MainMenu")); gl.Initialize(); gl.Start(); gl.UnInitialize(); } else { ehs::Console::Attach(); #if defined(EHS_OS_WINDOWS) lwe::GpuInstance::AddExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); #elif defined(EHS_OS_LINUX) lwe::GpuInstance::AddExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME); #endif lwe::GpuInstance::AddExtension(VK_KHR_SURFACE_EXTENSION_NAME); lwe::GpuInstance::Initialize(false); lwe::GpuDevice device = std::move(lwe::GpuDevice::GetBest()); lwe::GpuQueueFamily* family = device.GetQueueFamily(lwe::QueueType::GRAPHICS); lwe::GpuInterface inf(&device); inf.AddExtensions(VK_KHR_SWAPCHAIN_EXTENSION_NAME); lwe::GpuQueue primary(family, &inf, 1.0f); inf.Initialize(); lwe::RenderWindow win(&inf, &primary); win.Create_8(ehs::GetAppName_8(), {0, 0}, {1024, 768}); win.Show(); lwe::GameLoop gl(&win, (ehs::UInt_8)*(ehs::JsonNum*)config.RetrieveValue("engine.threadCount"), 0); gl.EnableTimeLock(*(ehs::JsonBool*)config.RetrieveValue("engine.timeLocked")); gl.SetMaxTPS((ehs::UInt_32)*(ehs::JsonNum*)config.RetrieveValue("engine.maxTPS")); gl.AddLevel(new TestLevel("Test")); gl.Initialize(); gl.Start(); gl.UnInitialize(); win.Close(); inf.Release(); lwe::GpuInstance::Release(); } ehs::Console::Free(); return 0; }