2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright(C) 2000-2016 Christoph Oelckers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2013-06-23 07:49:34 +00:00
|
|
|
/*
|
|
|
|
** gl_weapon.cpp
|
|
|
|
** Weapon sprite drawing
|
|
|
|
**
|
|
|
|
*/
|
2016-09-14 18:01:13 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_system.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
#include "r_utility.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
|
2013-09-03 16:29:39 +00:00
|
|
|
#include "gl/system/gl_interface.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/system/gl_cvars.h"
|
|
|
|
#include "gl/renderer/gl_renderer.h"
|
|
|
|
#include "gl/renderer/gl_lightdata.h"
|
|
|
|
#include "gl/renderer/gl_renderstate.h"
|
|
|
|
#include "gl/data/gl_data.h"
|
2014-05-12 20:24:26 +00:00
|
|
|
#include "gl/data/gl_vertexbuffer.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
#include "gl/dynlights/gl_glow.h"
|
|
|
|
#include "gl/scene/gl_drawinfo.h"
|
|
|
|
#include "gl/models/gl_models.h"
|
|
|
|
#include "gl/shaders/gl_shader.h"
|
|
|
|
#include "gl/textures/gl_material.h"
|
2016-08-22 12:00:25 +00:00
|
|
|
#include "gl/renderer/gl_quaddrawer.h"
|
2016-09-20 01:21:20 +00:00
|
|
|
#include "gl/stereo3d/gl_stereo3d.h"
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
EXTERN_CVAR (Bool, r_drawplayersprites)
|
|
|
|
EXTERN_CVAR(Float, transsouls)
|
|
|
|
EXTERN_CVAR (Bool, st_scale)
|
|
|
|
EXTERN_CVAR(Int, gl_fuzztype)
|
2014-09-21 09:08:38 +00:00
|
|
|
EXTERN_CVAR (Bool, r_deathcamera)
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawPSprite
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2016-06-17 15:21:42 +00:00
|
|
|
void FGLRenderer::DrawPSprite (player_t * player,DPSprite *psp, float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
float fU1,fV1;
|
|
|
|
float fU2,fV2;
|
2015-04-04 15:50:22 +00:00
|
|
|
float tx;
|
|
|
|
float x1,y1,x2,y2;
|
2013-06-23 07:49:34 +00:00
|
|
|
float scale;
|
2015-04-04 15:50:22 +00:00
|
|
|
float scalex;
|
2015-04-04 10:35:10 +00:00
|
|
|
float ftexturemid;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// [BB] In the HUD model step we just render the model and break out.
|
|
|
|
if ( hudModelStep )
|
|
|
|
{
|
2016-06-17 15:21:42 +00:00
|
|
|
gl_RenderHUDModel(psp, sx, sy);
|
2013-06-23 07:49:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// decide which patch to use
|
|
|
|
bool mirror;
|
2016-06-17 15:21:42 +00:00
|
|
|
FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, &mirror);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!lump.isValid()) return;
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
FMaterial * tex = FMaterial::ValidateTexture(lump, true, false);
|
2013-06-23 07:49:34 +00:00
|
|
|
if (!tex) return;
|
|
|
|
|
2014-09-09 10:00:42 +00:00
|
|
|
gl_RenderState.SetMaterial(tex, CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2015-04-04 15:50:22 +00:00
|
|
|
float vw = (float)viewwidth;
|
|
|
|
float vh = (float)viewheight;
|
|
|
|
|
|
|
|
FloatRect r;
|
|
|
|
tex->GetSpriteRect(&r);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// calculate edges of the shape
|
2016-09-12 18:29:26 +00:00
|
|
|
scalex = (320.0f / (240.0f * WidescreenRatio)) * vw / 320;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-03-21 01:57:02 +00:00
|
|
|
tx = sx - (160 - r.left);
|
2015-04-04 15:50:22 +00:00
|
|
|
x1 = tx * scalex + vw/2;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (x1 > vw) return; // off the right side
|
2015-04-04 15:50:22 +00:00
|
|
|
x1 += viewwindowx;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2015-04-04 15:50:22 +00:00
|
|
|
tx += r.width;
|
|
|
|
x2 = tx * scalex + vw / 2;
|
2013-06-23 07:49:34 +00:00
|
|
|
if (x2 < 0) return; // off the left side
|
2015-04-04 15:50:22 +00:00
|
|
|
x2 += viewwindowx;
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// killough 12/98: fix psprite positioning problem
|
2016-03-21 01:57:02 +00:00
|
|
|
ftexturemid = 100.f - sy - r.top;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
AWeapon * wi=player->ReadyWeapon;
|
2016-03-24 11:47:08 +00:00
|
|
|
if (wi && wi->YAdjust != 0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-03-24 11:47:08 +00:00
|
|
|
float fYAd = wi->YAdjust;
|
2015-04-04 15:50:22 +00:00
|
|
|
if (screenblocks >= 11)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2015-04-04 10:35:10 +00:00
|
|
|
ftexturemid -= fYAd;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else if (!st_scale)
|
|
|
|
{
|
2016-03-24 11:47:08 +00:00
|
|
|
ftexturemid -= StatusBar->GetDisplacement () * fYAd;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-04 15:50:22 +00:00
|
|
|
scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f);
|
|
|
|
y1 = viewwindowy + vh / 2 - (ftexturemid * scale);
|
|
|
|
y2 = y1 + (r.height * scale) + 1;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-10-12 01:15:46 +00:00
|
|
|
if (!(mirror) != !(psp->Flags & PSPF_FLIP))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-10-12 01:15:46 +00:00
|
|
|
fU2 = tex->GetSpriteUL();
|
|
|
|
fV1 = tex->GetSpriteVT();
|
|
|
|
fU1 = tex->GetSpriteUR();
|
|
|
|
fV2 = tex->GetSpriteVB();
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-12 01:15:46 +00:00
|
|
|
fU1 = tex->GetSpriteUL();
|
|
|
|
fV1 = tex->GetSpriteVT();
|
|
|
|
fU2 = tex->GetSpriteUR();
|
|
|
|
fV2 = tex->GetSpriteVB();
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
if (tex->GetTransparent() || OverrideShader != -1)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
gl_RenderState.Apply();
|
2016-08-22 12:00:25 +00:00
|
|
|
FQuadDrawer qd;
|
|
|
|
qd.Set(0, x1, y1, 0, fU1, fV1);
|
|
|
|
qd.Set(1, x1, y2, 0, fU1, fV2);
|
|
|
|
qd.Set(2, x2, y1, 0, fU2, fV1);
|
|
|
|
qd.Set(3, x2, y2, 0, fU2, fV2);
|
|
|
|
qd.Render(GL_TRIANGLE_STRIP);
|
2014-07-14 19:14:43 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
2016-06-17 15:21:42 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
static bool isBright(DPSprite *psp)
|
|
|
|
{
|
|
|
|
if (psp != nullptr && psp->GetState() != nullptr)
|
|
|
|
{
|
|
|
|
bool disablefullbright = false;
|
|
|
|
FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, NULL);
|
|
|
|
if (lump.isValid())
|
|
|
|
{
|
|
|
|
FMaterial * tex = FMaterial::ValidateTexture(lump, false, false);
|
|
|
|
if (tex)
|
|
|
|
disablefullbright = tex->tex->gl_info.bDisableFullbright;
|
|
|
|
}
|
|
|
|
return psp->GetState()->GetFullbright() && !disablefullbright;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawPlayerSprites
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
|
|
|
{
|
2016-06-17 15:21:42 +00:00
|
|
|
bool brightflash = false;
|
2013-06-23 07:49:34 +00:00
|
|
|
unsigned int i;
|
|
|
|
int lightlevel=0;
|
|
|
|
FColormap cm;
|
|
|
|
sector_t * fakesec, fs;
|
|
|
|
AActor * playermo=players[consoleplayer].camera;
|
|
|
|
player_t * player=playermo->player;
|
|
|
|
|
2016-09-20 01:21:20 +00:00
|
|
|
s3d::Stereo3DMode::getCurrentMode().AdjustPlayerSprites();
|
|
|
|
|
2013-11-30 12:01:48 +00:00
|
|
|
// this is the same as the software renderer
|
|
|
|
if (!player ||
|
|
|
|
!r_drawplayersprites ||
|
|
|
|
!camera->player ||
|
2014-09-21 09:08:38 +00:00
|
|
|
(player->cheats & CF_CHASECAM) ||
|
|
|
|
(r_deathcamera && camera->health <= 0))
|
2013-11-30 12:01:48 +00:00
|
|
|
return;
|
|
|
|
|
2016-06-17 15:21:42 +00:00
|
|
|
float bobx, boby, wx, wy;
|
|
|
|
DPSprite *weapon;
|
|
|
|
|
|
|
|
P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF);
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2016-06-17 15:21:42 +00:00
|
|
|
// Interpolate the main weapon layer once so as to be able to add it to other layers.
|
|
|
|
if ((weapon = camera->player->FindPSprite(PSP_WEAPON)) != nullptr)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-06-17 15:21:42 +00:00
|
|
|
if (weapon->firstTic)
|
2014-05-11 19:47:54 +00:00
|
|
|
{
|
2016-06-17 15:21:42 +00:00
|
|
|
wx = weapon->x;
|
|
|
|
wy = weapon->y;
|
2014-05-11 19:47:54 +00:00
|
|
|
}
|
2016-06-17 15:21:42 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF;
|
|
|
|
wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wx = 0;
|
|
|
|
wy = 0;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gl_fixedcolormap)
|
|
|
|
{
|
|
|
|
lightlevel=255;
|
2014-05-11 20:57:42 +00:00
|
|
|
cm.Clear();
|
2013-06-23 07:49:34 +00:00
|
|
|
fakesec = viewsector;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fakesec = gl_FakeFlat(viewsector, &fs, false);
|
|
|
|
|
|
|
|
// calculate light level for weapon sprites
|
|
|
|
lightlevel = gl_ClampLight(fakesec->lightlevel);
|
|
|
|
|
|
|
|
// calculate colormap for weapon sprites
|
|
|
|
if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting)
|
|
|
|
{
|
|
|
|
TArray<lightlist_t> & lightlist = viewsector->e->XFloor.lightlist;
|
|
|
|
for(i=0;i<lightlist.Size();i++)
|
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
double lightbottom;
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
if (i<lightlist.Size()-1)
|
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
lightbottom=lightlist[i+1].plane.ZatPoint(ViewPos);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-02 21:17:16 +00:00
|
|
|
lightbottom=viewsector->floorplane.ZatPoint(ViewPos);
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lightbottom<player->viewz)
|
|
|
|
{
|
|
|
|
cm = lightlist[i].extra_colormap;
|
2016-04-06 12:03:21 +00:00
|
|
|
lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel);
|
2013-06-23 07:49:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cm=fakesec->ColorMap;
|
|
|
|
if (glset.nocoloredspritelighting) cm.ClearColor();
|
|
|
|
}
|
|
|
|
|
2016-06-17 15:21:42 +00:00
|
|
|
lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true);
|
|
|
|
|
|
|
|
if (glset.lightmode == 8)
|
|
|
|
{
|
|
|
|
// Korshun: the way based on max possible light level for sector like in software renderer.
|
|
|
|
float min_L = 36.0 / 31.0 - ((lightlevel / 255.0) * (63.0 / 31.0)); // Lightlevel in range 0-63
|
|
|
|
if (min_L < 0)
|
|
|
|
min_L = 0;
|
|
|
|
else if (min_L > 1.0)
|
|
|
|
min_L = 1.0;
|
|
|
|
|
|
|
|
lightlevel = (1.0 - min_L) * 255;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lightlevel = (2 * lightlevel + 255) / 3;
|
|
|
|
}
|
|
|
|
lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos());
|
|
|
|
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
2014-12-31 22:01:06 +00:00
|
|
|
// Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!)
|
2013-06-23 07:49:34 +00:00
|
|
|
if (glset.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0))
|
|
|
|
{
|
|
|
|
lightlevel = 255;
|
|
|
|
}
|
|
|
|
|
2014-05-11 14:49:17 +00:00
|
|
|
PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff;
|
2014-05-12 12:45:41 +00:00
|
|
|
ThingColor.a = 255;
|
2014-05-11 14:49:17 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
visstyle_t vis;
|
|
|
|
|
|
|
|
vis.RenderStyle=playermo->RenderStyle;
|
2016-03-22 22:19:21 +00:00
|
|
|
vis.Alpha=playermo->Alpha;
|
2013-06-23 07:49:34 +00:00
|
|
|
vis.colormap = NULL;
|
|
|
|
if (playermo->Inventory)
|
|
|
|
{
|
|
|
|
playermo->Inventory->AlterWeaponSprite(&vis);
|
|
|
|
if (vis.colormap >= SpecialColormaps[0].Colormap &&
|
|
|
|
vis.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap &&
|
2014-05-11 20:57:42 +00:00
|
|
|
gl_fixedcolormap == CM_DEFAULT)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2014-05-11 19:47:54 +00:00
|
|
|
// this only happens for Strife's inverted weapon sprite
|
|
|
|
vis.RenderStyle.Flags |= STYLEF_InvertSource;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-25 09:55:47 +00:00
|
|
|
if (vis.RenderStyle.AsDWORD == 0)
|
|
|
|
{
|
|
|
|
// This is RenderStyle None.
|
|
|
|
return;
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
|
|
|
|
// Set the render parameters
|
|
|
|
|
2014-08-22 21:50:38 +00:00
|
|
|
int OverrideShader = -1;
|
2013-06-23 07:49:34 +00:00
|
|
|
float trans = 0.f;
|
|
|
|
if (vis.RenderStyle.BlendOp >= STYLEOP_Fuzz && vis.RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub)
|
|
|
|
{
|
|
|
|
vis.RenderStyle.CheckFuzz();
|
|
|
|
if (vis.RenderStyle.BlendOp == STYLEOP_Fuzz)
|
|
|
|
{
|
2014-06-21 13:50:32 +00:00
|
|
|
if (gl_fuzztype != 0)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
// Todo: implement shader selection here
|
|
|
|
vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent];
|
|
|
|
OverrideShader = gl_fuzztype + 4;
|
|
|
|
trans = 0.99f; // trans may not be 1 here
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vis.RenderStyle.BlendOp = STYLEOP_Shadow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gl_SetRenderStyle(vis.RenderStyle, false, false);
|
|
|
|
|
|
|
|
if (vis.RenderStyle.Flags & STYLEF_TransSoulsAlpha)
|
|
|
|
{
|
|
|
|
trans = transsouls;
|
|
|
|
}
|
|
|
|
else if (vis.RenderStyle.Flags & STYLEF_Alpha1)
|
|
|
|
{
|
|
|
|
trans = 1.f;
|
|
|
|
}
|
|
|
|
else if (trans == 0.f)
|
|
|
|
{
|
2016-03-22 22:19:21 +00:00
|
|
|
trans = vis.Alpha;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// now draw the different layers of the weapon
|
|
|
|
gl_RenderState.EnableBrightmap(true);
|
2014-05-11 14:49:17 +00:00
|
|
|
gl_RenderState.SetObjectColor(ThingColor);
|
2016-05-08 07:22:38 +00:00
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold);
|
2016-06-17 15:21:42 +00:00
|
|
|
|
2013-06-23 07:49:34 +00:00
|
|
|
// hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change
|
|
|
|
// light mode here to draw the weapon sprite.
|
|
|
|
int oldlightmode = glset.lightmode;
|
|
|
|
if (glset.lightmode == 8) glset.lightmode = 2;
|
2016-06-17 15:21:42 +00:00
|
|
|
|
|
|
|
for(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
2016-06-17 15:21:42 +00:00
|
|
|
if (psp->GetState() != nullptr)
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
FColormap cmc = cm;
|
2016-06-17 15:21:42 +00:00
|
|
|
int ll = lightlevel;
|
|
|
|
if (isBright(psp))
|
2013-06-23 07:49:34 +00:00
|
|
|
{
|
|
|
|
if (fakesec == viewsector || in_area != area_below)
|
|
|
|
{
|
|
|
|
cmc.LightColor.r=
|
|
|
|
cmc.LightColor.g=
|
|
|
|
cmc.LightColor.b=0xff;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-11 14:49:17 +00:00
|
|
|
// under water areas keep most of their color for fullbright objects
|
|
|
|
cmc.LightColor.r = (3 * cmc.LightColor.r + 0xff) / 4;
|
2013-06-23 07:49:34 +00:00
|
|
|
cmc.LightColor.g = (3*cmc.LightColor.g + 0xff)/4;
|
|
|
|
cmc.LightColor.b = (3*cmc.LightColor.b + 0xff)/4;
|
|
|
|
}
|
2016-06-17 15:21:42 +00:00
|
|
|
ll = 255;
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
2014-05-11 19:47:54 +00:00
|
|
|
// set the lighting parameters
|
|
|
|
if (vis.RenderStyle.BlendOp == STYLEOP_Shadow)
|
|
|
|
{
|
2014-05-11 20:57:42 +00:00
|
|
|
gl_RenderState.SetColor(0.2f, 0.2f, 0.2f, 0.33f, cmc.desaturation);
|
2014-05-11 19:47:54 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-06 08:00:02 +00:00
|
|
|
if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites)
|
2014-10-06 07:05:42 +00:00
|
|
|
{
|
|
|
|
gl_SetDynSpriteLight(playermo, NULL);
|
|
|
|
}
|
2016-06-17 15:21:42 +00:00
|
|
|
gl_SetColor(ll, 0, cmc, trans, true);
|
2014-05-11 19:47:54 +00:00
|
|
|
}
|
2016-06-17 15:21:42 +00:00
|
|
|
|
|
|
|
if (psp->firstTic)
|
|
|
|
{ // Can't interpolate the first tic.
|
|
|
|
psp->firstTic = false;
|
|
|
|
psp->oldx = psp->x;
|
|
|
|
psp->oldy = psp->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
float sx = psp->oldx + (psp->x - psp->oldx) * r_TicFracF;
|
|
|
|
float sy = psp->oldy + (psp->y - psp->oldy) * r_TicFracF;
|
|
|
|
|
|
|
|
if (psp->Flags & PSPF_ADDBOB)
|
|
|
|
{
|
|
|
|
sx += bobx;
|
|
|
|
sy += boby;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (psp->Flags & PSPF_ADDWEAPON && psp->GetID() != PSP_WEAPON)
|
|
|
|
{
|
|
|
|
sx += wx;
|
|
|
|
sy += wy;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DrawPSprite(player, psp, sx, sy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha));
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-11 14:49:17 +00:00
|
|
|
gl_RenderState.SetObjectColor(0xffffffff);
|
|
|
|
gl_RenderState.SetDynLight(0, 0, 0);
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.EnableBrightmap(false);
|
|
|
|
glset.lightmode = oldlightmode;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_DrawPlayerSprites
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FGLRenderer::DrawTargeterSprites()
|
|
|
|
{
|
|
|
|
AActor * playermo=players[consoleplayer].camera;
|
|
|
|
player_t * player=playermo->player;
|
|
|
|
|
|
|
|
if(!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites ||
|
|
|
|
mViewActor!=playermo) return;
|
|
|
|
|
|
|
|
gl_RenderState.EnableBrightmap(false);
|
|
|
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold);
|
|
|
|
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
2014-05-11 14:49:17 +00:00
|
|
|
gl_RenderState.ResetColor();
|
2013-06-23 07:49:34 +00:00
|
|
|
gl_RenderState.SetTextureMode(TM_MODULATE);
|
|
|
|
|
|
|
|
// The Targeter's sprites are always drawn normally.
|
2016-06-17 15:21:42 +00:00
|
|
|
for (DPSprite *psp = player->FindPSprite(PSP_TARGETCENTER); psp != nullptr; psp = psp->GetNext())
|
|
|
|
{
|
|
|
|
if (psp->GetState() != nullptr) DrawPSprite(player, psp, psp->x, psp->y, false, 0, false);
|
|
|
|
}
|
2013-06-23 07:49:34 +00:00
|
|
|
}
|