Recent

Author Topic: GLscene Runtime & Designtime difference  (Read 6523 times)

mmab

  • Jr. Member
  • **
  • Posts: 89
GLscene Runtime & Designtime difference
« on: November 03, 2010, 06:20:17 pm »
Hi,
I've noticed an unusual behavior of the GLsceneviewer. If I create the glsceneviewer at designtime everything works fine. However, if I create it in runtime using the following code,

Code: [Select]
unit ...
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  ExtCtrls, GLScene, GLViewer, Unit2;

type

  TForm1 = class(TForm)
   ...
    procedure GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton;      Shift: TShiftState; X, Y: Integer);
    procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState; X,      Y: Integer);
  private
    { private declarations }
  public
    { public declarations }
    GLSceneViewers: array of TGLSceneViewer;
  end;

var
  Form1: TForm1;
   mx, my:integer;
implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var id:integer;
begin
  id := length(GLSceneViewers);
  setlength(GLSceneViewers,id+1);
  GLSceneViewers[ id ] := TGLSceneViewer.Create(frame1_1);
  GLSceneViewers[ id ].Parent:=frame1_1;
  GLSceneViewers[ id ].Align:=alclient;

  GLSceneViewers[ id ].Camera:=frame1_1.GLCamera1;
  GLSceneViewers[ id ].Buffer.BackgroundColor:=clwhite;
  GLSceneViewers[ id ].Buffer.Lighting:=false;

  GLSceneViewers[ id ].OnMouseDown:=GLSceneViewer1.OnMouseDown;
  GLSceneViewers[ id ].OnMouseMove:=GLSceneViewer1.OnMouseMove;
  GLSceneViewers[ id ].RecreateWnd;
end;

procedure TForm1.GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   mx:=x; my:=y;
end;

procedure TForm1.GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
   if Shift<>[] then begin
      (sender as  TGLSceneViewer).Camera.MoveAroundTarget(my-y, mx-x);
      mx:=x; my:=y;
   end;
end;             

the glsceneviewer screen flashes ( becomes black and white while rotating and stays black ).

any ideas to solve this strange behaviour?
Moreover, it is not possible to create a frame which has a Glsceneviewer. It is giving "control frame1 has no parent window" error. Is this normal?

Thanks in advance


mrBrown

  • New Member
  • *
  • Posts: 15
Re: GLscene Runtime & Designtime difference
« Reply #1 on: December 01, 2010, 08:34:48 am »
You are creating an array of GLScene viewers with the same parent.
So you have multiple viewers at the same location your screen.

I do not know what you are trying to do, but this might well be the source of the flashing.


mmab

  • Jr. Member
  • **
  • Posts: 89
Re: GLscene Runtime & Designtime difference
« Reply #2 on: December 04, 2010, 08:53:12 pm »

It happens with a single GLscene also.
Any idea about the frame problem?

Thanks


Laksen

  • Hero Member
  • *****
  • Posts: 621
    • J-Software
Re: GLscene Runtime & Designtime difference
« Reply #3 on: December 05, 2010, 03:43:05 am »
I think that problem appeared in an old release of glscene. Try the trunk version of glscene and lazarus :)