Beispiel #1
0
	value lime_application_init (value application) {
		
		Application* app = (Application*)(intptr_t)val_float (application);
		app->Init ();
		return alloc_null ();
		
	}
Beispiel #2
0
int main(void)
{
    Application app;
    app.Init();
    app.Run();
    app.Exit();
}
Beispiel #3
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) {
    Application app;

    if (FAILED(app.Init(hInstance, true)))
        return 0;

    MSG msg;
    memset(&msg, 0, sizeof(MSG));
    DWORD startTime = GetTickCount();

    while (msg.message != WM_QUIT) {
        if (::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
            ::TranslateMessage(&msg);
            ::DispatchMessage(&msg);
        }
        else {
            DWORD t = GetTickCount();
            float deltaTime = (t - startTime) * 0.001f;

            app.Update(deltaTime);
            app.Render();

            startTime = t;
        }
    }

    app.Cleanup();

    return (int) msg.wParam;
}
Beispiel #4
0
void main(void)
{
	app.Init();
	//std::thread T1(Thread1);
	//std::thread T2(Thread2);

	app.Run();
	//T1.join();
	//T2.join();
	app.Exit();
}
Beispiel #5
0
int main() {
    Application* app = new ObjApp( "ObjApp" );

    if( app->Init() == ApplicationFail::NONE ) {
        while( app->Tick() ) {
            app->Update();
            app->Render();
        }
        app->Shutdown();
    }

    return 0;
}
Beispiel #6
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
	Application* pApp;

	globalInstance = hInstance;

	pApp = CreateApplication();

	pApp->Init();
	pApp->SceneInit();
	pApp->Run();

	delete pApp;
	return 0;
}
Beispiel #7
0
int main(int argc, char** argv) {
	std::cout << "Beginning " << argv[0] << std::endl;
	try {
		Application app;
		app.Init(argc, argv);
		app.Proc();
		app.Quit();
	}
	catch(std::exception& e) {
		std::cerr << "Fatal Error: " << e.what() << std::endl;
		return 1;
	}
	std::cout << "Clean exit from " << argv[0] << std::endl;
	return 0;
}
Beispiel #8
0
int main(int argc, char* argv[])
{
	std::cout << "main::Starting..." << std::endl;
	do
	{
		htws_globals::Restart = false;
		Application application;
		application.Init(argv,argc);
		application.Run();
		SingletonRegistry::DestroyAll();
	}
	while(htws_globals::Restart);
	std::cout << "main::Stopped..." << std::endl;
	return 0;
}
Beispiel #9
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
#ifdef _DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

	Application* application = new Application;
	if(application->Init(&__argc,__argv,hInstance,hPrevInstance,lpCmdLine,nCmdShow)){
		application->Run();
	}
	application->Close();
	delete application;

	printf("Push any key to Exit\n");
	_getch();
	return 0;
}
Beispiel #10
0
int main(int argc, char** argv)
{
    Application* app;
    bool isController;

    if (argc < 2)
        STOP_FAIL(1, "Config file argument not given, exiting");
        
    if (!configFile.Init(argv[1]))
        STOP_FAIL(1, "Invalid config file (%s)", argv[1]);

    InitLog();
    ParseArgs(argc, argv);
    StartClock();
    ConfigureSystemSettings();
    
    IOProcessor::Init(configFile.GetIntValue("io.maxfd", 32768));
    InitContextTransport();
    BloomFilter::StaticInit();
    
    isController = IsController();
    LogPrintVersion(isController);
    if (isController)
        app = new ConfigServerApp;
    else
        app = new ShardServerApp;
    
    app->Init();
    
    IOProcessor::BlockSignals(IOPROCESSOR_BLOCK_ALL);
    EventLoop::Init();
    EventLoop::Run();
    
    Log_Message("Shutting down...");
    
    EventLoop::Shutdown();
    app->Shutdown();
    delete app;
    
    IOProcessor::Shutdown();
    StopClock();
    configFile.Shutdown();
    Log_Shutdown();

    return 0;
}
int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow) {
	System::OpenLog();
	System::Log("Logfile opening");

	if(!System::FileExists("../data/config.txt")) {
		System::Notify("Could not find a config-file!","Error!");
		return 1;
	};
	ConfigFile cfg("../data/config.txt");
	if(!cfg.HasKey("width")) {cfg.Set("width",ToString(1280));};
	if(!cfg.HasKey("height")) {cfg.Set("height",ToString(720));};
	if(!cfg.HasKey("m_yaw")) {cfg.Set("m_yaw",ToString(0.022f));};
	if(!cfg.HasKey("m_pitch")) {cfg.Set("m_pitch",ToString(-0.022f));};
	if(!cfg.HasKey("m_sensitivity")) {cfg.Set("m_sensitivity",ToString(50.0f));};
	if(!cfg.HasKey("c_speed")) {cfg.Set("c_speed",ToString(20.0f));};
	if(!cfg.HasKey("c_znear")) {cfg.Set("c_znear",ToString(0.5f));};
	if(!cfg.HasKey("c_zfar")) {cfg.Set("c_zfar",ToString(1000.0f));};

	const int width=cfg.AsInt("width"),height=cfg.AsInt("height");

	// create window class for registration
	WNDCLASSEX wc;
	wc.cbSize=sizeof(WNDCLASSEX);
	wc.style=CS_HREDRAW|CS_VREDRAW|CS_OWNDC;
	wc.lpfnWndProc=WndProc;
	wc.cbClsExtra=0;
	wc.cbWndExtra=0;
	wc.hInstance=hInstance;
	wc.hIcon=::LoadIcon(wc.hInstance,MAKEINTRESOURCE(IDI_GPIIBASE));
	wc.hIconSm=::LoadIcon(wc.hInstance,MAKEINTRESOURCE(IDI_GPIIBASE));
	wc.hCursor=::LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground=(HBRUSH)::GetStockObject(BLACK_BRUSH);
	wc.lpszMenuName=NULL;
	wc.lpszClassName=L"kWndCls";

	if(!::RegisterClassEx(&wc)) {
		System::Notify("Could not register window class","Error!");
		return 1;
	};

	unsigned int style=(WS_OVERLAPPEDWINDOW&~(WS_THICKFRAME|WS_MAXIMIZEBOX|WS_MINIMIZEBOX));
	RECT rc={0,0,width,height}; 
	::AdjustWindowRect(&rc,style,FALSE); 

	// create the main window
	HWND hWnd=::CreateWindow(
		L"kWndCls",
		L"RenderWindow",
		style,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		rc.right-rc.left,
		rc.bottom-rc.top,
		NULL,NULL,
		hInstance,
		NULL);
	if(hWnd==NULL) {
		System::Notify("Could not create a window","Error!");
		return 1;
	};

	::ShowWindow(hWnd,nCmdShow);
	::UpdateWindow(hWnd);

	// create application
	Application application;
	if(!application.Init(&message_system,hWnd,cfg)) {
		System::Notify("Could not initialize Application!\n"\
			"Read log.txt for more information.","Error!");
		return -1;
	};

	MSG msg={0};
	while(msg.message!=WM_QUIT) {
		if(::PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		else {
			application.Tick();
			::Sleep(2);
		};
	};

	application.Shut();

	::DestroyWindow(hWnd);

	System::Log("Logfile closing");
	System::CloseLog();

	return 0;
};
Beispiel #12
0
int main(int argc, char ** argv)
{

	LOG("Starting game '%s'...", TITLE);

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

	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;
			}

			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("Exiting game '%s'...\n", TITLE);
	return main_return;
}
Beispiel #13
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;
}
Beispiel #14
0
	void lime_application_init (value application) {
		
		Application* app = (Application*)val_data (application);
		app->Init ();
		
	}
Beispiel #15
0
int main(int argc, char *argv[])
{
	int main_return = EXIT_SUCCESS;
	main_states state = MAIN_START;
	update_status update_state;

	if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS) == -1)
	{
		LOG("Application exit with error: %s", SDL_GetError());
		return EXIT_FAILURE;
	}

	Application app;

	while (state != MAIN_EXIT)
	{
		switch (state)
		{
		case MAIN_UPDATE:            //------------------UPDATE-----------------
			//LOG("UPDATING:");
			switch (update_state)
			{
			case UPDATE_CONTINUE:
				update_state = app.Update();
				break;
			case UPDATE_ERROR:
				state = MAIN_ERROR;
				break;
			case UPDATE_STOP:
				state = MAIN_FINISH;
				break;
			default:
				if (!app.ChangeTo(update_state)){ state = MAIN_ERROR; }
				else { update_state = UPDATE_CONTINUE; }
				break;
			}

			break;
		
		case MAIN_ERROR:            //------------------ERROR-----------------
			LOG("Application exit with error: %s", SDL_GetError());
			main_return = EXIT_FAILURE;
			state = MAIN_EXIT;
			break;
		
		case MAIN_START:            //------------------START-----------------
			LOG("Starting Application:");
			if (!app.Init()){ state = MAIN_ERROR; }
			else { state = MAIN_UPDATE; update_state = CHANGE_TO_TITLE; }
			break;
		
		case MAIN_FINISH:            //------------------FINISH-----------------
			LOG("Finishing Application:");
			if (!app.CleanUp()){ state = MAIN_ERROR; }
			else{ state = MAIN_EXIT; }
			SDL_Quit();
			break;
		}
	}
	return main_return;
}