2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** v_palette.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
2006-06-11 01:37:00 +00:00
|
|
|
** Copyright 1998-2006 Randy Heit
|
2006-02-24 04:48:15 +00:00
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __V_PALETTE_H__
|
|
|
|
#define __V_PALETTE_H__
|
|
|
|
|
2008-12-07 12:11:59 +00:00
|
|
|
#include "doomtype.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-16 04:19:20 +00:00
|
|
|
#define MAKERGB(r,g,b) DWORD(((r)<<16)|((g)<<8)|(b))
|
|
|
|
#define MAKEARGB(a,r,g,b) DWORD(((a)<<24)|((r)<<16)|((g)<<8)|(b))
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#define APART(c) (((c)>>24)&0xff)
|
|
|
|
#define RPART(c) (((c)>>16)&0xff)
|
|
|
|
#define GPART(c) (((c)>>8)&0xff)
|
|
|
|
#define BPART(c) ((c)&0xff)
|
|
|
|
|
|
|
|
struct FPalette
|
|
|
|
{
|
|
|
|
FPalette ();
|
|
|
|
FPalette (const BYTE *colors);
|
|
|
|
|
|
|
|
void SetPalette (const BYTE *colors);
|
|
|
|
|
|
|
|
void MakeGoodRemap ();
|
|
|
|
|
|
|
|
PalEntry BaseColors[256]; // non-gamma corrected palette
|
|
|
|
BYTE Remap[256]; // remap original palette indices to in-game indices
|
|
|
|
|
2006-07-20 05:13:39 +00:00
|
|
|
BYTE WhiteIndex; // white in original palette index
|
|
|
|
BYTE BlackIndex; // black in original palette index
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Given an array of colors, fills in remap with values to remap the
|
|
|
|
// passed array of colors to this palette.
|
|
|
|
void MakeRemap (const DWORD *colors, BYTE *remap, const BYTE *useful, int numcolors) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern FPalette GPalette;
|
2011-07-03 10:47:35 +00:00
|
|
|
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
// The color overlay to use for depleted items
|
|
|
|
#define DIM_OVERLAY MAKEARGB(170,0,0,0)
|
|
|
|
|
2006-12-01 02:51:56 +00:00
|
|
|
int BestColor (const uint32 *pal, int r, int g, int b, int first=1, int num=255);
|
2011-07-03 10:47:35 +00:00
|
|
|
void DoBlending (const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void InitPalette ();
|
|
|
|
|
|
|
|
// V_SetBlend()
|
|
|
|
// input: blendr: red component of blend
|
|
|
|
// blendg: green component of blend
|
|
|
|
// blendb: blue component of blend
|
|
|
|
// blenda: alpha component of blend
|
|
|
|
//
|
|
|
|
// Applies the blend to all palettes with PALETTEF_BLEND flag
|
|
|
|
void V_SetBlend (int blendr, int blendg, int blendb, int blenda);
|
|
|
|
|
|
|
|
// V_ForceBlend()
|
|
|
|
//
|
|
|
|
// Normally, V_SetBlend() does nothing if the new blend is the
|
2009-09-22 02:54:19 +00:00
|
|
|
// same as the old. This function will perform the blending
|
2006-02-24 04:48:15 +00:00
|
|
|
// even if the blend hasn't changed.
|
|
|
|
void V_ForceBlend (int blendr, int blendg, int blendb, int blenda);
|
|
|
|
|
|
|
|
|
|
|
|
// Colorspace conversion RGB <-> HSV
|
|
|
|
void RGBtoHSV (float r, float g, float b, float *h, float *s, float *v);
|
|
|
|
void HSVtoRGB (float *r, float *g, float *b, float h, float s, float v);
|
|
|
|
|
|
|
|
#endif //__V_PALETTE_H__
|