Exemplo n.º 1
0
int main(){
	ReportMemoryLeaks();
	
	//printf("Where am I? Why am I in an operating room? What is this terrible headache?\n I'm starting to remember everything... I wanted to end with my nightmares, but this seems just like one...\n I better start looking for the lake. My nightmares always stop when I find her in the lake. ");
	world w = world();
	w.createWorld();
	w.play();

	

}
extern "C" void malloc_debug_finalize(int malloc_debug_level) {
  // We only track leaks at level 10.
  if (malloc_debug_level == 10) {
    ReportMemoryLeaks();
  }
  if (g_backtrace_enabled) {
    backtrace_shutdown();
  }

  pthread_setspecific(g_debug_calls_disabled, NULL);
}
extern "C" void malloc_debug_finalize() {
  ReportMemoryLeaks();
  backtrace_shutdown();
}
Exemplo n.º 4
0
int main(int argc, char* args[])
{
	LOG("Engine starting ... %d");

	ReportMemoryLeaks();

	MainState state = MainState::CREATE;
	int result = EXIT_FAILURE;

	while(state != EXIT)
	{
		switch(state)
		{

			// Allocate the engine --------------------------------------------
			case CREATE:
			LOG("CREATION PHASE ===============================");

			App = new j1App(argc, args);

			if(App != NULL)
				state = AWAKE;
			else
				state = FAIL;

			break;

			// Awake all modules -----------------------------------------------
			case AWAKE:
			LOG("AWAKE PHASE ===============================");
			if(App->Awake() == true)
				state = START;
			else
			{
				LOG("ERROR: Awake failed");
				state = FAIL;
			}

			break;

			// Call all modules before first frame  ----------------------------
			case START:
			LOG("START PHASE ===============================");
			if(App->Start() == true)
			{
				state = LOOP;
				LOG("UPDATE PHASE ===============================");
			}
			else
			{
				state = FAIL;
				LOG("ERROR: Start failed");
			}
			break;

			// Loop all modules until we are asked to leave ---------------------
			case LOOP:
			if(App->Update() == false)
				state = CLEAN;
			break;

			// Cleanup allocated memory -----------------------------------------
			case CLEAN:
			LOG("CLEANUP PHASE ===============================");
			if(App->CleanUp() == true)
			{
				RELEASE(App);
				result = EXIT_SUCCESS;
				state = EXIT;
			}
			else
				state = FAIL;

			break;

			// Exit with errors and shame ---------------------------------------
			case FAIL:
			LOG("Exiting with errors :(");
			result = EXIT_FAILURE;
			state = EXIT;
			break;
		}
	}

	LOG("... Bye! :)\n\n");



	// Dump memory leaks
	return result;
}
int main(int argc, char* argv[])
{
	ReportMemoryLeaks();

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

				if (update_return == UPDATE_ERROR)
				{
					LOG("Application Update exits with error -----");
					state = MAIN_EXIT;
				} else 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");
	return main_return;
}
Exemplo n.º 6
0
int main()
{
	ReportMemoryLeaks();

	int main_return = EXIT_FAILURE;
	main_states state = MAIN_CREATION;
	Application* App = nullptr;

	while (state != MAIN_EXIT)
	{
		switch (state)
		{
			case MAIN_CREATION:
			{
				LOG("\nApplication Creation --------------");
				App = new Application();
				state = MAIN_START;
			}	break;

			case MAIN_START:
			{
				LOG("\nApplication Init -------------------");
				if(App->Init() == false)
				{
					LOG("\nApplication Init exits with error -----");
					state = MAIN_EXIT;
				}
				else
					state = MAIN_UPDATE;

			}	break;

			case MAIN_UPDATE:
			{
				int update_return = App->Update();

				if (update_return == UPDATE_ERROR)
				{
					LOG("\nApplication Update exits with error -----");
					state = MAIN_EXIT;
				}

				if (update_return == UPDATE_STOP)
					state = MAIN_FINISH;

			} break;

			case MAIN_FINISH:
			{
				LOG("\nApplication Finishing --------------");
				if (App->CleanUp() == false) 
					LOG("\nApplication Finish executed with errors -----");
				else 
					LOG("\nApplication Finish Successfull -----");
				state = MAIN_EXIT;
					
			}
			// TODO 1: Implement case MAIN_FINISH
		}
	}

	LOG("\nBye :)\n");

	return main_return;
}