• Advertisement
Sign in to follow this  

[.net] Main application loop

This topic is 4906 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I started with DirectX and Game design past thursday. Allthough I have tons of experience in almost all other areas, like compiler design, db design, 2D-engine design..., I find 3D the hardest thing I have ever done. Maybe I'm just getting way to old! :-) I have some problems/questions with my main loop. I'm writing business applications that use a DirectX9 - C# core. I'm writing this core, since it makes the business apps less boring to me. :-) Q1. Is it for example good practice to slow down the engine. For example, for many, many forms a refreshrate of 25 is more than enough. Q2. I would like to implement my own messagehandling instead of Application.DoEvents. When I look at the DX-examples provided, they just wrap the old api's like peekmessage, dispatchmessage, ... Q3. I have a hunch my main look stinks. I would greatly appreciate it if someone could have a say over this. By the way, I'm a hardcore Delphi developer, so unless they put me at gunpoint, I DON'T USE underscores. ;-) public void Run(){ if ((FMainForm != null) && FMainForm.InstallDevice()){ FMainForm.Show(); XCoreTimer.Init(); while(FMainForm.Created) { FKeyboard.Poll(); FMouse.Poll(); long now = XCoreTimer.MSTick; if (now < FNextTick){ int SleepTime = (int)(FNextTick - now); /* this should not be sleep, but msgWaitForMultipleObjects, it should handle messages */ System.Threading.Thread.Sleep(SleepTime); } FNextTick = XCoreTimer.MSTick + FExtraTicks; FMainForm.CallRender(); /* we need to trash this DoEvents thing*/ System.Windows.Forms.Application.DoEvents(); } } } Kind regards and many thanks Alexander

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement