示例#1
0
void Sys_ThrottleFPS(int max_fps) {
	static int throttler_ready = 0;
	static double end_of_prev_frame;
	double frame_time, current_time, time_to_wait;
    struct timespec ts = { 0 };
    
	if (throttler_ready) {
		frame_time = 1000.0/max_fps;

        do {
            current_time = Sys_GetTicks();
            time_to_wait = frame_time - (current_time - end_of_prev_frame);
                        
            if (time_to_wait > 0) {
                ts.tv_sec = 0;
                ts.tv_nsec = (long)(time_to_wait*1000000.0);
                nanosleep(&ts, NULL);
            }
        } while (0);
        
	} else {
        throttler_ready = 1;
	}
    end_of_prev_frame = Sys_GetTicks();

}
示例#2
0
ProfileBlockScoped::~ProfileBlockScoped()
{
	uint64 diff = Sys_GetTicks() - mStartTime;
	uint64 us = Sys_TicksToMicrosecond(diff);
	DebugPrintf("Block '%s' : %.3fms", mBlockName.c_str(), (float)us / 1000.0f);
}
示例#3
0
ProfileBlockScoped::ProfileBlockScoped(std::string blockName)
{
	mBlockName = blockName;
	mStartTime = Sys_GetTicks();
}