示例#1
0
//
// MidiRPC_StopServer
//
// Stops the RPC server so the program can shutdown.
//
void MidiRPC_StopServer()
{
    // Local shutdown tasks
    ShutdownSDL();
    delete song;
    song = NULL;

    // Stop RPC server
    RpcMgmtStopServerListening(NULL);
}
示例#2
0
void Shutdown(int UNUSED(flags))
{
	EndGame();

	ShutdownPs(); // Must delete g_GUI before g_ScriptingHost

	in_reset_handlers();

	TIMER_BEGIN(L"shutdown TexMan");
	delete &g_TexMan;
	TIMER_END(L"shutdown TexMan");

	// destroy renderer
	TIMER_BEGIN(L"shutdown Renderer");
	delete &g_Renderer;
	g_VBMan.Shutdown();
	TIMER_END(L"shutdown Renderer");

	tex_codec_unregister_all();

	g_Profiler2.ShutdownGPU();

	// Free cursors before shutting down SDL, as they may depend on SDL.
	cursor_shutdown();

	TIMER_BEGIN(L"shutdown SDL");
	ShutdownSDL();
	TIMER_END(L"shutdown SDL");

	g_VideoMode.Shutdown();

	TIMER_BEGIN(L"shutdown UserReporter");
	g_UserReporter.Deinitialize();
	TIMER_END(L"shutdown UserReporter");

	TIMER_BEGIN(L"shutdown ScriptingHost");
	delete &g_ScriptingHost;
	TIMER_END(L"shutdown ScriptingHost");

	TIMER_BEGIN(L"shutdown ConfigDB");
	delete &g_ConfigDB;
	TIMER_END(L"shutdown ConfigDB");

	// resource
	// first shut down all resource owners, and then the handle manager.
	TIMER_BEGIN(L"resource modules");
#if CONFIG2_AUDIO
		if (g_SoundManager)
			delete g_SoundManager;
#endif

		g_VFS.reset();

		// this forcibly frees all open handles (thus preventing real leaks),
		// and makes further access to h_mgr impossible.
		h_mgr_shutdown();

		file_stats_dump();

	TIMER_END(L"resource modules");

	TIMER_BEGIN(L"shutdown misc");
		timer_DisplayClientTotals();

		CNetHost::Deinitialize();

		SAFE_DELETE(g_ScriptStatsTable);

		// should be last, since the above use them
		SAFE_DELETE(g_Logger);
		delete &g_Profiler;
		delete &g_ProfileViewer;
	TIMER_END(L"shutdown misc");

#if OS_WIN
	TIMER_BEGIN(L"shutdown wmi");
	wmi_Shutdown();
	TIMER_END(L"shutdown wmi");
#endif
}
示例#3
0
void Shutdown(int flags)
{
	if ((flags & SHUTDOWN_FROM_CONFIG))
		goto from_config;

	EndGame();

	SAFE_DELETE(g_XmppClient);

	ShutdownPs();

	TIMER_BEGIN(L"shutdown TexMan");
	delete &g_TexMan;
	TIMER_END(L"shutdown TexMan");

	// destroy renderer
	TIMER_BEGIN(L"shutdown Renderer");
	delete &g_Renderer;
	g_VBMan.Shutdown();
	TIMER_END(L"shutdown Renderer");

	g_Profiler2.ShutdownGPU();

	#if OS_WIN
		TIMER_BEGIN(L"shutdown wmi");
		wmi_Shutdown();
		TIMER_END(L"shutdown wmi");
	#endif

	// Free cursors before shutting down SDL, as they may depend on SDL.
	cursor_shutdown();

	TIMER_BEGIN(L"shutdown SDL");
	ShutdownSDL();
	TIMER_END(L"shutdown SDL");

	g_VideoMode.Shutdown();

	TIMER_BEGIN(L"shutdown UserReporter");
	g_UserReporter.Deinitialize();
	TIMER_END(L"shutdown UserReporter");


	// JS debugger temporarily disabled during the SpiderMonkey upgrade (check trac ticket #2348 for details)
	//TIMER_BEGIN(L"shutdown DebuggingServer (if active)");
	//delete g_DebuggingServer;
	//TIMER_END(L"shutdown DebuggingServer (if active)");

	delete &g_L10n;

from_config:
	TIMER_BEGIN(L"shutdown ConfigDB");
	delete &g_ConfigDB;
	TIMER_END(L"shutdown ConfigDB");

	SAFE_DELETE(g_Console);

	// This is needed to ensure that no callbacks from the JSAPI try to use
	// the profiler when it's already destructed
	g_ScriptRuntime.reset();

	// resource
	// first shut down all resource owners, and then the handle manager.
	TIMER_BEGIN(L"resource modules");

		ISoundManager::SetEnabled(false);

		g_VFS.reset();

		// this forcibly frees all open handles (thus preventing real leaks),
		// and makes further access to h_mgr impossible.
		h_mgr_shutdown();

		file_stats_dump();

	TIMER_END(L"resource modules");

	TIMER_BEGIN(L"shutdown misc");
		timer_DisplayClientTotals();

		CNetHost::Deinitialize();

		// should be last, since the above use them
		SAFE_DELETE(g_Logger);
		delete &g_Profiler;
		delete &g_ProfileViewer;

		SAFE_DELETE(g_ScriptStatsTable);
	TIMER_END(L"shutdown misc");
}
示例#4
0
i32 RunApplicationMainLoop() {
	SDL_Event event;
	bool active = true;
	while (active) {
		while (SDL_PollEvent(&event)) {

			switch (event.type) {

			case SDL_QUIT:
				active = false;
				break;
			case SDL_KEYDOWN:
				if (event.key.keysym.sym == SDLK_ESCAPE) {
					active = false;
					break;
				}
				else {
					GApplicationKeyDownFunction(event.key.keysym.sym);
				}
				break;
			case SDL_TEXTINPUT:
				{
					GApplicationTextInputFunction((wchar_t*)event.text.text);
				}
				break;
			case SDL_MOUSEWHEEL:
				{
					GApplicationMouseWheelFunction(event.wheel.y);
				}
				break;
			case SDL_DROPFILE:
				{
					const char* path = event.drop.file;
					GApplicationFileDropFunction(path);
					SDL_free((void*)path);
				}
				break;
			case SDL_WINDOWEVENT:
				{
					switch (event.window.event) {
					case SDL_WINDOWEVENT_RESIZED:
						{
							GDisplaySettings.resolution.x = event.window.data1;
							GDisplaySettings.resolution.y = event.window.data2;
							WaitForCompletion();
							ResizeSwapChain(GDisplaySettings.resolution.x, GDisplaySettings.resolution.y);
							GApplicationWindowResizeFunction();
						}
						break;
					}
				}
				break;
			}
		}

		static INT64 PreviousTime = 0;
		static INT64 TicksPerSecond = 0;

		INT64 currentTime;
		Verify(QueryPerformanceCounter((LARGE_INTEGER *)&currentTime));

		double DeltaTime = (double)(currentTime - PreviousTime) / (double)TicksPerSecond;

		if (TicksPerSecond == 0) {
			Verify(QueryPerformanceFrequency((LARGE_INTEGER *)&TicksPerSecond));

			DeltaTime = 1. / 60.;
		}
		PreviousTime = currentTime;

		float fDeltaTime = (float)DeltaTime;

		ImGuiIO& io = ImGui::GetIO();
		RECT rect;
		GetClientRect(GDisplaySettings.hwnd, &rect);

		io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
		io.DeltaTime = (float)DeltaTime;
		io.MouseDrawCursor = true;
		SDL_ShowCursor(SDL_DISABLE);

		io.KeyShift = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_LSHIFT];
		io.KeyCtrl = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_LCTRL];
		io.KeyAlt = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_LALT];

		io.KeysDown[SDL_SCANCODE_TAB] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_TAB];
		io.KeysDown[SDL_SCANCODE_LEFT] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_LEFT];
		io.KeysDown[SDL_SCANCODE_RIGHT] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_RIGHT];
		io.KeysDown[SDL_SCANCODE_UP] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_UP];
		io.KeysDown[SDL_SCANCODE_DOWN] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_DOWN];
		io.KeysDown[SDL_SCANCODE_HOME] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_HOME];
		io.KeysDown[SDL_SCANCODE_END] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_END];
		io.KeysDown[SDL_SCANCODE_DELETE] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_DELETE];
		io.KeysDown[SDL_SCANCODE_RETURN] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_RETURN];
		io.KeysDown[SDL_SCANCODE_ESCAPE] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_ESCAPE];
		io.KeysDown[SDL_SCANCODE_BACKSPACE] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_BACKSPACE];
		io.KeysDown[SDL_SCANCODE_A] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_A];
		io.KeysDown[SDL_SCANCODE_C] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_C];
		io.KeysDown[SDL_SCANCODE_V] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_V];
		io.KeysDown[SDL_SCANCODE_X] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_X];
		io.KeysDown[SDL_SCANCODE_Y] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_Y];
		io.KeysDown[SDL_SCANCODE_Z] = !!SDL_GetKeyboardState(NULL)[SDL_SCANCODE_Z];

		int x, y;
		auto buttonState = SDL_GetMouseState(&x, &y);
		io.MousePos = ImVec2((float)x, (float)y);
		io.MouseDown[0] = !!(buttonState & SDL_BUTTON(SDL_BUTTON_LEFT));
		io.MouseDown[1] = !!(buttonState & SDL_BUTTON(SDL_BUTTON_RIGHT));
		io.MouseDown[2] = !!(buttonState & SDL_BUTTON(SDL_BUTTON_MIDDLE));

		ImGui::NewFrame();

		GApplicationTickFunction(fDeltaTime);

		EndCommandsFrame(GGPUMainQueue);
	}

	GApplicationShutdownFunction();

	WaitForCompletion();
	FreeModelsMemory();
	ImGui::Shutdown();
	ShutdownRenderingEngines();
	ShutdownResources();
	ShutdownDevice();
	FreeShadersMemory();

	ShutdownSDL(SDLWindow);

	ShutdownScheduler();
	ShutdownProfiler();
	ShutdownMainThread();
	return 0;
}