summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 903f156)
raw | patch | inline | side by side (parent: 903f156)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 28 Dec 2022 13:42:06 +0000 (16:42 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 9 Jun 2023 09:07:15 +0000 (12:07 +0300) |
src/game/renders/opengl/r_common.pas | patch | blob | history | |
src/game/renders/opengl/r_textures.pas | patch | blob | history |
index 9c6b8b420ff0052207db872a45f3dae8b494dbbb..174769b68f578edcece9a7b3f17964a8328df372 100644 (file)
function r_Common_LoadTextureMultiFromFileAndInfo (const filename: AnsiString; w, h, count: Integer; log: Boolean = True): TGLMultiTexture;
function r_Common_LoadTextureMultiTextFromFile (const filename: AnsiString; var txt: TAnimTextInfo; log: Boolean = True): TGLMultiTexture;
function r_Common_LoadTextureStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; log: Boolean = True): Boolean;
- function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; skipch: Integer; log: Boolean = true): TGLFont;
+ function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
procedure r_Common_Load;
procedure r_Common_Free;
r_Common_DrawBackgroundImage(BackgroundTexture.id)
end;
+ function r_Common_Std2Win (i: Integer): Integer;
+ begin
+ case i of
+ 0..223: result := i + 32;
+ 224..255: result := i - 224;
+ otherwise result := -1;
+ end
+ end;
+
function r_Common_LoadFont (const name: AnsiString): TGLFont;
- var info: TFontInfo; skiphack: Integer;
+ var info: TFontInfo; p: TConvProc;
begin
result := nil;
- if name = 'STD' then skiphack := 144 else skiphack := 0;
+ if name = 'STD' then p := @r_Common_Std2Win else p := nil;
if r_Font_LoadInfoFromFile(GameWad + ':FONTS/' + name + 'TXT', info) then
- result := r_Common_LoadTextureFontFromFile(GameWad + ':FONTS/' + name + 'FONT', info, skiphack, true);
+ result := r_Common_LoadTextureFontFromFile(GameWad + ':FONTS/' + name + 'FONT', info, p, true);
if result = nil then
e_logwritefln('failed to load font %s', [name]);
end;
r_Common_StepLoading(1);
end;
- function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; skipch: Integer; log: Boolean = true): TGLFont;
+ function r_Common_LoadTextureFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
begin
- result := r_Textures_LoadFontFromFile (filename, f, skipch, log);
+ result := r_Textures_LoadFontFromFile (filename, f, font2enc, log);
r_Common_StepLoading(1);
end;
index 0114880088cc352459cfd7911021c99978f2d85f..aa3bbff038c02bb6c37246f754bf3deb1ee94891 100644 (file)
anim: TAnimInfo;
end;
+ TConvProc = function (x: Integer): Integer;
+
procedure r_Textures_Initialize;
procedure r_Textures_Finalize;
function r_Textures_LoadStreamFromFile (const filename: AnsiString; w, h, count, cw: Integer; st: TGLTextureArray; rs: TRectArray; log: Boolean = True): Boolean;
- function r_Textures_LoadFontFromFile (const filename: AnsiString; constref f: TFontInfo; skipch: Integer; log: Boolean = true): TGLFont;
+ function r_Textures_LoadFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
implementation
(* --------- TGLFont --------- *)
- function r_Textures_LoadFontFromFile (const filename: AnsiString; constref f: TFontInfo; skipch: Integer; log: Boolean = true): TGLFont;
- var i: Integer; st: TGLTextureArray; font: TGLFont; t: TGLTexture;
+ function r_Textures_LoadFontFromFile (const filename: AnsiString; constref f: TFontInfo; font2enc: TConvProc; log: Boolean = true): TGLFont;
+ var i, ch: Integer; st, stch: TGLTextureArray; font: TGLFont;
begin
- ASSERT(skipch >= 0);
result := nil;
SetLength(st, 256);
if r_Textures_LoadStreamFromFile(filename, f.w, f.h, 256, 16, st, nil, log) then
begin
- if skipch > 0 then
+ font := TGLFont.Create();
+ font.info := f;
+ font.ch := st;
+ if Assigned(font2enc) then
begin
+ SetLength(stch, 256);
for i := 0 to 255 do
begin
- t := st[i];
- st[i] := st[(i + skipch) mod 256];
- st[(i + skipch) mod 256] := t;
+ ch := font2enc(i);
+ ASSERT((ch >= 0) and (ch <= 255));
+ stch[ch] := st[i];
end;
+ font.ch := stch;
+ SetLength(st, 0);
end;
- font := TGLFont.Create();
- font.info := f;
- font.ch := st;
result := font;
end;
end;