mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Add custom FOV support for HUD model definitions with the 'fov' DEF token (in build angles). Also adds an r_pr_overridehud cvar in order to preview DEF token changes in-game using the r_pr_hud* cvars.
git-svn-id: https://svn.eduke32.com/eduke32@1814 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
219c136f24
commit
4430b3ca3f
7 changed files with 77 additions and 19 deletions
|
@ -698,7 +698,7 @@ static inline int32_t md_tilehasmodel(int32_t tilenume,int32_t pal)
|
|||
int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, int32_t skinnum, float smoothduration, int32_t pal);
|
||||
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend, int32_t fps, int32_t flags);
|
||||
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor);
|
||||
int32_t md_definehud (int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags);
|
||||
int32_t md_definehud (int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags, int32_t fov);
|
||||
int32_t md_undefinetile(int32_t tile);
|
||||
int32_t md_undefinemodel(int32_t modelid);
|
||||
|
||||
|
|
|
@ -231,9 +231,9 @@ void freeallmodels(void);
|
|||
void clearskins(void);
|
||||
int32_t mddraw(spritetype *tspr);
|
||||
|
||||
typedef struct { float xadd, yadd, zadd; int16_t angadd, flags; } hudtyp;
|
||||
typedef struct { float xadd, yadd, zadd; int16_t angadd, flags, fov; } hudtyp;
|
||||
|
||||
EXTERN hudtyp hudmem[2][MAXTILES]; //~320KB ... ok for now ... could replace with dynamic alloc
|
||||
EXTERN hudtyp hudmem[2][MAXTILES];
|
||||
|
||||
EXTERN int32_t mdpause;
|
||||
EXTERN int32_t nummodelsalloced, nextmodelid;
|
||||
|
|
|
@ -53,6 +53,12 @@ extern int32_t pr_overridespecular;
|
|||
extern float pr_specularpower;
|
||||
extern float pr_specularfactor;
|
||||
extern int32_t pr_highpalookups;
|
||||
extern int32_t pr_overridehud;
|
||||
extern float pr_hudxadd;
|
||||
extern float pr_hudyadd;
|
||||
extern float pr_hudzadd;
|
||||
extern int32_t pr_hudangadd;
|
||||
extern int32_t pr_hudfov;
|
||||
extern int32_t pr_ati_fboworkaround;
|
||||
extern int32_t pr_ati_nodepthoffset;
|
||||
#ifdef __APPLE__
|
||||
|
@ -283,6 +289,7 @@ typedef struct s_pranimatespritesinfo {
|
|||
// EXTERNAL FUNCTIONS
|
||||
int32_t polymer_init(void);
|
||||
void polymer_uninit(void);
|
||||
void polymer_setaspect(int32_t);
|
||||
void polymer_glinit(void);
|
||||
void polymer_resetlights(void);
|
||||
void polymer_loadboard(void);
|
||||
|
|
|
@ -58,6 +58,7 @@ enum scripttoken_t
|
|||
T_YADD,
|
||||
T_ZADD,
|
||||
T_ANGADD,
|
||||
T_FOV,
|
||||
T_FLIPPED,
|
||||
T_HIDE,
|
||||
T_NOBOB,
|
||||
|
@ -1199,7 +1200,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
char *hudtokptr = script->ltextptr;
|
||||
char happy=1, *frameend;
|
||||
int32_t ftilenume = -1, ltilenume = -1, tilex = 0, flags = 0;
|
||||
int32_t ftilenume = -1, ltilenume = -1, tilex = 0, flags = 0, fov = -1;
|
||||
double xadd = 0.0, yadd = 0.0, zadd = 0.0, angadd = 0.0;
|
||||
|
||||
static const tokenlist modelhudtokens[] =
|
||||
|
@ -1211,6 +1212,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{ "yadd", T_YADD },
|
||||
{ "zadd", T_ZADD },
|
||||
{ "angadd", T_ANGADD },
|
||||
{ "fov", T_FOV },
|
||||
{ "hide", T_HIDE },
|
||||
{ "nobob", T_NOBOB },
|
||||
{ "flipped",T_FLIPPED},
|
||||
|
@ -1236,6 +1238,8 @@ static int32_t defsparser(scriptfile *script)
|
|||
scriptfile_getdouble(script,&zadd); break;
|
||||
case T_ANGADD:
|
||||
scriptfile_getdouble(script,&angadd); break;
|
||||
case T_FOV:
|
||||
scriptfile_getsymbol(script,&fov); break;
|
||||
case T_HIDE:
|
||||
flags |= 1; break;
|
||||
case T_NOBOB:
|
||||
|
@ -1267,7 +1271,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++)
|
||||
{
|
||||
switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags))
|
||||
switch (md_definehud(lastmodelid, tilex, xadd, yadd, zadd, angadd, flags, fov))
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
|
|
@ -372,7 +372,7 @@ int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t md_definehud(int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags)
|
||||
int32_t md_definehud(int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags, int32_t fov)
|
||||
{
|
||||
if (!mdinited) mdinit();
|
||||
|
||||
|
@ -384,6 +384,7 @@ int32_t md_definehud(int32_t modelid, int32_t tilex, double xadd, double yadd, d
|
|||
hudmem[(flags>>2)&1][tilex].zadd = zadd;
|
||||
hudmem[(flags>>2)&1][tilex].angadd = ((int16_t)angadd)|2048;
|
||||
hudmem[(flags>>2)&1][tilex].flags = (int16_t)flags;
|
||||
hudmem[(flags>>2)&1][tilex].fov = (int16_t)fov;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,12 @@ int32_t pr_overridespecular = 0;
|
|||
float pr_specularpower = 15.0f;
|
||||
float pr_specularfactor = 1.0f;
|
||||
int32_t pr_highpalookups = 1;
|
||||
int32_t pr_overridehud = 0;
|
||||
float pr_hudxadd = 0.0f;
|
||||
float pr_hudyadd = 0.0f;
|
||||
float pr_hudzadd = 0.0f;
|
||||
int32_t pr_hudangadd = 0;
|
||||
int32_t pr_hudfov = 426;
|
||||
int32_t pr_ati_fboworkaround = 0;
|
||||
int32_t pr_ati_nodepthoffset = 0;
|
||||
#ifdef __APPLE__
|
||||
|
@ -746,10 +752,23 @@ void polymer_uninit(void)
|
|||
}
|
||||
}
|
||||
|
||||
void polymer_glinit(void)
|
||||
void polymer_setaspect(int32_t ang)
|
||||
{
|
||||
float aspect;
|
||||
|
||||
if (pr_customaspect != 0.0f)
|
||||
aspect = pr_customaspect;
|
||||
else
|
||||
aspect = (float)(windowx2-windowx1+1) /
|
||||
(float)(windowy2-windowy1+1);
|
||||
|
||||
bglMatrixMode(GL_PROJECTION);
|
||||
bglLoadIdentity();
|
||||
bgluPerspective((float)(ang) / (2048.0f / 360.0f), aspect, 0.01f, 100.0f);
|
||||
}
|
||||
|
||||
void polymer_glinit(void)
|
||||
{
|
||||
bglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
bglClearStencil(0);
|
||||
bglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
@ -757,8 +776,6 @@ void polymer_glinit(void)
|
|||
|
||||
// texturing
|
||||
bglEnable(GL_TEXTURE_2D);
|
||||
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
|
||||
bglTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
|
||||
|
||||
bglEnable(GL_DEPTH_TEST);
|
||||
bglDepthFunc(GL_LEQUAL);
|
||||
|
@ -770,16 +787,8 @@ void polymer_glinit(void)
|
|||
bglPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
else
|
||||
bglPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
if (pr_customaspect != 0.0f)
|
||||
aspect = pr_customaspect;
|
||||
else
|
||||
aspect = (float)(windowx2-windowx1+1) /
|
||||
(float)(windowy2-windowy1+1);
|
||||
|
||||
bglMatrixMode(GL_PROJECTION);
|
||||
bglLoadIdentity();
|
||||
bgluPerspective((float)(pr_fov) / (2048.0f / 360.0f), aspect, 0.01f, 100.0f);
|
||||
|
||||
polymer_setaspect(pr_fov);
|
||||
|
||||
bglMatrixMode(GL_MODELVIEW);
|
||||
bglLoadIdentity();
|
||||
|
|
|
@ -5279,6 +5279,15 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
x1 = hudmem[(dastat&4)>>2][picnum].xadd;
|
||||
y1 = hudmem[(dastat&4)>>2][picnum].yadd;
|
||||
z1 = hudmem[(dastat&4)>>2][picnum].zadd;
|
||||
|
||||
#ifdef POLYMER
|
||||
if (pr_overridehud) {
|
||||
x1 = pr_hudxadd;
|
||||
y1 = pr_hudyadd;
|
||||
z1 = pr_hudzadd;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(hudmem[(dastat&4)>>2][picnum].flags&2)) //"NOBOB" is specified in DEF
|
||||
{
|
||||
fx = ((double)sx)*(1.0/65536.0);
|
||||
|
@ -5312,6 +5321,12 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
}
|
||||
tspr.ang = hudmem[(dastat&4)>>2][picnum].angadd+globalang;
|
||||
|
||||
#ifdef POLYMER
|
||||
if (pr_overridehud) {
|
||||
tspr.ang = pr_hudangadd + globalang;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (dastat&4) { x1 = -x1; y1 = -y1; }
|
||||
|
||||
// In Polymost, we don't care if the model is very big
|
||||
|
@ -5389,6 +5404,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
# ifdef POLYMER
|
||||
else
|
||||
{
|
||||
int32_t fov;
|
||||
|
||||
tspriteptr[MAXSPRITESONSCREEN] = &tspr;
|
||||
|
||||
bglEnable(GL_ALPHA_TEST);
|
||||
|
@ -5396,8 +5413,22 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
|
|||
|
||||
spriteext[tspr.owner].roll = a;
|
||||
spriteext[tspr.owner].zoff = z;
|
||||
|
||||
fov = hudmem[(dastat&4)>>2][picnum].fov;
|
||||
|
||||
if (fov == -1) {
|
||||
fov = pr_fov;
|
||||
}
|
||||
|
||||
if (pr_overridehud) {
|
||||
fov = pr_hudfov;
|
||||
}
|
||||
|
||||
polymer_setaspect(fov);
|
||||
|
||||
polymer_drawsprite(MAXSPRITESONSCREEN);
|
||||
|
||||
polymer_setaspect(pr_fov);
|
||||
|
||||
spriteext[tspr.owner].zoff = 0;
|
||||
spriteext[tspr.owner].roll = 0;
|
||||
|
@ -6245,6 +6276,12 @@ void polymost_initosdfuncs(void)
|
|||
{ "r_pr_specularpower", "r_pr_specularpower: overriden specular material power", (void *) &pr_specularpower, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 },
|
||||
{ "r_pr_specularfactor", "r_pr_specularfactor: overriden specular material factor", (void *) &pr_specularfactor, CVAR_FLOAT | CVAR_NOSAVE, -10, 1000 },
|
||||
{ "r_pr_highpalookups", "r_pr_highpalookups: enable/disable highpalookups", (void *) &pr_highpalookups, CVAR_BOOL, 0, 1 },
|
||||
{ "r_pr_overridehud", "r_pr_overridehud: overrides hud model parameters with values from the pr_hud* cvars; use it to fine-tune DEF tokens", (void *) &pr_overridehud, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
|
||||
{ "r_pr_hudxadd", "r_pr_hudxadd: overriden HUD xadd; see r_pr_overridehud", (void *) &pr_hudxadd, CVAR_FLOAT | CVAR_NOSAVE, -100, 100 },
|
||||
{ "r_pr_hudyadd", "r_pr_hudyadd: overriden HUD yadd; see r_pr_overridehud", (void *) &pr_hudyadd, CVAR_FLOAT | CVAR_NOSAVE, -100, 100 },
|
||||
{ "r_pr_hudzadd", "r_pr_hudzadd: overriden HUD zadd; see r_pr_overridehud", (void *) &pr_hudzadd, CVAR_FLOAT | CVAR_NOSAVE, -100, 100 },
|
||||
{ "r_pr_hudangadd", "r_pr_hudangadd: overriden HUD angadd; see r_pr_overridehud", (void *) &pr_hudangadd, CVAR_INT | CVAR_NOSAVE, -512, 512 },
|
||||
{ "r_pr_hudfov", "r_pr_hudfov: overriden HUD fov; see r_pr_overridehud", (void *) &pr_hudfov, CVAR_INT | CVAR_NOSAVE, 0, 1023 },
|
||||
{ "r_pr_ati_fboworkaround", "r_pr_ati_fboworkaround: enable this to workaround an ATI driver bug that causes sprite shadows to be square - you need to restart the renderer for it to take effect", (void *) &pr_ati_fboworkaround, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
|
||||
{ "r_pr_ati_nodepthoffset", "r_pr_ati_nodepthoffset: enable this to workaround an ATI driver bug that causes sprite drawing to freeze the game on Radeon X1x00 hardware - you need to restart the renderer for it to take effect", (void *) &pr_ati_nodepthoffset, CVAR_BOOL | CVAR_NOSAVE, 0, 1 },
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue