- remove old vid_maxfps implementations as they were garbage anyway and the new one works on all the platforms
This commit is contained in:
parent
6078428b84
commit
9f0f659db0
14 changed files with 44 additions and 281 deletions
|
|
@ -51,7 +51,6 @@
|
|||
#include "i_system.h"
|
||||
#include "swrenderer/r_swrenderer.h"
|
||||
|
||||
EXTERN_CVAR(Int, vid_maxfps)
|
||||
EXTERN_CVAR(Int, vid_backend)
|
||||
|
||||
extern HWND Window;
|
||||
|
|
@ -154,88 +153,3 @@ void I_InitGraphics ()
|
|||
|
||||
atterm (I_ShutdownGraphics);
|
||||
}
|
||||
|
||||
|
||||
static UINT FPSLimitTimer;
|
||||
HANDLE FPSLimitEvent;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetFPSLimit
|
||||
//
|
||||
// Initializes an event timer to fire at a rate of <limit>/sec. The video
|
||||
// update will wait for this timer to trigger before updating.
|
||||
//
|
||||
// Pass 0 as the limit for unlimited.
|
||||
// Pass a negative value for the limit to use the value of vid_maxfps.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static void StopFPSLimit()
|
||||
{
|
||||
I_SetFPSLimit(0);
|
||||
}
|
||||
|
||||
void I_SetFPSLimit(int limit)
|
||||
{
|
||||
if (limit < 0)
|
||||
{
|
||||
limit = vid_maxfps;
|
||||
}
|
||||
// Kill any leftover timer.
|
||||
if (FPSLimitTimer != 0)
|
||||
{
|
||||
timeKillEvent(FPSLimitTimer);
|
||||
FPSLimitTimer = 0;
|
||||
}
|
||||
if (limit == 0)
|
||||
{ // no limit
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
CloseHandle(FPSLimitEvent);
|
||||
FPSLimitEvent = NULL;
|
||||
}
|
||||
DPrintf(DMSG_NOTIFY, "FPS timer disabled\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FPSLimitEvent == NULL)
|
||||
{
|
||||
FPSLimitEvent = CreateEvent(NULL, FALSE, TRUE, NULL);
|
||||
if (FPSLimitEvent == NULL)
|
||||
{ // Could not create event, so cannot use timer.
|
||||
Printf(DMSG_WARNING, "Failed to create FPS limitter event\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
atterm(StopFPSLimit);
|
||||
// Set timer event as close as we can to limit/sec, in milliseconds.
|
||||
UINT period = 1000 / limit;
|
||||
FPSLimitTimer = timeSetEvent(period, 0, (LPTIMECALLBACK)FPSLimitEvent, 0, TIME_PERIODIC | TIME_CALLBACK_EVENT_SET);
|
||||
if (FPSLimitTimer == 0)
|
||||
{
|
||||
CloseHandle(FPSLimitEvent);
|
||||
FPSLimitEvent = NULL;
|
||||
Printf("Failed to create FPS limiter timer\n");
|
||||
return;
|
||||
}
|
||||
DPrintf(DMSG_NOTIFY, "FPS timer set to %u ms\n", period);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// StopFPSLimit
|
||||
//
|
||||
// Used for cleanup during application shutdown.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void I_FPSLimit()
|
||||
{
|
||||
if (FPSLimitEvent != NULL)
|
||||
{
|
||||
WaitForSingleObject(FPSLimitEvent, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue