- 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)
This commit is contained in:
parent
6b9f3c8247
commit
1acc3d00c4
35 changed files with 1101 additions and 738 deletions
161
src/v_video.cpp
161
src/v_video.cpp
|
|
@ -102,6 +102,28 @@ IMPLEMENT_ABSTRACT_CLASS (DDummyFrameBuffer)
|
|||
// try to generate a CreateNew() function.
|
||||
IMPLEMENT_ABSTRACT_CLASS (DSimpleCanvas)
|
||||
|
||||
class FPaletteTester : public FTexture
|
||||
{
|
||||
public:
|
||||
FPaletteTester ();
|
||||
|
||||
const BYTE *GetColumn(unsigned int column, const Span **spans_out);
|
||||
const BYTE *GetPixels();
|
||||
void Unload();
|
||||
bool CheckModified();
|
||||
void SetTranslation(int num);
|
||||
|
||||
protected:
|
||||
BYTE Pixels[16*16];
|
||||
int CurTranslation;
|
||||
int WantTranslation;
|
||||
static const Span DummySpan[2];
|
||||
|
||||
void MakeTexture();
|
||||
};
|
||||
|
||||
const FTexture::Span FPaletteTester::DummySpan[2] = { { 0, 24 }, { 0, 0 } };
|
||||
|
||||
int DisplayWidth, DisplayHeight, DisplayBits;
|
||||
|
||||
FFont *SmallFont, *SmallFont2, *BigFont, *ConFont;
|
||||
|
|
@ -226,7 +248,7 @@ void DCanvas::FlatFill (int left, int top, int right, int bottom, FTexture *src)
|
|||
|
||||
|
||||
// [RH] Set an area to a specified color
|
||||
void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uint32 color) const
|
||||
void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uint32 color)
|
||||
{
|
||||
int x, y;
|
||||
BYTE *dest;
|
||||
|
|
@ -267,7 +289,7 @@ void DCanvas::Clear (int left, int top, int right, int bottom, int palcolor, uin
|
|||
}
|
||||
}
|
||||
|
||||
void DCanvas::Dim (PalEntry color) const
|
||||
void DCanvas::Dim (PalEntry color)
|
||||
{
|
||||
PalEntry dimmer;
|
||||
float amount = dimamount;
|
||||
|
|
@ -289,7 +311,7 @@ void DCanvas::Dim (PalEntry color) const
|
|||
Dim (dimmer, amount, 0, 0, Width, Height);
|
||||
}
|
||||
|
||||
void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h) const
|
||||
void DCanvas::Dim (PalEntry color, float damount, int x1, int y1, int w, int h)
|
||||
{
|
||||
if (damount == 0.f)
|
||||
return;
|
||||
|
|
@ -701,7 +723,6 @@ DFrameBuffer::DFrameBuffer (int width, int height)
|
|||
void DFrameBuffer::DrawRateStuff ()
|
||||
{
|
||||
// Draws frame time and cumulative fps
|
||||
RateX = 0;
|
||||
if (vid_fps)
|
||||
{
|
||||
DWORD ms = I_MSTime ();
|
||||
|
|
@ -710,12 +731,13 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
{
|
||||
char fpsbuff[40];
|
||||
int chars;
|
||||
int rate_x;
|
||||
|
||||
chars = sprintf (fpsbuff, "%2u ms (%3u fps)", howlong, LastCount);
|
||||
RateX = Width - chars * 8;
|
||||
Clear (RateX, 0, Width, 8, 0, 0);
|
||||
rate_x = Width - chars * 8;
|
||||
Clear (rate_x, 0, Width, 8, 0, 0);
|
||||
SetFont (ConFont);
|
||||
DrawText (CR_WHITE, RateX, 0, (char *)&fpsbuff[0], TAG_DONE);
|
||||
DrawText (CR_WHITE, rate_x, 0, (char *)&fpsbuff[0], TAG_DONE);
|
||||
SetFont (SmallFont);
|
||||
|
||||
DWORD thisSec = ms/1000;
|
||||
|
|
@ -735,47 +757,114 @@ void DFrameBuffer::DrawRateStuff ()
|
|||
{
|
||||
int i = I_GetTime(false);
|
||||
int tics = i - LastTic;
|
||||
BYTE *buffer = GetBuffer () + (GetHeight()-1)*GetPitch();
|
||||
BYTE *buffer = GetBuffer();
|
||||
|
||||
LastTic = i;
|
||||
if (tics > 20) tics = 20;
|
||||
|
||||
for (i = 0; i < tics*2; i += 2) buffer[i] = 0xff;
|
||||
for ( ; i < 20*2; i += 2) buffer[i] = 0x00;
|
||||
|
||||
// Buffer can be NULL if we're doing hardware accelerated 2D
|
||||
if (buffer != NULL)
|
||||
{
|
||||
buffer += (GetHeight()-1)*GetPitch();
|
||||
|
||||
for (i = 0; i < tics*2; i += 2) buffer[i] = 0xff;
|
||||
for ( ; i < 20*2; i += 2) buffer[i] = 0x00;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < tics*2; i += 2) Clear(i, Height-1, i+1, Height, 255, 0);
|
||||
for ( ; i < 20*2; i += 2) Clear(i, Height-1, i+1, Height, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// draws the palette for debugging
|
||||
if (vid_showpalette)
|
||||
{
|
||||
int i, j, k, l;
|
||||
// This used to just write the palette to the display buffer.
|
||||
// With hardware-accelerated 2D, that doesn't work anymore.
|
||||
// Drawing it as a texture does and continues to show how
|
||||
// well the PalTex shader is working.
|
||||
static FPaletteTester palette;
|
||||
|
||||
BYTE *buffer = GetBuffer();
|
||||
for (i = k = 0; i < 16; ++i)
|
||||
palette.SetTranslation(vid_showpalette);
|
||||
DrawTexture(&palette, 0, 0,
|
||||
DTA_DestWidth, 16*7,
|
||||
DTA_DestHeight, 16*7,
|
||||
DTA_Masked, false,
|
||||
TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
FPaletteTester::FPaletteTester()
|
||||
{
|
||||
Width = 16;
|
||||
Height = 16;
|
||||
WidthBits = 4;
|
||||
HeightBits = 4;
|
||||
WidthMask = 15;
|
||||
CurTranslation = 0;
|
||||
WantTranslation = 1;
|
||||
MakeTexture();
|
||||
}
|
||||
|
||||
bool FPaletteTester::CheckModified()
|
||||
{
|
||||
return CurTranslation != WantTranslation;
|
||||
}
|
||||
|
||||
void FPaletteTester::SetTranslation(int num)
|
||||
{
|
||||
if (num >= 1 && num <= 9)
|
||||
{
|
||||
WantTranslation = num;
|
||||
}
|
||||
}
|
||||
|
||||
void FPaletteTester::Unload()
|
||||
{
|
||||
}
|
||||
|
||||
const BYTE *FPaletteTester::GetColumn (unsigned int column, const Span **spans_out)
|
||||
{
|
||||
if (CurTranslation != WantTranslation)
|
||||
{
|
||||
MakeTexture();
|
||||
}
|
||||
column &= 15;
|
||||
if (spans_out != NULL)
|
||||
{
|
||||
*spans_out = DummySpan;
|
||||
}
|
||||
return Pixels + column*16;
|
||||
}
|
||||
|
||||
const BYTE *FPaletteTester::GetPixels ()
|
||||
{
|
||||
if (CurTranslation != WantTranslation)
|
||||
{
|
||||
MakeTexture();
|
||||
}
|
||||
return Pixels;
|
||||
}
|
||||
|
||||
void FPaletteTester::MakeTexture()
|
||||
{
|
||||
int i, j, k, t;
|
||||
BYTE *p;
|
||||
|
||||
t = WantTranslation;
|
||||
p = Pixels;
|
||||
k = 0;
|
||||
for (i = 0; i < 16; ++i)
|
||||
{
|
||||
for (j = 0; j < 16; ++j)
|
||||
{
|
||||
for (j = 0; j < 8; ++j)
|
||||
{
|
||||
for (l = 0; l < 16; ++l)
|
||||
{
|
||||
int color;
|
||||
|
||||
if (vid_showpalette > 1 && vid_showpalette < 9)
|
||||
{
|
||||
color = translationtables[TRANSLATION_Standard][(vid_showpalette-2)*256+k];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = k;
|
||||
}
|
||||
memset (buffer, color, 8);
|
||||
buffer += 8;
|
||||
k++;
|
||||
}
|
||||
k -= 16;
|
||||
buffer += GetPitch() - 16*8;
|
||||
}
|
||||
*p++ = (t > 1) ? translationtables[TRANSLATION_Standard][t - 2]->Remap[k] : k;
|
||||
k += 16;
|
||||
}
|
||||
k -= 255;
|
||||
}
|
||||
CurTranslation = t;
|
||||
}
|
||||
|
||||
void DFrameBuffer::CopyFromBuff (BYTE *src, int srcPitch, int width, int height, BYTE *dest)
|
||||
|
|
@ -812,7 +901,7 @@ FNativeTexture *DFrameBuffer::CreateTexture(FTexture *gametex)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
FNativeTexture *DFrameBuffer::CreatePalette(const PalEntry *pal)
|
||||
FNativeTexture *DFrameBuffer::CreatePalette(FRemapTable *remap)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue