-
April 14th, 2013, 02:36 AM
#16
Re: Trying to multithread program. C++/CLI
yea i've never heard of a .net 4.3 either actually but i figured i'd take his word for it. I'll try and inclue the .NET framework installation with my setup program will be easier than making people install it manually. i'll also include the 2012 redistributables.
So you think i should use a Timer and on every timer tick draw everything whilst continuously doing the calculations required??
Or do you mean Update and Draw on one timer tick but use the stopclock just to keep track of the time taken to put into my calculations??
-
April 14th, 2013, 08:31 AM
#17
Re: Trying to multithread program. C++/CLI
 Originally Posted by welsh4evr
So you think i should use a Timer and on every timer tick draw everything whilst continuously doing the calculations required??
I'm not quite sure what you mean by "continuously", but if that involves a loop, then definitely no.
Or do you mean Update and Draw on one timer tick but use the stopclock just to keep track of the time taken to put into my calculations??
Yes, that's what I meant. It's easy when the calculations you perform in any simulation step just depend on time and some parameters that remain constant over the simulation run (of course it's absolutely fine to change parameters between simulation runs). If, however, your calculations also depend on results obtained in the previous step, it may become more complicated, since the timespan elapsed between steps may not be constant (which actually is the gist of the game loop approach).
But don't do any actual drawing in the timer tick handler. Just update your simulation parameters and call Invalidate(), which will result in OnPaint() being called, where you then do the actual drawing based on the updated simulation parameters, much like you're already doing in the code you uploaded.
To reduce CPU load caused by repainting, you may just invalidate the area that actually has changed rather than the entire form, sort of what is described in http://forums.codeguru.com/showthrea...92#post2005192. But CPU load probably won't be so dramatic either way.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|