0

I'm usually using TGLCanvas on GLDirectOpenGL1Render to draw lines like this:

uses
  GLCanvas,
  GLRenderContextInfo
{...}

procedure TForm1.GLDirectOpenGL1Render(Sender: TObject;
  var rci: TRenderContextInfo);
var
   glc: TGLCanvas;
begin
  glc:=TGLCanvas.Create(GLSceneViewerL.Width, GLSceneViewerL.Height);
  with glc do
  begin
    //Drawing lines here
    Line(0, 0, 10, 20);
    Line(10, 20, 30, 30);
    {...}
  end;
  glc.Free;
end;

But in current project I have more than one GLSceneViewer with different cameras and I need to draw lines only on one GLSceneViewer but not on all other scene viewers. OpenGl draw for fast speed is preffered. Any ideas?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Kainax
  • 1,431
  • 19
  • 29
  • I'm not very familiar with GLScene, but does a scene viewer render a scene? In which case, all scene viewers connected to the one scene render the same thing (although from different angles etc)? In which case, having something in one viewer but not the other, requires having different scenes? – David Jun 04 '15 at 10:05
  • @DavidM - No, actually in GLScene you connect viewer to a corresponding camera (just like in all other render systems that I know), so you can have one scene with many cameras/viewers from different angles. – Kainax Jun 06 '15 at 10:54
  • That's what I mean (ignoring the intermediate camera, which is how the viewer is connected (?)) The point is, if you have a single scene, all viewers view *the same content*. So, to change what's onscreen for one viewer, you need that viewer to be looking at a different scene, one set up to be similar but not identical, the difference being the different stuff you want to show in that one viewer...? – David Jun 08 '15 at 16:21
  • @DavidM You probably misunderstood question. I need to draw 2d line over final image canvas, not a 3d line inside 3D scene that will be visible on one viewer but not on another. For that purpose we don't need to render two different scenes. I already posted how to do it. – Kainax Jul 17 '15 at 11:40
  • Can I ask the reason for downvote? – Kainax Jul 17 '15 at 11:40
  • I don't know of a way to see who downvoted questions, in order to tag them to ask. You probably need to be a mod. (It's a bit of a problem with the Delphi tag - lots of random downvoting sometimes.) – David Jul 17 '15 at 17:17

1 Answers1

1

Ok, after playing around with GLSceneViewer I figured out how to do it: instead of drawing lines on onRender event of GLDirectOpenGL1, you should draw lines on PostRender event of a necessary GLSceneViewer, so code should look like that:

procedure TForm1.GLSceneViewerL(Sender: TObject);
var
   glc : TGLCanvas;
begin
    glc:=TGLCanvas.Create(GLSceneViewerL.Width, GLSceneViewerL.Height);
    with glc do
    begin
      //Drawing lines here
      Line(0, 0, 10, 20);
      Line(10, 20, 30, 30);
      {...}
    end;
    glc.Free;
end;

That's it, lines will be drawn exclusively on viewer with a "GLSceneViewerL" name, but not for all viewers of the scene.

Kainax
  • 1,431
  • 19
  • 29