Original Post
How can I limit the fps of a directx application in C++?
#include <mmsystem.h>void Render(){ static DWORD dwLastFrameTime = 0; dwFPSLimit = 60; // Or however many frames per second dwCurrentTime = timeGetTime(); if ((dwCurrentTime - dwLastFrameTime) < (1000 / dwFPSLimit)) // 1000 miliseconds in a second. { return; } dwLastFrameTime = dwCurrentTime;}
Quote:
Original post by CodeReaver
If the time since you rendered last is less than 1 second divided by your frame limit then don't render.#include <mmsystem.h>void Render(){ static DWORD dwLastFrameTime = 0; dwFPSLimit = 60; // Or however many frames per second dwCurrentTime = timeGetTime(); if ((dwCurrentTime - dwLastFrameTime) < (1000 / dwFPSLimit)) // 1000 miliseconds in a second. { return; } dwLastFrameTime = dwCurrentTime;}
This topic has been locked by a moderator. New replies are not allowed.
GameDev.net uses cookies to ensure you have the best experience on our platform. Learn more