mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-24 21:02:26 +00:00
fix some glsl issues.
fix gles+q3bsp black lightmaps bug. enable q3bsp support in webgl port. enable uncompressed pk3 support even if zlib isn't available. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4800 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
0256c19270
commit
f118bccc6a
10 changed files with 158 additions and 71 deletions
|
@ -4805,7 +4805,9 @@ void CL_StartCinematicOrMenu(void)
|
|||
if (!cls.state && !m_state && cl_demoreel.ival)
|
||||
CL_NextDemo();
|
||||
if (!cls.state && !m_state)
|
||||
M_ToggleMenu_f();
|
||||
//if we're (now) meant to be using csqc for menus, make sure that its running.
|
||||
if (!CSQC_UnconnectedInit())
|
||||
M_ToggleMenu_f();
|
||||
}
|
||||
//Con_ForceActiveNow();
|
||||
}
|
||||
|
|
|
@ -2490,6 +2490,7 @@ void Surf_LightmapMode(void)
|
|||
lightmap_bgra = false;
|
||||
if (gl_config.gles)
|
||||
{
|
||||
//rgb is a supported format, where bgr or rgbx are not.
|
||||
lightmap_bytes = 3;
|
||||
lightmap_bgra = false;
|
||||
}
|
||||
|
@ -2724,9 +2725,9 @@ void Surf_BuildModelLightmaps (model_t *m)
|
|||
|
||||
dst = lightmap[newfirst+i]->lightmaps;
|
||||
src = m->lightdata + i*m->lightmaps.width*m->lightmaps.height*3;
|
||||
if (lightmap_bytes == 4 && m->lightdata)
|
||||
if (m->lightdata)
|
||||
{
|
||||
if (lightmap_bgra)
|
||||
if (lightmap_bgra && lightmap_bytes == 4)
|
||||
{
|
||||
for (j = 0; j < m->lightmaps.width*m->lightmaps.height; j++, dst += 4, src += 3)
|
||||
{
|
||||
|
@ -2736,7 +2737,7 @@ void Surf_BuildModelLightmaps (model_t *m)
|
|||
dst[3] = 255;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!lightmap_bgra && lightmap_bytes == 4)
|
||||
{
|
||||
for (j = 0; j < m->lightmaps.width*m->lightmaps.height; j++, dst += 4, src += 3)
|
||||
{
|
||||
|
@ -2746,6 +2747,24 @@ void Surf_BuildModelLightmaps (model_t *m)
|
|||
dst[3] = 255;
|
||||
}
|
||||
}
|
||||
else if (lightmap_bgra && lightmap_bytes == 3)
|
||||
{
|
||||
for (j = 0; j < m->lightmaps.width*m->lightmaps.height; j++, dst += 3, src += 3)
|
||||
{
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
}
|
||||
}
|
||||
else if (!lightmap_bgra && lightmap_bytes == 3)
|
||||
{
|
||||
for (j = 0; j < m->lightmaps.width*m->lightmaps.height; j++, dst += 3, src += 3)
|
||||
{
|
||||
dst[0] = src[0];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -633,18 +633,31 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned
|
|||
palSourcei(src, AL_SOURCE_RELATIVE, AL_FALSE);
|
||||
// palSourcef(src, AL_ROLLOFF_FACTOR, s_al_rolloff_factor.value*chan->dist_mult);
|
||||
}
|
||||
switch(s_al_distancemodel.ival)
|
||||
|
||||
//this is disgustingly shit.
|
||||
//logically we want to set the distance divisor to 1 and the rolloff factor to dist_mult.
|
||||
//but openal clamps in an annoying order (probably to keep things signed in hardware) and webaudio refuses infinity, so we need to special case no attenuation to get around the issue
|
||||
if (chan->dist_mult < 0.000001)
|
||||
{
|
||||
default:
|
||||
palSourcef(src, AL_ROLLOFF_FACTOR, s_al_reference_distance.value);
|
||||
palSourcef(src, AL_REFERENCE_DISTANCE, 1);
|
||||
palSourcef(src, AL_MAX_DISTANCE, 1/chan->dist_mult); //clamp to the maximum distance you'd normally be allowed to hear... this is probably going to be annoying.
|
||||
break;
|
||||
case 2: //linear, mimic quake.
|
||||
palSourcef(src, AL_ROLLOFF_FACTOR, 1);
|
||||
palSourcef(src, AL_ROLLOFF_FACTOR, 0);
|
||||
palSourcef(src, AL_REFERENCE_DISTANCE, 0);
|
||||
palSourcef(src, AL_MAX_DISTANCE, 1/chan->dist_mult);
|
||||
break;
|
||||
palSourcef(src, AL_MAX_DISTANCE, 1); //doesn't matter, so long as its not a nan
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(s_al_distancemodel.ival)
|
||||
{
|
||||
default:
|
||||
palSourcef(src, AL_ROLLOFF_FACTOR, s_al_reference_distance.value);
|
||||
palSourcef(src, AL_REFERENCE_DISTANCE, 1);
|
||||
palSourcef(src, AL_MAX_DISTANCE, 1/chan->dist_mult); //clamp to the maximum distance you'd normally be allowed to hear... this is probably going to be annoying.
|
||||
break;
|
||||
case 2: //linear, mimic quake.
|
||||
palSourcef(src, AL_ROLLOFF_FACTOR, 1);
|
||||
palSourcef(src, AL_REFERENCE_DISTANCE, 0);
|
||||
palSourcef(src, AL_MAX_DISTANCE, 1/chan->dist_mult);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*and start it up again*/
|
||||
|
|
|
@ -325,8 +325,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#undef Q2SERVER //requires a dll anyway.
|
||||
#undef Q3CLIENT
|
||||
#undef Q3SERVER //trying to trim memory use
|
||||
#undef Q2BSPS //emscripten can't cope with bss, leading to increased download time. too lazy to fix.
|
||||
#undef Q3BSPS //emscripten can't cope with bss, leading to increased download time. too lazy to fix.
|
||||
// #undef Q2BSPS //emscripten can't cope with bss, leading to increased download time. too lazy to fix.
|
||||
// #undef Q3BSPS //emscripten can't cope with bss, leading to increased download time. too lazy to fix.
|
||||
// #undef PSET_SCRIPT //bss+size
|
||||
#define GLSLONLY //pointless having the junk
|
||||
#define GLESONLY //should reduce the conditions a little
|
||||
|
|
|
@ -424,7 +424,10 @@ static qboolean FS_Manifest_ParseTokens(ftemanifest_t *man)
|
|||
man->package[i].crcknown = crcknown;
|
||||
man->package[i].crc = crc;
|
||||
if (!Q_strcasecmp(fname, "archivedpackage"))
|
||||
man->package[i].extractname = Z_StrDup(Cmd_Argv(arg++));
|
||||
{
|
||||
char *extr = Cmd_Argv(arg++);
|
||||
man->package[i].extractname = Z_StrDup(extr);
|
||||
}
|
||||
else
|
||||
man->package[i].extractname = NULL;
|
||||
for (j = 0; arg+j < Cmd_Argc() && j < sizeof(man->package[i].mirrors) / sizeof(man->package[i].mirrors[0]); j++)
|
||||
|
@ -4374,7 +4377,7 @@ void COM_InitFilesystem (void)
|
|||
|
||||
//this is at the bottom of the file to ensure these globals are not used elsewhere
|
||||
extern searchpathfuncs_t *(QDECL VFSOS_OpenPath) (vfsfile_t *file, const char *desc);
|
||||
#ifdef AVAIL_ZLIB
|
||||
#if 1//def AVAIL_ZLIB
|
||||
extern searchpathfuncs_t *(QDECL FSZIP_LoadArchive) (vfsfile_t *packhandle, const char *desc);
|
||||
#endif
|
||||
extern searchpathfuncs_t *(QDECL FSPAK_LoadArchive) (vfsfile_t *packhandle, const char *desc);
|
||||
|
@ -4389,7 +4392,7 @@ void FS_RegisterDefaultFileSystems(void)
|
|||
FS_RegisterFileSystemType(NULL, "PAK", FSPAK_LoadArchive, true);
|
||||
#endif
|
||||
FS_RegisterFileSystemType(NULL, "pk3dir", VFSOS_OpenPath, true);
|
||||
#ifdef AVAIL_ZLIB
|
||||
#if 1//def AVAIL_ZLIB
|
||||
FS_RegisterFileSystemType(NULL, "pk3", FSZIP_LoadArchive, true);
|
||||
FS_RegisterFileSystemType(NULL, "pk4", FSZIP_LoadArchive, true);
|
||||
FS_RegisterFileSystemType(NULL, "apk", FSZIP_LoadArchive, false);
|
||||
|
|
|
@ -225,7 +225,7 @@ vfsfile_t *FS_DecompressGZip(vfsfile_t *infile, vfsfile_t *outfile)
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -425,6 +425,7 @@ static int QDECL FSZIP_GeneratePureCRC(searchpathfuncs_t *handle, int seed, int
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef AVAIL_ZLIB
|
||||
struct decompressstate
|
||||
{
|
||||
zipfile_t *source;
|
||||
|
@ -447,6 +448,7 @@ struct decompressstate *FSZIP_Decompress_Init(zipfile_t *source, qofs_t start, q
|
|||
st = Z_Malloc(sizeof(*st));
|
||||
st->cstart = st->cofs = start;
|
||||
st->cend = start + csize;
|
||||
st->usize = usize;
|
||||
st->strm.data_type = Z_UNKNOWN;
|
||||
st->source = source;
|
||||
qinflateInit2(&st->strm, -MAX_WBITS);
|
||||
|
@ -516,7 +518,74 @@ void FSZIP_Decompress_Destroy(struct decompressstate *st)
|
|||
qinflateEnd(&st->strm);
|
||||
Z_Free(st);
|
||||
}
|
||||
vfsfile_t *FSZIP_Decompress_ToTempFile(struct decompressstate *decompress)
|
||||
{ //if they're going to seek on a file in a zip, let's just copy it out
|
||||
qofs_t cstart = decompress->cstart, csize = decompress->cend - cstart;
|
||||
qofs_t upos = 0, usize = decompress->usize;
|
||||
qofs_t chunk;
|
||||
struct decompressstate *nc;
|
||||
qbyte buffer[16384];
|
||||
vfsfile_t *defer;
|
||||
zipfile_t *source = decompress->source;
|
||||
|
||||
defer = FS_OpenTemp();
|
||||
if (defer)
|
||||
{
|
||||
FSZIP_Decompress_Destroy(decompress);
|
||||
decompress = NULL;
|
||||
|
||||
nc = FSZIP_Decompress_Init(source, cstart, csize, usize);
|
||||
|
||||
while (upos < usize)
|
||||
{
|
||||
chunk = usize - upos;
|
||||
if (chunk > sizeof(buffer))
|
||||
chunk = sizeof(buffer);
|
||||
if (!FSZIP_Decompress_Read(nc, buffer, chunk))
|
||||
break;
|
||||
if (VFS_WRITE(defer, buffer, chunk) != chunk)
|
||||
break;
|
||||
upos += chunk;
|
||||
}
|
||||
FSZIP_Decompress_Destroy(nc);
|
||||
|
||||
return defer;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
struct decompressstate
|
||||
{
|
||||
// zipfile_t *source;
|
||||
// qofs_t cstart; //position of start of data
|
||||
// qofs_t cofs; //current read offset
|
||||
// qofs_t cend; //compressed data ends at this point.
|
||||
// qofs_t usize; //data remaining. refuse to read more bytes than this.
|
||||
// unsigned char inbuffer[16384];
|
||||
// unsigned char outbuffer[16384];
|
||||
// unsigned int readoffset;
|
||||
};
|
||||
struct decompressstate *FSZIP_Decompress_Init(zipfile_t *source, qofs_t start, qofs_t csize, qofs_t usize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
qofs_t FSZIP_Decompress_Read(struct decompressstate *st, qbyte *buffer, qofs_t bytes)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FSZIP_Decompress_Destroy(struct decompressstate *st)
|
||||
{
|
||||
}
|
||||
|
||||
vfsfile_t *FSZIP_Decompress_ToTempFile(struct decompressstate *decompress)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
//an open vfsfile_t
|
||||
typedef struct {
|
||||
vfsfile_t funcs;
|
||||
|
||||
|
@ -567,35 +636,9 @@ static qboolean QDECL VFSZIP_Seek (struct vfsfile_s *file, qofs_t pos)
|
|||
//This is *really* inefficient
|
||||
if (vfsz->decompress)
|
||||
{ //if they're going to seek on a file in a zip, let's just copy it out
|
||||
qofs_t cstart = vfsz->decompress->cstart, csize = vfsz->decompress->cend - cstart;
|
||||
qofs_t upos = 0, usize = vfsz->length;
|
||||
qofs_t chunk;
|
||||
struct decompressstate *nc;
|
||||
qbyte buffer[16384];
|
||||
|
||||
vfsz->defer = FS_OpenTemp();
|
||||
vfsz->defer = FSZIP_Decompress_ToTempFile(vfsz->decompress);
|
||||
if (vfsz->defer)
|
||||
{
|
||||
FSZIP_Decompress_Destroy(vfsz->decompress);
|
||||
vfsz->decompress = NULL;
|
||||
|
||||
nc = FSZIP_Decompress_Init(vfsz->parent, cstart, csize, usize);
|
||||
|
||||
while (upos < usize)
|
||||
{
|
||||
chunk = usize - upos;
|
||||
if (chunk > sizeof(buffer))
|
||||
chunk = sizeof(buffer);
|
||||
if (!FSZIP_Decompress_Read(nc, buffer, chunk))
|
||||
break;
|
||||
if (VFS_WRITE(vfsz->defer, buffer, chunk) != chunk)
|
||||
break;
|
||||
upos += chunk;
|
||||
}
|
||||
FSZIP_Decompress_Destroy(nc);
|
||||
|
||||
return VFS_SEEK(vfsz->defer, pos);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1468,5 +1511,3 @@ struct archivedeltafuncs_s *FSZIP_OpenDeltaZip(qdownload_t *dl)
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -562,6 +562,10 @@ void GLBE_UploadAllLightmaps(void)
|
|||
lightmap[i]->lightmaps);
|
||||
break;
|
||||
}
|
||||
//for completeness.
|
||||
lm->lightmap_texture->width = lm->width;
|
||||
lm->lightmap_texture->height = lm->height;
|
||||
lm->lightmap_texture->status = TEX_LOADED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3496,6 +3496,8 @@ void Shader_Programify (shader_t *s)
|
|||
pass = &s->passes[i];
|
||||
if (pass->rgbgen == RGB_GEN_LIGHTING_DIFFUSE)
|
||||
modellighting = pass;
|
||||
else if (pass->rgbgen == RGB_GEN_ENTITY)
|
||||
modellighting = pass;
|
||||
else if (pass->texgen == T_GEN_LIGHTMAP && pass->tcgen == TC_GEN_LIGHTMAP)
|
||||
lightmap = pass;
|
||||
}
|
||||
|
@ -3523,15 +3525,6 @@ void Shader_Programify (shader_t *s)
|
|||
s->numpasses = 0;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_DIFFUSE;
|
||||
|
||||
if (lightmap)
|
||||
{
|
||||
s->passes[s->numpasses++].texgen = T_GEN_LIGHTMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_NORMALMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_DELUXMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_FULLBRIGHT;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_SPECULAR;
|
||||
}
|
||||
|
||||
if (modellighting)
|
||||
{
|
||||
s->passes[s->numpasses++].texgen = T_GEN_LOWEROVERLAY;
|
||||
|
@ -3540,6 +3533,14 @@ void Shader_Programify (shader_t *s)
|
|||
s->passes[s->numpasses++].texgen = T_GEN_NORMALMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_SPECULAR;
|
||||
}
|
||||
else if (lightmap)
|
||||
{
|
||||
s->passes[s->numpasses++].texgen = T_GEN_LIGHTMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_NORMALMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_DELUXMAP;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_FULLBRIGHT;
|
||||
s->passes[s->numpasses++].texgen = T_GEN_SPECULAR;
|
||||
}
|
||||
}
|
||||
|
||||
void Shader_Finish (shader_t *s)
|
||||
|
|
|
@ -1486,6 +1486,14 @@ static GLhandleARB GLSlang_CreateShader (const char *name, int ver, const char *
|
|||
length[strings] = strlen(prstrings[strings]);
|
||||
strings++;
|
||||
}
|
||||
if (ver >= 140)
|
||||
{
|
||||
prstrings[strings] =
|
||||
"#define varying in\n"
|
||||
;
|
||||
length[strings] = strlen(prstrings[strings]);
|
||||
strings++;
|
||||
}
|
||||
break;
|
||||
case GL_TESS_CONTROL_SHADER_ARB:
|
||||
prstrings[strings] = "#define TESS_CONTROL_SHADER\n";
|
||||
|
@ -1513,14 +1521,7 @@ static GLhandleARB GLSlang_CreateShader (const char *name, int ver, const char *
|
|||
length[strings] = strlen(prstrings[strings]);
|
||||
strings++;
|
||||
}
|
||||
if (ver < 140)
|
||||
{
|
||||
prstrings[strings] =
|
||||
"#define in attribute\n"
|
||||
"#define out varying\n"
|
||||
;
|
||||
}
|
||||
else
|
||||
if (ver >= 140)
|
||||
{
|
||||
prstrings[strings] =
|
||||
"#define attribute in\n"
|
||||
|
@ -1532,9 +1533,9 @@ static GLhandleARB GLSlang_CreateShader (const char *name, int ver, const char *
|
|||
if (gl_config.nofixedfunc || ver >= 140)
|
||||
{
|
||||
prstrings[strings] =
|
||||
"in vec3 v_position1;\n"
|
||||
"attribute vec3 v_position1;\n"
|
||||
"#ifdef FRAMEBLEND\n"
|
||||
"in vec3 v_position2;\n"
|
||||
"attribute vec3 v_position2;\n"
|
||||
"uniform vec2 e_vblend;\n"
|
||||
"#define v_position ((v_position1*e_vblend.x)+(v_position2*e_vblend.y))\n"
|
||||
"#else\n"
|
||||
|
@ -1551,7 +1552,7 @@ static GLhandleARB GLSlang_CreateShader (const char *name, int ver, const char *
|
|||
{
|
||||
prstrings[strings] =
|
||||
"#ifdef FRAMEBLEND\n"
|
||||
"in vec3 v_position2;\n"
|
||||
"attribute vec3 v_position2;\n"
|
||||
"uniform vec2 e_vblend;\n"
|
||||
"#define v_position (gl_Vertex.xyz*e_vblend.x+v_position2*e_vblend.y)\n"
|
||||
"uniform mat4 m_modelviewprojection;\n"
|
||||
|
@ -1777,8 +1778,11 @@ union programhandle_u GLSlang_CreateProgram(const char *name, int ver, const cha
|
|||
|
||||
if (!gl_config.arb_shader_objects)
|
||||
return ret;
|
||||
if ((cont || frag) && !qglPatchParameteriARB)
|
||||
if ((cont || eval) && !qglPatchParameteriARB)
|
||||
{
|
||||
Con_Printf("GLSlang_CreateProgram: %s requires tesselation support, but your gl drivers do not appear to support this\n", name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!precompilerconstants)
|
||||
precompilerconstants = &nullconstants;
|
||||
|
|
|
@ -312,7 +312,7 @@ void Net_TCPListen(cluster_t *cluster, int port, qboolean ipv6)
|
|||
{
|
||||
printf("socket bind error %i (%s)\n", qerrno, strerror(qerrno));
|
||||
closesocket(sock);
|
||||
return INVALID_SOCKET;
|
||||
return;
|
||||
}
|
||||
|
||||
listen(sock, 2); //don't listen for too many clients.
|
||||
|
|
Loading…
Reference in a new issue