Pong/Main.cpp

59 lines
1.2 KiB
C++
Raw Normal View History

2024-06-29 22:28:46 -07:00
#include <ehs/Log.h>
#include <ehs/GC.h>
#include <lwe/GameLoop.h>
#include <lwe/RenderWindow.h>
2023-11-11 18:56:55 -08:00
2024-06-29 22:28:46 -07:00
#include <ehs/io/Console.h>
2023-11-11 18:56:55 -08:00
2024-06-29 22:28:46 -07:00
#include "Levels/Game.h"
2023-11-11 18:56:55 -08:00
2024-06-29 22:28:46 -07:00
ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer)
2023-11-11 18:56:55 -08:00
{
*appName = "Pong";
2023-11-14 00:08:54 -08:00
*appVerId = "Release";
*appVer = {1, 0, 0};
2023-11-11 18:56:55 -08:00
2024-07-01 19:39:05 -07:00
ehs::Log::EnableImmediateMode(true);
2024-06-29 22:28:46 -07:00
ehs::Console::Attach();
2023-11-11 18:56:55 -08:00
2024-06-29 22:28:46 -07:00
#if defined(EHS_OS_WINDOWS)
2023-11-11 18:56:55 -08:00
lwe::GpuInstance::AddExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
2024-06-29 22:28:46 -07:00
#elif defined(EHS_OS_LINUX)
2023-11-11 18:56:55 -08:00
lwe::GpuInstance::AddExtension(VK_KHR_XCB_SURFACE_EXTENSION_NAME);
#endif
lwe::GpuInstance::AddExtension(VK_KHR_SURFACE_EXTENSION_NAME);
2024-07-01 19:39:05 -07:00
lwe::GpuInstance::Initialize(false);
2023-11-11 18:56:55 -08:00
lwe::GpuDevice primary = lwe::GpuDevice::GetBest();
lwe::GpuQueueFamily* family = primary.GetQueueFamily(lwe::QueueType::GRAPHICS);
lwe::GpuInterface inf(&primary);
inf.AddExtensions(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
lwe::GpuQueue queue(family, &inf, 1.0f);
inf.Initialize();
lwe::RenderWindow win(&inf, &queue);
win.Create_8(*appName, {0, 0}, {1024, 768});
2024-07-01 19:39:05 -07:00
win.Show();
2023-11-11 18:56:55 -08:00
lwe::GameLoop gl(&win, 6, 0);
2024-06-29 22:28:46 -07:00
gl.AddLevel(new Game());
2023-11-11 18:56:55 -08:00
gl.Initialize();
gl.Start();
gl.UnInitialize();
win.Close();
inf.Release();
lwe::GpuInstance::Release();
return 0;
}