1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85:
| type THUD = class private fFontContextID: TFontContextID; fViewport: TGLVectori4; fPointFont, fLiveFont: TFont; public procedure Render(Points, Live: Integer); constructor Create(FontContextID: TFontContextID); destructor Destroy; override; end;
implementation
procedure THUD.Render(Points, Live: Integer);
function FillString(Str: String; FillChar: Char; StrLength: Integer): String; var i: Integer; begin result := Str; for i := Length(result) to StrLength do result := FillChar + result; end;
begin glMatrixMode(GL_PROJECTION); glPushMatrix; glLoadIdentity; glOrtho(0,fViewport[2],fViewport[3],0,0,10); glMatrixMode(GL_MODELVIEW); glDisable(GL_DEPTH_TEST);
fPointFont.TextOut('Points: '+FillString(IntToStr(Points),'0',10), fViewport[2]* 1/100, fViewport[3]* 1/100, fViewport[2]*48/100, fViewport[3]*10/100, TS_ALIGN_LEFT);
fLiveFont.TextOut('Live: '+FillString(IntToStr(Live),'0',2), fViewport[2]*50/100, fViewport[3]* 1/100, fViewport[2]*49/100, fViewport[3]*10/100, TS_ALIGN_RIGHT);
glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPopMatrix; glMatrixMode(GL_MODELVIEW); end;
constructor THUD.Create(FontContextID: TFontContextID); var Color: TVector4f; begin inherited Create;
glGetIntegerv(GL_VIEWPORT, @fViewport);
fFontContextID := FontContextID;
Color[0] := 1; Color[1] := 1; Color[2] := 1; Color[3] := 1;
fPointFont := TFont.Create(fFontContextID, TS_STYLE_NORMAL, round(fViewport[3]*5/100), ExtractFilePath(Application.ExeName)+'LCD_FONT.ttf', Color);
fLiveFont := TFont.Create(fFontContextID, TS_STYLE_NORMAL, round(fViewport[3]*5/100), ExtractFilePath(Application.ExeName)+'LCD_FONT.ttf', Color); end;
destructor THUD.Destroy; begin fPointFont.Destroy; fLivefont.Destroy; inherited Destroy; end; |