🔒 Locked
application.onidle
Advertisement
Original Post
hi,
has anyone tried application.onidle event for game main loop?
First i tried to make a window and its repeat until loop and
the second way is using the VCL which using application.onidle event and there is no speed difference between these two ways.
Or i have made something wrong.Because someone says that using
just a simple window is much much faster than using vcl.But when i tried the two ways,there is not important speed difference between them..
The VCL, deep down, in it''s heart of hearts, uses a PeekMessage() loop, and when idle, it triggers a OnIdle event. If the OnIdle sets done to true then it releases control back to windows, and acts like a normal windows prog. Since we are writing a game, we want to grab 100% of the windows'' CPU resource, so using OnIdle with Done=true means you get 100% of idle time. Which is what you want.
Using a repeat until loop gives the user no control, as you don''t get WIN messages, so the user cannot resize, move, tab away from the app.
If you have BCB5 pro (or maybe standard
) you can use the TApplicationEvents component to get these events in a visual VCL-manner.
Using a repeat until loop gives the user no control, as you don''t get WIN messages, so the user cannot resize, move, tab away from the app.
If you have BCB5 pro (or maybe standard
Handling the TApplication.OnIdle event and setting the Done parameter to False is very close to writing your own message loop. During my initial experiments with DirectX this is how I implemented the game loop and it is far better than the repeat..until loop you tried. I have now ditched the VCL and implement my own message loop, but it is the same principle.
c++freak: The TApplicationEvents component is available in all versions of C++ Builder 5 and Delphi 5 (I have BCB5Pro and D5Ent at home and use BCB5Std at work). I believe the component just adds more bulk to an already overweight VCL, but for people who do not like to type code such as
it would seem like a godsend.
Steve 'Sly' Williams
Tools Developer
Krome Studios
c++freak: The TApplicationEvents component is available in all versions of C++ Builder 5 and Delphi 5 (I have BCB5Pro and D5Ent at home and use BCB5Std at work). I believe the component just adds more bulk to an already overweight VCL, but for people who do not like to type code such as
Application.OnIdle := MyIdleHandler;
it would seem like a godsend.
Steve 'Sly' Williams
Tools Developer
Krome Studios
Although I''m not often on msg boards these days, just wanted to say something...
I''m using OnIdle event in all projects I''m working on. It''s just I haven''t seen anything better than this. I calculate the frame rate every second frame so the game reaction speed on slowdowns is pretty fast.
I''m using OnIdle event in all projects I''m working on. It''s just I haven''t seen anything better than this. I calculate the frame rate every second frame so the game reaction speed on slowdowns is pretty fast.
Ooops!!!
Set Done to false, not true. Silly me
.
Sly: I use the VCL all the time, and I also have the source code to it. I looked at it, and I cannot see what is sooo over weight about it. I mean, I just use it to create the window, and to host my dx components. + the TApplicationEvents component reroutes the handlers as inline functions, which call the handlers. I don''t see much loss in speed at that. Also why type out a function declaraction when you can just double click and there it is ready to be used with out having to setup the handlers or anything. Also the VCL would be really usefull for game editors etc. where you have std. Win32 and DX working together side by side.
Set Done to false, not true. Silly me
Sly: I use the VCL all the time, and I also have the source code to it. I looked at it, and I cannot see what is sooo over weight about it. I mean, I just use it to create the window, and to host my dx components. + the TApplicationEvents component reroutes the handlers as inline functions, which call the handlers. I don''t see much loss in speed at that. Also why type out a function declaraction when you can just double click and there it is ready to be used with out having to setup the handlers or anything. Also the VCL would be really usefull for game editors etc. where you have std. Win32 and DX working together side by side.
Win32...
Those "strange" float calculations I used to synchronize the demo to the music.

Edited by - baskuenen on September 15, 2000 7:24:04 PM
|
Those "strange" float calculations I used to synchronize the demo to the music.
Edited by - baskuenen on September 15, 2000 7:24:04 PM
quote:
Original post by c++freak
Sly: I use the VCL all the time, and I also have the source code to it. I looked at it, and I cannot see what is sooo over weight about it. I mean, I just use it to create the window, and to host my dx components. + the TApplicationEvents component reroutes the handlers as inline functions, which call the handlers. I don''t see much loss in speed at that.
I agree that there is no real loss of speed. What I don''t like is the bloat in executable size. My current testbed application is 120KB. If I merely use the Forms unit in one file, that blows out to over 400KB. Not only that, but at run-time it loads system DLLs such as OLEAUT32.DLL that are not required by the application.
quote:
Also why type out a function declaraction when you can just double click and there it is ready to be used with out having to setup the handlers or anything.
I guess I''m just an old school Delphi programmer. Started in Delphi 2 back in ''96. Application event handlers were always written out by hand. Besides, it''s so simple just to type it out.
quote:
Also the VCL would be really usefull for game editors etc. where you have std. Win32 and DX working together side by side.
Yes, it would be useful in game editors. But that is a different situation than the game itself.
Steve 'Sly' Williams
Tools Developer
Krome Studios
Hummmmm......
I can see your point of view, your mainly talking about code bloat. Time to concede the point
. Tho I still prefer VCL. The first hit on size is hard, but after that there is only a few kb for each component. I think.
Anyways its up to you.
I can see your point of view, your mainly talking about code bloat. Time to concede the point
Anyways its up to you.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement