why my game's fps can faster than my display's fps????

Started by
7 comments, last by repeat4 17 years, 6 months ago
why my game's fps can faster than my display's fps???? I know this problem is very basic ,but I really can't understand it, when my game begin to rend again and again but my display refurbishing is so slow that it can't really rend at the pace of my game's fps next is my code of Rending. ------------------------------------------------------------------- Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0); Device->BeginScene(); D3DXMATRIX I; D3DXMatrixIdentity(&I); if( TheTerrain ) TheTerrain->draw(&I, false); if( FPS ) FPS->render(0xffffffff, timeDelta); Device->EndScene(); Device->Present(0, 0, 0, 0)
Advertisement
I am guessing the answer to your problem is to enable/disable wait for v-sync in either your code or in your PCs video card settings. If you have wait for vsync enabled, and your monitor refreshes at 60hz, you arent going to get more the 60 fps.
Basically, your game is going through its main loop at say 70fps. The screen can say do only 60fps. Your game is running just fine, its just that the monitor may miss a few. Using v-sync can solve this problem quite easily.

V-Sync basically has your program wait to render until the monitor is ready.
Just to expand upon the explanations above a bit, monitors draw the screen from top to bottom, then there is a brief period, known as the vertical retrace, between the end of one screen being drawn and the next. When a program is "waiting for the vsync", it means it is waiting until this period before it draws the next scene. D3D will wait for this period when you call ->Present unless you tell it not to.

The reason for this is that if the monitor was halfway through drawing one screen and the graphics hardware updated the screen buffer with a new screen, what would briefly appear on the screen would be the top half of one frame and the bottom half of another.

This causes an effect known as tearing. Generally graphics applications will wait for the vertical retrace to ensure that, for any given monitor refresh, there is only one given frame in the screen buffer.

While you can disable vsync to increase your frame rate, you shouldn't. There are two reasons this is a bad idea - one, you can get the tearing effects described above and two, a user can override this with their local settings to force your app to wait for vsync, so you are back to square one.

Write your game (or whatever) so it runs independantly of the actual frame rate by calculating the time elapsed since the last frame and using this value to modify how fast things move and animate and so on. 60 fps is more than enough to appear "smooth" to the human eye.
User could disable wait for vsync, and you would have a problem. Use triplebuffering.

I use drawing at speeds around 24 FPS, 25/30 FPS if I can know the refresh rate of the monitor.

Of course I have decoupled input from the game engine, and the game engine is decoupled from 3D engine.
Quote:Original post by Raghar
User could disable wait for vsync, and you would have a problem. Use triplebuffering.

I use drawing at speeds around 24 FPS, 25/30 FPS if I can know the refresh rate of the monitor.

Of course I have decoupled input from the game engine, and the game engine is decoupled from 3D engine.


I'm curious - what would the advantage of triple buffering be if the user had disabled vsync?
Quote:Original post by EasilyConfused
I'm curious - what would the advantage of triple buffering be if the user had disabled vsync?
Obviously, no tearing and more fluid drawing. Thought the differences between double and triple buffering are often negligible.




Re repeat4 you might like to look here:
http://www.thefreedictionary.com/rend

Also this page,
http://www.tech-hounds.com/article8/ArticlesPage3.html
and all other pages here
http://www.tech-hounds.com/articles.html
might be quite useful. (Cleanly done pages about basics, and about some quite important details)
I thought that the whole point of triple buffering was that while the first back buffer was waiting (for the vertical retrace) to swap with the primary buffer to the screen, you could go ahead and render to the second back buffer while waiting.

Surely if vsync is off, triple buffering is meaningless? And how, without vsync, does triple buffering prevent tearing? Sorry if I'm misunderstanding and please explain if my understanding is flawed in some way as I've never used triple buffering. I did think I understood the concept though.
Thank you for your replies!

This topic is closed to new replies.

Advertisement