#include <ehs/Log.h>
#include <ehs/GC.h>
#include <lwe/GameLoop.h>
#include <lwe/RenderWindow.h>

#include <ehs/io/Console.h>

#include "Levels/Game.h"

int main()
{
	ehs::Initialize("Pong", "Release", {1, 0, 0});

	ehs::Log::EnableImmediateMode(true);

	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(true);

	lwe::GpuDevice primary = lwe::GpuDevice::GetBest();

	lwe::GpuQueueFamily* family = primary.GetQueueFamily(lwe::QueueType::GRAPHICS);

	lwe::GpuInterface inf(&primary);
	inf.AddExtension(VK_KHR_SWAPCHAIN_EXTENSION_NAME);

	lwe::GpuQueue queue(family, &inf, 1.0f);

	inf.Initialize();

	lwe::RenderWindow win(&inf, &queue);
	win.Create_8(ehs::GetAppName_8(), {0, 0}, {1024, 768});
	win.Show();

	lwe::GameLoop gl(&win, 6, 0);
	gl.AddLevel(new Game());

	gl.Initialize();
	gl.Start();
	gl.UnInitialize();

	win.Close();

	inf.Release();

	lwe::GpuInstance::Release();

	ehs::Uninitialize();

	return 0;
}