Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi GLScene - GLCanvas und TextOut (https://www.delphipraxis.net/55148-glscene-glcanvas-und-textout.html)

Slavik 17. Okt 2005 13:02


GLScene - GLCanvas und TextOut
 
Hallo,

ich habe ein etwas blödes Problem. Ich will über GLCanvas von GLScene ein paar Linien zeichnen und ein bisschen Schrift ausgeben. Mein Code ist bis jetzt:

Delphi-Quellcode:
procedure TCMP_PLAYLIST.GLDirectOpenGL1Render(Sender: TObject; var rci: TRenderContextInfo);
var
  OGLCanvas: TGLCanvas;
  x,y,i: integer;
begin

  x:=GLSceneViewer1.Width;
  y:=GLSceneViewer1.Height;
  OGLCanvas:=TGLCanvas.Create(x,y);
  OGLCanvas.PenColor:=clBlack;
  OGLCanvas.PenAlpha:=1;
  OGLCanvas.PenWidth:=1;

  for i:=0 to 10 do
  begin
    GLWindowsBitmapFont1.TextOut(rci,random(100),random(100),'hello',Random(256*256*256));
    OGLCanvas.MoveTo(i*10,20);
    OGLCanvas.LineTo(i*10,y);
  end;

  OGLCanvas.Free;
end;
Führe ich das nun aus, erhalte ich stehts eine Fehlermeldung 'invalid operation'. Zeichne ich erst die Schrift und dann die Linien erhalte ich diesen Fehler nicht, doch ist dies eine eher unkomfortable Lösung.

Wo liegt also mein Fehler, oder ist es anders möglich? GLHudText hatte ich bereits ausprobiert, ist aber leider viel zu umständlich.

Ich bedanke mich im Vorraus,

Slavik

Slavik 18. Okt 2005 23:21

Re: GLScene - GLCanvas und TextOut
 
*schieb*

gar keiner eine Idee? :(

Slavik

turboPASCAL 19. Okt 2005 00:31

Re: GLScene - GLCanvas und TextOut
 
Liste der Anhänge anzeigen (Anzahl: 1)
Delphi-Quellcode:
procedure TForm1.GLDirectOpenGL1Render(Sender: TObject;
  var rci: TRenderContextInfo);
var
  OGLCanvas: TGLCanvas;
  x,y,i: integer;
begin

  x:=GLSceneViewer1.Width-1;
  y:=GLSceneViewer1.Height-1;
  OGLCanvas:=TGLCanvas.Create(x,y);
  OGLCanvas.PenColor:=clYellow;
  OGLCanvas.PenAlpha:=1;
  OGLCanvas.PenWidth:=1;

  GLWindowsBitmapFont1.TextOut(rci,20,20,'text', clred);

  for i:=0 to 10 do
  begin
    OGLCanvas.StopPrimitive; // <---<<< ruf den mal vorher auf.
    GLWindowsBitmapFont1.TextOut(rci,random(100),random(100),'hello',Random(256*256*256));

    OGLCanvas.MoveTo(i*10,0);
    OGLCanvas.LineTo(i*10,y);
  end;

  OGLCanvas.Free;
end;

Zitat:

{: Stops the current internal primitive.


This function is invoked automatically by TGLCanvas when changeing
primitives, you should directly call if you want to render your
own stuff intertwined with TGLCanvas drawings. In that case, call
it before your own OpenGL calls. }

Slavik 19. Okt 2005 08:05

Re: GLScene - GLCanvas und TextOut
 
Super, es klappt!
Ich danke Dir vielmals.

Slavik

turboPASCAL 19. Okt 2005 09:49

Re: GLScene - GLCanvas und TextOut
 
Hi, OGLCanvas.StopPrimitive; vor der Schleife aufrufen sollte reichen. :gruebel:

Slavik 19. Okt 2005 11:08

Re: GLScene - GLCanvas und TextOut
 
Zitat:

Zitat von turboPASCAL
Hi, OGLCanvas.StopPrimitive; vor der Schleife aufrufen sollte reichen. :gruebel:

Habe ich ausprobiert, funktioniert aber wirklich nur wenn man OGLCanvas.StopPrimitive; und sofort danach OGLCanvas.TextOut(...); verwendet, also direkt in der Schleife.

Slavik


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz