Menu

Draw on canvas/texture

Help
Daniel
2019-10-22
2019-10-25
  • Daniel

    Daniel - 2019-10-22

    Hello everyone!

    I need to draw lines and text in runtime, it can either be on a Hudsprite or directly on the SceneViewer.
    How would I do that, and which way is faster?

    Kind regards and thanks in advance,
    Daniel

     
  • shine world

    shine world - 2019-10-24

    I write HUD Text using this code:

        // private data declaration
        FUserMessageHud: TGLHudText;
        FUserMessageHudBitmapFont: TGLWindowsBitmapFont;
    ...
    ..
    ...
      // form class constructor
    
      // creates and sets user message objects
      FUserMessageHudBitmapFont := TGLWindowsBitmapFont.Create(Self);
      FUserMessageHudBitmapFont.Font.Color := clYellow;
      FUserMessageHudBitmapFont.Font.Name := 'Tahoma';
      FUserMessageHudBitmapFont.Font.Size := 22;
    
      FUserMessageHud := TGLHudText.Create(GLSceneViewer);
      FUserMessageHud.BitmapFont := FUserMessageHudBitmapFont;
      FUserMessageHud.Text := '';
      FUserMessageHud.Visible := False;
      GLScene.Objects.AddChild(FUserMessageHud);
    ...
    ..
    ...
        // draws text in scene
        GLScene.BeginUpdate;
        try
          FUserMessageHud.Text := Value;
          FUserMessageHud.Position.X := 10;
          FUserMessageHud.Position.Y := 10;
          FUserMessageHud.Visible := True;
        finally
          GLScene.EndUpdate;
        end;
    
     
  • Daniel

    Daniel - 2019-10-24

    Thanks! I will try this!

    But still I need to be able to draw lines on a 2d canvas.
    Is there a fast way to draw on a HUDSprite for example?
    Do I have to draw on a bitmap and assign it to the HUDSprite every frame?

     
  • Jerome.D (BeanzMaster)

    Hi Daniel, for drawing on canvas you can use TGLCanvas and a TGLDirectRender, see sample in Bench/Canvas

    Cheers

     
  • Daniel

    Daniel - 2019-10-25

    Cool! That seems to be what I need. I will try it out.
    Thanks again!!

     

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.