PDA

View Full Version : GLYPHMETRICSFLOAT in DELPHI?



spokojnie
01-29-2002, 05:45 AM
How can I use 'gmfCellIncX' in delphi? I need to get the center of the text
I am displaying.
I found the C++ code but I can't translate it in to Delphi.

GLYPHMETRICSFLOAT gmf[256]; this is in C++ but how to do it in DELPHI???????

I tried to do it in delphi as gmf: array[0...255] of GLYPHMETRICSFLOAT; but
I get an error during compilation :

Incompatible types: 'Array' and 'PGlyphMetricsFloat';

wglUseFontOutlines( h_DC, 0, 255,
base,
0.0, 0.2,
WGL_FONT_POLYGONS,
gmf); <--Incompatible types: 'Array' and 'PGlyphM
etricsFloat';

Please Help me!!!

Thank you for your time

Eric
01-29-2002, 06:21 AM
I don't know Delphi but it looks like this language does not think that an Array (i.e. gmf of type GLYPHMETRICSFLOAT) is the same than a pointer to a variable of the same type. Can you typecast your "gmf" variable to a pointer to GLYPHMETRICSFLOAT ? Or can you create a pointer to such an array using something like the "new" operator of C++ ?

Sure, some Delphi experts will help you on that !

Regards.

Eric

Tom Nuydens
01-29-2002, 06:31 AM
wglUseFontOutlines( h_DC, 0, 255, base, 0.0, 0.2, WGL_FONT_POLYGONS, @gmf[0]);

-- Tom

Eric
01-29-2002, 06:56 AM
I knew Tom would be the man !

Regards.

Eric

spokojnie
01-29-2002, 12:29 PM
Thank you for your help!
It works but i came up with another problem:

The problem is that when I am using "wglUseFontOutlines" I can't get the lines centered ( the first one is O.K. right in the middle but ones bellow are moved to the right ) - I read that
"wglUseFontOutlines" isn't precise and that is way I can't get it working.

I made the following function:
procedure glPrint(text : PChar);
var y:integer;
begin
howlong:=0;
if (text = '') then
Exit;

for y:=0 to (length(text)) do
begin
howlong:=howlong+agmf[y].gmfCellIncX;
end;
glPushAttrib(GL_LIST_BIT);
glListBase(base);
glTranslatef(-howlong/2,0.7,0.0);
glCallLists(length(text), GL_UNSIGNED_BYTE, text);
glTranslatef(-howlong,-0.7,0.0);
glCallLists(length(text), GL_UNSIGNED_BYTE, text);
glPopAttrib();
end;

Is there anything wrong with it?
Shouldn't the two lines be exactly one under the other?

Thanx once more for any help
Regards,
Eryk


[This message has been edited by spokojnie (edited 01-29-2002).]

V-man
01-30-2002, 10:42 PM
That's cause the raster position moves. Its just like calling glBitmap, so make sure you call glRasterPos.... before rendering the text.

V-man