2006-02-24 04:48:15 +00:00
|
|
|
/*
|
|
|
|
** v_font.h
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
- 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
|
|
|
** Copyright 1998-2008 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_FONT_H__
|
|
|
|
#define __V_FONT_H__
|
|
|
|
|
|
|
|
#include "doomtype.h"
|
|
|
|
#include "farchive.h"
|
|
|
|
|
|
|
|
class DCanvas;
|
|
|
|
class FTexture;
|
- 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
|
|
|
struct FRemapTable;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
enum EColorRange
|
|
|
|
{
|
2006-09-19 23:25:51 +00:00
|
|
|
CR_UNDEFINED = -1,
|
2006-02-24 04:48:15 +00:00
|
|
|
CR_BRICK,
|
|
|
|
CR_TAN,
|
|
|
|
CR_GRAY,
|
|
|
|
CR_GREY = CR_GRAY,
|
|
|
|
CR_GREEN,
|
|
|
|
CR_BROWN,
|
|
|
|
CR_GOLD,
|
|
|
|
CR_RED,
|
|
|
|
CR_BLUE,
|
|
|
|
CR_ORANGE,
|
|
|
|
CR_WHITE,
|
|
|
|
CR_YELLOW,
|
|
|
|
CR_UNTRANSLATED,
|
- Added support for casting color names in ACS print-type statements. What that
means is that instead of writing this:
print (s:"\cDSome text");
You can write this:
print (r:CR_GREEN, s:"Some text");
- Added some new colors, based on the ones jimmy91 posted in the forum: cream,
light blue, black, olive, dark green, dark red, dark brown, purple, and dark
gray.
- Simplified FFont::BuildTranslations() and BuildTranslations2() to make adding
new colors easier.
SVN r306 (trunk)
2006-08-22 21:58:24 +00:00
|
|
|
CR_BLACK,
|
|
|
|
CR_LIGHTBLUE,
|
|
|
|
CR_CREAM,
|
|
|
|
CR_OLIVE,
|
|
|
|
CR_DARKGREEN,
|
|
|
|
CR_DARKRED,
|
|
|
|
CR_DARKBROWN,
|
|
|
|
CR_PURPLE,
|
|
|
|
CR_DARKGRAY,
|
2006-02-24 04:48:15 +00:00
|
|
|
NUM_TEXT_COLORS
|
|
|
|
};
|
|
|
|
|
2006-08-31 00:16:12 +00:00
|
|
|
extern int NumTextColors;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
inline FArchive &operator<< (FArchive &arc, EColorRange &i)
|
|
|
|
{
|
|
|
|
BYTE val = (BYTE)i;
|
|
|
|
arc << val;
|
|
|
|
i = (EColorRange)val;
|
|
|
|
return arc;
|
|
|
|
}
|
|
|
|
|
|
|
|
class FFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FFont (const char *fontname, const char *nametemplate, int first, int count, int base);
|
|
|
|
~FFont ();
|
|
|
|
|
|
|
|
FTexture *GetChar (int code, int *const width) const;
|
|
|
|
int GetCharWidth (int code) const;
|
- 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
|
|
|
FRemapTable *GetColorTranslation (EColorRange range) const;
|
2006-02-24 04:48:15 +00:00
|
|
|
int GetSpaceWidth () const { return SpaceWidth; }
|
|
|
|
int GetHeight () const { return FontHeight; }
|
|
|
|
int GetDefaultKerning () const { return GlobalKerning; }
|
|
|
|
|
|
|
|
static FFont *FindFont (const char *fontname);
|
|
|
|
|
|
|
|
// Return width of string in pixels (unscaled)
|
2006-09-14 00:02:31 +00:00
|
|
|
int StringWidth (const BYTE *str) const;
|
|
|
|
inline int StringWidth (const char *str) const { return StringWidth ((const BYTE *)str); }
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
FFont ();
|
|
|
|
|
- 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
|
|
|
void BuildTranslations (const double *luminosity, const BYTE *identity, const void *ranges, int total_colors);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
static int SimpleTranslation (BYTE *colorsused, BYTE *translation, BYTE *identity, double **luminosity);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int FirstChar, LastChar;
|
|
|
|
int SpaceWidth;
|
|
|
|
int FontHeight;
|
|
|
|
int GlobalKerning;
|
|
|
|
struct CharData
|
|
|
|
{
|
|
|
|
FTexture *Pic;
|
|
|
|
} *Chars;
|
|
|
|
int ActiveColors;
|
- 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
|
|
|
TArray<FRemapTable> Ranges;
|
2006-02-24 04:48:15 +00:00
|
|
|
BYTE *PatchRemap;
|
|
|
|
|
|
|
|
char *Name;
|
|
|
|
FFont *Next;
|
|
|
|
|
|
|
|
static FFont *FirstFont;
|
2006-05-09 03:40:15 +00:00
|
|
|
friend struct FontsDeleter;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
friend void V_Shutdown();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
friend FArchive &SerializeFFontPtr (FArchive &arc, FFont* &font);
|
|
|
|
};
|
|
|
|
|
|
|
|
template<> inline FArchive &operator<< <FFont> (FArchive &arc, FFont* &font)
|
|
|
|
{
|
|
|
|
return SerializeFFontPtr (arc, font);
|
|
|
|
}
|
|
|
|
|
|
|
|
class FSingleLumpFont : public FFont
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FSingleLumpFont (const char *fontname, int lump);
|
|
|
|
|
|
|
|
protected:
|
2006-08-30 02:38:39 +00:00
|
|
|
void CheckFON1Chars (int lump, const BYTE *data, double *luminosity);
|
2006-02-24 04:48:15 +00:00
|
|
|
void BuildTranslations2 ();
|
|
|
|
void FixupPalette (BYTE *identity, double *luminosity, const BYTE *palette, bool rescale);
|
|
|
|
void LoadFON1 (int lump, const BYTE *data);
|
|
|
|
void LoadFON2 (int lump, const BYTE *data);
|
|
|
|
void CreateFontFromPic (int picnum);
|
|
|
|
};
|
|
|
|
|
2006-09-14 00:02:31 +00:00
|
|
|
void RecordTextureColors (FTexture *pic, BYTE *colorsused);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
extern FFont *SmallFont, *SmallFont2, *BigFont, *ConFont;
|
|
|
|
|
2006-10-06 21:07:58 +00:00
|
|
|
void V_InitFonts();
|
2006-08-31 00:16:12 +00:00
|
|
|
EColorRange V_FindFontColor (FName name);
|
2007-01-09 04:40:58 +00:00
|
|
|
PalEntry V_LogColorFromColorRange (EColorRange range);
|
|
|
|
EColorRange V_ParseFontColor (const BYTE *&color_value, int normalcolor, int boldcolor);
|
|
|
|
FFont *V_GetFont(const char *);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#endif //__V_FONT_H__
|