Board index » cppbuilder » Real-time rendering without timer?

Real-time rendering without timer?

Hi,

I'm attempting to convert all of our internal game development tools to BCB
and I'm having a bit of a problem.  I can't seem to find a way to
continually update a scene during idle time.  Using a high resolution timer
works OK, but I know its the "wrong way".  Is there some way to hook into
the idle time of the message loop (if there is a message loop)?  MFC has
OnIdle and if you are using straight Win32 you just have a while loop that
dispatches messages and if there are no messages you can render the scene
(like the DirectX samples do).

Is there any way to do this in BCB?  I'm guessing a thread would work but
that seems like a lot of work to do something quite simple.

Any help is appreciated!

- Jason Zisk
- nFusion Interactive LLC

 

Re:Real-time rendering without timer?


You will require a timer in some way, as you will have to wait some
excess time, or make the movement slower on a faster machine

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com

Re:Real-time rendering without timer?


Not true, I usually allow all of our games to be framerate independant.

Using a timer to update the scene and flip the frame is generally not the
right way to do things, but since this is just an editor I can cheat a bit.

- Jason Zisk
- nFusion Interactive LLC

tschagge...@access.ch (Rene Tschaggelar) wrote in <3857B34D.68D36056
@access.ch>:

Quote
>You will require a timer in some way, as you will have to wait some
>excess time, or make the movement slower on a faster machine

>Rene

Re:Real-time rendering without timer?


Hi Jason,
You can use an idle loop. To set up an idle loop in BCB. First, add a member
function to your main form
with the foollowing signature.
void __fastcall IdleLoop(TObject*, bool&);
Then, in your form counstructor, set this function as the Application's OnIdle
event:
Application->OnIdle = IdleLoop;
Last, in the IdleLoop implementation, set the bool reference to false to tell
the application that the idle loop is not done processing. You can also check
out an example OpenGL program that uses it at:
http://community.borland.com/article/0,1410,10528,00.html//jt
--
John R. Thomas Jr. (JT)
Developer Relations Mgr
  Borland C++Builder
   j...@borland.com

Re:Real-time rendering without timer?


Quote
"Jason Zisk" <zi...@n-fusion.com> wrote in message

news:837f06$7st18@forums.borland.com...

Quote
> Hi,

> I'm attempting to convert all of our internal game development tools to
BCB
> and I'm having a bit of a problem.  I can't seem to find a way to
> continually update a scene during idle time.  Using a high resolution
timer
> works OK, but I know its the "wrong way".  Is there some way to hook into
> the idle time of the message loop (if there is a message loop)?  MFC has
> OnIdle and if you are using straight Win32 you just have a while loop that
> dispatches messages and if there are no messages you can render the scene
> (like the DirectX samples do).

> Is there any way to do this in BCB?  I'm guessing a thread would work but
> that seems like a lot of work to do something quite simple.

> Any help is appreciated!

> - Jason Zisk
> - nFusion Interactive LLC

OnIdle is part of TApplication if you're using VCL. It's in the help
(including an example) but the basics are:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   Application->OnIdle = IdleHandler;

Quote
}

void __fastcall TForm1::IdleHandler(TObject *Sender, bool &Done)
{
  ...

Quote
}

Hope it helps,

Allister

Re:Real-time rendering without timer?


Thanks to both of you who replied, this is EXACTLY what I was looking
for.  For some reason I couldn't find it in the help.

Thanks!

- Jason Zisk
- nFusion Interactive LLC

j...@borland.com (JT (Borland)) wrote in <38581C5C.49E04...@borland.com>:

Quote
>Hi Jason,
>You can use an idle loop. To set up an idle loop in BCB. First, add a
>member function to your main form
>with the foollowing signature.
>void __fastcall IdleLoop(TObject*, bool&);
>Then, in your form counstructor, set this function as the Application's
>OnIdle event:
>Application->OnIdle = IdleLoop;
>Last, in the IdleLoop implementation, set the bool reference to false to
>tell the application that the idle loop is not done processing. You can
>also check out an example OpenGL program that uses it at:
>http://community.borland.com/article/0,1410,10528,00.html
>//jt
>--
>John R. Thomas Jr. (JT)
>Developer Relations Mgr
>  Borland C++Builder
>   j...@borland.com

Other Threads