2017-04-17 10:27:19 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
2017-02-02 14:10:06 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// Copyright 1993-1996 id Software
|
|
|
|
// Copyright 1999-2016 Randy Heit
|
|
|
|
// Copyright 2016 Magnus Norddahl
|
2017-02-02 14:10:06 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2017-02-02 14:10:06 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
2017-02-02 14:10:06 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2017-04-17 10:27:19 +00:00
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2017-02-02 14:10:06 +00:00
|
|
|
//
|
2017-04-17 10:27:19 +00:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see http://www.gnu.org/licenses/
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
2017-02-02 14:10:06 +00:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "r_drawerargs.h"
|
|
|
|
|
|
|
|
namespace swrenderer
|
|
|
|
{
|
|
|
|
void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade)
|
|
|
|
{
|
|
|
|
mBaseColormap = base_colormap;
|
2017-03-15 21:04:23 +00:00
|
|
|
assert(mBaseColormap->Maps != nullptr);
|
2017-02-02 14:10:06 +00:00
|
|
|
mLight = light;
|
|
|
|
mShade = shade;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawerArgs::SetTranslationMap(lighttable_t *translation)
|
|
|
|
{
|
|
|
|
mTranslation = translation;
|
|
|
|
}
|
|
|
|
|
2017-03-12 17:54:39 +00:00
|
|
|
uint8_t *DrawerArgs::Colormap(RenderViewport *viewport) const
|
2017-02-02 14:10:06 +00:00
|
|
|
{
|
|
|
|
if (mBaseColormap)
|
|
|
|
{
|
2017-03-12 17:54:39 +00:00
|
|
|
if (viewport->RenderTarget->IsBgra())
|
2017-02-02 14:10:06 +00:00
|
|
|
return mBaseColormap->Maps;
|
|
|
|
else
|
|
|
|
return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return mTranslation;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadeConstants DrawerArgs::ColormapConstants() const
|
|
|
|
{
|
|
|
|
ShadeConstants shadeConstants;
|
|
|
|
if (mBaseColormap)
|
|
|
|
{
|
|
|
|
shadeConstants.light_red = mBaseColormap->Color.r * 256 / 255;
|
|
|
|
shadeConstants.light_green = mBaseColormap->Color.g * 256 / 255;
|
|
|
|
shadeConstants.light_blue = mBaseColormap->Color.b * 256 / 255;
|
|
|
|
shadeConstants.light_alpha = mBaseColormap->Color.a * 256 / 255;
|
|
|
|
shadeConstants.fade_red = mBaseColormap->Fade.r;
|
|
|
|
shadeConstants.fade_green = mBaseColormap->Fade.g;
|
|
|
|
shadeConstants.fade_blue = mBaseColormap->Fade.b;
|
|
|
|
shadeConstants.fade_alpha = mBaseColormap->Fade.a;
|
|
|
|
shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256;
|
|
|
|
shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
shadeConstants.light_red = 256;
|
|
|
|
shadeConstants.light_green = 256;
|
|
|
|
shadeConstants.light_blue = 256;
|
|
|
|
shadeConstants.light_alpha = 256;
|
|
|
|
shadeConstants.fade_red = 0;
|
|
|
|
shadeConstants.fade_green = 0;
|
|
|
|
shadeConstants.fade_blue = 0;
|
|
|
|
shadeConstants.fade_alpha = 256;
|
|
|
|
shadeConstants.desaturate = 0;
|
|
|
|
shadeConstants.simple_shade = true;
|
|
|
|
}
|
|
|
|
return shadeConstants;
|
|
|
|
}
|
|
|
|
}
|