Craig, I'm restarting my directx app (simple car simulator) from scratch since the performance is pretty bad with the CPU in the 80s constantly, so I was wondering what should I use for the Game Loop. In Tom's book, he uses the OnPaint event and he's had some blog postings against using the Application.DoEvents(), all of your samples still use it so I was wondering what are your thoughts about it and which approach you suggest I should be using? thx a lot.
Game app = new Game(); app.InitializeGraphics(); app.Show();
while (app.Created) { app.Render(); Application.DoEvents(); }
OR
using(Engine frm = new Engine()) { frm.Show(); frm.InitializeGraphics(); Application.Run(frm); }
When in doubt, do what Tom Miller advises. His method will save a few hundred bytes of garbage per DoEvents call, which can decrease the stutter you sometimes see due to garbage collection.
I really need to get a DirectX wiki set up one of these days...
Craig, I'm restarting my directx app (simple car simulator) from scratch since the performance is pretty bad with the CPU in the 80s constantly, so I was wondering what should I use for the Game Loop. In Tom's book, he uses the OnPaint event and he's had some blog postings against using the Application.DoEvents(), all of your samples still use it so I was wondering what are your thoughts about it and which approach you suggest I should be using? thx a lot.
ReplyDeleteGame app = new Game();
app.InitializeGraphics();
app.Show();
while (app.Created)
{
app.Render();
Application.DoEvents();
}
OR
using(Engine frm = new Engine())
{
frm.Show();
frm.InitializeGraphics();
Application.Run(frm);
}
When in doubt, do what Tom Miller advises. His method will save a few hundred bytes of garbage per DoEvents call, which can decrease the stutter you sometimes see due to garbage collection.
ReplyDeleteI really need to get a DirectX wiki set up one of these days...