text: #include "Globals.h"
  #include "Utils/Logger.h"
  
  #include "Application.h"
  #include "Modules/ModuleRender.h"
  
  #include "glew.h"
  #include <stdlib.h>
  #include "SDL.h"
  #pragma comment(lib, "SDL2.lib")
  #pragma comment(lib, "SDL2main.lib")
  
  #ifdef _DEBUG
  #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
  #define new DEBUG_NEW
  #define _CRTDBG_MAP_ALLOC
  #include <cstdlib>
  #include <crtdbg.h>
  #endif
  
  #include "optick.h"
  
  void DumpLeaks(void)
  {
  	_CrtDumpMemoryLeaks(); // Show leaks with file and line where allocation was made
  }
  
  enum main_states
  {
  	MAIN_CREATION,
  	MAIN_START,
  	MAIN_UPDATE,
  	MAIN_FINISH,
  	MAIN_EXIT
  };
  
  Application* App = NULL;
  Logger* Logging = NULL;
  
  int main(int argc, char** argv)
  {
  	atexit(DumpLeaks);
  	Logging = new Logger();
  
  	int main_return = EXIT_FAILURE;
  	main_states state = MAIN_CREATION;
  
  	while (state != MAIN_EXIT)
  	{
  		switch (state)
  		{
  		case MAIN_CREATION:
  
  			LOG("Application Creation --------------");
  			App = new Application();
  			state = MAIN_START;
  			break;
  
  		case MAIN_START:
  
  			LOG("Application Init --------------");
  			if (App->Init() == false)
  			{
  				LOG("Application Init exits with error -----");
  				state = MAIN_EXIT;
  			}
  			else
  			{
  				state = MAIN_UPDATE;
  				LOG("Application Update --------------");
  			}
  
  			break;
  
  		case MAIN_UPDATE:
  		{
  			int update_return = App->Update();
  			OPTICK_FRAME("MainThread");
  
  			if (update_return == UPDATE_ERROR)
  			{
  				LOG("Application Update exits with error -----");
  				state = MAIN_EXIT;
  			}
  
  			if (update_return == UPDATE_STOP)
  				state = MAIN_FINISH;
  		}
  		break;
  
  		case MAIN_FINISH:
  
  			LOG("Application CleanUp --------------");
  			if (App->CleanUp() == false)
  			{
  				LOG("Application CleanUp exits with error -----");
  			}
  			else
  				main_return = EXIT_SUCCESS;
  
  			state = MAIN_EXIT;
  
  			break;
  		}
  	}
  
  	delete App;
  	LOG("Bye :)\n");
  	delete Logging;
  	return main_return;
  }
  