about summary refs log tree commit diff
path: root/src/engine/client/client.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2012-01-03 21:39:10 +0100
committerMagnus Auvinen <magnus.auvinen@gmail.com>2012-01-03 21:39:10 +0100
commit50d872531aae6640f57da98e8dcf6dbae1f9cd82 (patch)
treee3a88d02f1b7ec3a37a4e3b6acb2413e51cbebc2 /src/engine/client/client.cpp
parente59b24d8db8a7a9ec21c654302d89e01903f4d96 (diff)
downloadzcatch-50d872531aae6640f57da98e8dcf6dbae1f9cd82.tar.gz
zcatch-50d872531aae6640f57da98e8dcf6dbae1f9cd82.zip
cleaned up the code. fixed so that SDL is inited on main thread and then transfers the gl context to the render thread
Diffstat (limited to 'src/engine/client/client.cpp')
-rw-r--r--src/engine/client/client.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp
index b7244db4..5067f8b2 100644
--- a/src/engine/client/client.cpp
+++ b/src/engine/client/client.cpp
@@ -1690,11 +1690,24 @@ void CClient::InitInterfaces()
 	m_Friends.Init();
 }
 
+#include "SDL.h"
+
 void CClient::Run()
 {
 	m_LocalStartTime = time_get();
 	m_SnapshotParts = 0;
 
+	// init SDL
+	{
+		if(SDL_Init(0) < 0)
+		{
+			dbg_msg("client", "unable to init SDL base: %s", SDL_GetError());
+			return;
+		}
+
+		atexit(SDL_Quit); // ignore_convention
+	}
+
 	// init graphics
 	{
 		if(g_Config.m_GfxThreaded)
@@ -1713,6 +1726,9 @@ void CClient::Run()
 		}
 	}
 
+	// init sound, allowed to fail
+	m_SoundInitFailed = Sound()->Init() != 0;
+
 	// open socket
 	{
 		NETADDR BindAddr;
@@ -1737,8 +1753,6 @@ void CClient::Run()
 	// init the editor
 	//m_pEditor->Init();
 
-	// init sound, allowed to fail
-	m_SoundInitFailed = Sound()->Init() != 0;
 
 	// load data
 	if(!LoadData())
@@ -1937,6 +1951,11 @@ void CClient::Run()
 
 	m_pGraphics->Shutdown();
 	m_pSound->Shutdown();
+
+	// shutdown SDL
+	{
+		SDL_Quit();
+	}
 }