Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Sa Jul 19, 2025 20:50

Foren-Übersicht » Programmierung » OpenGL
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Autor Nachricht
 Betreff des Beitrags: createfont ändert fontgröße nicht
BeitragVerfasst: Sa Sep 03, 2005 05:02 
Offline
DGL Member
Benutzeravatar

Registriert: Do Jun 09, 2005 13:48
Beiträge: 117
Wohnort: Sankt Augustin
Hallo,

ich habe mir eine komponente (siehe code) glFont geschrieben, die mir einen 3D-font erzeugt und
an einer beliebigen stelle anzeigen kann. leider wird dieser font immer in der gleichen größe ausgegeben.
ob ich den font einmal, zweimal, dreimal oder wie oft auch immer mit jeweils unterschiedlichen
parametern für fontsize erzeuge, scheint dem font nichts auszumachen. er bleibt stur auf einer
größe.

kann mir da jemand helfen?

Code:
  1.  
  2. unit glFont;
  3.  
  4. interface
  5.  
  6. uses
  7.   Windows,
  8.   Graphics,
  9.   SysUtils,
  10.   Classes,
  11.   Controls,
  12.   Dialogs,
  13.   Forms,
  14.   Camera,
  15.   OpenGLUtil,
  16.   DglOpenGL;
  17.  
  18. type
  19.   TPglFont=^TglFont;
  20.   TglFont=class(TComponent)
  21.   private
  22.     FFont: HFONT;                                    // Windows Font ID
  23.     FFontList: TGLUint;
  24.     FFontSize: integer;
  25.     FFontThickness: integer;
  26.     FFontWidth: integer;
  27.     FFontItalic: integer;
  28.     FFontUnderline: integer;
  29.     FFontStrikeout: integer;
  30.     FFontBold: integer;
  31.     FFontgmf : array [0..255] of GLYPHMETRICSFLOAT;  // Address Buffer For Font Storage
  32.     FEnabled: boolean;
  33.   public
  34.     constructor Create(AOwner:TComponent); override;
  35.     destructor Destroy; override;
  36.     procedure Print(text: pChar;
  37.                     Pos, Dir: TGKvector;
  38.                     PCamera: TPCamera);
  39.     procedure BuildFont (FontName: string; glFontDC: HDC);
  40.     procedure KillFont;
  41.   published
  42.     property Enabled: boolean read FEnabled write FEnabled;
  43.     property FontSize: integer read FFontSize write FFontSize;
  44.     property FontThickness: integer read FFontThickness write FFontThickness;
  45.     property FontWidth: integer read FFontWidth write FFontWidth;
  46.     property FontItalic: integer read FFontItalic write FFontItalic;
  47.     property FontUnderline: integer read FFontUnderline write FFontUnderline;
  48.     property FontStrikeout: integer read FFontStrikeout write FFontStrikeout;
  49.     property FontBold: integer read FFontBold write FFontBold;
  50.   end; {TOpenGL}
  51.  
  52. procedure Register;
  53.  
  54. var
  55.   OldFont: string;
  56.  
  57. implementation
  58.  
  59. constructor TglFont.Create(AOwner:TComponent);
  60. begin
  61.   inherited Create(AOwner);
  62.   FFont := 0;
  63.   FFontSize := 32;
  64.   FFontWidth := 10;
  65.   FFontThickness := 1;
  66.   FFontItalic := 0;
  67.   FFontUnderline := 0;
  68.   FFontStrikeout := 0;
  69.   FFontBold := 0;
  70. end;
  71.  
  72. destructor TglFont.Destroy;
  73. begin
  74.   inherited destroy;
  75. end;
  76.  
  77. procedure TglFont.BuildFont (FontName: string; glFontDC: HDC); // Build Our Bitmap Font
  78. begin
  79.   if not FEnabled then
  80.     exit;
  81.   if FFont <> 0 then
  82.     KillFont;
  83.  
  84.   FFontList := glGenLists(256);             // Storage For 256 Characters
  85.   glEnable(GL_POINT_SMOOTH);
  86.  
  87.   FFont := CreateFont(FFontSize,            // Height Of Font
  88.                       FFontWidth,           // Width Of Font
  89.                       0,                    // Angle Of Escapement
  90.                       0,                    // Orientation Angle
  91.                       FFontBold,            // Font Weight
  92.                       FFontItalic,          // Italic
  93.                       FFontUnderline,       // Underline
  94.                       FFontStrikeout,       // Strikeout
  95.                       ANSI_CHARSET,         // Character Set Identifier
  96.                       OUT_TT_PRECIS,        // Output Precision
  97.                       CLIP_DEFAULT_PRECIS,  // Clipping Precision
  98.                       ANTIALIASED_QUALITY,  // Output Quality
  99.                       FF_DONTCARE or DEFAULT_PITCH, // Family And Pitch
  100.                       PCHAR(FontName));     // Font Name
  101.  
  102.   SelectObject(glFontDC, FFont);            // Selects The Font We Want
  103.  
  104.   wglUseFontOutlines(glFontDC,              // Select The wanted DC
  105.                      0,                     // Starting Character
  106.                      256,                   // Number Of Display Lists To Build
  107.                      FFontList,             // Starting Display Lists
  108.                      0.0,                   // Deviation From The True Outlines
  109.                      FFontThickness/10,     // Font Thickness In The Z Direction
  110.                      WGL_FONT_POLYGONS,     // Use Polygons, Not Lines
  111.                      @FFontgmf);            // Address Of Buffer To Recieve Data
  112. end;
  113.  
  114. procedure TglFont.KillFont;
  115. begin
  116.   if not FEnabled then
  117.     exit;
  118.   if not glIsList (FFontList) then
  119.     exit;
  120.   glDeleteLists(FFontList, 256);                   // Lösche alle 256 Zeichen
  121.   DeleteObject (FFont);
  122.   FFont := 0;
  123. end;
  124.  
  125. procedure TglFont.Print(text: pChar;
  126.                         Pos, Dir: TGKvector;
  127.                         PCamera: TPCamera);
  128. var
  129.   laenge: glfloat;
  130.   loop: integer;
  131.   V2: TGLvector;
  132.   Rotation: TRotation;
  133.   normale: TGLVector;
  134. begin
  135.   if not FEnabled then
  136.     exit;
  137.   if text = '' then
  138.     exit;
  139.   if not glIsList (FFontList) then
  140.     exit;
  141.  
  142.   V2 := GK2GLvector (Pos);
  143.   GetRotation (V2, GK2GLvector (Dir), Rotation, normale);
  144.  
  145.   // länge des texts ermitteln (für was auch immer...)
  146.   laenge := 0;
  147.   for loop:=1 to length(text)-1 do
  148.     laenge := laenge + FFontgmf[loop].gmfCellIncX;
  149.  
  150.   //glPushAttrib(GL_LIST_BIT);
  151.   glPushAttrib (GL_ALL_ATTRIB_BITS);
  152.   PCamera^.Apply;
  153.   glListBase(FFontList);
  154.   glTranslatef(V2.x, V2.y, V2.z);
  155.   if Rotation.Angle <> 0.0 then
  156.     glRotated(Rotation.Angle,
  157.               Rotation.X,
  158.               Rotation.Y,   // um errechneten Winkel auf der
  159.               Rotation.Z);  // errechneten Achse drehen
  160.   glCallLists(length(text),GL_UNSIGNED_BYTE,text);
  161.   glPopAttrib;
  162. end;
  163.  
  164. procedure Register;
  165. begin
  166.   RegisterComponents('OpenGL',[TglFont]);
  167. end;
  168.  
  169. end.
  170.  


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Foren-Übersicht » Programmierung » OpenGL


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 27 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.010s | 14 Queries | GZIP : On ]