Einzelnen Beitrag anzeigen

.chicken

Registriert seit: 5. Dez 2006
459 Beiträge
 
#3

Re: [DirectX] D3DXCreateFont - Performancefrage

  Alt 28. Mai 2008, 20:57
Jaja, das weiss ich, habe mich wohl nicht genau genug ausgedrueckt

Also ich meine, dass ich für jeden Text mit anderer Formation einen neuen Font erstellen muss ist blöd.
Naja wenns der Performance entscheidend gut tut, dann mach ichs so.

Noch ne Frage:
Habe mir ne eigene FontKlasse geschrieben:
Delphi-Quellcode:
procedure T2DXFont.Load(_Height, _Width: Integer; _Family: String);
var
  _FontType: tagLOGFONT;
  i: Integer;
begin
  _FontType.lfHeight := _Height;
  _FontType.lfWidth := _Width;
  _FontType.lfQuality := PROOF_QUALITY;
  _FontType.lfCharSet := DEFAULT_CHARSET;
  StrPCopy(_FontType.lfFaceName, _Family);
  D3DXCreateFontIndirect(Parent.Device, _FontType, Font);
end;
So lade ich den Font.
Jetzt will ich ihn im Timer Zeichnen.

Delphi-Quellcode:
procedure TForm1.OnTimer(_TimeKey: Single);
begin
  Ship.Animate(_TimeKey);
  Background.TextureOffset := Get2DXVector2(Background.TextureOffset.X, Background.TextureOffset.Y - _TimeKey / 100 * Ship.Speed);
  Surface.Initialize;
    Surface.SetUpView;
    Surface.Clear(Get2DXColor(0, 0, 0, 0));
    Engine.RenderAll;
    aFont.Load(30, 10, 'Arial Black');
    aFont.Draw(IntToStr(Timer.FPS) + ' FPS', Rect(10, 0, Surface.Width, Surface.Height), [FF_LEFT, FF_TOP], Get2DXColor(150, 150, 150, 100));
  Surface.Present;
end;
So geht das, aber da wird der Font halt jedes mal neu geladen. Wenn ich im FormCreate direkt hinter den Font-Konstruktor die Load-Methode aufrufe, dann wird der Text nicht angezeigt. Weiss wer woran das liegt? Das Draw rufe ich trotzdem im Timer auf.

Grüße
  Mit Zitat antworten Zitat