![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Application.RaiseIdle In VB I am doing an animation via Application.Idle. My idle routine is: Private Sub Form1_Idle(ByVal sender As System.Object, ByVal e As System.EventArgs) Draw() Application.RaiseIdle(e) End Sub I use RaiseIdle so I don't just draw one frame and wait until I wiggle the mouse or something so it can go back to idle. The animation is very smooth, and I get about a 1000 frames per second (fps) This works for a while, but my application is very unresponsive and quits after about a minute. If I run in the IDE, it quits in only 5 seconds or so. If I add Application.DoEvents right after Draw, the app is very responsive, but I get a stack overflow. How do I avoid these problems? Thanks, Jon |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Application.RaiseIdle I'm not familar with the RaiseIdle() method but it doesn't sound like the right place to put animation code. What if the user were moving the mouse around or clicking on the window - wouldn't that make the idle even called less? Also it sounds like the DoEvents() is synchronously calling your Idle method and if you're then calling DoEvents() within then you get into circular loop. Why not use a timer? You can probably get 30 fps reliably enough with that. 1000 fps is pretty rediculous since a human probably can't even see anything beyond 50 or 60 if even that. I'm not sure how your animation is generated but you could use another thread to create frames at some constant and reliable rate (since the timer thread is lower priority) and then use the timer events just to display the "correct" frame for that time. If you really want to do more sophisticated animation you'll probably need to use directX. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Application.RaiseIdle > I'm not familar with the RaiseIdle() method but it doesn't sound like Quote: > the right place to put animation code. What if the user were moving the animation code, but apparently, in the .Net environment, the way it is implemented is problematic. Quote: > the mouse around or clicking on the window - wouldn't that make the > idle even called less? Quote: > Why not use a timer? You can probably get 30 fps reliably enough with > that. 1000 fps is pretty rediculous since a human probably can't even > see anything beyond 50 or 60 if even that. read recommends against them. Quote: > I'm not sure how your animation is generated but you could use another > thread to create frames at some constant and reliable rate (since the I use logic in the image generaion so the motion maintains proper speed in spite of changing fps. Quote: > If you really want to do more sophisticated animation you'll probably > need to use directX. programming environments. Now I am trying to port it into VB.NET. Just trying to work through the issues for this particular programming environment. Thanks, Jon |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Application.RaiseIdle On May 30, 4:17*pm, Jon Jacobs <JonJac...@xxxxxx> wrote: Quote: Quote: > > I'm not sure how your animation is generated but you could use another > > thread to create frames at some constant and reliable rate (since the > Also gotchas when doing this with other threads, according to what I've read. > I use logic in the image generaion so the motion maintains proper speed in > spite of changing fps. generated the frames e.g. if your animation routine is a function of an iterator you could keep a buffer of generated timestamped frames and then when the timer comes back lookup the closest frame based on the current time. Or your animation routine is a function of time, so given an arbitrary time generate the appropriate frame. Quote: > I've been doing very sophisticated animation with OpenGL in other > programming environments. Now I am trying to port it into VB.NET. Just trying > to work through the issues for this particular programming environment. bitmaps using a timer or writing direct show filters in C++ which is really more video processing than "animation" except for some simple diagnostic image sources which had to generate frames from nothing. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Application.RaiseIdle >Or your animation routine is a function of time, so Quote: >given an arbitrary time generate the appropriate frame. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |