![]() |
OpenGL (Tip) Mehrere Fontlisten erstellen
Habe wie blöd im Net gesucht nach einer möglichkeit unter >= D2009 mehrere Fontlisten zu erstellen.
Überall habe ich nur BuildFont gefunden deshalb habe ich mal meine eigene procedure erstellt. Wenn ihr verbesserungsvorschläge habt nur her damit. Das erste problem in bezug auf Unicode PWideChar ist das diese Variable eine länge von 2 Bytes hat. Dazu eine erklärung von Sascha.. Zitat:
Hier mal die procedure zum erstellen der FontListen.
Delphi-Quellcode:
Zwei Fontlisten erstellen..
procedure TFormMain.GenerateFontLists(Face: PWideChar; bold, italic: Bool;
listsID: PGLuint; deviation: single; var gmf: GLYPHMETRICSFLOAT); var CustomFont, oldfont: HFONT; mBold: Integer; begin if bold then mBold := FW_EXTRABOLD else mBold := FW_THIN; CustomFont := CreateFont(round(-0.04 * Width), 0,0, 0, mBold, cardinal(italic), 0, 0, ANSI_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE, face); oldfont := SelectObject(h_DC, CustomFont); if Assigned(listsID) then glDeleteLists(listsID^, 256); listsID^ := glGenLists(256); wglUseFontOutlines(h_DC, 0, 255, listsID^, deviation, (Settings.fontDepth / 100), WGL_FONT_POLYGONS, @gmf); SelectObject(h_DC, oldfont); DeleteObject(CustomFont); end;
Delphi-Quellcode:
Declaration..
GenerateFontLists(PWideChar(Settings.lyricsFont.Name),
fsBold in Settings.lyricsFont.Style, fsItalic in Settings.lyricsFont.Style, @ListsLyricsFont, 0.6, gmfLyrics[0]); GenerateFontLists(PWideChar(Settings.infoFont.Name), fsBold in Settings.infoFont.Style, fsItalic in Settings.infoFont.Style, @ListsInfoFont, 0.0, gmfInfo[0]);
Delphi-Quellcode:
Text rendern..
gmfLyrics: array [0..256] of GLYPHMETRICSFLOAT;
gmfInfo: array [0..256] of GLYPHMETRICSFLOAT;
Delphi-Quellcode:
Wie schon angedeutet muss hier der Text als Ansistring übergeben werden.
procedure TFormMain.createTimeList;
var bufferWord: AnsiString; begin // Time display list if (ListTime > 0) then glDeleteLists(ListTime, 1); ListTime := glGenLists(1); glNewList(ListTime, GL_COMPILE); bufferword := AnsiString(GetSongPosStr(currentTime, timeMinSec) + ' \ ' + durationString); glTranslatef(-0.16, -0.97, 0); glScalef(0.04, 0.04, 0.04); glEnable(GL_MULTISAMPLE_ARB); glListBase(ListsInfoFont); glColor3f(Settings.bottombarTextColor.r, Settings.bottombarTextColor.g, Settings.bottombarTextColor.b); glCallLists(Length(bufferWord), GL_UNSIGNED_BYTE, PAnsiString(bufferWord)); glDisable(GL_MULTISAMPLE_ARB); glEndList(); end; Um Datenverluste zu vermeiden den String nach AnsiString konvertieren. Das ist nur ein Beispiel zur veranschaulichung) Vielleicht hilft das ja den ein oder anderen ... gruss |
AW: OpenGL (Tip) Mehrere Fontlisten erstellen
Habe noch zwei schwerwiegende probleme festgestellt..
Delphi-Quellcode:
procedure TFormMain.GenerateFontLists(Face: PWideChar; bold, italic: Bool;
out listsID: GLuint; deviation: single; var gmf: GLYPHMETRICSFLOAT); var CustomFont, oldfont: HFONT; mBold: Integer; begin if bold then mBold := FW_EXTRABOLD else mBold := FW_THIN; CustomFont := CreateFont(round(-0.04 * Width), 0,0, 0, mBold, cardinal(italic), 0, 0, ANSI_CHARSET, OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE, face); oldfont := SelectObject(h_DC, CustomFont); if listsID > 0 then glDeleteLists(listsID, 256); listsID := glGenLists(256); wglUseFontOutlines(h_DC, 0, 255, listsID, deviation, (Settings.fontDepth / 100), WGL_FONT_POLYGONS, @gmf); SelectObject(h_DC, oldfont); DeleteObject(CustomFont); end;
Delphi-Quellcode:
Zum einen den Pointer für die listsID entfernt und "out" vorangestellt.
GenerateFontLists(PWideChar(Settings.lyricsFont.Name),
fsBold in Settings.lyricsFont.Style, fsItalic in Settings.lyricsFont.Style, ListsLyricsFont, 0.6, gmfLyrics[0]); Hatte nicht berücksichtigt das der Font zwar richtig eingetragen aber die ID an ListsLyricsFont nicht zurückgegeben wurde. Das hatte zur folge das beim nächsten Fontwechsel (erstellen einer neuen Liste) die alte nicht gelöscht wurde. gruss |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:08 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz