Fix stuff and reimplement the kart features that went poof

This commit is contained in:
Latapostrophe 2019-06-12 21:36:47 +02:00
parent ff04e0c103
commit 53df420546
9 changed files with 321 additions and 287 deletions

View file

@ -346,6 +346,13 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
grtex->mipmap.height = (UINT16)blockheight; grtex->mipmap.height = (UINT16)blockheight;
grtex->mipmap.grInfo.format = textureformat; grtex->mipmap.grInfo.format = textureformat;
#ifdef GLENCORE
grtex->mipmap.colormap = colormaps;
if (encoremode)
grtex->mipmap.colormap += (256*32);
#endif
block = MakeBlock(&grtex->mipmap); block = MakeBlock(&grtex->mipmap);
if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading)
@ -617,6 +624,13 @@ void HWR_GetFlat(lumpnum_t flatlumpnum)
grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap; grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
#ifdef GLENCORE
grmip->colormap = colormaps;
if (encoremode)
grmip->colormap += (256*32);
#endif
if (!grmip->downloaded && !grmip->grInfo.data) if (!grmip->downloaded && !grmip->grInfo.data)
HWR_CacheFlat(grmip, flatlumpnum); HWR_CacheFlat(grmip, flatlumpnum);

View file

@ -76,6 +76,7 @@
#include "../r_state.h" #include "../r_state.h"
#include "../tables.h" #include "../tables.h"
#include "r_opengl/r_opengl.h" #include "r_opengl/r_opengl.h"
#include "../r_main.h" // for cv_fov
#ifdef HAVE_SPHEREFRUSTRUM #ifdef HAVE_SPHEREFRUSTRUM
static GLdouble viewMatrix[16]; static GLdouble viewMatrix[16];
@ -329,7 +330,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
// NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function
float render_fov = FIXED_TO_FLOAT(cv_grfov.value); float render_fov = FIXED_TO_FLOAT(cv_fov.value);
float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right? float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right?
float render_multiplier = 64.0f / render_fovratio / RMUL; float render_multiplier = 64.0f / render_fovratio / RMUL;

View file

@ -562,7 +562,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
} }
else // Do TRANSMAP** fade. else // Do TRANSMAP** fade.
{ {
Surf.PolyColor.s.rgba = pLocalPalette[color].rgba; Surf.PolyColor.rgba = pLocalPalette[color].rgba;
Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f); Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f);
} }
HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);

View file

@ -29,6 +29,7 @@
#include "../p_setup.h" #include "../p_setup.h"
#include "../r_local.h" #include "../r_local.h"
#include "../r_bsp.h" #include "../r_bsp.h"
#include "../r_main.h" // cv_fov
#include "../d_clisrv.h" #include "../d_clisrv.h"
#include "../w_wad.h" #include "../w_wad.h"
#include "../z_zone.h" #include "../z_zone.h"
@ -55,9 +56,7 @@ struct hwdriver_s hwdriver;
static void CV_filtermode_ONChange(void); static void CV_filtermode_ONChange(void);
static void CV_anisotropic_ONChange(void); static void CV_anisotropic_ONChange(void);
static void CV_grFov_OnChange(void);
static CV_PossibleValue_t grfov_cons_t[] = {{0, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}};
static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"},
{HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"}, {HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"},
{HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"}, {HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"},
@ -67,7 +66,6 @@ static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA
CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grfov = {"gr_fov", "90", CV_FLOAT|CV_CALL, grfov_cons_t, CV_grFov_OnChange, 0, NULL, NULL, 0, 0, NULL};
// Unfortunately, this can no longer be saved.. // Unfortunately, this can no longer be saved..
consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_CALL, grfiltermode_cons_t, consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_CALL, grfiltermode_cons_t,
@ -163,6 +161,20 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, UINT32 mixcolor, UIN
fog_color.s.green = (UINT8)(((float)fog_color.s.green) * fog_alpha); fog_color.s.green = (UINT8)(((float)fog_color.s.green) * fog_alpha);
fog_color.s.blue = (UINT8)(((float)fog_color.s.blue) * fog_alpha); fog_color.s.blue = (UINT8)(((float)fog_color.s.blue) * fog_alpha);
{
// be careful, this may get negative for high lightlevel values.
float fog = (fog_alpha - (light_level/255.0f))*3/2;
if (fog < 0)
fog = 0;
float red = (fog_color.s.red/255.0f) * fog / 1.0f + (final_color.s.red/255.0f) * (1.0f - fog) / 1.0f;
float green = (fog_color.s.green/255.0f) * fog / 1.0f + (final_color.s.green/255.0f) * (1.0f - fog) / 1.0f;
float blue = (fog_color.s.blue/255.0f) * fog / 1.0f + (final_color.s.blue/255.0f) * (1.0f - fog) / 1.0f;
final_color.s.red = (UINT8)(red*255.0f);
final_color.s.green = (UINT8)(green*255.0f);
final_color.s.blue = (UINT8)(blue*255.0f);
}
Surface->PolyColor.rgba = final_color.rgba; Surface->PolyColor.rgba = final_color.rgba;
Surface->FadeColor.rgba = fog_color.rgba; Surface->FadeColor.rgba = fog_color.rgba;
Surface->LightInfo.light_level = light_level; Surface->LightInfo.light_level = light_level;
@ -2947,7 +2959,7 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
// This is expecting a pointer to an array containing 4 wallVerts for a sprite // This is expecting a pointer to an array containing 4 wallVerts for a sprite
static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts) static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts)
{ {
if (cv_grspritebillboarding.value && spr && spr->mobj && wallVerts) if (cv_grspritebillboarding.value && spr && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE) && wallVerts)
{ {
float basey = FIXED_TO_FLOAT(spr->mobj->z); float basey = FIXED_TO_FLOAT(spr->mobj->z);
float lowy = wallVerts[0].y; float lowy = wallVerts[0].y;
@ -3225,7 +3237,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
wallVerts[1].y = endbot; wallVerts[1].y = endbot;
// The x and y only need to be adjusted in the case that it's not a papersprite // The x and y only need to be adjusted in the case that it's not a papersprite
if (cv_grspritebillboarding.value && spr->mobj) if (cv_grspritebillboarding.value && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE))
{ {
// Get the x and z of the vertices so billboarding draws correctly // Get the x and z of the vertices so billboarding draws correctly
realheight = realbot - realtop; realheight = realbot - realtop;
@ -3254,7 +3266,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
wallVerts[0].y = wallVerts[1].y = bot; wallVerts[0].y = wallVerts[1].y = bot;
// The x and y only need to be adjusted in the case that it's not a papersprite // The x and y only need to be adjusted in the case that it's not a papersprite
if (cv_grspritebillboarding.value && spr->mobj) if (cv_grspritebillboarding.value && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE))
{ {
// Get the x and z of the vertices so billboarding draws correctly // Get the x and z of the vertices so billboarding draws correctly
realheight = realbot - realtop; realheight = realbot - realtop;
@ -4210,28 +4222,63 @@ void HWR_ProjectSprite(mobj_t *thing)
I_Error("sprframes NULL for sprite %d\n", thing->sprite); I_Error("sprframes NULL for sprite %d\n", thing->sprite);
#endif #endif
if (sprframe->rotate) if (thing->player)
{ ang = R_PointToAngle (thing->x, thing->y) - thing->player->frameangle;
// choose a different rotation based on player view
ang = R_PointToAngle(thing->x, thing->y); // uses viewx,viewy
rot = (ang-thing->angle+ANGLE_202h)>>29;
//Fab: lumpid is the index for spritewidth,spriteoffset... tables
lumpoff = sprframe->lumpid[rot];
flip = sprframe->flip & (1<<rot);
}
else else
ang = R_PointToAngle (thing->x, thing->y) - thing->angle;
if (sprframe->rotate == SRF_SINGLE)
{ {
// use single rotation for all views // use single rotation for all views
rot = 0; //Fab: for vis->patch below rot = 0; //Fab: for vis->patch below
lumpoff = sprframe->lumpid[0]; //Fab: see note above lumpoff = sprframe->lumpid[0]; //Fab: see note above
flip = sprframe->flip; // Will only be 0x00 or 0xFF flip = sprframe->flip; // Will only be 0x00 or 0xFF
if (papersprite && ang < ANGLE_180)
{
if (flip)
flip = 0;
else
flip = 255;
}
}
else
{
// choose a different rotation based on player view
if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right
rot = 6; // F7 slot
else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left
rot = 2; // F3 slot
else // Normal behaviour
rot = (ang+ANGLE_202h)>>29;
//Fab: lumpid is the index for spritewidth,spriteoffset... tables
lumpoff = sprframe->lumpid[rot];
flip = sprframe->flip & (1<<rot);
if (papersprite && ang < ANGLE_180)
{
if (flip)
flip = 0;
else
flip = 1<<rot;
}
} }
if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES)
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)thing->skin)->highresscale); this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)thing->skin)->highresscale);
rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); if (papersprite)
rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); {
rightsin = FIXED_TO_FLOAT(FINESINE((thing->angle)>>ANGLETOFINESHIFT));
rightcos = FIXED_TO_FLOAT(FINECOSINE((thing->angle)>>ANGLETOFINESHIFT));
}
else
{
rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT));
rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT));
}
if (flip) if (flip)
{ {
x1 = (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset) * this_scale); x1 = (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset) * this_scale);
@ -4248,6 +4295,7 @@ void HWR_ProjectSprite(mobj_t *thing)
x1 = tr_x + x1 * rightcos; x1 = tr_x + x1 * rightcos;
x2 = tr_x - x2 * rightcos; x2 = tr_x - x2 * rightcos;
if (thing->eflags & MFE_VERTICALFLIP) if (thing->eflags & MFE_VERTICALFLIP)
{ {
gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale; gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
@ -4295,6 +4343,7 @@ void HWR_ProjectSprite(mobj_t *thing)
vis->flip = flip; vis->flip = flip;
vis->mobj = thing; vis->mobj = thing;
//Hurdler: 25/04/2000: now support colormap in hardware mode //Hurdler: 25/04/2000: now support colormap in hardware mode
if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
{ {
@ -4308,16 +4357,24 @@ void HWR_ProjectSprite(mobj_t *thing)
else if (thing->color) else if (thing->color)
{ {
// New colormap stuff for skins Tails 06-07-2002 // New colormap stuff for skins Tails 06-07-2002
if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player! if (thing->colorized)
vis->colormap = R_GetTranslationColormap(TC_RAINBOW, thing->color, GTC_CACHE);
else if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player!
{ {
size_t skinnum = (skin_t*)thing->skin-skins; size_t skinnum = (skin_t*)thing->skin-skins;
vis->colormap = R_GetTranslationColormap((INT32)skinnum, thing->color, GTC_CACHE); vis->colormap = R_GetTranslationColormap((INT32)skinnum, thing->color, GTC_CACHE);
} }
else else
vis->colormap = R_GetTranslationColormap(TC_DEFAULT, vis->mobj->color ? vis->mobj->color : SKINCOLOR_CYAN, GTC_CACHE); vis->colormap = R_GetTranslationColormap(TC_DEFAULT, thing->color, GTC_CACHE);
} }
else else
{
vis->colormap = colormaps; vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)))
vis->colormap += (256*32);
#endif
}
// set top/bottom coords // set top/bottom coords
vis->ty = gzt; vis->ty = gzt;
@ -4431,6 +4488,11 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->colormap = colormaps; vis->colormap = colormaps;
#ifdef GLENCORE
if (encoremap)
vis->colormap += (256*32);
#endif
// set top/bottom coords // set top/bottom coords
vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset);
@ -4476,7 +4538,7 @@ void HWR_DrawSkyBackground(void)
// The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture
angle = (viewangle + xtoviewangle[0]); angle = (viewangle + xtoviewangle[0]);
dimensionmultiply = ((float)textures[skytexture]->width/256.0f); dimensionmultiply = ((float)textures[skytexture]->width/256.0f)*2;
v[0].s = v[3].s = ((float) angle / ((ANGLE_90-1)*dimensionmultiply)); v[0].s = v[3].s = ((float) angle / ((ANGLE_90-1)*dimensionmultiply));
v[2].s = v[1].s = (-1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply)); v[2].s = v[1].s = (-1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply));
@ -4485,6 +4547,12 @@ void HWR_DrawSkyBackground(void)
angle = aimingangle; angle = aimingangle;
dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio)); dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio));
if (atransform.mirror)
{
angle = InvAngle(angle);
dimensionmultiply *= -1;
}
if (splitscreen == 1) if (splitscreen == 1)
{ {
dimensionmultiply *= 2; dimensionmultiply *= 2;
@ -4589,7 +4657,7 @@ void HWR_SetViewSize(void)
void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
{ {
angle_t a1; angle_t a1;
const float fpov = FIXED_TO_FLOAT(cv_grfov.value+player->fovadd); const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
postimg_t *postprocessor; postimg_t *postprocessor;
INT32 i; INT32 i;
@ -4658,6 +4726,9 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
if (*postprocessor == postimg_flip) if (*postprocessor == postimg_flip)
atransform.flip = true; atransform.flip = true;
if (*postprocessor == postimg_mirror)
atransform.mirror = true;
// Clear view, set viewport (glViewport), set perspective... // Clear view, set viewport (glViewport), set perspective...
HWR_ClearView(); HWR_ClearView();
HWR_ClearSprites(); HWR_ClearSprites();
@ -4731,7 +4802,6 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
{ {
const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on
// Clear the color buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. // Clear the color buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs.
if (viewnumber == 0) // Only do it if it's the first screen being rendered if (viewnumber == 0) // Only do it if it's the first screen being rendered
{ {
@ -4769,12 +4839,6 @@ void HWR_FoggingOn(void)
// 3D ENGINE COMMANDS // 3D ENGINE COMMANDS
// ========================================================================== // ==========================================================================
static void CV_grFov_OnChange(void)
{
if ((netgame || multiplayer) && !cv_debug && cv_grfov.value != 90*FRACUNIT)
CV_Set(&cv_grfov, cv_grfov.defaultvalue);
}
// ************************************************************************** // **************************************************************************
// 3D ENGINE SETUP // 3D ENGINE SETUP
// ************************************************************************** // **************************************************************************
@ -4786,7 +4850,6 @@ static void CV_grFov_OnChange(void)
void HWR_AddCommands(void) void HWR_AddCommands(void)
{ {
CV_RegisterVar(&cv_grrounddown); CV_RegisterVar(&cv_grrounddown);
CV_RegisterVar(&cv_grfov);
CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_grfiltermode);
CV_RegisterVar(&cv_granisotropicmode); CV_RegisterVar(&cv_granisotropicmode);
CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grcorrecttricks);

View file

@ -28,6 +28,8 @@
#include "../d_player.h" #include "../d_player.h"
#include "../r_defs.h" #include "../r_defs.h"
#define GLENCORE
// Startup & Shutdown the hardware mode renderer // Startup & Shutdown the hardware mode renderer
void HWR_Startup(void); void HWR_Startup(void);
void HWR_Shutdown(void); void HWR_Shutdown(void);
@ -42,6 +44,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale,
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right. void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right.
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color);
void HWR_drawAMline(const fline_t *fl, INT32 color); void HWR_drawAMline(const fline_t *fl, INT32 color);
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength); void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength);
void HWR_DrawConsoleBack(UINT32 color, INT32 height); void HWR_DrawConsoleBack(UINT32 color, INT32 height);
@ -50,22 +53,6 @@ void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
UINT8 *HWR_GetScreenshot(void); UINT8 *HWR_GetScreenshot(void);
boolean HWR_Screenshot(const char *lbmname); boolean HWR_Screenshot(const char *lbmname);
<<<<<<< HEAD
void HWR_InitTextureMapping(void);
void HWR_SetViewSize(void);
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, const UINT8 *colormap);
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
void HWR_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum);
void HWR_PrepLevelCache(size_t pnumtextures);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right.
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color);
void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum);
=======
>>>>>>> e251f9c230beda984cdcdea7e903d765f1c68f6f
// hw_main.c // hw_main.c
void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox); void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox);
@ -85,12 +72,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, UINT32 color); // Let's see if this can wor
void HWR_FoggingOn(void); void HWR_FoggingOn(void);
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
<<<<<<< HEAD
INT32 HWR_GetTextureUsed(void);
=======
// hw_main.c: Post-rendering // hw_main.c: Post-rendering
>>>>>>> e251f9c230beda984cdcdea7e903d765f1c68f6f
void HWR_DoPostProcessor(player_t *player); void HWR_DoPostProcessor(player_t *player);
void HWR_StartScreenWipe(void); void HWR_StartScreenWipe(void);
void HWR_EndScreenWipe(void); void HWR_EndScreenWipe(void);
@ -123,10 +106,6 @@ void HWR_DrawSkyBackground(void);
#ifdef POLYOBJECTS #ifdef POLYOBJECTS
void HWR_AddPolyObjectSegs(void); void HWR_AddPolyObjectSegs(void);
#endif #endif
<<<<<<< HEAD
extern consvar_t cv_grmdls;
extern consvar_t cv_grfallbackplayermodel;
=======
// hw_main.c: BSP // hw_main.c: BSP
void HWR_RenderBSPNode(INT32 bspnum); void HWR_RenderBSPNode(INT32 bspnum);
@ -154,8 +133,7 @@ void HWR_CorrectSWTricks(void);
extern consvar_t cv_grshaders; extern consvar_t cv_grshaders;
extern consvar_t cv_grshearing; extern consvar_t cv_grshearing;
extern consvar_t cv_grfov; extern consvar_t cv_grfov;
extern consvar_t cv_grmd2; extern consvar_t cv_grmdls;
>>>>>>> e251f9c230beda984cdcdea7e903d765f1c68f6f
extern consvar_t cv_grfog; extern consvar_t cv_grfog;
extern consvar_t cv_grfogdensity; extern consvar_t cv_grfogdensity;
extern consvar_t cv_grsoftwarefog; extern consvar_t cv_grsoftwarefog;
@ -168,26 +146,8 @@ extern consvar_t cv_grcorrecttricks;
extern consvar_t cv_grfovchange; extern consvar_t cv_grfovchange;
extern consvar_t cv_grsolvetjoin; extern consvar_t cv_grsolvetjoin;
extern consvar_t cv_grspritebillboarding; extern consvar_t cv_grspritebillboarding;
extern consvar_t cv_grfallbackplayermodel;
<<<<<<< HEAD
extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowx, gr_baseviewwindowy;
extern float gr_basewindowcenterx, gr_basewindowcentery;
// BP: big hack for a test in lighting ref : 1249753487AB
extern fixed_t *hwbbox;
extern FTransform atransform;
typedef struct
{
wallVert3D floorVerts[4];
FSurfaceInfo Surf;
INT32 texnum;
INT32 blend;
INT32 drawcount;
} floorinfo_t;
=======
extern CV_PossibleValue_t granisotropicmode_cons_t[]; extern CV_PossibleValue_t granisotropicmode_cons_t[];
>>>>>>> e251f9c230beda984cdcdea7e903d765f1c68f6f
#endif #endif

View file

@ -37,6 +37,7 @@
#include "../r_things.h" #include "../r_things.h"
#include "../r_draw.h" #include "../r_draw.h"
#include "../p_tick.h" #include "../p_tick.h"
#include "../k_kart.h" // colortranslations
#include "hw_model.h" #include "hw_model.h"
#include "hw_main.h" #include "hw_main.h"
@ -70,7 +71,6 @@
#include "errno.h" #include "errno.h"
#endif #endif
md2_t md2_models[NUMSPRITES]; md2_t md2_models[NUMSPRITES];
md2_t md2_playermodels[MAXSKINS]; md2_t md2_playermodels[MAXSKINS];
@ -92,7 +92,11 @@ static void md2_freeModel (model_t *model)
static model_t *md2_readModel(const char *filename) static model_t *md2_readModel(const char *filename)
{ {
//Filename checking fixed ~Monster Iestyn and Golden //Filename checking fixed ~Monster Iestyn and Golden
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC); if (FIL_FileExists(va("%s"PATHSEP"%s", srb2home, filename)))
return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC);
else if (FIL_FileExists(va("%s"PATHSEP"%s", srb2path, filename)))
return LoadModel(va("%s"PATHSEP"%s", srb2path, filename), PU_STATIC);
return NULL;
} }
static inline void md2_printModelInfo (model_t *model) static inline void md2_printModelInfo (model_t *model)
@ -152,16 +156,20 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
jmp_buf jmpbuf; jmp_buf jmpbuf;
#endif #endif
#endif #endif
png_FILE_p png_FILE; volatile png_FILE_p png_FILE;
//Filename checking fixed ~Monster Iestyn and Golden //Filename checking fixed ~Monster Iestyn and Golden
char *pngfilename = va("%s"PATHSEP"md2"PATHSEP"%s", srb2home, filename); char *pngfilename = va("%s"PATHSEP"mdls"PATHSEP"%s", srb2home, filename);
FIL_ForceExtension(pngfilename, ".png"); FIL_ForceExtension(pngfilename, ".png");
png_FILE = fopen(pngfilename, "rb"); png_FILE = fopen(pngfilename, "rb");
if (!png_FILE) if (!png_FILE)
{ {
pngfilename = va("%s"PATHSEP"mdls"PATHSEP"%s", srb2path, filename);
FIL_ForceExtension(pngfilename, ".png");
png_FILE = fopen(pngfilename, "rb");
//CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename); //CONS_Debug(DBG_RENDER, "M_SavePNG: Error on opening %s for loading\n", filename);
return 0; if (!png_FILE)
return 0;
} }
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL,
@ -283,12 +291,18 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
INT32 ch, rep; INT32 ch, rep;
FILE *file; FILE *file;
//Filename checking fixed ~Monster Iestyn and Golden //Filename checking fixed ~Monster Iestyn and Golden
char *pcxfilename = va("%s"PATHSEP"md2"PATHSEP"%s", srb2home, filename); char *pcxfilename = va("%s"PATHSEP"mdls"PATHSEP"%s", srb2home, filename);
FIL_ForceExtension(pcxfilename, ".pcx"); FIL_ForceExtension(pcxfilename, ".pcx");
file = fopen(pcxfilename, "rb"); file = fopen(pcxfilename, "rb");
if (!file) if (!file)
return 0; {
pcxfilename = va("%s"PATHSEP"mdls"PATHSEP"%s", srb2path, filename);
FIL_ForceExtension(pcxfilename, ".pcx");
file = fopen(pcxfilename, "rb");
if (!file)
return 0;
}
if (fread(&header, sizeof (PcxHeader), 1, file) != 1) if (fread(&header, sizeof (PcxHeader), 1, file) != 1)
{ {
@ -472,23 +486,28 @@ void HWR_InitMD2(void)
md2_models[i].error = false; md2_models[i].error = false;
} }
// read the md2.dat file // read the mdls.dat file
//Filename checking fixed ~Monster Iestyn and Golden //Filename checking fixed ~Monster Iestyn and Golden
f = fopen(va("%s"PATHSEP"%s", srb2home, "md2.dat"), "rt"); f = fopen(va("%s"PATHSEP"%s", srb2home, "mdls.dat"), "rt");
if (!f) if (!f)
{ {
CONS_Printf("%s %s\n", M_GetText("Error while loading md2.dat:"), strerror(errno)); f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
nomd2s = true; if (!f)
return; {
CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno));
nomd2s = true;
return;
}
} }
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{ {
if (stricmp(name, "PLAY") == 0) /*if (stricmp(name, "PLAY") == 0)
{ {
CONS_Printf("MD2 for sprite PLAY detected in md2.dat, use a player skin instead!\n"); CONS_Printf("MD2 for sprite PLAY detected in mdls.dat, use a player skin instead!\n");
continue; continue;
} }*/
// 8/1/19: Allow PLAY to load for default MD2.
for (i = 0; i < NUMSPRITES; i++) for (i = 0; i < NUMSPRITES; i++)
{ {
@ -519,8 +538,8 @@ void HWR_InitMD2(void)
goto md2found; goto md2found;
} }
} }
// no sprite/player skin name found?!? // no sprite/player skin name found?!?D
//CONS_Printf("Unknown sprite/player skin %s detected in md2.dat\n", name); CONS_Printf("Unknown sprite/player skin %s detected in mdls.dat\n", name);
md2found: md2found:
// move on to next line... // move on to next line...
continue; continue;
@ -539,15 +558,19 @@ void HWR_AddPlayerMD2(int skin) // For MD2's that were added after startup
CONS_Printf("AddPlayerMD2()...\n"); CONS_Printf("AddPlayerMD2()...\n");
// read the md2.dat file // read the mdls.dat file
//Filename checking fixed ~Monster Iestyn and Golden //Filename checking fixed ~Monster Iestyn and Golden
f = fopen(va("%s"PATHSEP"%s", srb2home, "md2.dat"), "rt"); f = fopen(va("%s"PATHSEP"%s", srb2home, "mdls.dat"), "rt");
if (!f) if (!f)
{ {
CONS_Printf("Error while loading md2.dat\n"); f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
nomd2s = true; if (!f)
return; {
CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno));
nomd2s = true;
return;
}
} }
// Check for any MD2s that match the names of sprite names! // Check for any MD2s that match the names of sprite names!
@ -574,7 +597,7 @@ playermd2found:
void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startup void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startup
{ {
FILE *f; FILE *f;
// name[18] is used to check for names in the md2.dat file that match with sprites or player skins // name[18] is used to check for names in the mdls.dat file that match with sprites or player skins
// sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long // sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long
char name[18], filename[32]; char name[18], filename[32];
float scale, offset; float scale, offset;
@ -587,16 +610,20 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
// Read the md2.dat file // Read the md2.dat file
//Filename checking fixed ~Monster Iestyn and Golden //Filename checking fixed ~Monster Iestyn and Golden
f = fopen(va("%s"PATHSEP"%s", srb2home, "md2.dat"), "rt"); f = fopen(va("%s"PATHSEP"%s", srb2home, "mdls.dat"), "rt");
if (!f) if (!f)
{ {
CONS_Printf("Error while loading md2.dat\n"); f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
nomd2s = true; if (!f)
return; {
CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno));
nomd2s = true;
return;
}
} }
// Check for any MD2s that match the names of player skins! // Check for any MD2s that match the names of sprite names!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{ {
if (stricmp(name, sprnames[spritenum]) == 0) if (stricmp(name, sprnames[spritenum]) == 0)
@ -615,8 +642,18 @@ spritemd2found:
fclose(f); fclose(f);
} }
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) // Define for getting accurate color brightness readings according to how the human eye sees them.
// https://en.wikipedia.org/wiki/Relative_luminance
// 0.2126 to red
// 0.7152 to green
// 0.0722 to blue
// (See this same define in k_kart.c!)
#define SETBRIGHTNESS(brightness,r,g,b) \
brightness = (UINT8)(((1063*((UINT16)r)/5000) + (3576*((UINT16)g)/5000) + (361*((UINT16)b)/5000)) / 3)
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolors_t color)
{ {
UINT8 i;
UINT16 w = gpatch->width, h = gpatch->height; UINT16 w = gpatch->width, h = gpatch->height;
UINT32 size = w*h; UINT32 size = w*h;
RGBA_t *image, *blendimage, *cur, blendcolor; RGBA_t *image, *blendimage, *cur, blendcolor;
@ -642,175 +679,109 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
image = gpatch->mipmap.grInfo.data; image = gpatch->mipmap.grInfo.data;
blendimage = blendgpatch->mipmap.grInfo.data; blendimage = blendgpatch->mipmap.grInfo.data;
switch (color) // Average all of the translation's colors
{ {
case SKINCOLOR_WHITE: const UINT8 div = 6;
blendcolor = V_GetColor(3); const UINT8 start = 4;
break; UINT32 r, g, b;
case SKINCOLOR_SILVER:
blendcolor = V_GetColor(10);
break;
case SKINCOLOR_GREY:
blendcolor = V_GetColor(15);
break;
case SKINCOLOR_BLACK:
blendcolor = V_GetColor(27);
break;
case SKINCOLOR_CYAN:
blendcolor = V_GetColor(215);
break;
case SKINCOLOR_TEAL:
blendcolor = V_GetColor(221);
break;
case SKINCOLOR_STEELBLUE:
blendcolor = V_GetColor(203);
break;
case SKINCOLOR_BLUE:
blendcolor = V_GetColor(232);
break;
case SKINCOLOR_PEACH:
blendcolor = V_GetColor(71);
break;
case SKINCOLOR_TAN:
blendcolor = V_GetColor(79);
break;
case SKINCOLOR_PINK:
blendcolor = V_GetColor(147);
break;
case SKINCOLOR_LAVENDER:
blendcolor = V_GetColor(251);
break;
case SKINCOLOR_PURPLE:
blendcolor = V_GetColor(195);
break;
case SKINCOLOR_ORANGE:
blendcolor = V_GetColor(87);
break;
case SKINCOLOR_ROSEWOOD:
blendcolor = V_GetColor(94);
break;
case SKINCOLOR_BEIGE:
blendcolor = V_GetColor(40);
break;
case SKINCOLOR_BROWN:
blendcolor = V_GetColor(57);
break;
case SKINCOLOR_RED:
blendcolor = V_GetColor(130);
break;
case SKINCOLOR_DARKRED:
blendcolor = V_GetColor(139);
break;
case SKINCOLOR_NEONGREEN:
blendcolor = V_GetColor(184);
break;
case SKINCOLOR_GREEN:
blendcolor = V_GetColor(166);
break;
case SKINCOLOR_ZIM:
blendcolor = V_GetColor(180);
break;
case SKINCOLOR_OLIVE:
blendcolor = V_GetColor(108);
break;
case SKINCOLOR_YELLOW:
blendcolor = V_GetColor(104);
break;
case SKINCOLOR_GOLD:
blendcolor = V_GetColor(115);
break;
case SKINCOLOR_SUPER1: blendcolor = V_GetColor(colortranslations[color][start]);
blendcolor = V_GetColor(97); r = (UINT32)(blendcolor.s.red*blendcolor.s.red);
break; g = (UINT32)(blendcolor.s.green*blendcolor.s.green);
case SKINCOLOR_SUPER2: b = (UINT32)(blendcolor.s.blue*blendcolor.s.blue);
blendcolor = V_GetColor(100);
break;
case SKINCOLOR_SUPER3:
blendcolor = V_GetColor(103);
break;
case SKINCOLOR_SUPER4:
blendcolor = V_GetColor(113);
break;
case SKINCOLOR_SUPER5:
blendcolor = V_GetColor(116);
break;
case SKINCOLOR_TSUPER1: for (i = 1; i < div; i++)
blendcolor = V_GetColor(81); {
break; RGBA_t nextcolor = V_GetColor(colortranslations[color][start+i]);
case SKINCOLOR_TSUPER2: r += (UINT32)(nextcolor.s.red*nextcolor.s.red);
blendcolor = V_GetColor(82); g += (UINT32)(nextcolor.s.green*nextcolor.s.green);
break; b += (UINT32)(nextcolor.s.blue*nextcolor.s.blue);
case SKINCOLOR_TSUPER3: }
blendcolor = V_GetColor(84);
break;
case SKINCOLOR_TSUPER4:
blendcolor = V_GetColor(85);
break;
case SKINCOLOR_TSUPER5:
blendcolor = V_GetColor(87);
break;
case SKINCOLOR_KSUPER1: blendcolor.s.red = (UINT8)(FixedSqrt((r/div)<<FRACBITS)>>FRACBITS);
blendcolor = V_GetColor(122); blendcolor.s.green = (UINT8)(FixedSqrt((g/div)<<FRACBITS)>>FRACBITS);
break; blendcolor.s.blue = (UINT8)(FixedSqrt((b/div)<<FRACBITS)>>FRACBITS);
case SKINCOLOR_KSUPER2:
blendcolor = V_GetColor(123);
break;
case SKINCOLOR_KSUPER3:
blendcolor = V_GetColor(124);
break;
case SKINCOLOR_KSUPER4:
blendcolor = V_GetColor(125);
break;
case SKINCOLOR_KSUPER5:
blendcolor = V_GetColor(126);
break;
default:
blendcolor = V_GetColor(247);
break;
} }
while (size--) // rainbow support, could theoretically support boss ones too
if (skinnum == TC_RAINBOW)
{ {
if (blendimage->s.alpha == 0) while (size--)
{ {
// Don't bother with blending the pixel if the alpha of the blend pixel is 0 if (image->s.alpha == 0 && blendimage->s.alpha == 0)
cur->rgba = image->rgba; {
// Don't bother with blending the pixel if the alpha of the blend pixel is 0
cur->rgba = image->rgba;
}
else
{
UINT32 tempcolor;
UINT16 imagebright, blendbright, finalbright, colorbright;
SETBRIGHTNESS(imagebright,image->s.red,image->s.green,image->s.blue);
SETBRIGHTNESS(blendbright,blendimage->s.red,blendimage->s.green,blendimage->s.blue);
// slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway
finalbright = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255;
SETBRIGHTNESS(colorbright,blendcolor.s.red,blendcolor.s.green,blendcolor.s.blue);
tempcolor = (finalbright*blendcolor.s.red)/colorbright;
tempcolor = min(255, tempcolor);
cur->s.red = (UINT8)tempcolor;
tempcolor = (finalbright*blendcolor.s.green)/colorbright;
tempcolor = min(255, tempcolor);
cur->s.green = (UINT8)tempcolor;
tempcolor = (finalbright*blendcolor.s.blue)/colorbright;
tempcolor = min(255, tempcolor);
cur->s.blue = (UINT8)tempcolor;
cur->s.alpha = image->s.alpha;
}
cur++; image++; blendimage++;
} }
else }
else
{
while (size--)
{ {
INT32 tempcolor; if (blendimage->s.alpha == 0)
INT16 tempmult, tempalpha; {
tempalpha = -(abs(blendimage->s.red-127)-127)*2; // Don't bother with blending the pixel if the alpha of the blend pixel is 0
if (tempalpha > 255) cur->rgba = image->rgba;
tempalpha = 255; }
else if (tempalpha < 0) else
tempalpha = 0; {
INT32 tempcolor;
INT16 tempmult, tempalpha;
tempalpha = -(abs(blendimage->s.red-127)-127)*2;
if (tempalpha > 255)
tempalpha = 255;
else if (tempalpha < 0)
tempalpha = 0;
tempmult = (blendimage->s.red-127)*2; tempmult = (blendimage->s.red-127)*2;
if (tempmult > 255) if (tempmult > 255)
tempmult = 255; tempmult = 255;
else if (tempmult < 0) else if (tempmult < 0)
tempmult = 0; tempmult = 0;
tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255; tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255;
cur->s.red = (UINT8)tempcolor; cur->s.red = (UINT8)tempcolor;
tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255; tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255;
cur->s.green = (UINT8)tempcolor; cur->s.green = (UINT8)tempcolor;
tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255; tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255;
cur->s.blue = (UINT8)tempcolor; cur->s.blue = (UINT8)tempcolor;
cur->s.alpha = image->s.alpha; cur->s.alpha = image->s.alpha;
}
cur++; image++; blendimage++;
} }
cur++; image++; blendimage++;
} }
return; return;
} }
static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, const UINT8 *colormap, skincolors_t color) #undef SETBRIGHTNESS
static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color)
{ {
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment // mostly copied from HWR_GetMappedPatch, hence the similarities and comment
GLMipmap_t *grmip, *newmip; GLMipmap_t *grmip, *newmip;
@ -851,7 +822,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, con
grmip->nextcolormap = newmip; grmip->nextcolormap = newmip;
newmip->colormap = colormap; newmip->colormap = colormap;
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, color); HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
HWD.pfnSetTexture(newmip); HWD.pfnSetTexture(newmip);
Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED);
@ -871,11 +842,10 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
char filename[64]; char filename[64];
INT32 frame = 0; INT32 frame = 0;
INT32 nextFrame = -1; INT32 nextFrame = -1;
FTransform p; FTransform p;
FSurfaceInfo Surf; FSurfaceInfo Surf;
if (!cv_grmd2.value) if (!cv_grmdls.value)
return; return;
if (spr->precip) if (spr->precip)
@ -883,6 +853,7 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
// MD2 colormap fix // MD2 colormap fix
// colormap test // colormap test
if (spr->mobj->subsector)
{ {
sector_t *sector = spr->mobj->subsector->sector; sector_t *sector = spr->mobj->subsector->sector;
extracolormap_t *colormap = sector->extra_colormap; extracolormap_t *colormap = sector->extra_colormap;
@ -914,6 +885,10 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
else else
HWR_NoColormapLighting(&Surf, lightlevel, GL_NORMALFOG, GL_FADEFOG); HWR_NoColormapLighting(&Surf, lightlevel, GL_NORMALFOG, GL_FADEFOG);
} }
else
{
Surf.PolyColor.rgba = 0xFFFFFFFF;
}
// Look at HWR_ProjectSprite for more // Look at HWR_ProjectSprite for more
{ {
@ -942,20 +917,20 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
// 1. load model+texture if not already loaded // 1. load model+texture if not already loaded
// 2. draw model with correct position, rotation,... // 2. draw model with correct position, rotation,...
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) // Use the player MD2 list if the mobj has a skin and is using the player sprites if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && !md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound) // Use the player MD2 list if the mobj has a skin and is using the player sprites
{ {
md2 = &md2_playermodels[(skin_t*)spr->mobj->skin-skins]; md2 = &md2_playermodels[(skin_t*)spr->mobj->skin-skins];
md2->skin = (skin_t*)spr->mobj->skin-skins; md2->skin = (skin_t*)spr->mobj->skin-skins;
} }
else else // if we can't find the player md2, use SPR_PLAY's MD2.
md2 = &md2_models[spr->mobj->sprite]; md2 = &md2_models[spr->mobj->sprite];
if (md2->error) if (md2->error)
return; // we already failed loading this before :( return; // we already failed loading this before :(
if (!md2->model) if (!md2->model)
{ {
//CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]); CONS_Debug(DBG_RENDER, "Loading model... (%s, %s)", sprnames[spr->mobj->sprite], md2->filename);
sprintf(filename, "md2/%s", md2->filename); sprintf(filename, "mdls/%s", md2->filename);
md2->model = md2_readModel(filename); md2->model = md2_readModel(filename);
if (md2->model) if (md2->model)
@ -987,7 +962,30 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format
&& gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height)
{ {
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, spr->colormap, (skincolors_t)spr->mobj->color); INT32 skinnum = TC_DEFAULT;
if ((spr->mobj->flags & MF_BOSS) && (spr->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
{
if (spr->mobj->type == MT_CYBRAKDEMON)
skinnum = TC_ALLWHITE;
else if (spr->mobj->type == MT_METALSONIC_BATTLE)
skinnum = TC_METALSONIC;
else
skinnum = TC_BOSS;
}
else if (spr->mobj->color)
{
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
if (spr->mobj->colorized)
skinnum = TC_RAINBOW;
else
{
skinnum = (INT32)((skin_t*)spr->mobj->skin-skins);
}
}
else skinnum = TC_DEFAULT;
}
HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color);
} }
else else
{ {
@ -1011,8 +1009,9 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
//FIXME: this is not yet correct //FIXME: this is not yet correct
frame = (spr->mobj->frame & FF_FRAMEMASK) % md2->model->meshes[0].numFrames; frame = (spr->mobj->frame & FF_FRAMEMASK) % md2->model->meshes[0].numFrames;
#ifdef USE_MODEL_NEXTFRAME #ifdef USE_MODEL_NEXTFRAME
if (cv_grmd2.value == 1 && tics <= durs) if (cv_grmdls.value == 1 && tics <= durs)
{ {
// frames are handled differently for states with FF_ANIMATE, so get the next frame differently for the interpolation // frames are handled differently for states with FF_ANIMATE, so get the next frame differently for the interpolation
if (spr->mobj->frame & FF_ANIMATE) if (spr->mobj->frame & FF_ANIMATE)
@ -1053,14 +1052,11 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
if (sprframe->rotate) if (sprframe->rotate)
{ {
fixed_t anglef = AngleFixed(spr->mobj->angle); fixed_t anglef;
// \todo adapt for 2.2 directionchar? The below code is from Kart
#if 0
if (spr->mobj->player) if (spr->mobj->player)
anglef = AngleFixed(spr->mobj->player->frameangle); anglef = AngleFixed(spr->mobj->player->frameangle);
else else
anglef = AngleFixed(spr->mobj->angle); anglef = AngleFixed(spr->mobj->angle);
#endif
p.angley = FIXED_TO_FLOAT(anglef); p.angley = FIXED_TO_FLOAT(anglef);
} }
else else

View file

@ -1285,15 +1285,14 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
{IT_STRING|IT_CVAR, NULL, "Shaders", &cv_grshaders, 10}, {IT_STRING|IT_CVAR, NULL, "Shaders", &cv_grshaders, 10},
{IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 20}, {IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 20},
{IT_STRING|IT_CVAR, NULL, "Field of view", &cv_grfov, 40}, {IT_STRING|IT_CVAR, NULL, "Quality", &cv_scr_depth, 40},
{IT_STRING|IT_CVAR, NULL, "Quality", &cv_scr_depth, 50}, {IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 50},
{IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 60}, {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 60},
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 70},
#ifdef _WINDOWS #ifdef _WINDOWS
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 80}, {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 70},
#endif #endif
{IT_SUBMENU|IT_STRING, NULL, "Fog...", &OP_OpenGLFogDef, 110}, {IT_SUBMENU|IT_STRING, NULL, "Fog...", &OP_OpenGLFogDef, 100},
{IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 120}, {IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 110},
}; };
static menuitem_t OP_OpenGLFogMenu[] = static menuitem_t OP_OpenGLFogMenu[] =

View file

@ -137,7 +137,7 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = {
{1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{0, "None"}, {0, NULL}}; {0, "None"}, {0, NULL}};
static CV_PossibleValue_t fov_cons_t[] = {{0, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t fov_cons_t[] = {{45*FRACUNIT, "MIN"}, {120*FRACUNIT, "MAX"}, {0, NULL}};
//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; //static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}};
static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
@ -181,7 +181,9 @@ consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL,
//consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
//consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL};
// cap fov, fov too high tears software apart.
consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL};
// Okay, whoever said homremoval causes a performance hit should be shot. // Okay, whoever said homremoval causes a performance hit should be shot.
consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};

View file

@ -76,7 +76,6 @@ consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons
// console variables in development // console variables in development
consvar_t cv_grmdls = {"gr_mdls", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmdls = {"gr_mdls", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grfallbackplayermodel = {"gr_fallbackplayermodel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};