initial
This commit is contained in:
49
common/vgui_surfacelib/BitmapFont.h
Normal file
49
common/vgui_surfacelib/BitmapFont.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======
|
||||
//
|
||||
// Baked Bitmap fonts
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
#ifndef _BITMAPFONT_H_
|
||||
#define _BITMAPFONT_H_
|
||||
|
||||
#include "vguifont.h"
|
||||
#include "BitmapFontFile.h"
|
||||
|
||||
class ITexture;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: encapsulates a windows font
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBitmapFont : public font_t
|
||||
{
|
||||
public:
|
||||
CBitmapFont();
|
||||
~CBitmapFont();
|
||||
|
||||
// creates the font. returns false if the compiled font does not exist.
|
||||
virtual bool Create(const char *windowsFontName, float scalex, float scaley, int flags);
|
||||
|
||||
// returns true if the font is equivalent to that specified
|
||||
virtual bool IsEqualTo(const char *windowsFontName, float scalex, float scaley, int flags);
|
||||
|
||||
// gets the abc widths for a character
|
||||
virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
|
||||
virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
|
||||
|
||||
// gets the texture coords in the compiled texture page
|
||||
void GetCharCoords( int ch, float *left, float *top, float *right, float *bottom );
|
||||
|
||||
// sets the scale of the font.
|
||||
void SetScale( float sx, float sy );
|
||||
|
||||
// gets the compiled texture page
|
||||
ITexture *GetTexturePage();
|
||||
|
||||
private:
|
||||
int m_bitmapFontHandle;
|
||||
float m_scalex;
|
||||
float m_scaley;
|
||||
};
|
||||
|
||||
#endif // _BITMAPFONT_H
|
||||
71
common/vgui_surfacelib/FontAmalgam.h
Normal file
71
common/vgui_surfacelib/FontAmalgam.h
Normal file
@@ -0,0 +1,71 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FONTAMALGAM_H
|
||||
#define FONTAMALGAM_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vguifont.h"
|
||||
#include "BitmapFont.h"
|
||||
#include "utlvector.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: object that holds a set of fonts in specified ranges
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFontAmalgam
|
||||
{
|
||||
public:
|
||||
CFontAmalgam();
|
||||
~CFontAmalgam();
|
||||
|
||||
// adds a font to the amalgam
|
||||
void AddFont( font_t *font, int lowRange, int highRange);
|
||||
|
||||
// returns the font for the given character
|
||||
font_t *GetFontForChar(int ch);
|
||||
|
||||
// returns the max height of the font set
|
||||
int GetFontHeight();
|
||||
|
||||
// returns the maximum width of a character in a font
|
||||
int GetFontMaxWidth();
|
||||
|
||||
// returns the flags used to make the first font
|
||||
int GetFlags(int i);
|
||||
|
||||
// returns the windows name for the font
|
||||
const char *GetFontName(int i);
|
||||
|
||||
// returns the number of fonts in this amalgam
|
||||
int GetCount();
|
||||
|
||||
// returns true if this font is underlined
|
||||
bool GetUnderlined();
|
||||
|
||||
// sets the scale of a bitmap font
|
||||
void SetFontScale(float sx, float sy);
|
||||
|
||||
// clears the fonts
|
||||
void RemoveAll();
|
||||
|
||||
private:
|
||||
struct TFontRange
|
||||
{
|
||||
int lowRange;
|
||||
int highRange;
|
||||
font_t *pWin32Font;
|
||||
};
|
||||
|
||||
CUtlVector<TFontRange> m_Fonts;
|
||||
int m_iMaxWidth;
|
||||
int m_iMaxHeight;
|
||||
};
|
||||
|
||||
|
||||
#endif // FONTAMALGAM_H
|
||||
159
common/vgui_surfacelib/Win32Font.h
Normal file
159
common/vgui_surfacelib/Win32Font.h
Normal file
@@ -0,0 +1,159 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef WIN32FONT_H
|
||||
#define WIN32FONT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if !defined( _X360 ) && !defined( _PS3 )
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define OEMRESOURCE
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifdef GetCharABCWidths
|
||||
#undef GetCharABCWidths
|
||||
#endif
|
||||
|
||||
#include "utlrbtree.h"
|
||||
#include "tier1/utlsymbol.h"
|
||||
|
||||
#if defined(_PS3)
|
||||
class IFont;
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: encapsulates a windows font
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CWin32Font
|
||||
{
|
||||
public:
|
||||
CWin32Font();
|
||||
~CWin32Font();
|
||||
|
||||
// creates the font from windows. returns false if font does not exist in the OS.
|
||||
virtual bool Create(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// writes the char into the specified 32bpp texture
|
||||
virtual void GetCharRGBA(wchar_t ch, int rgbaWide, int rgbaTall, unsigned char *rgba);
|
||||
|
||||
// returns true if the font is equivalent to that specified
|
||||
virtual bool IsEqualTo(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// returns true only if this font is valid for use
|
||||
virtual bool IsValid();
|
||||
|
||||
// gets the abc widths for a character
|
||||
virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
|
||||
|
||||
#if !defined (_PS3)
|
||||
// set the font to be the one to currently draw with in the gdi
|
||||
virtual void SetAsActiveFont(HDC hdc);
|
||||
#endif
|
||||
|
||||
// returns the height of the font, in pixels
|
||||
virtual int GetHeight();
|
||||
|
||||
// returns the ascent of the font, in pixels (ascent=units above the base line)
|
||||
virtual int GetAscent();
|
||||
|
||||
// returns the maximum width of a character, in pixels
|
||||
virtual int GetMaxCharWidth();
|
||||
|
||||
// returns the flags used to make this font
|
||||
virtual int GetFlags();
|
||||
|
||||
// returns true if this font is underlined
|
||||
bool GetUnderlined() { return m_bUnderlined; }
|
||||
|
||||
// gets the name of this font
|
||||
const char *GetName() { return m_szName.String(); }
|
||||
|
||||
// gets the width of ch given its position around before and after chars
|
||||
virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
|
||||
|
||||
#if defined( _X360 )
|
||||
// generates texture data for a set of chars
|
||||
virtual void GetCharsRGBA( newChar_t *newChars, int numNewChars, unsigned char *pRGBA );
|
||||
|
||||
virtual void CloseResource();
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
HFONT m_hFont;
|
||||
HDC m_hDC;
|
||||
HBITMAP m_hDIB;
|
||||
#elif defined ( _PS3 )
|
||||
IFont *m_pFont;
|
||||
#elif defined( _X360 )
|
||||
HXUIFONT m_hFont;
|
||||
HDC m_hDC;
|
||||
#endif
|
||||
|
||||
// pointer to buffer for use when generated bitmap versions of a texture
|
||||
unsigned char *m_pBuf;
|
||||
|
||||
protected:
|
||||
CUtlSymbol m_szName;
|
||||
|
||||
short m_iTall;
|
||||
|
||||
#ifdef _PS3
|
||||
int m_iWeight;
|
||||
#else
|
||||
unsigned short m_iWeight;
|
||||
#endif
|
||||
|
||||
unsigned short m_iFlags;
|
||||
unsigned short m_iScanLines;
|
||||
unsigned short m_iBlur;
|
||||
unsigned short m_rgiBitmapSize[2];
|
||||
|
||||
unsigned int m_iHeight : 8;
|
||||
unsigned int m_iMaxCharWidth : 8;
|
||||
unsigned int m_iAscent : 8;
|
||||
unsigned int m_iDropShadowOffset : 1;
|
||||
unsigned int m_iOutlineSize : 1;
|
||||
unsigned int m_bAntiAliased : 1;
|
||||
unsigned int m_bRotary : 1;
|
||||
unsigned int m_bAdditive : 1;
|
||||
unsigned int m_bUnderlined : 1; //30
|
||||
|
||||
private:
|
||||
// abc widths
|
||||
struct abc_t
|
||||
{
|
||||
short b;
|
||||
char a;
|
||||
char c;
|
||||
};
|
||||
|
||||
// cache for additional or asian characters (since it's too big too just store them all)
|
||||
struct abc_cache_t
|
||||
{
|
||||
wchar_t wch;
|
||||
abc_t abc;
|
||||
};
|
||||
CUtlRBTree<abc_cache_t, unsigned short> m_ExtendedABCWidthsCache;
|
||||
static bool ExtendedABCWidthsCacheLessFunc(const abc_cache_t &lhs, const abc_cache_t &rhs);
|
||||
|
||||
// First range of characters are automatically cached
|
||||
#if defined( _PS3 )
|
||||
enum { ABCWIDTHS_CACHE_SIZE = 128 };
|
||||
abc_t m_ABCWidthsCache[ABCWIDTHS_CACHE_SIZE];
|
||||
#elif defined( _X360 )
|
||||
// 360 requires all possible characters during font init
|
||||
enum { ABCWIDTHS_CACHE_SIZE = 256 };
|
||||
abc_t m_ABCWidthsCache[ABCWIDTHS_CACHE_SIZE];
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // WIN32FONT_H
|
||||
129
common/vgui_surfacelib/fontmanager.h
Normal file
129
common/vgui_surfacelib/fontmanager.h
Normal file
@@ -0,0 +1,129 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FONTMANAGER_H
|
||||
#define FONTMANAGER_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui/vgui.h"
|
||||
#include "vgui_surfacelib/FontAmalgam.h"
|
||||
#include "vgui_surfacelib/ifontsurface.h"
|
||||
#include "materialsystem/imaterialsystem.h"
|
||||
#include "filesystem.h"
|
||||
#include "vguifont.h"
|
||||
|
||||
#ifdef LINUX
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
typedef void *(*FontDataHelper)( const char *pchFontName, int &size );
|
||||
#endif
|
||||
|
||||
#ifdef CreateFont
|
||||
#undef CreateFont
|
||||
#endif
|
||||
|
||||
|
||||
using vgui::HFont;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Creates and maintains list of actively used fonts
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFontManager
|
||||
{
|
||||
public:
|
||||
CFontManager();
|
||||
~CFontManager();
|
||||
|
||||
void SetLanguage(const char *language);
|
||||
const char *GetLanguage();
|
||||
|
||||
// clears the current font list, frees any resources
|
||||
void ClearAllFonts();
|
||||
|
||||
HFont CreateFont();
|
||||
bool SetFontGlyphSet(HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
bool SetFontGlyphSet(HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags, int nRangeMin, int nRangeMax);
|
||||
bool SetBitmapFontGlyphSet(HFont font, const char *windowsFontName, float scalex, float scaley, int flags);
|
||||
void SetFontScale(HFont font, float sx, float sy);
|
||||
const char *GetFontName( HFont font );
|
||||
void GetCharABCwide(HFont font, int ch, int &a, int &b, int &c);
|
||||
int GetFontTall(HFont font);
|
||||
int GetFontAscent(HFont font, wchar_t wch);
|
||||
int GetCharacterWidth(HFont font, int ch);
|
||||
bool GetFontUnderlined( HFont font );
|
||||
void GetTextSize(HFont font, const wchar_t *text, int &wide, int &tall);
|
||||
|
||||
font_t *GetFontForChar(HFont, wchar_t wch);
|
||||
bool IsFontAdditive(HFont font);
|
||||
bool IsBitmapFont(HFont font );
|
||||
|
||||
void SetInterfaces( IFileSystem *pFileSystem, IMaterialSystem *pMaterialSystem )
|
||||
{
|
||||
m_pFileSystem = pFileSystem;
|
||||
m_pMaterialSystem = pMaterialSystem;
|
||||
}
|
||||
IFileSystem *FileSystem() { return m_pFileSystem; }
|
||||
IMaterialSystem *MaterialSystem() { return m_pMaterialSystem; }
|
||||
|
||||
#ifdef LINUX
|
||||
FT_Library GetFontLibraryHandle() { return library; }
|
||||
void SetFontDataHelper( FontDataHelper helper ) { pFontDataHelper = helper; }
|
||||
#endif
|
||||
|
||||
#if defined( _X360 )
|
||||
// secondary cache to speed TTF setup
|
||||
bool GetCachedXUIMetrics( const char *pWindowsFontName, int tall, int style, XUIFontMetrics *pFontMetrics, XUICharMetrics charMetrics[256] );
|
||||
void SetCachedXUIMetrics( const char *pWindowsFontName, int tall, int style, XUIFontMetrics *pFontMetrics, XUICharMetrics charMetrics[256] );
|
||||
#endif
|
||||
|
||||
// used as a hint that intensive TTF operations are finished
|
||||
void ClearTemporaryFontCache();
|
||||
void GetKernedCharWidth( vgui::HFont font, wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
|
||||
|
||||
private:
|
||||
bool IsFontForeignLanguageCapable(const char *windowsFontName);
|
||||
font_t *CreateOrFindWin32Font(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
CBitmapFont *CreateOrFindBitmapFont(const char *windowsFontName, float scalex, float scaley, int flags);
|
||||
const char *GetFallbackFontName(const char *windowsFontName);
|
||||
const char *GetForeignFallbackFontName();
|
||||
|
||||
CUtlVector<CFontAmalgam> m_FontAmalgams;
|
||||
CUtlVector<font_t *> m_Win32Fonts;
|
||||
|
||||
#ifdef LINUX
|
||||
FT_Library library;
|
||||
FontDataHelper pFontDataHelper;
|
||||
#endif
|
||||
char m_szLanguage[64];
|
||||
IFileSystem *m_pFileSystem;
|
||||
IMaterialSystem *m_pMaterialSystem;
|
||||
|
||||
#if defined( _X360 )
|
||||
// These are really bounded by the number of fonts that the game would ever realistically create, so ~100 is expected.
|
||||
// Many of these fonts are redundant and the same underlying metrics can be used. This avoid the very expensive TTF font metric lookup.
|
||||
struct XUIMetricCache_t
|
||||
{
|
||||
// the font signature that can change
|
||||
CUtlSymbol fontSymbol;
|
||||
int tall;
|
||||
int style;
|
||||
|
||||
// the metrics
|
||||
XUIFontMetrics fontMetrics;
|
||||
XUICharMetrics charMetrics[256];
|
||||
};
|
||||
CUtlVector< XUIMetricCache_t > m_XUIMetricCache;
|
||||
#endif
|
||||
};
|
||||
|
||||
// singleton accessor
|
||||
extern CFontManager &FontManager();
|
||||
|
||||
|
||||
#endif // FONTMANAGER_H
|
||||
118
common/vgui_surfacelib/fonttexturecache.h
Normal file
118
common/vgui_surfacelib/fonttexturecache.h
Normal file
@@ -0,0 +1,118 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef FONTTEXTURECACHE_H
|
||||
#define FONTTEXTURECACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "vgui_surfacelib/fontmanager.h"
|
||||
#include "utlrbtree.h"
|
||||
#include "utlmap.h"
|
||||
#include "bitmap/texturepacker.h"
|
||||
|
||||
class ITexture;
|
||||
|
||||
#define MAX_COMMON_CHARS 256
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: manages texture memory for unicode fonts
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFontTextureCache
|
||||
{
|
||||
public:
|
||||
CFontTextureCache();
|
||||
~CFontTextureCache();
|
||||
|
||||
void SetPrefix( const char *pTexturePagePrefix );
|
||||
|
||||
// returns a texture ID and a pointer to an array of 4 texture coords for the given character & font
|
||||
// generates+uploads more texture if necessary
|
||||
bool GetTextureForChar( FontHandle_t font, FontDrawType_t type, wchar_t wch, int *textureID, float **texCoords );
|
||||
// This function copies the texcoords out from the static into a preallocated passed in arg.
|
||||
bool GetTextureAndCoordsForChar( FontHandle_t font, FontDrawType_t type, wchar_t wch, int *textureID, float *texCoords );
|
||||
|
||||
// for each character in an array (not assumed to be a NULL-terminated string), returns a
|
||||
// texture ID and a pointer to an array of 4 texture coords for the given character & font
|
||||
// generates+uploads more texture if necessary
|
||||
bool GetTextureForChars( FontHandle_t font, FontDrawType_t type, wchar_t *wch, int *textureID, float **texCoords, int numChars = 1 );
|
||||
|
||||
// clears the cache
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
|
||||
ITexture *AllocateNewPage( char *pTextureName );
|
||||
|
||||
// hold the common characters
|
||||
struct charDetail_t
|
||||
{
|
||||
int page;
|
||||
float texCoords[4];
|
||||
};
|
||||
struct CommonChar_t
|
||||
{
|
||||
charDetail_t details[MAX_COMMON_CHARS];
|
||||
};
|
||||
|
||||
// a single character in the cache
|
||||
typedef unsigned short HCacheEntry;
|
||||
struct CacheEntry_t
|
||||
{
|
||||
FontHandle_t font;
|
||||
wchar_t wch;
|
||||
short pad;
|
||||
int page;
|
||||
float texCoords[4];
|
||||
};
|
||||
|
||||
struct CacheMapEntry_t
|
||||
{
|
||||
Rect_t rc;
|
||||
bool bInUse;
|
||||
};
|
||||
|
||||
// a single texture page
|
||||
struct Page_t
|
||||
{
|
||||
public:
|
||||
Page_t()
|
||||
{
|
||||
pPackedFontTextureCache = NULL;
|
||||
}
|
||||
|
||||
short textureID[FONT_DRAW_TYPE_COUNT];
|
||||
CTexturePacker *pPackedFontTextureCache; // the character mapping cache to use for this page.
|
||||
};
|
||||
|
||||
// allocates a new page for a given character
|
||||
bool AllocatePageForChar(int charWide, int charTall, int &pageIndex, int &drawX, int &drawY, int &twide, int &ttall);
|
||||
|
||||
// Creates font materials
|
||||
void CreateFontMaterials( Page_t &page, ITexture *pFontTexture, bool bitmapFont = false );
|
||||
|
||||
CommonChar_t *m_CommonCharCache[384];
|
||||
|
||||
static bool CacheEntryLessFunc(const CacheEntry_t &lhs, const CacheEntry_t &rhs);
|
||||
CUtlRBTree< CacheEntry_t, HCacheEntry > m_CharCache;
|
||||
|
||||
// cache
|
||||
typedef CUtlVector<Page_t> FontPageList_t;
|
||||
FontPageList_t m_PageList;
|
||||
|
||||
int m_CurrPage;
|
||||
CUtlMap< FontHandle_t, Page_t > m_FontPages;
|
||||
|
||||
// Prefix to use when this cache creates font pages
|
||||
CUtlString m_TexturePagePrefix;
|
||||
};
|
||||
|
||||
|
||||
#endif // FONTTEXTURECACHE_H
|
||||
|
||||
|
||||
107
common/vgui_surfacelib/ifontsurface.h
Normal file
107
common/vgui_surfacelib/ifontsurface.h
Normal file
@@ -0,0 +1,107 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef IFONTSURFACE_H
|
||||
#define IFONTSURFACE_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "mathlib/vector2d.h" // must be before the namespace line
|
||||
|
||||
#ifdef CreateFont
|
||||
#undef CreateFont
|
||||
#endif
|
||||
|
||||
|
||||
// returns true if the surface supports minimize & maximize capabilities
|
||||
// Numbered this way to prevent interface change in surface.
|
||||
enum FontFeature_t
|
||||
{
|
||||
FONT_FEATURE_ANTIALIASED_FONTS = 1,
|
||||
FONT_FEATURE_DROPSHADOW_FONTS = 2,
|
||||
FONT_FEATURE_OUTLINE_FONTS = 6,
|
||||
};
|
||||
|
||||
// adds to the font
|
||||
enum FontFlags_t
|
||||
{
|
||||
FONTFLAG_NONE,
|
||||
FONTFLAG_ITALIC = 0x001,
|
||||
FONTFLAG_UNDERLINE = 0x002,
|
||||
FONTFLAG_STRIKEOUT = 0x004,
|
||||
FONTFLAG_SYMBOL = 0x008,
|
||||
FONTFLAG_ANTIALIAS = 0x010,
|
||||
FONTFLAG_GAUSSIANBLUR = 0x020,
|
||||
FONTFLAG_ROTARY = 0x040,
|
||||
FONTFLAG_DROPSHADOW = 0x080,
|
||||
FONTFLAG_ADDITIVE = 0x100,
|
||||
FONTFLAG_OUTLINE = 0x200,
|
||||
FONTFLAG_CUSTOM = 0x400, // custom generated font - never fall back to asian compatibility mode
|
||||
FONTFLAG_BITMAP = 0x800, // compiled bitmap font - no fallbacks
|
||||
};
|
||||
|
||||
enum FontDrawType_t
|
||||
{
|
||||
// Use the "additive" value from the scheme file
|
||||
FONT_DRAW_DEFAULT = 0,
|
||||
|
||||
// Overrides
|
||||
FONT_DRAW_NONADDITIVE,
|
||||
FONT_DRAW_ADDITIVE,
|
||||
|
||||
FONT_DRAW_TYPE_COUNT = 2,
|
||||
};
|
||||
|
||||
|
||||
struct FontVertex_t
|
||||
{
|
||||
FontVertex_t() {}
|
||||
FontVertex_t( const Vector2D &pos, const Vector2D &coord = Vector2D( 0, 0 ) )
|
||||
{
|
||||
m_Position = pos;
|
||||
m_TexCoord = coord;
|
||||
}
|
||||
void Init( const Vector2D &pos, const Vector2D &coord = Vector2D( 0, 0 ) )
|
||||
{
|
||||
m_Position = pos;
|
||||
m_TexCoord = coord;
|
||||
}
|
||||
|
||||
Vector2D m_Position;
|
||||
Vector2D m_TexCoord;
|
||||
};
|
||||
|
||||
typedef unsigned long FontHandle_t;
|
||||
|
||||
struct FontCharRenderInfo
|
||||
{
|
||||
// Text pos
|
||||
int x, y;
|
||||
// Top left and bottom right
|
||||
// This is now a pointer to an array maintained by the surface, to avoid copying the data on the 360
|
||||
FontVertex_t *verts;
|
||||
int textureId;
|
||||
int abcA;
|
||||
int abcB;
|
||||
int abcC;
|
||||
int fontTall;
|
||||
FontHandle_t currentFont;
|
||||
// In:
|
||||
FontDrawType_t drawType;
|
||||
wchar_t ch;
|
||||
|
||||
// Out
|
||||
bool valid;
|
||||
// In/Out (true by default)
|
||||
bool shouldclip;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // IFONTSURFACE_H
|
||||
168
common/vgui_surfacelib/linuxfont.h
Normal file
168
common/vgui_surfacelib/linuxfont.h
Normal file
@@ -0,0 +1,168 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef LINUXFONT_H
|
||||
#define LINUXFONT_H
|
||||
|
||||
#include "utlrbtree.h"
|
||||
#include <tier0/memdbgoff.h>
|
||||
#include <tier0/memdbgon.h>
|
||||
#include "tier1/strtools.h"
|
||||
#include "tier1/utlstring.h"
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: encapsulates a OSX font
|
||||
//-----------------------------------------------------------------------------
|
||||
class CLinuxFont
|
||||
{
|
||||
public:
|
||||
CLinuxFont();
|
||||
~CLinuxFont();
|
||||
|
||||
// creates the font from windows. returns false if font does not exist in the OS.
|
||||
virtual bool Create(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// writes the char into the specified 32bpp texture
|
||||
virtual void GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned char *rgba);
|
||||
|
||||
// returns true if the font is equivalent to that specified
|
||||
virtual bool IsEqualTo(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// returns true only if this font is valid for use
|
||||
virtual bool IsValid();
|
||||
|
||||
// gets the abc widths for a character
|
||||
virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
|
||||
|
||||
// set the font to be the one to currently draw with in the gdi
|
||||
void *SetAsActiveFont( void *glContext );
|
||||
|
||||
// returns the height of the font, in pixels
|
||||
virtual int GetHeight();
|
||||
|
||||
// returns the ascent of the font, in pixels (ascent=units above the base line)
|
||||
virtual int GetAscent();
|
||||
|
||||
// returns the maximum width of a character, in pixels
|
||||
virtual int GetMaxCharWidth();
|
||||
|
||||
// returns the flags used to make this font
|
||||
virtual int GetFlags();
|
||||
|
||||
// returns true if this font is underlined
|
||||
virtual bool GetUnderlined() { return m_bUnderlined; }
|
||||
|
||||
// gets the name of this font
|
||||
const char *GetName() { return m_szName.String(); }
|
||||
|
||||
// gets the weight of the font
|
||||
virtual int GetWeight() { return m_iWeight; }
|
||||
|
||||
// gets the width of ch given its position around before and after chars
|
||||
virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
void Validate( CValidator &validator, char *pchName );
|
||||
#endif
|
||||
|
||||
virtual bool CreateFromMemory(const char *windowsFontName, void *data, int size, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
|
||||
protected:
|
||||
CUtlString m_szName;
|
||||
int m_iTall;
|
||||
int m_iWeight;
|
||||
int m_iFlags;
|
||||
bool m_bAntiAliased;
|
||||
bool m_bRotary;
|
||||
bool m_bAdditive;
|
||||
int m_iDropShadowOffset;
|
||||
bool m_bUnderlined;
|
||||
int m_iOutlineSize;
|
||||
|
||||
int m_iHeight;
|
||||
int m_iMaxCharWidth;
|
||||
int m_iAscent;
|
||||
|
||||
int m_iScanLines;
|
||||
int m_iBlur;
|
||||
float *m_pGaussianDistribution;
|
||||
|
||||
private:
|
||||
void InitMetrics();
|
||||
|
||||
|
||||
|
||||
static void CreateFontList();
|
||||
// abc widths
|
||||
struct abc_t
|
||||
{
|
||||
short b;
|
||||
char a;
|
||||
char c;
|
||||
};
|
||||
|
||||
// cache for storing asian abc widths (since it's too big too just store them all)
|
||||
struct abc_cache_t
|
||||
{
|
||||
wchar_t wch;
|
||||
abc_t abc;
|
||||
};
|
||||
|
||||
|
||||
CUtlRBTree<abc_cache_t, unsigned short> m_ExtendedABCWidthsCache;
|
||||
static bool ExtendedABCWidthsCacheLessFunc(const abc_cache_t &lhs, const abc_cache_t &rhs);
|
||||
|
||||
// cache for storing asian abc widths (since it's too big too just store them all)
|
||||
struct kernedSize
|
||||
{
|
||||
float wide;
|
||||
// float abcA; //$ Not yet used...
|
||||
// float abcC; //
|
||||
};
|
||||
|
||||
struct kerned_abc_cache_t
|
||||
{
|
||||
wchar_t wch;
|
||||
wchar_t wchBefore;
|
||||
wchar_t wchAfter;
|
||||
kernedSize abc;
|
||||
};
|
||||
|
||||
CUtlRBTree<kerned_abc_cache_t, unsigned short> m_ExtendedKernedABCWidthsCache;
|
||||
static bool ExtendedKernedABCWidthsCacheLessFunc(const kerned_abc_cache_t &lhs, const kerned_abc_cache_t &rhs);
|
||||
|
||||
|
||||
int m_rgiBitmapSize[2];
|
||||
unsigned char *m_pBuf; // pointer to buffer for use when generated bitmap versions of a texture
|
||||
|
||||
FT_Face face;
|
||||
|
||||
struct font_name_entry
|
||||
{
|
||||
font_name_entry()
|
||||
{
|
||||
m_pchFile = NULL;
|
||||
m_pchFriendlyName = NULL;
|
||||
}
|
||||
|
||||
char *m_pchFile;
|
||||
char *m_pchFriendlyName;
|
||||
bool operator<( const font_name_entry &rhs ) const
|
||||
{
|
||||
return V_stricmp( rhs.m_pchFriendlyName, m_pchFriendlyName ) > 0;
|
||||
}
|
||||
};
|
||||
static CUtlRBTree< font_name_entry > m_FriendlyNameCache;
|
||||
static bool ms_bSetFriendlyNameCacheLessFunc;
|
||||
};
|
||||
|
||||
#endif // OSXFONT_H
|
||||
149
common/vgui_surfacelib/osxfont.h
Normal file
149
common/vgui_surfacelib/osxfont.h
Normal file
@@ -0,0 +1,149 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef OSXFONT_H
|
||||
#define OSXFONT_H
|
||||
|
||||
#include "utlrbtree.h"
|
||||
#include "utlsymbol.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "tier1/utlstring.h"
|
||||
#include <tier0/memdbgoff.h>
|
||||
#include <ApplicationServices/ApplicationServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include <CoreText/CoreText.h>
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: encapsulates a OSX font
|
||||
//-----------------------------------------------------------------------------
|
||||
class COSXFont
|
||||
{
|
||||
public:
|
||||
COSXFont();
|
||||
~COSXFont();
|
||||
|
||||
// creates the font from windows. returns false if font does not exist in the OS.
|
||||
virtual bool Create(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// writes the char into the specified 32bpp texture
|
||||
virtual void GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned char *rgba);
|
||||
|
||||
// returns true if the font is equivalent to that specified
|
||||
virtual bool IsEqualTo(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// returns true only if this font is valid for use
|
||||
virtual bool IsValid();
|
||||
|
||||
// gets the abc widths for a character
|
||||
virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
|
||||
|
||||
// set the font to be the one to currently draw with in the gdi
|
||||
void *SetAsActiveFont( CGContextRef cgContext );
|
||||
|
||||
// returns the height of the font, in pixels
|
||||
virtual int GetHeight();
|
||||
|
||||
// returns the ascent of the font, in pixels (ascent=units above the base line)
|
||||
virtual int GetAscent();
|
||||
|
||||
// returns the descent of the font, in pixels (descent=units below the base line)
|
||||
virtual int GetDescent();
|
||||
|
||||
// returns the maximum width of a character, in pixels
|
||||
virtual int GetMaxCharWidth();
|
||||
|
||||
// returns the flags used to make this font
|
||||
virtual int GetFlags();
|
||||
|
||||
// returns true if this font is underlined
|
||||
virtual bool GetUnderlined() { return m_bUnderlined; }
|
||||
|
||||
// gets the name of this font
|
||||
const char *GetName() { return m_szName.String(); }
|
||||
|
||||
// gets the weight of the font
|
||||
virtual int GetWeight() { return m_iWeight; }
|
||||
|
||||
// gets the width of ch given its position around before and after chars
|
||||
virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
|
||||
|
||||
#ifdef DBGFLAG_VALIDATE
|
||||
void Validate( CValidator &validator, char *pchName );
|
||||
#endif
|
||||
|
||||
private:
|
||||
static void CreateFontList( bool bForceReload );
|
||||
|
||||
protected:
|
||||
CUtlString m_szName;
|
||||
int m_iTall;
|
||||
int m_iWeight;
|
||||
int m_iFlags;
|
||||
bool m_bAntiAliased;
|
||||
bool m_bRotary;
|
||||
bool m_bAdditive;
|
||||
int m_iDropShadowOffset;
|
||||
bool m_bUnderlined;
|
||||
int m_iOutlineSize;
|
||||
|
||||
int m_iHeight;
|
||||
int m_iMaxCharWidth;
|
||||
int m_iAscent;
|
||||
int m_iDescent;
|
||||
|
||||
int m_iScanLines;
|
||||
int m_iBlur;
|
||||
float *m_pGaussianDistribution;
|
||||
|
||||
private:
|
||||
// abc widths
|
||||
struct abc_t
|
||||
{
|
||||
short b;
|
||||
char a;
|
||||
char c;
|
||||
};
|
||||
|
||||
// cache for storing asian abc widths (since it's too big too just store them all)
|
||||
struct abc_cache_t
|
||||
{
|
||||
wchar_t wch;
|
||||
abc_t abc;
|
||||
};
|
||||
CUtlRBTree<abc_cache_t, unsigned short> m_ExtendedABCWidthsCache;
|
||||
static bool ExtendedABCWidthsCacheLessFunc(const abc_cache_t &lhs, const abc_cache_t &rhs);
|
||||
|
||||
// cache for storing asian abc widths (since it's too big too just store them all)
|
||||
struct kernedSize
|
||||
{
|
||||
float wide;
|
||||
float abcA;
|
||||
float abcC;
|
||||
};
|
||||
|
||||
struct kerned_abc_cache_t
|
||||
{
|
||||
wchar_t wch;
|
||||
wchar_t wchBefore;
|
||||
wchar_t wchAfter;
|
||||
kernedSize abc;
|
||||
};
|
||||
|
||||
CUtlRBTree<kerned_abc_cache_t, unsigned short> m_ExtendedKernedABCWidthsCache;
|
||||
static bool ExtendedKernedABCWidthsCacheLessFunc(const kerned_abc_cache_t &lhs, const kerned_abc_cache_t &rhs);
|
||||
|
||||
|
||||
int m_rgiBitmapSize[2];
|
||||
unsigned char *m_pBuf; // pointer to buffer for use when generated bitmap versions of a texture
|
||||
|
||||
CTFontRef m_hFont;
|
||||
char *m_pContextMemory;
|
||||
CGContextRef m_ContextRef;
|
||||
};
|
||||
|
||||
#endif // OSXFONT_H
|
||||
165
common/vgui_surfacelib/ps3font.h
Normal file
165
common/vgui_surfacelib/ps3font.h
Normal file
@@ -0,0 +1,165 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: console support for fonts
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef PS3FONT_H
|
||||
#define PS3FONT_H
|
||||
|
||||
#ifdef GetCharABCWidths
|
||||
#undef GetCharABCWidths
|
||||
#endif
|
||||
|
||||
#include "UtlRBTree.h"
|
||||
#include "tier1/UtlSymbol.h"
|
||||
#include "vguifont.h"
|
||||
|
||||
#if defined(_PS3)
|
||||
#if defined(HFONT)
|
||||
#error HFONT defined twice, which breaks the kooky typedef in ps3font.h
|
||||
#else
|
||||
typedef void * HPS3FONT ;
|
||||
#endif
|
||||
#include <cell/fontFT.h>
|
||||
#endif
|
||||
|
||||
struct CPS3FontMetrics : public CellFontHorizontalLayout
|
||||
{
|
||||
float fMaxWidth; // must be initialized externally
|
||||
inline CPS3FontMetrics() : fMaxWidth(NAN) {};
|
||||
};
|
||||
|
||||
// has some inline accessors to translate from PS3 members to XUI ones
|
||||
struct CPS3CharMetrics : public CellFontGlyphMetrics
|
||||
{
|
||||
inline int A() { return 0; }
|
||||
inline int B() { return ceilf( Horizontal.advance ); }
|
||||
inline int C() { return 0; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: encapsulates a windows font
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CPS3Font
|
||||
{
|
||||
public:
|
||||
CPS3Font();
|
||||
~CPS3Font();
|
||||
|
||||
// creates the font from windows. returns false if font does not exist in the OS.
|
||||
virtual bool Create(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// writes the char into the specified 32bpp texture
|
||||
virtual void GetCharsRGBA( newChar_t *newChars, int numNewChars, unsigned char *pRGBA );
|
||||
virtual void GetCharRGBA( wchar_t ch, int rgbaWide, int rgbaTall, unsigned char *pRGBA );
|
||||
|
||||
// returns true if the font is equivalent to that specified
|
||||
virtual bool IsEqualTo(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags);
|
||||
|
||||
// returns true only if this font is valid for use
|
||||
virtual bool IsValid();
|
||||
|
||||
// gets the abc widths for a character
|
||||
virtual void GetCharABCWidths(int ch, int &a, int &b, int &c);
|
||||
virtual void GetKernedCharWidth( wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &abcA, float &abcC );
|
||||
|
||||
// returns the height of the font, in pixels
|
||||
virtual int GetHeight();
|
||||
|
||||
// returns the ascent of the font, in pixels (ascent=units above the base line)
|
||||
virtual int GetAscent();
|
||||
|
||||
// returns the maximum width of a character, in pixels
|
||||
virtual int GetMaxCharWidth();
|
||||
|
||||
// returns the flags used to make this font
|
||||
virtual int GetFlags();
|
||||
|
||||
// returns true if this font is underlined
|
||||
bool GetUnderlined() { return m_bUnderlined; }
|
||||
|
||||
// gets the name of this font
|
||||
const char *GetName() { return m_szName.String(); }
|
||||
|
||||
// dump the system resource, if it's open
|
||||
void CloseResource();
|
||||
|
||||
enum FontStyleFlags_t
|
||||
{
|
||||
kFONT_STYLE_NORMAL = 0,
|
||||
kFONT_STYLE_ITALIC = 2,
|
||||
kFONT_STYLE_UNDERLINE = 4,
|
||||
kFONT_STYLE_BOLD = 8,
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
#if !defined( _GAMECONSOLE )
|
||||
HFONT m_hFont;
|
||||
HDC m_hDC;
|
||||
HBITMAP m_hDIB;
|
||||
#elif defined ( _PS3 )
|
||||
HPS3FONT m_hFont;
|
||||
#elif defined( _X360 )
|
||||
HXUIFONT m_hFont;
|
||||
HDC m_hDC;
|
||||
#endif
|
||||
|
||||
// pointer to buffer for use when generated bitmap versions of a texture
|
||||
unsigned char *m_pBuf;
|
||||
|
||||
protected:
|
||||
CUtlSymbol m_szName;
|
||||
|
||||
short m_iTall;
|
||||
|
||||
int m_iWeight;
|
||||
|
||||
unsigned short m_iFlags;
|
||||
unsigned short m_iScanLines;
|
||||
unsigned short m_iBlur;
|
||||
unsigned short m_rgiBitmapSize[2];
|
||||
|
||||
unsigned int m_iHeight : 8;
|
||||
unsigned int m_iMaxCharWidth : 8;
|
||||
unsigned int m_iAscent : 8;
|
||||
unsigned int m_iDropShadowOffset : 1;
|
||||
unsigned int m_iOutlineSize : 1;
|
||||
unsigned int m_bAntiAliased : 1;
|
||||
unsigned int m_bRotary : 1;
|
||||
unsigned int m_bAdditive : 1;
|
||||
unsigned int m_bUnderlined : 1; //30
|
||||
|
||||
private:
|
||||
// abc widths
|
||||
struct abc_t
|
||||
{
|
||||
short b;
|
||||
char a;
|
||||
char c;
|
||||
};
|
||||
|
||||
// cache for additional or asian characters (since it's too big too just store them all)
|
||||
struct abc_cache_t
|
||||
{
|
||||
wchar_t wch;
|
||||
abc_t abc;
|
||||
};
|
||||
CUtlRBTree<abc_cache_t, unsigned short> m_ExtendedABCWidthsCache;
|
||||
static bool ExtendedABCWidthsCacheLessFunc(const abc_cache_t &lhs, const abc_cache_t &rhs);
|
||||
|
||||
// First range of characters are automatically cached
|
||||
#if defined( _PS3 )
|
||||
enum { ABCWIDTHS_CACHE_SIZE = 256 }; // was 128
|
||||
abc_t m_ABCWidthsCache[ABCWIDTHS_CACHE_SIZE];
|
||||
#elif defined( _X360 )
|
||||
// 360 requires all possible characters during font init
|
||||
enum { ABCWIDTHS_CACHE_SIZE = 256 };
|
||||
abc_t m_ABCWidthsCache[ABCWIDTHS_CACHE_SIZE];
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // PS3FONT_H
|
||||
102
common/vgui_surfacelib/texturedictionary.h
Normal file
102
common/vgui_surfacelib/texturedictionary.h
Normal file
@@ -0,0 +1,102 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Contains all texture state for the material system surface to use
|
||||
//
|
||||
// $Revision: $
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef TEXTUREDICTIONARY_H
|
||||
#define TEXTUREDICTIONARY_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "rendersystem/irenderdevice.h"
|
||||
|
||||
class IMaterial;
|
||||
class IMaterial2;
|
||||
|
||||
enum
|
||||
{
|
||||
INVALID_TEXTURE_ID = -1
|
||||
};
|
||||
|
||||
|
||||
enum ETextureScaling
|
||||
{
|
||||
k_ETextureScalingLinear = 1,
|
||||
k_ETextureScalingPointSample = 2,
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// A class that manages textures used by the material system surface
|
||||
//-----------------------------------------------------------------------------
|
||||
class ITextureDictionary
|
||||
{
|
||||
public:
|
||||
// Create, destroy textures
|
||||
virtual int CreateTexture( bool procedural = false ) = 0;
|
||||
virtual void DestroyTexture( int id ) = 0;
|
||||
virtual void DestroyAllTextures() = 0;
|
||||
|
||||
// Is this a valid id?
|
||||
virtual bool IsValidId( int id ) const = 0;
|
||||
|
||||
// Binds a material to a texture
|
||||
virtual void BindTextureToFile( int id, const char *pFileName ) = 0;
|
||||
|
||||
// Binds a material to a texture
|
||||
virtual void BindTextureToMaterial( int id, IMaterial *pMaterial ) = 0;
|
||||
|
||||
// Binds a material to a texture
|
||||
virtual void BindTextureToMaterialReference( int id, int referenceId, IMaterial *pMaterial ) = 0;
|
||||
|
||||
// Texture info
|
||||
virtual IMaterial *GetTextureMaterial( int id ) = 0; // Source1 version
|
||||
virtual HRenderTexture GetTextureHandle( int textureId ) = 0; // Source2 version
|
||||
virtual void GetTextureSize(int id, int& iWide, int& iTall ) = 0;
|
||||
virtual void GetTextureTexCoords( int id, float &s0, float &t0, float &s1, float &t1 ) = 0;
|
||||
|
||||
virtual void SetTextureRGBA( int id, const char* rgba, int wide, int tall ) = 0;
|
||||
virtual void SetTextureRGBAEx( int id, const char* rgba, int wide, int tall, ImageFormat format, ETextureScaling eScaling ) = 0;
|
||||
|
||||
virtual int FindTextureIdForTextureFile( char const *pFileName ) = 0;
|
||||
virtual void SetSubTextureRGBA( int id, int drawX, int drawY, unsigned const char *rgba, int subTextureWide, int subTextureTall ) = 0;
|
||||
virtual void SetSubTextureRGBAEx( int id, int drawX, int drawY, unsigned const char *rgba, int subTextureWide, int subTextureTall, ImageFormat format ) = 0;
|
||||
|
||||
virtual void UpdateSubTextureRGBA( int id, int drawX, int drawY, unsigned const char *rgba, int subTextureWide, int subTextureTall, ImageFormat imageFormat ) = 0;
|
||||
|
||||
virtual void BindTextureToMaterial2Reference( int id, int referenceId, IMaterial2 *pMaterial ) = 0;
|
||||
virtual void BindTextureToMaterial2( int id, IMaterial2 *pMaterial ) = 0;
|
||||
virtual IMaterial2 *GetTextureMaterial2( int id ) = 0; // Source2 version
|
||||
|
||||
#if defined( _X360 )
|
||||
|
||||
//
|
||||
// Local gamerpic
|
||||
//
|
||||
|
||||
// Get the texture id for the local gamerpic.
|
||||
virtual int GetLocalGamerpicTextureID( void ) const = 0;
|
||||
|
||||
// Update the local gamerpic texture. Use the given texture if a gamerpic cannot be loaded.
|
||||
virtual bool SetLocalGamerpicTexture( DWORD userIndex, const char *pDefaultGamerpicFileName ) = 0;
|
||||
|
||||
//
|
||||
// Remote gamerpic
|
||||
//
|
||||
|
||||
// Get the texture id for a remote gamerpic with the given xuid.
|
||||
virtual int GetRemoteGamerpicTextureID( XUID xuid ) = 0;
|
||||
|
||||
// Update the remote gamerpic texture for the given xuid. Use the given texture if a gamerpic cannot be loaded.
|
||||
virtual bool SetRemoteGamerpicTextureID( XUID xuid, const char *pDefaultGamerpicFileName ) = 0;
|
||||
|
||||
#endif // _X360
|
||||
};
|
||||
|
||||
ITextureDictionary *TextureDictionary();
|
||||
|
||||
#endif // TEXTUREDICTIONARY_H
|
||||
40
common/vgui_surfacelib/vguifont.h
Normal file
40
common/vgui_surfacelib/vguifont.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef VGUIFONT_H
|
||||
#define VGUIFONT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
// Structure passed to CWin32Font::GetCharsRGBA
|
||||
struct newChar_t
|
||||
{
|
||||
wchar_t wch; // A new character to generate texture data for
|
||||
int fontWide; // Texel width of the character
|
||||
int fontTall; // Texel height of the character
|
||||
int offset; // Offset into the buffer given to GetCharsRGBA
|
||||
};
|
||||
|
||||
#if defined( WIN32 )
|
||||
#include "Win32Font.h"
|
||||
typedef CWin32Font font_t;
|
||||
#elif defined(_PS3)
|
||||
#include "ps3font.h"
|
||||
typedef CPS3Font font_t;
|
||||
#elif defined(OSX)
|
||||
#include "osxfont.h"
|
||||
typedef COSXFont font_t;
|
||||
#elif defined(LINUX)
|
||||
#include "linuxfont.h"
|
||||
typedef CLinuxFont font_t;
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
|
||||
#endif //VGUIFONT_H
|
||||
Reference in New Issue
Block a user