Menu

Number with comma in TGLHUDtext

Help
Sergio
2015-01-24
2015-01-28
  • Sergio

    Sergio - 2015-01-24

    I am trying to write a number like -2,00 (minus two) using HUDtext but the comma and the minus signal do not appear
    I use the line GLHudText1.Text:= FloatToStrF(res3DminForm3D, fffixed, 8, 1);
    The text appear as 200 instead of -2,00
    Can you help me ?

     
  • Pavel Vassiliev

    Pavel Vassiliev - 2015-01-25

    Sergio,
    Your drawback is not confirmed. See e.g. Bmpfont demos in Interface section.
    Set in procedure TForm1.TTimer1Timer(Sender: TObject);
    HUDTextFPS.Text := FloatToStr(-2.01);
    or
    HUDTextFPS.Text := FloatToStrF(-2.01, ffFixed, 8,1);
    instead of
    HUDTextFPS.Text := Format...
    and you will get -2.01 on screen but not 201 (or 200 as you say.
    Hope you are using current SVN version.


    PW

     
  • Sergio

    Sergio - 2015-01-25

    Please see above that I am not using format
    I am using
    GLHudText1.Text:= FloatToStrF(res3DminForm3D, fffixed, 8, 1);
    and the value of the real res3DminForm3D is -2 so I am using exactly wjat you indicated
    That´s why I do not understand that the -2,0 do not appear and instead I have 20 (like twnty or 2,0 without the comma)
    Just to cjeck I runned the line Text:= FloatToStrF(-2.01, fffixed, 8, 1);
    and it comes in the screen as 20
    Do you know some other diferrent way odf writing this ?
    Do you know some demo in GLscene where a number with a decimal appear in the screen as a result . In all of the ones I see what is written is an integer and not a number with a decimal point

     
  • Pavel Vassiliev

    Pavel Vassiliev - 2015-01-26

    Hm, it seems as you have some special localazation page in your OS. For Win 8.1 there is no such problem even for russian localization with comma delimeters between integer and fractional parts of numbers instead of dots. Try to add a line
    System.SysUtils.FormatSettings.DecimalSeparator := ',';
    before you invoke FloatToStrF or set a value to your res3DminForm3D.
    PW

     
  • Sergio

    Sergio - 2015-01-27

    Thank you. I tried but not worked. Actually I have already in the program a line
    if DecimalSeparatorAtual<> ',' then DecimalSeparator := ',' ;
    The value of res3DminForm3D is well defined when it is used
    The strange thing is that if res3DminForm3D=-2 in the screen it appears 2
    if res3DminForm3D=104,4 it appears 1044 (see attachment png)
    The comma and the minus signal disappear and are not written (see that there are no "invisible" spaces)
    I am trying to find any GLscene example where it appears a number with a comma or a negative signal and I never found one. Always I find integers
    Any suggestion

     
  • nelsonchu

    nelsonchu - 2015-01-28

    See the Winfont demo. You need to specific a character set for the Windows Bitmap font that HUDText uses so that the proper font texture is generated. In that sample, there is a line WindowsBitmapFont1.EnsureString(HUDText1.Text);
    which would ensure whatever character appearing in HUDText1.Text gets included in the Bitmap font texture.
    I just checked and it can output "-2.01".

     
  • Sergio

    Sergio - 2015-01-28

    Thank you very much for your help. It worked
    see attachment
    If other coleagues need this here is the code
    with HSPalette do
    begin
    Material.MaterialLibrary := GLMaterialLibrary1 ;
    Material.LibMaterialName := 'Palette' ;
    Width:=Trunc(0.90pnlViewRight.height);
    Position.X:=height ;
    Position.y:=Trunc(0.50
    pnlViewRight.height);
    Rotation:=90;
    end ;

    with HTPaletteMin do
    begin
    BitmapFont := WindowsBitmapFont1 ;
    Text:= FloatToStrF(res3DminForm3D,fffixed, 8, 1);
    WindowsBitmapFont1.EnsureString(text);
    Rotation:= 0;
    Position.X:= HSPalette.Position.X-10 ;
    Position.Y:= HSPalette.Position.Y + 0.50*pnlViewRight.height-20 ;
    end;

    with HTPaletteMax do
    begin
    BitmapFont := WindowsBitmapFont1 ;
    Text:= FloatToStrF(res3DmaxForm3D, fffixed, 8, 1);
    WindowsBitmapFont1.EnsureString(text);
    Rotation:= 0;
    Position.X:= HSPalette.Position.X-10 ;
    Position.Y:= HSPalette.Position.Y - 0.50*pnlViewRight.height ;
    end;

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.