SDL works a bit better now
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@768 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
0ce5b03f32
commit
b192d3a175
7 changed files with 549 additions and 29 deletions
|
@ -5,9 +5,9 @@ CPUOPTIMIZATIONS=
|
|||
BASE_DIR=.
|
||||
|
||||
ifeq ($(FTE_TARGET),)
|
||||
ifdef windir
|
||||
FTE_TARGET=win32
|
||||
endif
|
||||
# ifdef windir
|
||||
# FTE_TARGET=win32
|
||||
# endif
|
||||
|
||||
FTE_TARGET ?= sdl
|
||||
endif
|
||||
|
@ -320,31 +320,31 @@ endif
|
|||
MCL_DIR=mcl_mgw
|
||||
|
||||
else
|
||||
#if FTE_TARGET != win32 (so sdl builds then)
|
||||
|
||||
|
||||
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o
|
||||
GLCL_OBJS=$(GL_OBJS) $(GLQUAKE_OBJS) gl_vidsdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o
|
||||
GL_EXE_NAME=../fteqw_sdl.gl
|
||||
GLCL_EXE_NAME=../fteqwcl_sdl.gl
|
||||
ifdef windir
|
||||
GL_LDFLAGS=$(GLLDFLAGS) -lmingw32 -lwsock32 -lSDLmain -lSDL
|
||||
GL_LDFLAGS=$(GLLDFLAGS) -lmingw32 -lwsock32 `sdl-config --libs`
|
||||
else
|
||||
#pthread is needed because of SDL.
|
||||
GL_LDFLAGS=$(GLLDFLAGS) -lSDLmain -lSDL -lpng -ljpeg -lpthread
|
||||
GL_LDFLAGS=$(GLLDFLAGS) -lpng -ljpeg `sdl-config --libs`
|
||||
endif
|
||||
GL_CFLAGS=$(GLCFLAGS)
|
||||
GL_CFLAGS=$(GLCFLAGS) `sdl-config --cflags`
|
||||
GLB_DIR=gl_sdl
|
||||
GLCL_DIR=glcl_sdl
|
||||
|
||||
SWCL_OBJS=$(SOFTWARE_OBJS) vid_sdl.o snd_sdl.o cd_sdl.o sys_sdl.o
|
||||
SW_EXE_NAME=../fteswqw.sw
|
||||
SWCL_EXE_NAME=../fteswqwcl.sw
|
||||
SWCL_OBJS=$(SOFTWARE_OBJS) vid_sdl.o snd_sdl.o cd_sdl.o sys_sdl.o in_sdl.o
|
||||
SW_EXE_NAME=../fteqw_sdl.sw
|
||||
SWCL_EXE_NAME=../fteqwcl_sdl.sw
|
||||
ifdef windir
|
||||
SW_LDFLAGS=$(SWLDFLAGS) -lmingw32 -lwsock32 -lSDLmain -lSDL
|
||||
else
|
||||
#pthread is needed because of SDL.
|
||||
SW_LDFLAGS=$(SWLDFLAGS) -lSDLmain -lSDL -lpthread
|
||||
SW_LDFLAGS=$(SWLDFLAGS) `sdl-config --libs` -lpng -ljpeg -lSDLmain
|
||||
endif
|
||||
SW_CFLAGS=$(SWCFLAGS)
|
||||
SW_CFLAGS=$(SWCFLAGS) `sdl-config --cflags`
|
||||
SWB_DIR=sw_mgw
|
||||
SWCL_DIR=swcl_mgw
|
||||
endif
|
||||
|
@ -428,9 +428,9 @@ gl-dbg:
|
|||
|
||||
|
||||
swcl-tmp:
|
||||
$(MAKE) -f Makefile.SDL $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(SWCL_EXE_NAME)" CFLAGS="$(SW_CFLAGS)" LDFLAGS="$(SW_LDFLAGS)" SOBJS="SWCL_OBJS"
|
||||
$(MAKE) -f Makefile.SDL $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(SWCL_EXE_NAME)" CFLAGS="$(SW_CFLAGS)" LDFLAGS="$(SW_LDFLAGS)" SOBJS="$(SWCL_OBJS)"
|
||||
sw-tmp:
|
||||
$(MAKE) -f Makefile.SDL $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(SW_EXE_NAME)" CFLAGS="$(SW_CFLAGS)" LDFLAGS="$(SW_LDFLAGS)" SOBJS="SWCL_OBJS"
|
||||
$(MAKE) -f Makefile.SDL $(TYPE) OUT_DIR="$(OUT_DIR)" EXE_NAME="$(SW_EXE_NAME)" CFLAGS="$(SW_CFLAGS)" LDFLAGS="$(SW_LDFLAGS)" SOBJS="$(SWCL_OBJS)"
|
||||
|
||||
swcl-rel:
|
||||
$(MAKE) -f Makefile.SDL swcl-tmp TYPE=_cl-rel OUT_DIR="$(RELEASE_DIR)/$(SWCL_DIR)"
|
||||
|
|
|
@ -333,8 +333,6 @@ int CDAudio_Init(void)
|
|||
{
|
||||
int n;
|
||||
|
||||
Con_Printf("SDL has no sound code\n");
|
||||
|
||||
#if 0 // QW
|
||||
if (cls.state == ca_dedicated)
|
||||
return -1;
|
||||
|
|
329
engine/client/in_sdl.c
Normal file
329
engine/client/in_sdl.c
Normal file
|
@ -0,0 +1,329 @@
|
|||
#include "quakedef.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
SDL_Surface *sdlsurf;
|
||||
|
||||
qboolean ActiveApp;
|
||||
qboolean mouseactive;
|
||||
extern qboolean mouseusedforgui;
|
||||
extern qboolean vid_isfullscreen;
|
||||
|
||||
void IN_ActivateMouse(void)
|
||||
{
|
||||
if (mouseactive)
|
||||
return;
|
||||
|
||||
mouseactive = true;
|
||||
SDL_ShowCursor(0);
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
}
|
||||
|
||||
void IN_DeactivateMouse(void)
|
||||
{
|
||||
if (!mouseactive)
|
||||
return;
|
||||
|
||||
mouseactive = false;
|
||||
SDL_ShowCursor(1);
|
||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||
}
|
||||
|
||||
void IN_UpdateGrabs(void)
|
||||
{
|
||||
if (!vid_isfullscreen)
|
||||
{
|
||||
if (!_windowed_mouse.value)
|
||||
{
|
||||
if (mouseactive)
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((key_dest == key_game||mouseusedforgui) && ActiveApp)
|
||||
IN_ActivateMouse ();
|
||||
else if (!(key_dest == key_game || mouseusedforgui) || !ActiveApp)
|
||||
IN_DeactivateMouse ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define tenoh 0,0,0,0,0, 0,0,0,0,0
|
||||
#define fiftyoh tenoh, tenoh, tenoh, tenoh, tenoh
|
||||
#define hundredoh fiftyoh, fiftyoh
|
||||
static unsigned int tbl_sdltoquake[] =
|
||||
{
|
||||
0,0,0,0, //SDLK_UNKNOWN = 0,
|
||||
0,0,0,0, //SDLK_FIRST = 0,
|
||||
K_BACKSPACE, //SDLK_BACKSPACE = 8,
|
||||
K_TAB, //SDLK_TAB = 9,
|
||||
0,0,
|
||||
0, //SDLK_CLEAR = 12,
|
||||
K_ENTER, //SDLK_RETURN = 13,
|
||||
0,0,0,0,0,
|
||||
K_PAUSE, //SDLK_PAUSE = 19,
|
||||
0,0,0,0,0,0,0,
|
||||
K_ESCAPE, //SDLK_ESCAPE = 27,
|
||||
0,0,0,0,
|
||||
K_SPACE, //SDLK_SPACE = 32,
|
||||
'!', //SDLK_EXCLAIM = 33,
|
||||
'"', //SDLK_QUOTEDBL = 34,
|
||||
'#', //SDLK_HASH = 35,
|
||||
'$', //SDLK_DOLLAR = 36,
|
||||
0,
|
||||
'&', //SDLK_AMPERSAND = 38,
|
||||
'\'', //SDLK_QUOTE = 39,
|
||||
'(', //SDLK_LEFTPAREN = 40,
|
||||
')', //SDLK_RIGHTPAREN = 41,
|
||||
'*', //SDLK_ASTERISK = 42,
|
||||
'+', //SDLK_PLUS = 43,
|
||||
',', //SDLK_COMMA = 44,
|
||||
'-', //SDLK_MINUS = 45,
|
||||
'.', //SDLK_PERIOD = 46,
|
||||
'/', //SDLK_SLASH = 47,
|
||||
'0', //SDLK_0 = 48,
|
||||
'1', //SDLK_1 = 49,
|
||||
'2', //SDLK_2 = 50,
|
||||
'3', //SDLK_3 = 51,
|
||||
'4', //SDLK_4 = 52,
|
||||
'5', //SDLK_5 = 53,
|
||||
'6', //SDLK_6 = 54,
|
||||
'7', //SDLK_7 = 55,
|
||||
'8', //SDLK_8 = 56,
|
||||
'9', //SDLK_9 = 57,
|
||||
':', //SDLK_COLON = 58,
|
||||
';', //SDLK_SEMICOLON = 59,
|
||||
'<', //SDLK_LESS = 60,
|
||||
'=', //SDLK_EQUALS = 61,
|
||||
'>', //SDLK_GREATER = 62,
|
||||
'?', //SDLK_QUESTION = 63,
|
||||
'@', //SDLK_AT = 64,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
'[', //SDLK_LEFTBRACKET = 91,
|
||||
'\\', //SDLK_BACKSLASH = 92,
|
||||
']', //SDLK_RIGHTBRACKET = 93,
|
||||
'^', //SDLK_CARET = 94,
|
||||
'_', //SDLK_UNDERSCORE = 95,
|
||||
'`', //SDLK_BACKQUOTE = 96,
|
||||
'a', //SDLK_a = 97,
|
||||
'b', //SDLK_b = 98,
|
||||
'c', //SDLK_c = 99,
|
||||
'd', //SDLK_d = 100,
|
||||
'e', //SDLK_e = 101,
|
||||
'f', //SDLK_f = 102,
|
||||
'g', //SDLK_g = 103,
|
||||
'h', //SDLK_h = 104,
|
||||
'i', //SDLK_i = 105,
|
||||
'j', //SDLK_j = 106,
|
||||
'k', //SDLK_k = 107,
|
||||
'l', //SDLK_l = 108,
|
||||
'm', //SDLK_m = 109,
|
||||
'n', //SDLK_n = 110,
|
||||
'o', //SDLK_o = 111,
|
||||
'p', //SDLK_p = 112,
|
||||
'q', //SDLK_q = 113,
|
||||
'r', //SDLK_r = 114,
|
||||
's', //SDLK_s = 115,
|
||||
't', //SDLK_t = 116,
|
||||
'u', //SDLK_u = 117,
|
||||
'v', //SDLK_v = 118,
|
||||
'w', //SDLK_w = 119,
|
||||
'x', //SDLK_x = 120,
|
||||
'y', //SDLK_y = 121,
|
||||
'z', //SDLK_z = 122,
|
||||
0,0,0,0,
|
||||
K_DEL, //SDLK_DELETE = 127,
|
||||
hundredoh /*227*/, tenoh, tenoh, 0,0,0,0,0,0,0,0,
|
||||
K_KP_INS, //SDLK_KP0 = 256,
|
||||
K_KP_END, //SDLK_KP1 = 257,
|
||||
K_KP_DOWNARROW, //SDLK_KP2 = 258,
|
||||
K_KP_PGDN, //SDLK_KP3 = 259,
|
||||
K_KP_LEFTARROW, //SDLK_KP4 = 260,
|
||||
K_KP_5, //SDLK_KP5 = 261,
|
||||
K_KP_RIGHTARROW, //SDLK_KP6 = 262,
|
||||
K_KP_HOME, //SDLK_KP7 = 263,
|
||||
K_KP_UPARROW, //SDLK_KP8 = 264,
|
||||
K_KP_PGUP, //SDLK_KP9 = 265,
|
||||
K_KP_DEL,//SDLK_KP_PERIOD = 266,
|
||||
K_KP_SLASH,//SDLK_KP_DIVIDE = 267,
|
||||
K_KP_STAR,//SDLK_KP_MULTIPLY= 268,
|
||||
K_KP_MINUS, //SDLK_KP_MINUS = 269,
|
||||
K_KP_PLUS, //SDLK_KP_PLUS = 270,
|
||||
K_KP_ENTER, //SDLK_KP_ENTER = 271,
|
||||
K_KP_EQUALS,//SDLK_KP_EQUALS = 272,
|
||||
K_UPARROW, //SDLK_UP = 273,
|
||||
K_DOWNARROW,//SDLK_DOWN = 274,
|
||||
K_RIGHTARROW,//SDLK_RIGHT = 275,
|
||||
K_LEFTARROW,//SDLK_LEFT = 276,
|
||||
K_INS, //SDLK_INSERT = 277,
|
||||
K_HOME, //SDLK_HOME = 278,
|
||||
K_END, //SDLK_END = 279,
|
||||
K_PGUP, //SDLK_PAGEUP = 280,
|
||||
K_PGDN, //SDLK_PAGEDOWN = 281,
|
||||
K_F1, //SDLK_F1 = 282,
|
||||
K_F2, //SDLK_F2 = 283,
|
||||
K_F3, //SDLK_F3 = 284,
|
||||
K_F4, //SDLK_F4 = 285,
|
||||
K_F5, //SDLK_F5 = 286,
|
||||
K_F6, //SDLK_F6 = 287,
|
||||
K_F7, //SDLK_F7 = 288,
|
||||
K_F8, //SDLK_F8 = 289,
|
||||
K_F9, //SDLK_F9 = 290,
|
||||
K_F10, //SDLK_F10 = 291,
|
||||
K_F11, //SDLK_F11 = 292,
|
||||
K_F12, //SDLK_F12 = 293,
|
||||
0, //SDLK_F13 = 294,
|
||||
0, //SDLK_F14 = 295,
|
||||
0, //SDLK_F15 = 296,
|
||||
0,0,0,
|
||||
0,//K_NUMLOCK, //SDLK_NUMLOCK = 300,
|
||||
K_CAPSLOCK, //SDLK_CAPSLOCK = 301,
|
||||
0,//K_SCROLLOCK,//SDLK_SCROLLOCK= 302,
|
||||
K_SHIFT, //SDLK_RSHIFT = 303,
|
||||
K_SHIFT, //SDLK_LSHIFT = 304,
|
||||
K_CTRL, //SDLK_RCTRL = 305,
|
||||
K_CTRL, //SDLK_LCTRL = 306,
|
||||
K_ALT, //SDLK_RALT = 307,
|
||||
K_ALT, //SDLK_LALT = 308,
|
||||
0, //SDLK_RMETA = 309,
|
||||
0, //SDLK_LMETA = 310,
|
||||
0, //SDLK_LSUPER = 311, /* Left "Windows" key */
|
||||
0, //SDLK_RSUPER = 312, /* Right "Windows" key */
|
||||
0, //SDLK_MODE = 313, /* "Alt Gr" key */
|
||||
0, //SDLK_COMPOSE = 314, /* Multi-key compose key */
|
||||
0, //SDLK_HELP = 315,
|
||||
0, //SDLK_PRINT = 316,
|
||||
0, //SDLK_SYSREQ = 317,
|
||||
K_PAUSE, //SDLK_BREAK = 318,
|
||||
0, //SDLK_MENU = 319,
|
||||
0, //SDLK_POWER = 320, /* Power Macintosh power key */
|
||||
'e', //SDLK_EURO = 321, /* Some european keyboards */
|
||||
0 //SDLK_UNDO = 322, /* Atari keyboard has Undo */
|
||||
};
|
||||
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
#ifdef SWQUAKE
|
||||
void ResetFrameBuffers(void);
|
||||
#endif
|
||||
|
||||
void Sys_SendKeyEvents(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case SDL_ACTIVEEVENT:
|
||||
if (event.active.state & SDL_APPINPUTFOCUS)
|
||||
{ //follow keyboard status
|
||||
ActiveApp = !!event.active.gain;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_VIDEORESIZE:
|
||||
switch(qrenderer)
|
||||
{
|
||||
#ifdef RGLQUAKE
|
||||
case QR_OPENLGL:
|
||||
glwidth = event.resize.w;
|
||||
glheight = event.resize.h;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SWQUAKE
|
||||
case QR_SOFTWARE:
|
||||
vid.width = event.resize.w;
|
||||
vid.height = event.resize.h;
|
||||
ResetFrameBuffers();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
case SDL_KEYDOWN:
|
||||
Key_Event(tbl_sdltoquake[event.key.keysym.sym], event.key.state);
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
mouse_x += event.motion.xrel;
|
||||
mouse_y += event.motion.yrel;
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
//Hmm. SDL allows for 255 buttons...
|
||||
if (event.button.button > 6)
|
||||
event.button.button = 6;
|
||||
Key_Event(K_MOUSE1+event.button.button-1, event.button.state);
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
Cbuf_AddText("quit", RESTRICT_LOCAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void IN_Shutdown (void)
|
||||
{
|
||||
}
|
||||
void IN_Init (void)
|
||||
{
|
||||
Cvar_Register (&in_xflip, "input controls");
|
||||
}
|
||||
void IN_Move (usercmd_t *cmd, int pnum) //add mouse movement to cmd
|
||||
{
|
||||
mouse_x *= sensitivity.value;
|
||||
mouse_y *= sensitivity.value;
|
||||
|
||||
|
||||
if (!cl.paused && mouseactive)
|
||||
{
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state[pnum] & 1) || (lookstrafe.value && (in_mlook.state[pnum] & 1) ))
|
||||
cmd->sidemove += m_side.value * mouse_x;
|
||||
else
|
||||
cl.viewangles[pnum][YAW] -= m_yaw.value * mouse_x;
|
||||
|
||||
if (in_mlook.state[pnum] & 1)
|
||||
V_StopPitchDrift (pnum);
|
||||
|
||||
if ( (in_mlook.state[pnum] & 1) && !(in_strafe.state[pnum] & 1))
|
||||
{
|
||||
cl.viewangles[pnum][PITCH] += m_pitch.value * mouse_y;
|
||||
|
||||
CL_ClampPitch(pnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((in_strafe.state[pnum] & 1) && noclip_anglehack)
|
||||
cmd->upmove -= m_forward.value * mouse_y;
|
||||
else
|
||||
cmd->forwardmove -= m_forward.value * mouse_y;
|
||||
}
|
||||
}
|
||||
|
||||
mouse_x = 0;
|
||||
mouse_y = 0;
|
||||
}
|
||||
void IN_Accumulate(void) //input polling
|
||||
{
|
||||
}
|
||||
void IN_Commands (void) //used to Cbuf_AddText joystick button events in windows.
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -15,8 +15,14 @@ int snd_firsttime = 0;
|
|||
|
||||
int aimedforguid;
|
||||
|
||||
//lamocodec.
|
||||
static char buffer[SOUND_BUFFER_SIZE];
|
||||
int sndpos;
|
||||
|
||||
void SNDDMA_Submit(soundcardinfo_t *sc)
|
||||
{
|
||||
{ //We already wrote it into the 'dma' buffer (heh, the closest we can get to it at least)
|
||||
//so we now wait for sdl to request it.
|
||||
//yes, this can result in slow sound.
|
||||
}
|
||||
void SNDDMA_Shutdown(soundcardinfo_t *sc)
|
||||
{
|
||||
|
@ -28,7 +34,22 @@ void SNDDMA_Shutdown(soundcardinfo_t *sc)
|
|||
}
|
||||
int SNDDMA_GetDMAPos(soundcardinfo_t *sc)
|
||||
{
|
||||
return 0;
|
||||
sc->sn.samplepos = (sndpos / (sc->sn.samplebits/8)) % sc->sn.samples;
|
||||
return sc->sn.samplepos;
|
||||
}
|
||||
|
||||
void SNDDMA_Paint(void *userdata, qbyte *stream, int len)
|
||||
{
|
||||
if (len > SOUND_BUFFER_SIZE)
|
||||
len = SOUND_BUFFER_SIZE; //whoa nellie!
|
||||
if (len > SOUND_BUFFER_SIZE - sndpos)
|
||||
{ //buffer will wrap, fill in the rest
|
||||
memcpy(stream, buffer + sndpos, SOUND_BUFFER_SIZE - sndpos);
|
||||
len -= SOUND_BUFFER_SIZE - sndpos;
|
||||
sndpos = 0;
|
||||
} //and finish from the start
|
||||
memcpy(stream, buffer + sndpos, len);
|
||||
sndpos += len;
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,13 +60,17 @@ void S_UpdateCapture(void) //any ideas how to get microphone input?
|
|||
int SNDDMA_Init(soundcardinfo_t *sc)
|
||||
{
|
||||
SDL_AudioSpec desired, obtained;
|
||||
|
||||
MessageBox(NULL, "hello", "fnar", 0);
|
||||
|
||||
if (snd_inited)
|
||||
{ //our init code actually calls this function multiple times, in the case that the user has multiple sound cards
|
||||
// Con_Printf("Sound was already inited\n");
|
||||
return 2; //erm. SDL won't allow multiple sound cards anyway.
|
||||
}
|
||||
|
||||
Con_Printf("SDL AUDIO INITING\n");
|
||||
if(SDL_InitSubSystem(SDL_INIT_AUDIO))
|
||||
{
|
||||
Con_Print("Couldn't initialize SDL audio subsystem\n");
|
||||
MessageBox(NULL, "hjkl", "fnar", 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -67,20 +92,27 @@ int SNDDMA_Init(soundcardinfo_t *sc)
|
|||
desired.channels = 2;
|
||||
desired.samples = SOUND_BUFFER_SIZE;
|
||||
desired.format = AUDIO_S16;
|
||||
desired.callback = paint;
|
||||
|
||||
desired.callback = SNDDMA_Paint;
|
||||
desired.userdata = sc;
|
||||
|
||||
|
||||
if ( SDL_OpenAudio(&desired, &obtained) < 0 )
|
||||
{
|
||||
Con_Printf("SDL: SNDDMA_Init: couldn't open sound device (%s).\n", SDL_GetError());
|
||||
MessageBox(NULL, "hello", "fghjfghjfgfnar", 0);
|
||||
return false;
|
||||
}
|
||||
sc->sn.numchannels = obtained.channels;
|
||||
sc->sn.speed = desired.freq;
|
||||
sc->sn.samplebits = 16;
|
||||
sc->sn.samples = SOUND_BUFFER_SIZE;
|
||||
sc->sn.buffer = buffer;
|
||||
Con_Printf("Got sound %i-%i\n", obtained.freq, obtained.format);
|
||||
snd_inited = true;
|
||||
SDL_PauseAudio(0);
|
||||
MessageBox(NULL, "he;'lk'khjllo", "fnghkfghar", 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SNDDMA_SetUnderWater(qboolean underwater)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ void Sys_Error (const char *error, ...)
|
|||
Con_Print (string);
|
||||
Con_Print ("\n");
|
||||
|
||||
if (COM_CheckParm("-crashonerror"))
|
||||
*(int*)-3 = 0;
|
||||
|
||||
Host_Shutdown ();
|
||||
exit (1);
|
||||
}
|
||||
|
@ -198,7 +201,7 @@ void Sys_CloseTerminal (void)
|
|||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
int SDL_main(int argc, char **argv)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
float time, newtime, oldtime;
|
||||
quakeparms_t parms;
|
||||
|
@ -287,6 +290,11 @@ int SDL_main(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Sys_HighFPPrecision(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Sys_LowFPPrecision(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -240,6 +240,8 @@ qboolean Draw_RealPicFromWad (mpic_t *out, char *name)
|
|||
{
|
||||
sprintf(name2, "pics/%s", name);
|
||||
texnum = Mod_LoadHiResTexture(name2, false, true, false);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND); //make sure.
|
||||
}
|
||||
|
||||
if (texnum)
|
||||
|
@ -3373,4 +3375,4 @@ int GL_LoadPicTexture (qpic_t *pic)
|
|||
}
|
||||
|
||||
/****************************************/
|
||||
#endif
|
||||
#endif
|
||||
|
|
151
engine/sw/vid_sdl.c
Executable file
151
engine/sw/vid_sdl.c
Executable file
|
@ -0,0 +1,151 @@
|
|||
#include "quakedef.h"
|
||||
#include "d_local.h"
|
||||
#include "SDL.h"
|
||||
|
||||
extern qboolean vid_isfullscreen;
|
||||
|
||||
extern qboolean ActiveApp;
|
||||
|
||||
extern SDL_Surface *sdlsurf;
|
||||
|
||||
qbyte vid_curpal[256];
|
||||
|
||||
cvar_t in_xflip = {"in_xflip", "0"};
|
||||
|
||||
void ResetFrameBuffers(void)
|
||||
{
|
||||
int vid_surfcachesize;
|
||||
void *vid_surfcache;
|
||||
int buffersize;
|
||||
|
||||
if (d_pzbuffer)
|
||||
{
|
||||
D_FlushCaches();
|
||||
free(d_pzbuffer);
|
||||
d_pzbuffer = NULL;
|
||||
}
|
||||
buffersize = vid.width * vid.height * sizeof(*d_pzbuffer);
|
||||
vid_surfcachesize = D_SurfaceCacheForRes (vid.width, vid.height, 0);
|
||||
buffersize += vid_surfcachesize;
|
||||
|
||||
d_pzbuffer = malloc(buffersize);
|
||||
vid_surfcache = (qbyte *) d_pzbuffer + vid.width * vid.height * sizeof(*d_pzbuffer);
|
||||
|
||||
D_InitCaches(vid_surfcache, vid_surfcachesize);
|
||||
}
|
||||
|
||||
qboolean SWVID_Init (rendererstate_t *info, unsigned char *palette)
|
||||
{
|
||||
int flags;
|
||||
Con_Printf("SDL SWVID_Init\n");
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
|
||||
|
||||
if (info->fullscreen)
|
||||
{
|
||||
flags = SDL_FULLSCREEN;
|
||||
vid_isfullscreen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = 0; // :( SDL_RESIZABLE;
|
||||
vid_isfullscreen = false;
|
||||
}
|
||||
|
||||
sdlsurf = SDL_SetVideoMode(info->width, info->height, info->bpp, flags|SDL_DOUBLEBUF);
|
||||
if (!sdlsurf)
|
||||
return false; //bummer.
|
||||
|
||||
vid.width = vid.conwidth = sdlsurf->w;
|
||||
vid.height = vid.conheight = sdlsurf->h;
|
||||
vid.colormap = host_colormap;
|
||||
|
||||
vid.maxwarpwidth = WARP_WIDTH;
|
||||
vid.maxwarpheight = WARP_HEIGHT;
|
||||
ActiveApp = true;
|
||||
|
||||
SDL_SetClipRect(sdlsurf, NULL);
|
||||
|
||||
|
||||
vid.numpages = (sdlsurf->flags & SDL_DOUBLEBUF)?2:1;
|
||||
vid.aspect = ((float)vid.height/vid.width);
|
||||
|
||||
r_pixbytes = info->bpp/8;
|
||||
|
||||
SWVID_LockBuffer(); //make sure our buffer and pitch are set up right.
|
||||
|
||||
ResetFrameBuffers();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SWVID_SetPalette(unsigned char *palette)
|
||||
{
|
||||
int i;
|
||||
SDL_Color colours[256];
|
||||
memcpy(vid_curpal, palette, sizeof(vid_curpal));
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
colours[i].r = palette[i*3+0];
|
||||
colours[i].g = palette[i*3+1];
|
||||
colours[i].b = palette[i*3+2];
|
||||
}
|
||||
SDL_SetColors(sdlsurf, colours, 0, 256);
|
||||
}
|
||||
void SWVID_ShiftPalette(unsigned char *palette)
|
||||
{
|
||||
SWVID_SetPalette(palette);
|
||||
}
|
||||
|
||||
void SWVID_Shutdown(void)
|
||||
{
|
||||
ActiveApp = false;
|
||||
|
||||
IN_Shutdown();
|
||||
Con_Printf("Restoring gamma\n");
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
void SWVID_LockBuffer (void)
|
||||
{
|
||||
if (SDL_LockSurface(sdlsurf)<0)
|
||||
if (SDL_LockSurface(sdlsurf)<0)
|
||||
Sys_Error("Couldn't lock surface\n");
|
||||
|
||||
vid.buffer = vid.conbuffer = sdlsurf->pixels;
|
||||
vid.rowbytes = vid.conrowbytes = sdlsurf->pitch/r_pixbytes;
|
||||
}
|
||||
|
||||
void SWVID_ForceLockState (int lk) //I detest these functions. FIXME: Remove
|
||||
{
|
||||
SWVID_LockBuffer();
|
||||
}
|
||||
|
||||
void SWVID_UnlockBuffer (void)
|
||||
{
|
||||
SDL_UnlockSurface(sdlsurf);
|
||||
}
|
||||
|
||||
int SWVID_ForceUnlockedAndReturnState(void) //FIXME: Remove
|
||||
{
|
||||
SWVID_UnlockBuffer();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SWVID_Update(vrect_t *rects)
|
||||
{
|
||||
SDL_Flip(sdlsurf);
|
||||
|
||||
IN_UpdateGrabs();
|
||||
}
|
||||
|
||||
void SWVID_HandlePause (qboolean pause)
|
||||
{
|
||||
}
|
||||
|
||||
void SWD_BeginDirectRect (int x, int y, qbyte *pbitmap, int width, int height)
|
||||
{
|
||||
}
|
||||
void SWD_EndDirectRect (int x, int y, int width, int height)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in a new issue