Getting Smooth animation.
Ive been working on a high speed pong type game in my spare time while not coding my main project,and have ran into a few intresting problems.
1. Problems with differnt FPS outputs,with differnt max monitor refresh rates.
2. Non-smooth animation/movement when fps is ever below monitor refresh max.
3. Loss of accurate collision detection with just a drop of 1 or 2 FPS.
Ok ill go on and explain what i mean.
1.If my monitor is set where for 640x480x16 refreshs at 75fps ,I will get like 38fps in a menu system(Its not using any images in vram,ect so i expected this.)However if i make my monitor refresh at 60fps for that mode i can get 54 and 60 fps in the menu for some reason.
2. I update all my movement by time instead of FPS.
xpos+xvel*time;
Now if my monitor refreshs at 60fps and i get 60fps no problem my animation is very smooth even at really high speed. However if i get 59 or 58fps my animation/movement of objects is very shaky/jittery.
3. I loss collision detection accuracy(probally just the drop of times it gets called. I really need someway to make it where it is called 60 or 75 times per loop no matter what.)
Anyways i tryed using tripple buffering and that helped alot but it takes up to much vram for what im targeting(2mb video cards.)
Also heres alittle info bout my program. Im using directdraw and the directdraw4 interface. I am using fullscreen exclusive mode of 640x480x16,and am using double buffering and pageflipping via the flip command. I am using the WAIT command on the flip,and all blits.
Well, in response to part 1, the reason that you are getting 38 fps (really 37.5) is that you are probably just missing the vsync consistantly. Because of that you are only refreshing every other vsync, which is 37.5Hz. By dropping the Hz to 60, you are giving yourself more time to render the frame and still make that vsync (which you are obviously doing because it is making 60fps)
- Splat
- Splat
Ya i was thinking that might be the case,but is there anyway i can make it so that mode is always 60hz?
Triple buffering is the best way if you can spare the video memory. I haven''t tried this but here''s a suggestion.
Whenever you finish rendering a frame, if the monitor happens to be in its vertical refresh (GetFlipStatus) then do a flip as normal. Otherwise, immediately Blit the back-buffer to the primary-buffer without flipping.
Two problems: more time Bliting, you might get tearing.
Whenever you finish rendering a frame, if the monitor happens to be in its vertical refresh (GetFlipStatus) then do a flip as normal. Otherwise, immediately Blit the back-buffer to the primary-buffer without flipping.
Two problems: more time Bliting, you might get tearing.
From my understanding the cap DDFLIP_NOVSYNC(which i tried using)is hardware dependent. Hmmmm ill look into trying just a normal blit like that with the refesh though it sounds like it could lead to further problems(like you said tearing). Another thing ive been considering is instead of just using the wait flag for blits,to check to see if it can blt yet and if not run collision checks untill it can.(so i increase a bit more accuracy with the checks.) Overall i really dont understand why just a few frames under the refresh screws the movement so bad. I mean here is the real world event. I run without music i get 75 or 76fps if i put cd music to go i get 72-74fps,and my animation is all shaky/jerky/ect. Now another thing i dont get is why if i play my game and run the cd from cdplayer i dont experince the fps lost.
Dosn''t turning of v-sync cause problems with tearing?
For the un-initiated tearing is when the screen gets drawn when the vertical refresh is still in progress, leaving a nasty visual effect known as tearing
That could be another point to consider, how about giving the user the option (simple yes/no in a menu) like Quake 2 does.
PS - I personally run DirectDraw 640x480 @ 120Hz (using Asus drivers), but I don''t know how to change the refresh rate through code, and I have never seen any program override my 120Hz.
For the un-initiated tearing is when the screen gets drawn when the vertical refresh is still in progress, leaving a nasty visual effect known as tearing
That could be another point to consider, how about giving the user the option (simple yes/no in a menu) like Quake 2 does.
PS - I personally run DirectDraw 640x480 @ 120Hz (using Asus drivers), but I don''t know how to change the refresh rate through code, and I have never seen any program override my 120Hz.
Sounds like you need to use a better collision detection scheme also, since there will always be times where the computer just freezes for a little bit (and you end up with less frame rate than usual). I dunno what you''re using now but you might try checking the line/shape between the previous position and the new position instead of just checking the new position (which sounds like what you might be doing) In a pong game this shouldn''t be that tough to do.
Hope this helps, or at least doesn''t hurt :-)
-ns
Hope this helps, or at least doesn''t hurt :-)
-ns
-ns-
Ya well what i had try to do for collision detection earlier was step through the movement path of the ball at one pixel at a time and check collisions for each pixel moved,instead of whatever speed the ball is going,but i didnt have any luck with that. But what is really getting me is the non smooth movement of the ball.I mean i can understand it somewhat if the ball is moveing ar 24pixels per frame,and im getting 30fps,but just a 1 or 2 fps drop.......
God damn i''m so fucking pissed. WHAT THE FUCK is a clear fields button here for....AAAARRRRGGGG!!!!
I had just finished typing about 1.5 pages to you (Zenroth) to help you with your troubles, when i dropped my drink on my keyboard and lost EVERYTHING i had typed ... I stared at the screen in amazement for nearly a minute, looking for a way to recall it when I noticed the box around ''clear fields''. It was then that I contemplated homicide. ARRRRGGGGGG!
I really do want to help you, and I think the system we use at work would cure your problems, but I cannot bring myself to retype so much. I have two solutions for you. One, the prefered if you live in the US, is me to e-mail you a sample of our system, AND my phone number. Then you can call me and I''ll explain it to you (should take 5-15 minutes, so say $0.50 - $2.00 For this to work you need to tell me what compiler you use, and when you would want to call me. The second is to wait until I finish the article I''m writing for Gamdev.net which is about High performance timers and various sytems of usage to meet your needs. This may be 1-2 weeks, so it''s probably not ideal.
Good luck!
I had just finished typing about 1.5 pages to you (Zenroth) to help you with your troubles, when i dropped my drink on my keyboard and lost EVERYTHING i had typed ... I stared at the screen in amazement for nearly a minute, looking for a way to recall it when I noticed the box around ''clear fields''. It was then that I contemplated homicide. ARRRRGGGGGG!
I really do want to help you, and I think the system we use at work would cure your problems, but I cannot bring myself to retype so much. I have two solutions for you. One, the prefered if you live in the US, is me to e-mail you a sample of our system, AND my phone number. Then you can call me and I''ll explain it to you (should take 5-15 minutes, so say $0.50 - $2.00 For this to work you need to tell me what compiler you use, and when you would want to call me. The second is to wait until I finish the article I''m writing for Gamdev.net which is about High performance timers and various sytems of usage to meet your needs. This may be 1-2 weeks, so it''s probably not ideal.
Good luck!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement