fix some non-gl builds.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4492 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2013-10-08 16:13:18 +00:00
parent d396450a0a
commit c469bcd446
10 changed files with 244 additions and 209 deletions

View file

@ -1374,11 +1374,10 @@ qboolean Media_Playing(void);
struct cin_s *Media_StartCin(char *name);
texid_tf Media_UpdateForShader(cin_t *cin);
void Media_ShutdownCin(cin_t *cin);
qboolean Media_FakeTrack(int i, qboolean loop);
qboolean Media_BackgroundTrack(char *initialtrack, char *looptrack);
void Media_NumberedTrack(int initialtrack, int looptrack);
void Media_EndedTrack(void); //cd is no longer running, media code needs to pick a new track (cd track or faketrack)
#endif
qboolean Media_BackgroundTrack(char *initialtrack, char *looptrack); //new background music interface
void Media_NumberedTrack(unsigned int initialtrack, unsigned int looptrack); //legacy cd interface for protocols that only support numbered tracks.
void Media_EndedTrack(void); //cd is no longer running, media code needs to pick a new track (cd track or faketrack)
//these accept NULL for cin to mean the current fullscreen video
void Media_Send_Command(cin_t *cin, char *command);

View file

@ -1985,8 +1985,10 @@ void Key_Event (int devid, int key, unsigned int unicode, qboolean down)
else
M_ToggleMenu_f ();
}
#ifdef TEXTEDITOR
else if (Key_Dest_Has(kdm_editor))
Editor_Key (key, unicode);
#endif
else if (Key_Dest_Has(kdm_menu))
M_Keydown (key, unicode);
else if (Key_Dest_Has(kdm_message))
@ -2022,8 +2024,10 @@ void Key_Event (int devid, int key, unsigned int unicode, qboolean down)
}
if (Key_Dest_Has(kdm_menu))
M_Keyup (key, unicode);
#ifndef NOMEDIA
if (Media_PlayingFullScreen())
Media_Send_KeyEvent(NULL, key, unicode, down?0:1);
#endif
if (!deltaused[key][keystate]) //this wasn't down, so don't make it leave down state.
return;
@ -2087,11 +2091,13 @@ void Key_Event (int devid, int key, unsigned int unicode, qboolean down)
Key_Console (con_current, unicode, key);
return;
}
#ifdef TEXTEDITOR
if (Key_Dest_Has(kdm_editor))
{
Editor_Key (key, unicode);
return;
}
#endif
if (Key_Dest_Has(kdm_menu))
{
M_Keydown (key, unicode);
@ -2102,11 +2108,13 @@ void Key_Event (int devid, int key, unsigned int unicode, qboolean down)
Key_Message (key, unicode);
return;
}
#ifndef NOMEDIA
if (Media_PlayingFullScreen())
{
Media_Send_KeyEvent(NULL, key, unicode, down?0:1);
return;
}
#endif
//anything else is a key binding.

View file

@ -7,6 +7,201 @@
#endif
#include "shader.h"
#if !defined(NOMEDIA)
typedef struct mediatrack_s{
char filename[MAX_QPATH];
char nicename[MAX_QPATH];
int length;
struct mediatrack_s *next;
} mediatrack_t;
static mediatrack_t currenttrack;
int media_playing=true;//try to continue from the standard playlist
#endif
static char cdloopingtrack[MAX_QPATH];
static qboolean fakecdactive;
#define REMAPPED_TRACKS 100
static struct
{
char fname[MAX_QPATH];
} cdremap[REMAPPED_TRACKS];
static qboolean cdenabled;
static int cdplayingtrack; //currently playing cd track (becomes 0 when paused)
static int cdpausedtrack; //currently paused cd track
static int cdnumtracks; //maximum cd track we can play.
//flushes music channel on all soundcards, and the tracks that arn't decoded yet.
void Media_Clear (void)
{
//make sure we're not playing any cd music.
if (cdplayingtrack || cdpausedtrack)
{
cdplayingtrack = 0;
cdpausedtrack = 0;
CDAudio_Stop();
}
#if !defined(NOMEDIA)
Q_strncpyz(currenttrack.filename, "", sizeof(currenttrack.filename));
fakecdactive = false;
media_playing = false;
#endif
S_Music_Clear(NULL);
}
//fake cd tracks.
qboolean Media_BackgroundTrack(char *track, char *looptrack)
{
unsigned int tracknum;
#if !defined(NOMEDIA)
static char *path[] =
{
"music/",
"sound/cdtracks/",
"",
NULL
};
static char *ext[] =
{
"",
".ogg",
#ifdef WINAVI
".mp3",
#endif
".wav",
NULL
};
char trackname[MAX_QPATH];
int ie, ip;
#endif
char *trackend;
qboolean found = false;
if (!track || !*track) //ignore calls if the primary track is invalid. whatever is already playing will continue to play.
return false;
if (!looptrack || !*looptrack) //null or empty looptrack loops using the primary track, for compat with q3.
looptrack = track;
//check if its a proper number (0123456789 without any other weird stuff. if so, we can use fake track paths or actual cd tracks)
tracknum = strtoul(track, &trackend, 0);
if (*trackend)
tracknum = 0;
if (tracknum > 0 && tracknum < REMAPPED_TRACKS && *cdremap[tracknum].fname)
{ //remap the track if its remapped.
track = cdremap[tracknum].fname;
tracknum = strtoul(track, &trackend, 0);
if (*trackend)
tracknum = 0;
}
if (!strcmp(looptrack, "-")) //- for the looptrack argument can be used to prevent looping.
looptrack = "";
#if defined(NOMEDIA)
found = false;
#else
for(ip = 0; path[ip] && !found; ip++)
{
if (tracknum)
{
if (tracknum <= 999)
{
for(ie = 0; ext[ie] && !found; ie++)
{
Q_snprintfz(trackname, sizeof(trackname), "%strack%03i%s", path[ip], tracknum, ext[ie]);
found = COM_FCheckExists(trackname);
}
}
if (tracknum <= 99)
{
for(ie = 0; ext[ie] && !found; ie++)
{
Q_snprintfz(trackname, sizeof(trackname), "%strack%02i%s", path[ip], tracknum, ext[ie]);
found = COM_FCheckExists(trackname);
}
}
}
if (!found)
{
for(ie = 0; ext[ie] && !found; ie++)
{
Q_snprintfz(trackname, sizeof(trackname), "%s%s%s", path[ip], track, ext[ie]);
found = COM_FCheckExists(trackname);
}
}
}
if (found)
{
Q_strncpyz(cdloopingtrack, looptrack, sizeof(cdloopingtrack));
Media_Clear();
Q_strncpyz(currenttrack.filename, trackname, sizeof(currenttrack.filename));
fakecdactive = true;
media_playing = true;
return true;
}
#endif
if (tracknum && cdenabled)
{
Q_strncpyz(cdloopingtrack, looptrack, sizeof(cdloopingtrack));
//couldn't do a faketrack, resort to actual cd tracks, if we're allowed
if (!CDAudio_Startup())
return false;
if (cdnumtracks <= 0)
cdnumtracks = CDAudio_GetAudioDiskInfo();
if (tracknum > cdnumtracks)
{
Con_DPrintf("CDAudio: Bad track number %u.\n", tracknum);
return false; //can't play that, sorry. its not an available track
}
if (cdplayingtrack == tracknum)
return true; //already playing, don't need to do anything
Media_Clear();
cdpausedtrack = 0;
cdplayingtrack = tracknum;
CDAudio_Play(tracknum);
return true;
}
return false;
}
//for q3
void Media_NamedTrack_f(void)
{
if (Cmd_Argc() == 3)
Media_BackgroundTrack(Cmd_Argv(1), Cmd_Argv(2));
else
Media_BackgroundTrack(Cmd_Argv(1), Cmd_Argv(1));
}
void Media_NumberedTrack(unsigned int initialtrack, unsigned int looptrack)
{
char *init = initialtrack?va("%u", initialtrack):NULL;
char *loop = looptrack?va("%u", looptrack):NULL;
Media_BackgroundTrack(init, loop);
}
void Media_EndedTrack(void)
{
cdplayingtrack = 0;
cdpausedtrack = 0;
if (cdloopingtrack)
Media_BackgroundTrack(cdloopingtrack, cdloopingtrack);
}
#if !defined(NOMEDIA)
@ -27,17 +222,8 @@ HWND hwnd_winamp;
qboolean Media_EvaluateNextTrack(void);
typedef struct mediatrack_s{
char filename[MAX_QPATH];
char nicename[MAX_QPATH];
int length;
struct mediatrack_s *next;
} mediatrack_t;
static mediatrack_t currenttrack;
int lasttrackplayed;
int media_playing=true;//try to continue from the standard playlist
cvar_t media_shuffle = SCVAR("media_shuffle", "1");
cvar_t media_repeat = SCVAR("media_repeat", "1");
#ifdef WINAMP
@ -212,162 +398,6 @@ qboolean Media_EvaluateNextTrack(void)
return true;
}
static char cdloopingtrack[MAX_QPATH];
static qboolean fakecdactive;
#define REMAPPED_TRACKS 100
static struct
{
char fname[MAX_QPATH];
} cdremap[REMAPPED_TRACKS];
static qboolean cdenabled;
static int cdplayingtrack; //currently playing cd track (becomes 0 when paused)
static int cdpausedtrack; //currently paused cd track
static int cdnumtracks; //maximum cd track we can play.
//flushes music channel on all soundcards, and the tracks that arn't decoded yet.
void Media_Clear (void)
{
//make sure we're not playing any cd music.
if (cdplayingtrack || cdpausedtrack)
{
cdplayingtrack = 0;
cdpausedtrack = 0;
CDAudio_Stop();
}
Q_strncpyz(currenttrack.filename, "", sizeof(currenttrack.filename));
fakecdactive = false;
media_playing = false;
S_Music_Clear(NULL);
}
//fake cd tracks.
qboolean Media_BackgroundTrack(char *track, char *looptrack)
{
unsigned int tracknum;
static char *path[] =
{
"music/",
"sound/cdtracks/",
"",
NULL
};
static char *ext[] =
{
"",
".ogg",
#ifdef WINAVI
".mp3",
#endif
".wav",
NULL
};
char *trackend;
char trackname[MAX_QPATH];
int ie, ip;
qboolean found = false;
if (!track || !*track) //ignore calls if the primary track is invalid. whatever is already playing will continue to play.
return false;
if (!looptrack || !*looptrack) //null or empty looptrack loops using the primary track, for compat with q3.
looptrack = track;
//check if its a proper number (0123456789 without any other weird stuff. if so, we can use fake track paths or actual cd tracks)
tracknum = strtoul(track, &trackend, 0);
if (*trackend)
tracknum = 0;
if (tracknum > 0 && tracknum < REMAPPED_TRACKS && *cdremap[tracknum].fname)
{ //remap the track if its remapped.
track = cdremap[tracknum].fname;
tracknum = strtoul(track, &trackend, 0);
if (*trackend)
tracknum = 0;
}
if (!strcmp(looptrack, "-")) //- for the looptrack argument can be used to prevent looping.
looptrack = "";
for(ip = 0; path[ip] && !found; ip++)
{
if (tracknum)
{
if (tracknum <= 999)
{
for(ie = 0; ext[ie] && !found; ie++)
{
Q_snprintfz(trackname, sizeof(trackname), "%strack%03i%s", path[ip], tracknum, ext[ie]);
found = COM_FCheckExists(trackname);
}
}
if (tracknum <= 99)
{
for(ie = 0; ext[ie] && !found; ie++)
{
Q_snprintfz(trackname, sizeof(trackname), "%strack%02i%s", path[ip], tracknum, ext[ie]);
found = COM_FCheckExists(trackname);
}
}
}
if (!found)
{
for(ie = 0; ext[ie] && !found; ie++)
{
Q_snprintfz(trackname, sizeof(trackname), "%s%s%s", path[ip], track, ext[ie]);
found = COM_FCheckExists(trackname);
}
}
}
if (found)
{
Q_strncpyz(cdloopingtrack, looptrack, sizeof(cdloopingtrack));
Media_Clear();
Q_strncpyz(currenttrack.filename, trackname, sizeof(currenttrack.filename));
fakecdactive = true;
media_playing = true;
return true;
}
if (tracknum && cdenabled)
{
Q_strncpyz(cdloopingtrack, looptrack, sizeof(cdloopingtrack));
//couldn't do a faketrack, resort to actual cd tracks, if we're allowed
if (!CDAudio_Startup())
return false;
if (cdnumtracks <= 0)
cdnumtracks = CDAudio_GetAudioDiskInfo();
if (tracknum > cdnumtracks)
{
Con_DPrintf("CDAudio: Bad track number %u.\n", tracknum);
return false; //can't play that, sorry. its not an available track
}
if (cdplayingtrack == tracknum)
return true; //already playing, don't need to do anything
Media_Clear();
cdpausedtrack = 0;
cdplayingtrack = tracknum;
CDAudio_Play(tracknum);
return true;
}
return false;
}
//for q3
void Media_NamedTrack_f(void)
{
if (Cmd_Argc() == 3)
Media_BackgroundTrack(Cmd_Argv(1), Cmd_Argv(2));
else
Media_BackgroundTrack(Cmd_Argv(1), Cmd_Argv(1));
}
void Media_SetPauseTrack(qboolean paused)
{
if (paused)
@ -384,23 +414,6 @@ void Media_SetPauseTrack(qboolean paused)
}
}
void Media_NumberedTrack(int initialtrack, int looptrack)
{
char *init = initialtrack?va("%i", initialtrack):NULL;
char *loop = looptrack?va("%i", looptrack):NULL;
Media_BackgroundTrack(init, loop);
}
void Media_EndedTrack(void)
{
cdplayingtrack = 0;
cdpausedtrack = 0;
if (cdloopingtrack)
Media_BackgroundTrack(cdloopingtrack, cdloopingtrack);
}
void CD_f (void)
{
char *command;

View file

@ -222,7 +222,10 @@ void M_ToggleMenu_f (void)
if (Key_Dest_Has(kdm_console))
{
if (cls.state != ca_active)
{
Key_Dest_Remove(kdm_console);
M_Menu_Main_f();
}
else
Con_ToggleConsole_Force ();
}

View file

@ -537,7 +537,7 @@ void D3D11BE_Init(void)
be_maxpasses = MAX_TMUS;
memset(&shaderstate, 0, sizeof(shaderstate));
shaderstate.curvertdecl = -1;
for (i = 0; i < MAXLIGHTMAPS; i++)
for (i = 0; i < MAXRLIGHTMAPS; i++)
shaderstate.dummybatch.lightmap[i] = -1;
BE_CreateSamplerStates();
@ -1834,10 +1834,14 @@ void D3D11BE_SelectMode(backendmode_t mode)
D3D11BE_ApplyShaderBits(SBITS_MASK_BITS);
}
void D3D11BE_SelectDLight(dlight_t *dl, vec3_t colour)
qboolean D3D11BE_SelectDLight(dlight_t *dl, vec3_t colour, unsigned int lmode)
{
shaderstate.curdlight = dl;
VectorCopy(colour, shaderstate.curdlight_colours);
if (lmode != LSHADER_STANDARD)
return false;
return true;
}
void D3D11BE_SelectEntity(entity_t *ent)
@ -2496,7 +2500,7 @@ static void BE_SubmitMeshesSortList(batch_t *sortlist)
}
if (batch->shader->flags & SHADER_NODLIGHT)
if (shaderstate.mode == BEM_LIGHT || shaderstate.mode == BEM_SMAPLIGHT)
if (shaderstate.mode == BEM_LIGHT)
continue;
if (batch->shader->flags & SHADER_SKY)
@ -2828,7 +2832,7 @@ void D3D11BE_SubmitMeshes (qboolean drawworld, batch_t **blist, int first, int s
void D3D11BE_BaseEntTextures(void)
{
batch_t *batches[SHADER_SORT_COUNT];
BE_GenModelBatches(batches);
BE_GenModelBatches(batches, shaderstate.curdlight, shaderstate.mode);
D3D11BE_SubmitMeshes(false, batches, SHADER_SORT_PORTAL, SHADER_SORT_DECAL);
BE_SelectEntity(&r_worldentity);
}
@ -2874,7 +2878,8 @@ void D3D11BE_DrawWorld (qboolean drawworld, qbyte *vis)
D3D11BE_SetupViewCBuffer();
BE_GenModelBatches(batches);
shaderstate.curdlight = NULL;
BE_GenModelBatches(batches, shaderstate.curdlight, BEM_STANDARD);
if (vis)
{

View file

@ -2158,10 +2158,14 @@ void D3D9BE_SelectMode(backendmode_t mode)
BE_ApplyShaderBits(SBITS_MASK_BITS);
}
void D3D9BE_SelectDLight(dlight_t *dl, vec3_t colour)
qboolean D3D9BE_SelectDLight(dlight_t *dl, vec3_t colour, unsigned int lmode)
{
shaderstate.curdlight = dl;
VectorCopy(colour, shaderstate.curdlight_colours);
if (lmode != LSHADER_STANDARD)
return false;
return true;
}
void D3D9BE_SelectEntity(entity_t *ent)
@ -2756,7 +2760,7 @@ static void BE_SubmitMeshesSortList(batch_t *sortlist)
}
if (batch->shader->flags & SHADER_NODLIGHT)
if (shaderstate.mode == BEM_LIGHT || shaderstate.mode == BEM_SMAPLIGHT)
if (shaderstate.mode == BEM_LIGHT)
continue;
if (batch->shader->flags & SHADER_SKY)
@ -3087,7 +3091,7 @@ void D3D9BE_SubmitMeshes (qboolean drawworld, batch_t **blist, int first, int st
void D3D9BE_BaseEntTextures(void)
{
batch_t *batches[SHADER_SORT_COUNT];
BE_GenModelBatches(batches);
BE_GenModelBatches(batches, shaderstate.curdlight, shaderstate.mode);
D3D9BE_SubmitMeshes(false, batches, SHADER_SORT_PORTAL, SHADER_SORT_DECAL);
BE_SelectEntity(&r_worldentity);
}
@ -3126,7 +3130,8 @@ void D3D9BE_DrawWorld (qboolean drawworld, qbyte *vis)
shaderstate.wbatch = 0;
}
BE_GenModelBatches(batches);
shaderstate.curdlight = NULL;
BE_GenModelBatches(batches, shaderstate.curdlight, BEM_STANDARD);
if (drawworld)
{

View file

@ -953,7 +953,7 @@ static void (D3D9_SCR_UpdateScreen) (void)
if (scr_disabled_for_loading)
{
extern float scr_disabled_time;
if (Sys_DoubleTime() - scr_disabled_time > 60 || key_dest != key_game)
if (Sys_DoubleTime() - scr_disabled_time > 60 || Key_Dest_Has(~kdm_game))
{
scr_disabled_for_loading = false;
}

View file

@ -1012,7 +1012,7 @@ static void (D3D11_SCR_UpdateScreen) (void)
if (scr_disabled_for_loading)
{
extern float scr_disabled_time;
if (Sys_DoubleTime() - scr_disabled_time > 60 || key_dest != key_game)
if (Sys_DoubleTime() - scr_disabled_time > 60 || Key_Dest_Has(~kdm_game))
{
scr_disabled_for_loading = false;
}
@ -1117,7 +1117,7 @@ static void (D3D11_SCR_UpdateScreen) (void)
scr_con_forcedraw = false;
if (noworld)
{
if ((key_dest == key_console || key_dest == key_game) && SCR_GetLoadingStage() == LS_NONE)
if ((!Key_Dest_Has(~(kdm_game|kdm_console))) && SCR_GetLoadingStage() == LS_NONE)
scr_con_current = vid.height;
if (scr_con_current != vid.height)

View file

@ -61,7 +61,9 @@ extern cvar_t r_glsl_offsetmapping, r_noportals;
static void BE_SendPassBlendDepthMask(unsigned int sbits);
void GLBE_SubmitBatch(batch_t *batch);
#ifdef RTLIGHTS
static qboolean GLBE_RegisterLightShader(int mode);
#endif
struct {
//internal state
@ -3396,15 +3398,9 @@ qboolean GLBE_SelectDLight(dlight_t *dl, vec3_t colour, unsigned int lmode)
}
#endif
shaderstate.lastuniform = 0;
shaderstate.curdlight = dl;
shaderstate.lightmode = 1u<<lmode;
if (lmode != LSHADER_SPOT)
{
if (TEXVALID(shaderstate.lightcubemap) && GLBE_RegisterLightShader(shaderstate.lightmode | (1u<<LSHADER_CUBE)))
shaderstate.lightmode |= 1u<<LSHADER_CUBE;
}
if (!GLBE_RegisterLightShader(shaderstate.lightmode))
return false;
/*simple info*/
shaderstate.lightradius = dl->radius;
@ -3414,9 +3410,15 @@ qboolean GLBE_SelectDLight(dlight_t *dl, vec3_t colour, unsigned int lmode)
#ifdef RTLIGHTS
VectorCopy(dl->lightcolourscales, shaderstate.lightcolourscale);
shaderstate.lightcubemap = dl->cubetexture;
#endif
shaderstate.lastuniform = 0;
if (lmode != LSHADER_SPOT)
{
if (TEXVALID(shaderstate.lightcubemap) && GLBE_RegisterLightShader(shaderstate.lightmode | (1u<<LSHADER_CUBE)))
shaderstate.lightmode |= 1u<<LSHADER_CUBE;
}
if (!GLBE_RegisterLightShader(shaderstate.lightmode))
return false;
#endif
return true;
}

View file

@ -598,7 +598,7 @@ void D3D9BE_UploadAllLightmaps(void);
void D3D9BE_DrawWorld (qboolean drawworld, qbyte *vis);
qboolean D3D9BE_LightCullModel(vec3_t org, model_t *model);
void D3D9BE_SelectEntity(entity_t *ent);
void D3D9BE_SelectDLight(dlight_t *dl, vec3_t colour);
qboolean D3D9BE_SelectDLight(dlight_t *dl, vec3_t colour, unsigned int lmode);
void D3D9BE_VBO_Begin(vbobctx_t *ctx, unsigned int maxsize);
void D3D9BE_VBO_Data(vbobctx_t *ctx, void *data, unsigned int size, vboarray_t *varray);
void D3D9BE_VBO_Finish(vbobctx_t *ctx, void *edata, unsigned int esize, vboarray_t *earray);
@ -624,7 +624,7 @@ void D3D11BE_UploadAllLightmaps(void);
void D3D11BE_DrawWorld (qboolean drawworld, qbyte *vis);
qboolean D3D11BE_LightCullModel(vec3_t org, model_t *model);
void D3D11BE_SelectEntity(entity_t *ent);
void D3D11BE_SelectDLight(dlight_t *dl, vec3_t colour);
qboolean D3D11BE_SelectDLight(dlight_t *dl, vec3_t colour, unsigned int lmode);
qboolean D3D11Shader_CreateProgram (program_t *prog, const char *name, int permu, char **precompilerconstants, char *vert, char *frag);
int D3D11Shader_FindUniform(union programhandle_u *h, int type, char *name);