Added VF_PROJECTIONOFFSET to offset the projection (for GoaLitiuM).

Added mod_h2holey_bugged cvar for better compat with quakespasm's bugs (for xaGe et al).
Some minor compiler warning/error fixes.


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5600 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2020-01-13 07:03:28 +00:00
parent 73f92fb799
commit 67b5041ec8
14 changed files with 68 additions and 48 deletions

View File

@ -6522,7 +6522,9 @@ void Host_FinishLoading(void)
return;
}
#ifdef PLUGINS
Plug_Initialise(true);
#endif
Con_History_Load();

View File

@ -1750,13 +1750,13 @@ int Image_WritePNG (const char *filename, enum fs_relative fsroot, int compressi
case PTI_L8:
havepad = false;
colourtype = PNG_COLOR_TYPE_GRAY;
chanbits = 16;
chanbits = 8;
bgr = false;
break;
case PTI_L8A8:
havepad = false;
colourtype = PNG_COLOR_TYPE_GRAY_ALPHA;
chanbits = 16;
chanbits = 8;
bgr = false;
break;
@ -11246,13 +11246,17 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
rgbadata = BZ_Malloc(imgwidth * imgheight*4);
for (i = 0; i < imgwidth * imgheight; i++)
{
if (((qbyte*)rawdata)[i] == 0xff || ((qbyte*)rawdata)[i] == 0)
{//fixme: blend non-0xff neighbours. no, just use premultiplied alpha instead, where it matters.
qbyte px = ((qbyte*)rawdata)[i];
//Note: The proper value here is 0.
//However, hexen2 has a bug that ALSO treats 255 the same way, but ONLY in the GL version.
//So allow both.
if (px == 0xff || px == 0)
{//fixme: blend opaque neighbours? no, just use premultiplied alpha instead, where it matters.
rgbadata[i] = 0;
mips->encoding = PTI_RGBA8;
}
else
rgbadata[i] = d_8to24rgbtable[((qbyte*)rawdata)[i]];
rgbadata[i] = d_8to24rgbtable[px];
}
if (freedata)
BZ_Free(rawdata);

View File

@ -1239,7 +1239,7 @@ static void PM_PreparePackageList(void)
//figure out what we've previously installed.
if (!loadedinstalled)
{
size_t sz = 0;
qofs_t sz = 0;
char *f = FS_MallocFile(INSTALLEDFILES, FS_ROOT, &sz);
loadedinstalled = true;
if (f)

View File

@ -262,6 +262,7 @@ typedef struct
vec3_t viewaxis[3]; /*forward, left, up (NOT RIGHT)*/
vec3_t headaxis[3]; /*this is for head mounted displays. this is relative to the view*/
vec3_t eyeoffset; /*world space, for vr screenies*/
vec2_t projectionoffset; /*for off-centre rendering*/
float fov_x, fov_y, afov;
float fovv_x, fovv_y; //viewmodel fovs

View File

@ -211,6 +211,7 @@ cvar_t r_menutint = CVARF ("r_menutint", "0.68 0.4 0.13",
CVAR_RENDERERCALLBACK);
cvar_t r_netgraph = CVARD ("r_netgraph", "0", "Displays a graph of packet latency. A value of 2 will give additional info about what sort of data is being received from the server.");
extern cvar_t r_lerpmuzzlehack;
extern cvar_t mod_h2holey_bugged;
cvar_t r_nolerp = CVARF ("r_nolerp", "0", CVAR_ARCHIVE);
cvar_t r_noframegrouplerp = CVARF ("r_noframegrouplerp", "0", CVAR_ARCHIVE);
cvar_t r_nolightdir = CVARF ("r_nolightdir", "0", CVAR_ARCHIVE);
@ -555,6 +556,9 @@ void GLRenderer_Init(void)
#ifdef PSKMODELS
Cvar_Register (&dpcompat_psa_ungroup, GLRENDEREROPTIONS);
#endif
#ifdef MD1MODELS
Cvar_Register (&mod_h2holey_bugged, GLRENDEREROPTIONS);
#endif
Cvar_Register (&r_lerpmuzzlehack, GLRENDEREROPTIONS);
Cvar_Register (&r_noframegrouplerp, GLRENDEREROPTIONS);

View File

@ -1544,6 +1544,7 @@ void V_ClearRefdef(playerview_t *pv)
r_refdef.fov_y = 0;
r_refdef.fovv_x = 0;
r_refdef.fovv_y = 0;
r_refdef.projectionoffset[0] = r_refdef.projectionoffset[1] = 0;
r_refdef.drawsbar = (cl.intermissionmode == IM_NONE);
r_refdef.flags = 0;

View File

@ -20,6 +20,9 @@
qboolean r_loadbumpmapping;
extern cvar_t r_noframegrouplerp;
cvar_t r_lerpmuzzlehack = CVARF ("r_lerpmuzzlehack", "1", CVAR_ARCHIVE);
#ifdef MD1MODELS
cvar_t mod_h2holey_bugged = CVARD ("mod_h2holey_bugged", "0", "Hexen2's holey-model flag uses index 0 as transparent (and additionally 255 in gl, due to a bug). GLQuake engines tend to have bugs that use ONLY index 255, resulting in a significant compatibility issue that can be resolved only with this shitty cvar hack.");
#endif
static void QDECL r_meshpitch_callback(cvar_t *var, char *oldvalue)
{
if (!strcmp(var->string, "-1") || !strcmp(var->string, "1"))
@ -585,7 +588,7 @@ static const float *Alias_ConvertBoneData(skeltype_t sourcetype, const float *so
for (i = 0; i < bonecount; i++)
{
if (bones[i].parent >= 0)
R_ConcatTransforms((void*)(dest + bones[i].parent*12), (void*)(sourcedata+i*12), (void*)(dest+i*12));
R_ConcatTransforms((const void*)(dest + bones[i].parent*12), (const void*)(sourcedata+i*12), (void*)(dest+i*12));
else
{
Vector4Copy(sourcedata+i*12+0, dest+i*12+0);
@ -609,7 +612,7 @@ static const float *Alias_ConvertBoneData(skeltype_t sourcetype, const float *so
for (i = 0; i < bonecount; i++)
{
Matrix3x4_Invert_Simple(bones[i].inverse, iim);
R_ConcatTransforms((void*)(sourcedata + i*12), (void*)iim, (void*)(dest + i*12));
R_ConcatTransforms((const void*)(sourcedata + i*12), (const void*)iim, (void*)(dest + i*12));
}
sourcedata = dest;
sourcetype = SKEL_ABSOLUTE;
@ -627,7 +630,7 @@ static const float *Alias_ConvertBoneData(skeltype_t sourcetype, const float *so
if (bones[i].parent >= 0)
{
Matrix3x4_Invert_Simple(sourcedata+bones[i].parent*12, ip);
R_ConcatTransforms((void*)ip, (void*)(sourcedata+i*12), (void*)(dest+i*12));
R_ConcatTransforms((const void*)ip, (const void*)(sourcedata+i*12), (void*)(dest+i*12));
}
else
{
@ -648,7 +651,7 @@ static const float *Alias_ConvertBoneData(skeltype_t sourcetype, const float *so
{
float *dest = (sourcedata == destbuffer)?destbufferalt:destbuffer;
for (i = 0; i < bonecount; i++)
R_ConcatTransforms((void*)(sourcedata + i*12), (void*)(bones[i].inverse), (void*)(dest + i*12));
R_ConcatTransforms((const void*)(sourcedata + i*12), (const void*)(bones[i].inverse), (void*)(dest + i*12));
sourcedata = dest;
sourcetype = SKEL_INVERSE_ABSOLUTE;
}
@ -1369,7 +1372,7 @@ static void Alias_BuildSkeletalMesh(mesh_t *mesh, framestate_t *framestate, gali
if (meshcache.bonecachetype != SKEL_INVERSE_ABSOLUTE)
meshcache.usebonepose = Alias_GetBoneInformation(inf, framestate, meshcache.bonecachetype=SKEL_INVERSE_ABSOLUTE, meshcache.boneposebuffer1, meshcache.boneposebuffer2, MAX_BONES);
if (1)
if ((1))
Alias_TransformVerticies_VNST(meshcache.usebonepose, inf->numverts, bidx, weight,
inf->ofs_skel_xyz[0], mesh->xyz_array[0],
inf->ofs_skel_norm[0], mesh->normals_array[0],
@ -2560,7 +2563,7 @@ static qboolean Mod_Trace(model_t *model, int forcehullnum, const framestate_t *
{
vec3_t iaxis[3];
vec3_t norm;
Matrix3x3_RM_Invert_Simple((void *)axis, iaxis);
Matrix3x3_RM_Invert_Simple((const void *)axis, iaxis);
VectorCopy(trace->plane.normal, norm);
trace->plane.normal[0] = DotProduct(norm, iaxis[0]);
trace->plane.normal[1] = DotProduct(norm, iaxis[1]);
@ -3075,7 +3078,12 @@ void Mod_LoadAliasShaders(model_t *mod)
else
#endif
if(mod->flags & MFH2_HOLEY)
skintranstype = TF_H2_TRANS8_0; //hexen2
{
//in hexen2, the official value is 0.
//hexen2's GL renderer ONLY also has a bug that ADDITIONALLY translates index 255. this is the 'normal' behaviour.
//quakespasm has a bug that translates ONLY 255 and ignores 0. massive fuckup, when index 0 is more commonly used (and is also a dupe anyway, with q1's palette).
skintranstype = mod_h2holey_bugged.ival?TF_TRANS8:TF_H2_TRANS8_0; //hexen2
}
#ifdef HEXEN2
else if(mod->flags & MFH2_SPECIAL_TRANS)
skintranstype = TF_H2_T4A4; //hexen2
@ -5077,7 +5085,7 @@ qboolean Mod_GetTag(model_t *model, int tagnum, framestate_t *fstate, float *res
tagnum = bone[tagnum].parent;
}
for (b = 0; b < numbonegroups; lerp++, b++)
for (b = 0; b < numbonegroups; b++)
for (k = 0; k < lerps[b].lerpcount; k++)
BZ_Free(lerps[b].needsfree[k]);
return true;

View File

@ -523,7 +523,7 @@ static qboolean FS_GamedirIsOkay(const char *path)
//don't allow leading dots, hidden files are evil.
//don't allow complex paths. those are evil too.
if (!*path || *path == '.' || !strcmp(path, ".") || strstr(path, "..") || strstr(path, "/")
|| strstr(path, "\\") || strstr(path, ":") )
|| strstr(path, "\\") || strstr(path, ":") || strstr(path, "\""))
{
Con_Printf ("Gamedir should be a single filename, not \"%s\"\n", path);
return false;
@ -2252,6 +2252,7 @@ void FS_CreatePath(const char *pname, enum fs_relative relativeto)
COM_CreatePath(fullname);
}
//FIXME: why is this qofs_t and not size_t?!?
void *FS_MallocFile(const char *filename, enum fs_relative relativeto, qofs_t *filesize)
{
vfsfile_t *f;
@ -2264,9 +2265,15 @@ void *FS_MallocFile(const char *filename, enum fs_relative relativeto, qofs_t *f
len = VFS_GETLEN(f);
if (filesize)
*filesize = len;
if (len >= ~(size_t)0)
{
VFS_CLOSE(f);
Con_Printf(CON_ERROR"File %s: too large\n", filename);
return NULL;
}
buf = (qbyte*)BZ_Malloc(len+1);
if (!buf)
if (!buf) //this could be a soft error, but I don't want to have to deal with users reporting misc unrelated issues (and frankly most malloc failures are due to OOB writes)
Sys_Error ("FS_MallocFile: out of memory loading %s", filename);
((qbyte *)buf)[len] = 0;
@ -3269,10 +3276,8 @@ void COM_Gamedir (const char *dir, const struct gamepacks *packagespaths)
if (!fs_manifest)
FS_ChangeGame(NULL, true, false);
//don't allow leading dots, hidden files are evil.
//don't allow complex paths. those are evil too.
if (*dir == '.' || !strcmp(dir, ".") || strstr(dir, "..") || strstr(dir, "/")
|| strstr(dir, "\\") || strstr(dir, ":") || strstr(dir, "\"") )
//we do allow empty here, for base.
if (*dir && !FS_GamedirIsOkay(dir))
{
Con_Printf ("Gamedir should be a single filename, not \"%s\"\n", dir);
return;
@ -3352,8 +3357,9 @@ void COM_Gamedir (const char *dir, const struct gamepacks *packagespaths)
/*ezquake cheats and compat*/
#define EZQUAKECOMPETITIVE "set ruleset_allow_fbmodels 1\nset sv_demoExtensions \"\"\n"
/*quake requires a few settings for compatibility*/
#define QRPCOMPAT "set cl_cursor_scale 0.2\nset cl_cursor_bias_x 7.5\nset cl_cursor_bias_y 0.8"
#define QCFG "set v_gammainverted 1\nset con_stayhidden 0\nset com_parseutf8 0\nset allow_download_pakcontents 1\nset allow_download_refpackages 0\nset sv_bigcoords \"\"\nmap_autoopenportals 1\n" "sv_port "STRINGIFY(PORT_QWSERVER)" "STRINGIFY(PORT_NQSERVER)"\n" ZFIXHACK EZQUAKECOMPETITIVE QRPCOMPAT
#define QRPCOMPAT "set cl_cursor_scale 0.2\nset cl_cursor_bias_x 7.5\nset cl_cursor_bias_y 0.8\n"
#define QUAKESPASMSUCKS "mod_h2holey_bugged 1\n"
#define QCFG "set v_gammainverted 1\nset con_stayhidden 0\nset com_parseutf8 0\nset allow_download_pakcontents 1\nset allow_download_refpackages 0\nset sv_bigcoords \"\"\nmap_autoopenportals 1\n" "sv_port "STRINGIFY(PORT_QWSERVER)" "STRINGIFY(PORT_NQSERVER)"\n" ZFIXHACK EZQUAKECOMPETITIVE QRPCOMPAT QUAKESPASMSUCKS
/*NetQuake reconfiguration, to make certain people feel more at home...*/
#define NQCFG "//-nohome\ncfg_save_auto 1\n" QCFG "sv_nqplayerphysics 1\ncl_loopbackprotocol auto\ncl_sbar 1\nplug_sbar 0\nsv_port "STRINGIFY(PORT_NQSERVER)"\ncl_defaultport "STRINGIFY(PORT_NQSERVER)"\n"
//nehahra has to be weird with its extra cvars, and buggy fullbrights.

View File

@ -742,7 +742,8 @@ typedef enum
VF_ENVMAP = 220, //cubemap image for reflectcube
VF_USERDATA = 221,
VF_SKYROOM_CAMERA = 222,
VF_PIXELPSCALE = 223, //[dpi_x, dpi_y, dpi_y/dpi_x]
VF_PIXELPSCALE = 223, //[dpi_x, dpi_y, dpi_y/dpi_x]
VF_PROJECTIONOFFSET = 224, //allows for off-axis projections.
} viewflags;
/*FIXME: this should be changed*/

View File

@ -599,6 +599,11 @@ void R_SetupGL (float stereooffset, int i)
Matrix4x4_CM_Projection_Inf(r_refdef.m_projection_std, fov_x, fov_y, r_refdef.mindist, false);
Matrix4x4_CM_Projection_Inf(r_refdef.m_projection_view, fovv_x, fovv_y, r_refdef.mindist, false);
}
r_refdef.m_projection_std[8] += r_refdef.projectionoffset[0];
r_refdef.m_projection_std[9] += r_refdef.projectionoffset[1];
r_refdef.m_projection_view[8] += r_refdef.projectionoffset[0];
r_refdef.m_projection_view[9] += r_refdef.projectionoffset[1];
}
else
{

View File

@ -297,8 +297,6 @@ char *GLVID_GetRGBInfo(int *bytestride, int *truewidth, int *trueheight, enum up
}*/
else if (gl_config.gles || (*truewidth&3))
{
qbyte *p;
//gles:
//Only two format/type parameter pairs are accepted.
//GL_RGBA/GL_UNSIGNED_BYTE is always accepted, and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.
@ -306,20 +304,10 @@ char *GLVID_GetRGBInfo(int *bytestride, int *truewidth, int *trueheight, enum up
//desktopgl:
//total line byte length must be aligned to GL_PACK_ALIGNMENT. by reading rgba instead of rgb, we can ensure the line is a multiple of 4 bytes.
*fmt = PTI_RGBA8;
ret = BZ_Malloc((*truewidth)*(*trueheight)*4);
qglReadPixels (0, 0, (*truewidth), (*trueheight), GL_RGBA, GL_UNSIGNED_BYTE, ret);
*bytestride = *truewidth*-3;
*fmt = PTI_RGB8;
c = (*truewidth)*(*trueheight);
p = ret;
for (i = 1; i < c; i++)
{
p[i*3+0]=p[i*4+0];
p[i*3+1]=p[i*4+1];
p[i*3+2]=p[i*4+2];
}
ret = BZ_Realloc(ret, (*truewidth)*(*trueheight)*3);
*bytestride = *truewidth*-4;
}
#if 1//def _DEBUG
else if (!gl_config.gles && sh_config.texfmt[PTI_BGRA8])

View File

@ -1143,7 +1143,7 @@ LRESULT CALLBACK MySubclassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
for (colon1 = line+strlen(line)-1; *colon1 <= ' ' && colon1>=line; colon1--)
*colon1 = '\0';
if (!strncmp(line, "warning: ", 9))
memmove(line, line+9, sizeof(line));
memmove(line, line+9, sizeof(line)-9);
colon1=line;
do
{
@ -2474,7 +2474,8 @@ char *GetTooltipText(editor_t *editor, int pos, pbool dwell)
if (dwell)
{
strncpy(tooltip_variable, term, sizeof(tooltip_variable)-1);
strncpy(tooltip_variable, term, sizeof(tooltip_variable));
tooltip_variable[sizeof(tooltip_variable)-1] = 0;
tooltip_position = pos;
tooltip_editor = editor;
@ -6291,9 +6292,11 @@ static LRESULT CALLBACK MainWndProc(HWND hWnd,UINT message,
oldlen = strlen(filename);
newlen = strlen(i.pszText);
if (oldlen + newlen + 2 > sizeof(filename))
break; //don't overflow.
memmove(filename+newlen+1, filename, oldlen+1);
filename[newlen] = '/';
strncpy(filename, i.pszText, newlen);
memcpy(filename, i.pszText, newlen);
}
EditFile(filename, -1, false);
break;

View File

@ -3044,6 +3044,8 @@ void PF_setmodel_Internal (pubprogfuncs_t *prinst, edict_t *e, const char *m)
}
else
{
//qw was fixed - it never sets the size of an alias model, mostly because it doesn't know it.
//this of course means that precache_model+setmodel doesn't stall.
if (mod && mod->type != mod_alias)
{
while(mod->loadstate == MLS_LOADING)
@ -3052,9 +3054,9 @@ void PF_setmodel_Internal (pubprogfuncs_t *prinst, edict_t *e, const char *m)
VectorCopy (mod->mins, e->v->mins);
VectorCopy (mod->maxs, e->v->maxs);
VectorSubtract (mod->maxs, mod->mins, e->v->size);
World_LinkEdict (&sv.world, (wedict_t*)e, false);
}
//qw was fixed - it never sets the size of an alias model, mostly because it doesn't know it.
//but do relink, because stuff bugs out otherwise.
World_LinkEdict (&sv.world, (wedict_t*)e, false);
}
}
}
@ -12622,6 +12624,7 @@ void PR_DumpPlatform_f(void)
{"VF_ENVMAP", "const float", CS|MENU, D("The cubemap name to use as a fallback for $reflectcube, if a shader was unable to load one. Note that this doesn't automatically change shader permutations or anything."), VF_ENVMAP},
{"VF_USERDATA", "const float", CS|MENU, D("Pointer (and byte size) to an array of vec4s. This data is then globally visible to all glsl via the w_user uniform."), VF_USERDATA},
{"VF_SKYROOM_CAMERA", "const float", CS, D("Controls the camera position of the skyroom (which will be drawn underneath transparent sky surfaces). This should move slightly with the real camera, but not so much that the skycamera enters walls. Requires a skyshader with a blend mode on the first pass (or no passes)."), VF_SKYROOM_CAMERA},
{"VF_PROJECTIONOFFSET", "const float", CS|MENU, D("vec2 horizontal+vertical offset for the projection matrix, for weird off-centre rendering."), VF_PROJECTIONOFFSET},
{"IMGFMT_R8G8B8A8", "const float", CS|MENU, D("Typical 32bit rgba pixel format."), 1},
{"IMGFMT_R16G16B16A16F","const float", CS|MENU, D("Half-Float pixel format. Requires gl3 support."), 2},

View File

@ -7,12 +7,6 @@
extern plugmodfuncs_t *modfuncs;
extern plugfsfuncs_t *filefuncs;
#if MAX_INDICIES == 0xffffu
#warning 16bit indexes
#else
#warning 32bit indexes
#endif
#ifdef SKELETALMODELS
#define GLTFMODELS
#endif