From 08b10ca03c54013f1196e3ae571f7e4af29abccb Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 21 Apr 2013 19:55:11 +0000 Subject: [PATCH] Draw the flat on-screen CHAINGUN in a way inspired by 3688, preventing seam. Specifically, in GL modes, and if the CHAINGUN is not replaced by a model, - draw the upper part twice: first, two screen pixels * weapon scale lower, then at the original position - reverse the previous order: draw the upper part first, then the lower part This is much preferable to the previous engine-side hack, and to my eye, it looks perfect now. git-svn-id: https://svn.eduke32.com/eduke32@3695 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/polymost.c | 19 ++---------- polymer/eduke32/source/player.c | 45 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 1db92a6e2..4430ee0d5 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -1053,6 +1053,8 @@ static void fixtransparency(int32_t dapicnum, coltype *dapic, int32_t daxsiz, in coltype *wpptr; int32_t j, x, y, r, g, b, dox, doy, naxsiz2; + UNREFERENCED_PARAMETER(dapicnum); + dox = daxsiz2-1; doy = daysiz2-1; if (dameth&4) { dox = min(dox,daxsiz); doy = min(doy,daysiz); } else { daxsiz = daxsiz2; daysiz = daysiz2; } //Make repeating textures duplicate top/left parts @@ -1066,23 +1068,6 @@ static void fixtransparency(int32_t dapicnum, coltype *dapic, int32_t daxsiz, in wpptr = &dapic[y*daxsiz2+dox]; for (x=dox; x>=0; x--,wpptr--) { - // HACK for on-screen lower part of chaingun sprite to prevent a subtexel - // transparent horizontal line between the bottom and top parts with linear - // filtering. - if (dapicnum==2536 && tilesizx[2536]==211 && tilesizy[2536]==55) // CHAINGUN - { - if (doy>=3 && y==2 && x>=78 && x<=157) - { - const coltype *onedown = &dapic[(y+1)*daxsiz2+x]; - if (wpptr->a==0 && onedown->a!=0) - Bmemcpy(wpptr, onedown, sizeof(coltype)); - // Remove the comment to see what texels are affected: - //wpptr->r=255; wpptr->g = wpptr->b = 0; wpptr->a = 255; - continue; - } - } - // END HACK - if (wpptr->a) continue; r = g = b = j = 0; diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 69908160c..f26c9bcda 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -1743,6 +1743,8 @@ static inline int32_t weapsc(int32_t sc) return scale(sc, ud.weaponscale, 100); } +static int32_t g_dts_yadd; + static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation, int32_t p) { int32_t ang = 0; @@ -1796,7 +1798,7 @@ static void G_DrawTileScaled(int32_t x, int32_t y, int32_t tilenum, int32_t shad y += (224-weapsc(224)); #endif rotatesprite(weapsc(x<<16) + ((xoff-weapsc(xoff))<<16), - weapsc(y<<16) + ((200-weapsc(200))<<16) + yofs, + weapsc((y<<16) + g_dts_yadd) + ((200-weapsc(200))<<16) + yofs, weapsc(65536L),ang,tilenum,shade,p,(2|orientation), wx[0],wy[0], wx[1],wy[1]); } @@ -1829,36 +1831,33 @@ static void G_DrawWeaponTile(int32_t x, int32_t y, int32_t tilenum, int32_t shad switch (ud.drawweapon) { - default: - return; case 1: +#ifdef USE_OPENGL + if (getrendermode()>=REND_POLYMOST) + if (tilenum >= CHAINGUN+1 && tilenum <= CHAINGUN+4) + if (!usemodels || md_tilehasmodel(tilenum,p) < 0) + { + // HACK: Draw the upper part of the chaingun two screen + // pixels (not texels; multiplied by weapon scale) lower + // first, preventing ugly horizontal seam. + g_dts_yadd = (65536*2*200)/ydim; + G_DrawTileScaled(x,y,tilenum,shadef[slot],orientation,p); + g_dts_yadd = 0; + } +#endif G_DrawTileScaled(x,y,tilenum,shadef[slot],orientation,p); return; + case 2: { const DukePlayer_t *const ps = g_player[screenpeek].ps; const int32_t sc = scale(65536,ud.statusbarscale,100); - switch (hudweap.cur) - { - case PISTOL_WEAPON: - case CHAINGUN_WEAPON: - case RPG_WEAPON: - case FREEZE_WEAPON: - case SHRINKER_WEAPON: - case GROW_WEAPON: - case DEVISTATOR_WEAPON: - case TRIPBOMB_WEAPON: - case HANDREMOTE_WEAPON: - case HANDBOMB_WEAPON: - case SHOTGUN_WEAPON: + if ((unsigned)hudweap.cur < MAX_WEAPONS && hudweap.cur != KNEE_WEAPON) rotatesprite_win(160<<16,(180+(ps->weapon_pos*ps->weapon_pos))<<16, sc,0,hudweap.cur==GROW_WEAPON?GROWSPRITEICON:WeaponPickupSprites[hudweap.cur], 0,0,2); - return; - default: - return; - } + return; } } } @@ -2365,9 +2364,6 @@ void P_DisplayWeapon(int32_t snum) weapon_xoffset += 1-(rand()&3); } - G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, - CHAINGUN,gs,o,pal,0); - switch (*kb) { case 0: @@ -2401,6 +2397,9 @@ void P_DisplayWeapon(int32_t snum) break; } + + G_DrawWeaponTile(weapon_xoffset+168-(p->look_ang>>1),looking_arc+260-gun_pos, + CHAINGUN,gs,o,pal,0); } break;