about summary refs log tree commit diff
path: root/src/engine/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/client')
-rw-r--r--src/engine/client/ec_client.c10
-rw-r--r--src/engine/client/ec_gfx.c198
-rw-r--r--src/engine/client/ec_inp.c141
-rw-r--r--src/engine/client/ec_snd.c77
4 files changed, 46 insertions, 380 deletions
diff --git a/src/engine/client/ec_client.c b/src/engine/client/ec_client.c
index 1c499e85..73dd921f 100644
--- a/src/engine/client/ec_client.c
+++ b/src/engine/client/ec_client.c
@@ -1574,7 +1574,7 @@ static void client_run()
 				inp_mouse_mode_absolute();
 			window_must_refocus = 1;
 		}
-		else if (config.dbg_focus && inp_key_pressed(KEY_ESC))
+		else if (config.dbg_focus && inp_key_pressed(KEY_ESCAPE))
 		{
 			inp_mouse_mode_absolute();
 			window_must_refocus = 1;
@@ -1597,19 +1597,11 @@ static void client_run()
 		}
 
 		/* panic quit button */
-		#ifdef CONFIG_NO_SDL
-		if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('Q'))
-			break;
-
-		if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('E'))
-			config.cl_editor = config.cl_editor^1;
-		#else
 		if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_pressed('q'))
 			break;
 
 		if(inp_key_pressed(KEY_LCTRL) && inp_key_pressed(KEY_LSHIFT) && inp_key_down('e'))
 			config.cl_editor = config.cl_editor^1;
-		#endif
 		
 		if(!gfx_window_open())
 			break;
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index 35e43e41..8ed6a737 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -2,24 +2,19 @@
 
 #include <base/detect.h>
 
-#ifdef CONFIG_NO_SDL
-	#include <GL/glfw.h>
-#else
-	#include "SDL.h"
-	
-	#ifdef CONF_FAMILY_WINDOWS
-		#define WIN32_LEAN_AND_MEAN
-		#include <windows.h>
-	#endif
-	
-	#ifdef CONF_PLATFORM_MACOSX
-		#include <OpenGL/gl.h>
-		#include <OpenGL/glu.h>
-	#else
-		#include <GL/gl.h>
-		#include <GL/glu.h>
-	#endif
+#include "SDL.h"
+
+#ifdef CONF_FAMILY_WINDOWS
+	#define WIN32_LEAN_AND_MEAN
+	#include <windows.h>
+#endif
 
+#ifdef CONF_PLATFORM_MACOSX
+	#include <OpenGL/gl.h>
+	#include <OpenGL/glu.h>
+#else
+	#include <GL/gl.h>
+	#include <GL/glu.h>
 #endif
 
 #include <base/system.h>
@@ -99,10 +94,7 @@ static TEXTURE textures[MAX_TEXTURES];
 static int first_free_texture;
 static int memory_usage = 0;
 
-#ifdef CONFIG_NO_SDL
-#else
-	SDL_Surface *screen_surface;
-#endif
+static SDL_Surface *screen_surface;
 
 
 #if 0
@@ -316,15 +308,6 @@ static void draw_quad()
 		flush();
 }
 
-#ifdef CONFIG_NO_SDL
-static void screen_resize(int width, int height)
-{
-	screen_width = width;
-	screen_height = height;
-	glViewport(0, 0, screen_width, screen_height);
-}
-#endif
-
 int gfx_init()
 {
 	int i;
@@ -339,57 +322,6 @@ int gfx_init()
 		screen_height = 240;
 	}
 
-
-#ifdef CONFIG_NO_SDL
-	glfwInit();
-
-	/* set antialiasing	*/
-	if(config.gfx_fsaa_samples)
-		glfwOpenWindowHint(GLFW_FSAA_SAMPLES, config.gfx_fsaa_samples);
-	
-	/* set refresh rate */
-	if(config.gfx_refresh_rate)
-		glfwOpenWindowHint(GLFW_REFRESH_RATE, config.gfx_refresh_rate);
-	
-	/* no resizing allowed */
-	if (!config.gfx_debug_resizable)
-		glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, 1);
-		
-	/* open window */	
-	if(config.gfx_fullscreen)
-	{
-		int result = glfwOpenWindow(screen_width, screen_height, 8, 8, 8, config.gfx_alphabits, 24, 0, GLFW_FULLSCREEN);
-		if(result != GL_TRUE)
-		{
-			dbg_msg("game", "failed to create gl context");
-			return 0;
-		}
-	}
-	else
-	{
-		int result = glfwOpenWindow(screen_width, screen_height, 0, 0, 0, config.gfx_alphabits, 24, 0, GLFW_WINDOW);
-		if(result != GL_TRUE)
-		{
-			dbg_msg("game", "failed to create gl context");
-			return 0;
-		}
-	}
-	
-	glfwSetWindowSizeCallback(screen_resize);
-	
-	glGetIntegerv(GL_ALPHA_BITS, &i);
-	dbg_msg("gfx", "alphabits = %d", i);
-	glGetIntegerv(GL_DEPTH_BITS, &i);
-	dbg_msg("gfx", "depthbits = %d", i);
-	glGetIntegerv(GL_STENCIL_BITS, &i);
-	dbg_msg("gfx", "stencilbits = %d", i);
-	
-	glfwSetWindowTitle("Teeworlds");
-	
-	/* We don't want to see the window when we run the stress testing */
-	if(config.dbg_stress)
-		glfwIconifyWindow();
-#else
 	if(SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0)
 	{
         dbg_msg("gfx", "Unable to init SDL: %s\n", SDL_GetError());
@@ -443,8 +375,6 @@ int gfx_init()
 	}
 	
 	SDL_ShowCursor(0);
-
-#endif
 	
 	/* Init vertices */
 	if (vertices)
@@ -535,20 +465,12 @@ void gfx_mask_op(int mask, int write)
 
 int gfx_window_active()
 {
-#ifdef CONFIG_NO_SDL
-	return glfwGetWindowParam(GLFW_ACTIVE) == GL_TRUE ? 1 : 0;
-#else
-	return SDL_GetAppState()&SDL_APPINPUTFOCUS; /* TODO: SDL*/
-#endif
+	return SDL_GetAppState()&SDL_APPINPUTFOCUS;
 }
 
 int gfx_window_open()
 {
-#ifdef CONFIG_NO_SDL
-	return glfwGetWindowParam(GLFW_OPENED) == GL_TRUE ? 1 : 0;
-#else
-	return SDL_GetAppState()&SDL_APPACTIVE; /* TODO: SDL*/
-#endif
+	return SDL_GetAppState()&SDL_APPACTIVE;
 }
 
 VIDEO_MODE fakemodes[] = {
@@ -577,6 +499,9 @@ VIDEO_MODE fakemodes[] = {
 
 int gfx_get_video_modes(VIDEO_MODE *list, int maxcount)
 {
+	int num_modes = 0;
+	SDL_Rect **modes;
+
 	if(config.gfx_display_all_modes)
 	{
 		int count = sizeof(fakemodes)/sizeof(VIDEO_MODE);
@@ -586,52 +511,39 @@ int gfx_get_video_modes(VIDEO_MODE *list, int maxcount)
 		return count;
 	}
 	
-#ifdef CONFIG_NO_SDL
-	return glfwGetVideoModes((GLFWvidmode *)list, maxcount);
-#else
+	/* TODO: fix this code on osx or windows */
+		
+	modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|SDL_FULLSCREEN);
+	if(modes == NULL)
 	{
-		/* TODO: fix this code on osx or windows */
-		int num_modes = 0;
-		SDL_Rect **modes;
-			
-		modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_GL_DOUBLEBUFFER|SDL_FULLSCREEN);
-		if(modes == NULL)
-		{
-			/* no modes */
-		}
-		else if(modes == (SDL_Rect**)-1)
-		{
-			/* all modes */
-		}
-		else
+		/* no modes */
+	}
+	else if(modes == (SDL_Rect**)-1)
+	{
+		/* all modes */
+	}
+	else
+	{
+		int i;
+		for(i = 0; modes[i]; ++i)
 		{
-			int i;
-			for(i = 0; modes[i]; ++i)
-			{
-				if(num_modes == maxcount)
-					break;
-				list[num_modes].width = modes[i]->w;
-				list[num_modes].height = modes[i]->h;
-				list[num_modes].red = 8;
-				list[num_modes].green = 8;
-				list[num_modes].blue = 8;
-				num_modes++;
-			}
+			if(num_modes == maxcount)
+				break;
+			list[num_modes].width = modes[i]->w;
+			list[num_modes].height = modes[i]->h;
+			list[num_modes].red = 8;
+			list[num_modes].green = 8;
+			list[num_modes].blue = 8;
+			num_modes++;
 		}
 	}
 	
-
 	return 1; /* TODO: SDL*/
-#endif	
 }
 
 void gfx_set_vsync(int val)
 {
-#ifdef CONFIG_NO_SDL
-	glfwSwapInterval(val);
-#else
 	/* TODO: SDL*/
-#endif	
 }
 
 int gfx_unload_texture(int index)
@@ -836,13 +748,9 @@ void gfx_shutdown()
 {
 	if (vertices)
 		mem_free(vertices);
-#ifdef CONFIG_NO_SDL
-	glfwCloseWindow();
-	glfwTerminate();
-#else
+
 	/* TODO: SDL, is this correct? */
 	SDL_Quit();
-#endif	
 }
 
 void gfx_screenshot()
@@ -926,26 +834,12 @@ void gfx_swap()
 	{
 		static PERFORMACE_INFO pscope = {"glfwSwapBuffers", 0};
 		perf_start(&pscope);
-#ifdef CONFIG_NO_SDL
-		glfwSwapBuffers();
-#else
 		SDL_GL_SwapBuffers();
-#endif
 		perf_end();
 	}
 	
 	if(render_enable && config.gfx_finish)
 		glFinish();
-
-#ifdef CONFIG_NO_SDL
-	{
-		static PERFORMACE_INFO pscope = {"glfwPollEvents", 0};
-		perf_start(&pscope);
-		glfwPollEvents();
-		perf_end();
-	}
-#else
-#endif
 }
 
 void gfx_screenshot_direct(const char *filename)
@@ -1500,16 +1394,10 @@ void gfx_clip_disable()
 
 void gfx_minimize()
 {
-#ifdef CONFIG_NO_SDL
-	glfwIconifyWindow();
-#else
-#endif
+	/* TODO: SDL */
 }
 
 void gfx_maximize()
 {
-#ifdef CONFIG_NO_SDL
-	glfwRestoreWindow();
-#else
-#endif
+	/* TODO: SDL */
 }
diff --git a/src/engine/client/ec_inp.c b/src/engine/client/ec_inp.c
index 74c79c90..2aff68d6 100644
--- a/src/engine/client/ec_inp.c
+++ b/src/engine/client/ec_inp.c
@@ -1,10 +1,6 @@
 /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
 #include <string.h>
-#ifdef CONFIG_NO_SDL
-	#include <GL/glfw.h>
-#else
-	#include "SDL.h"
-#endif
+#include "SDL.h"
 
 #include <base/system.h>
 #include <engine/e_client_interface.h>
@@ -19,12 +15,8 @@ static struct
 static unsigned char input_state[2][1024] = {{0}, {0}};
 
 static int input_current = 0;
-#ifdef CONFIG_NO_SDL
-static int keyboard_first = 1;
-#else
 static int input_grabbed = 0;
 static int input_use_grab = 0;
-#endif
 
 static unsigned int last_release = 0;
 static unsigned int release_delta = -1;
@@ -43,17 +35,6 @@ void inp_mouse_relative(int *x, int *y)
 		last_sens = config.inp_mousesens;
 	}
 	
-#ifdef CONFIG_NO_SDL
-	glfwGetMousePos(&nx, &ny);
-
-	nx *= sens;
-	ny *= sens;
-	
-	*x = nx-last_x;
-	*y = ny-last_y;
-	last_x = nx;
-	last_y = ny;
-#else
 	if(input_use_grab)
 		SDL_GetRelativeMouseState(&nx, &ny);
 	else
@@ -68,7 +49,6 @@ void inp_mouse_relative(int *x, int *y)
 
 	*x = nx*sens;
 	*y = ny*sens;
-#endif
 }
 
 enum
@@ -111,98 +91,6 @@ INPUT_EVENT inp_get_event(int index)
 	return input_events[index];
 }
 
-#ifdef CONFIG_NO_SDL
-static void char_callback(int character, int action)
-{
-	if(action == GLFW_PRESS && character < 256)
-		add_event((char)character, 0, 0);
-}
-
-static void key_callback(int key, int action)
-{
-	if(action == GLFW_PRESS)
-		add_event(0, key, INPFLAG_PRESS);
-	else
-		add_event(0, key, INPFLAG_RELEASE);
-	
-	if(action == GLFW_PRESS)
-		input_count[input_current^1][key].presses++;
-	if(action == GLFW_RELEASE)
-		input_count[input_current^1][key].releases++;
-	input_state[input_current^1][key] = action;
-}
-
-static void mousebutton_callback(int button, int action)
-{
-	if(action == GLFW_PRESS)
-		add_event(0, KEY_MOUSE_FIRST+button, INPFLAG_PRESS);
-	else
-		add_event(0, KEY_MOUSE_FIRST+button, INPFLAG_RELEASE);
-		
-	if(action == GLFW_PRESS)
-		input_count[input_current^1][KEY_MOUSE_FIRST+button].presses++;
-	if(action == GLFW_RELEASE)
-	{
-		if(button == 0)
-		{
-			release_delta = time_get() - last_release;
-			last_release = time_get();
-		}
-		input_count[input_current^1][KEY_MOUSE_FIRST+button].releases++;
-	}
-	input_state[input_current^1][KEY_MOUSE_FIRST+button] = action;
-}
-
-
-static void mousewheel_callback(int pos)
-{
-	if(pos > 0)
-	{
-		while(pos-- != 0)
-		{
-			input_count[input_current^1][KEY_MOUSE_WHEEL_UP].presses++;
-			input_count[input_current^1][KEY_MOUSE_WHEEL_UP].releases++;
-		}
-		
-		add_event(0, KEY_MOUSE_WHEEL_UP, INPFLAG_PRESS);
-		add_event(0, KEY_MOUSE_WHEEL_UP, INPFLAG_RELEASE);
-	}
-	else if(pos < 0)
-	{
-		while(pos++ != 0)
-		{
-			input_count[input_current^1][KEY_MOUSE_WHEEL_DOWN].presses++;
-			input_count[input_current^1][KEY_MOUSE_WHEEL_DOWN].releases++;
-		}	
-
-		add_event(0, KEY_MOUSE_WHEEL_DOWN, INPFLAG_PRESS);
-		add_event(0, KEY_MOUSE_WHEEL_DOWN, INPFLAG_RELEASE);
-	}
-	glfwSetMouseWheel(0);
-}
-
-
-void inp_init()
-{
-	glfwEnable(GLFW_KEY_REPEAT);
-	glfwSetCharCallback(char_callback);
-	glfwSetKeyCallback(key_callback);
-	glfwSetMouseButtonCallback(mousebutton_callback);
-	glfwSetMouseWheelCallback(mousewheel_callback);
-}
-
-void inp_mouse_mode_absolute()
-{
-	glfwEnable(GLFW_MOUSE_CURSOR);
-}
-
-void inp_mouse_mode_relative()
-{
-	/*if (!config.gfx_debug_resizable)*/
-	glfwDisable(GLFW_MOUSE_CURSOR);
-}
-#else
-
 void inp_init()
 {
 	SDL_EnableUNICODE(1);
@@ -224,7 +112,6 @@ void inp_mouse_mode_relative()
 	if(input_use_grab)
 		SDL_WM_GrabInput(SDL_GRAB_ON);
 }
-#endif
 
 int inp_mouse_doubleclick()
 {
@@ -259,31 +146,6 @@ int inp_button_pressed(int button) { return input_state[input_current][button];
 
 void inp_update()
 {
-#ifdef CONFIG_NO_SDL
-    int i, v;
-
-	/* clear and begin count on the other one */
-	mem_zero(&input_count[input_current], sizeof(input_count[input_current]));
-	mem_copy(input_state[input_current], input_state[input_current^1], sizeof(input_state[input_current]));
-	input_current^=1;
-
-    if(keyboard_first)
-    {
-        /* make sure to reset */
-        keyboard_first = 0;
-        inp_update();
-    }
-    
-    /*keyboard_current = keyboard_current^1;*/
-    for(i = 0; i < KEY_LAST; i++)
-    {
-	    if (i >= KEY_MOUSE_FIRST)
-			v = glfwGetMouseButton(i-KEY_MOUSE_FIRST) == GLFW_PRESS ? 1 : 0;
-		else
-			v = glfwGetKey(i) == GLFW_PRESS ? 1 : 0;
-        input_state[input_current][i] = v;
-    }
-#else
 	int i;
 	
 	if(input_grabbed && !gfx_window_active())
@@ -368,5 +230,4 @@ void inp_update()
 
 		}
 	}
-#endif
 }
diff --git a/src/engine/client/ec_snd.c b/src/engine/client/ec_snd.c
index 11c19d2d..a7219b65 100644
--- a/src/engine/client/ec_snd.c
+++ b/src/engine/client/ec_snd.c
@@ -4,12 +4,7 @@
 #include <engine/e_config.h>
 #include <engine/e_engine.h>
 
-#ifdef CONFIG_NO_SDL
-	#include <portaudio.h>
-#else
-	#include "SDL.h"
-#endif
-
+#include "SDL.h"
 
 #include <engine/external/wavpack/wavpack.h>
 #include <stdio.h>
@@ -239,76 +234,13 @@ static void mix(short *final_out, unsigned frames)
 	}
 }
 
-#ifdef CONFIG_NO_SDL
-static PaStream *stream;
-static int pacallback(const void *in, void *out, unsigned long frames, const PaStreamCallbackTimeInfo* time, PaStreamCallbackFlags status, void *user)
-{
-	mix(out, frames);
-	return 0;
-}
-#else
 static void sdlcallback(void *unused, Uint8 *stream, int len)
 {
 	mix((short *)stream, len/2/2);
 }
-#endif
-
 
 int snd_init()
 {
-#ifdef CONFIG_NO_SDL
-	PaStreamParameters params;
-	PaError err = Pa_Initialize();
-	
-	sound_lock = lock_create();
-	
-	if(!config.snd_enable)
-		return 0;
-	
-	mixing_rate = config.snd_rate;
-
-	{
-		int num = Pa_GetDeviceCount();
-		int i;
-		const PaDeviceInfo *info;
-		
-		for(i = 0; i < num; i++)
-		{
-			info = Pa_GetDeviceInfo(i);
-			dbg_msg("snd", "device #%d name='%s'", i, info->name);
-		}
-	}
-
-	params.device = config.snd_device;
-	if(params.device == -1)
-	{
-		params.device = Pa_GetDefaultOutputDevice();
-		if(params.device < 0)
-		{
-			dbg_msg("snd", "no default device (%d)", params.device);
-			return 1;
-		}
-	}
-
-	if(params.device < 0)
-		return 1;
-	dbg_msg("snd", "device = %d", params.device);
-	params.channelCount = 2;
-	params.sampleFormat = paInt16;
-	params.suggestedLatency = Pa_GetDeviceInfo(params.device)->defaultLowOutputLatency;
-	params.hostApiSpecificStreamInfo = 0x0;
-
-	err = Pa_OpenStream(
-			&stream,        /* passes back stream pointer */
-			0,              /* no input channels */
-			&params,                /* pointer to parameters */
-			mixing_rate,          /* sample rate */
-			128,            /* frames per buffer */
-			paClipOff,              /* no clamping */
-			pacallback,             /* specify our custom callback */
-			0x0); /* pass our data through to callback */
-	err = Pa_StartStream(stream);
-#else
     SDL_AudioSpec format;
 	
 	sound_lock = lock_create();
@@ -337,7 +269,6 @@ int snd_init()
 
 	SDL_PauseAudio(0);
 	
-#endif
 	sound_enabled = 1;
 	snd_update(); /* update the volume */
 	return 0;
@@ -363,14 +294,8 @@ int snd_update()
 
 int snd_shutdown()
 {
-#ifdef CONFIG_NO_SDL	
-	Pa_StopStream(stream);
-	Pa_Terminate();
-#else
 	SDL_CloseAudio();
-#endif
 	lock_destroy(sound_lock);
-
 	return 0;
 }