On Mon, 20 Feb 2006 18:44:48 +0000
"Tony Pelton" <[EMAIL PROTECTED]> wrote:
> hi all,
>
> where to begin ...
>
> i've been using FPC for a little while now for a couple of projects.
>
> i've installed and given Lazarus a go a couple of times as well, but
> nothing too serious.
>
> i have never been a Delphi user.
>
> i've recently been trying to do some GUI development, using LCL, but
> NOT using the Lazarus RAD (don't care for the RAD, i like to know how
> things _really_ work).
>
> things seem to be going fine and i'm slowly educating myself on the
> LCL libraries and GUI development in general using the LCL and using
> the FP IDE for development and compiling.
>
> i've run into one behavior that doesn't make any sense to me and i was
> hoping someone could educate me.
>
> i've got a Type that extends 'TForm'.
>
> i have a 'TOpenGLControl' field on my TForm class.
>
> i also have a TTimer field on my TForm class.
>
> during construction of my TForm class, i Create() the OpenGL control,
> and the TTimer control, and pass 'self' to the controls during
> Create().
>
> for the TTimer, i'm registering a "paint" procedure that renders into
> the OpenGL control.
>
> everything works fine up to this point ... but here is my PROBLEM :
>
> it seems like the TTimer doesn't start firing events to cause my
> "paint" to start working until i "jiggle" my window after the app
> starts.
>
> it also seems like i can get the timer to stop/start firing by playing
> around with resizing my window.
>
> so my animation will stop/start as i play around with the "resize
> handle" on my window.
>
> this is on Win32.
>
> i'm gonna include some relevant bits of my code below, but it is
> _very_ messy right now, as i'm just doing some demo work to try and
> figure out how things fit together.
>
> "glpaint" is the opengl rendering callback
>
> is there some assumption i'm making about TTimer ?
>
> i had assumed that this was just an object that would fire at
> "intervals" and do a callback for me, independent of the window
> system.
>
> so my thought was that i could use this for getting an animation to
> run in my opengl window while my application idles on the users
> desktop.
>
> am i way off ?
>
> if TTimer is the "wrong thing" to use to try and get an animation to
> run in my opengl window ... is there something else i can use ?
>
> i don't need precise timing, as i can control timing in the callback
> based on Delta ... i just need something that will call my paint
> routine with some type of frequency without needing a user driven
> event.
>
> tia,
> Tony
>
> -- SNIP messy code --
>
> Type Txm_main_form = Class(TForm)
> Private
> { dressing }
> ctrl_status_bar : TStatusBar;
> menu_main : TMainMenu;
> menu_file : TMenuItem;
> menu_file_exit : TMenuItem;
>
> { controls }
> ctrl_graphic : TImage;
> ctrl_group_box_top : TGroupBox;
> ctrl_group_box_bottom : TGroupBox;
> ctrl_combo_box : TComboBox;
> ctrl_opengl : TOpenGLControl;
> ctrl_timer : TTimer;
>
> { methods }
> procedure event_menu_onclick_file_exit(Sender : TObject);
> procedure formpaint(Sender : TObject);
> procedure glpaint(Sender : TObject); // PAINT OPENGL STUFF
> procedure event_combo_box_onchange(Sender : TObject);
>
> Public
> constructor create(AOwner : TComponent); override;
> cube_rotationx: GLFloat;
> cube_rotationy: GLFloat;
> cube_rotationz: GLFloat;
> end;
>
> constructor Txm_main_form.create(AOwner : TComponent);
> begin
> inherited create(AOwner);
>
> self.Height := 480;
> self.Width := 640;
>
> ctrl_status_bar := TStatusBar.Create(self);
> ctrl_status_bar.SimpleText := 'foobar';
> ctrl_status_bar.Parent := self;
>
> menu_main := TMainMenu.Create(self);
> self.Menu := menu_main;
>
> menu_file := TMenuItem.Create(menu_main);
> menu_file.Caption := 'File';
> menu_main.Items.Add(menu_file);
>
> menu_file_exit:= TMenuItem.Create(menu_file);
> menu_file_exit.Caption := 'Exit';
> menu_file_exit.OnClick := @self.event_menu_onclick_file_exit;
> menu_file.Add(menu_file_exit);
>
> ctrl_opengl := TOpenGLControl.Create(self);
> with ctrl_opengl do begin
> Name:='ctrl_opengl';
> Align:=alClient;
> Parent:=Self;
> end;
>
> ctrl_timer := TTimer.Create(self);
> with ctrl_timer do
> begin
> OnTimer := @glpaint;
> Interval := 100;
> end;
>
> end;
I just tried under linux and it works:
Call in glpaint ctrl_opengl.Invalidate and paint in ctrl_opengl.OnPaint.
Mattias
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives