得到每帧的渲染耗时

原创 2007年10月07日 18:59:00

Getting the Time for Each Frame

To accurately time your animations, you need to call the QueryPerformanceCounter function
twice within the game loop: once before you start a drawing, and once after all drawing
has been completed. Both values returned contain the number of counts from the system
at the time the function was called. Because the performance counter has such a high resolution,
both of these values should be unique. You can use the difference between these
two values to determine the number of counts that has passed between the calls.
For example, you could write the following code:
LARGE_INTEGER timeStart;
LARGE_INTEGER timeEnd;
QueryPerformanceCounter(&timeStart);
Render( );
QueryPerformanceCounter(&timeEnd);
LARGE_INTEGER numCounts = ( timeEnd.QuadPart – timeStart.QuadPart )

Now that you’ve updated the sprite code, you have to add in the timer code. The timer
code requires three new global variables:

LARGE_INTEGER timeStart; // holds the starting count
LARGE_INTEGER timeEnd; // holds the ending count
LARGE_INTEGER timerFreq; // holds the frequency of the counter

Next, you need to make a call to QueryPerformanceFrequency to get the frequency of the
counter. You should call this function right before the main message loop:

QueryPerformanceFrequency(&timerFreq);

Finally, you need to add the calls around the Render function to QueryPerformanceCounter.
The first one should go right before the call to Render.

QueryPerformanceCounter(&timeStart);

The second call should go after the call to Render.

QueryPerformanceCounter(&timeEnd);

Immediately following the last QueryPerformanceCounter function, you must determine the
new animation rate.

anim_rate = ( (float)timeEnd.QuadPart - (float)timeStart.QuadPart ) /
timerFreq.QuadPart; 

相关文章推荐

cocos2dx 3.2 渲染(Director::drawScene 在游戏loop里每帧调用。 内部实际通过调用场景内每个node的 visit方法完成渲染)

渲染

AVI中提取每帧图像

  • 2014年10月29日 08:58
  • 18.8MB
  • 下载

seed-dvs6467 encodedecode实例 采集的图像质量很差,只有隔行显示,而且每帧图像不断的往下移动?

seed-dvs6467 encodedecode
  • zhh2012
  • zhh2012
  • 2013年12月31日 16:25
  • 1918

用Mathematica从GIF文件中导入每帧的DisplayDurations

http://mathematica.stackexchange.com/questions/5361/when-importing-gif-animation-how-to-find-the-cor...

获取码流每帧大小 idx.awk

  • 2017年06月30日 17:58
  • 456B
  • 下载

ffmpeg中将每帧视频图像保存为图片的方法

ffmpeg初识

yolov2-cpu检测90ms每帧之tinier模型(3.5M)应用

众所周知,yolov2是个很好的深度学习框架,是检测算法的得力助手。但是yolov2在windows下cpu的测试速度不尽如人意,原作者给出的模型有多种,如tiny-yolo,以及full-yolo。...
  • samylee
  • samylee
  • 2017年06月08日 20:49
  • 2561

Unity3D学习笔记(4)——获取单帧中函数耗时

Unity3D学习笔记(4)参考链接1 参考链接2CheckFunctionTimeInSingleFrame.csnamespace Assets.Scripts { using Unit...
  • leoroom
  • leoroom
  • 2017年04月20日 21:31
  • 239

音频、视频时间戳计算及每帧播放时间

av_rescale_q用于计算Packet的PTS。av_rescale_q的返回值是一个很大的整数,且每次计算的结果间隔很大。 不同于avcodec_encode_video改变AVCode...

耗时操作通用类示例

  • 2015年02月28日 13:16
  • 1.75MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:得到每帧的渲染耗时
举报原因:
原因补充:

(最多只允许输入30个字)