hge source explor 0x8 timer

Timer

  时间部分,在hge中提供对于fps的控制,时间的控制等。

  其中会用到的参数有。

hge_impl.h
    // Timer
    float                fTime;
    float                fDeltaTime;
    DWORD                nFixedDelta;
    int                  nFPS;
    DWORD                t0, t0fps, dt;
    int                  cfps;

  在system.cpp中使用到,用来控制帧率

if(dt >= nFixedDelta)
            {
                // fDeltaTime = time step in seconds returned by Timer_GetDelta

                fDeltaTime=dt/1000.0f;

                // Cap too large time steps usually caused by lost focus to avoid jerks

                if(fDeltaTime > 0.2f)
                {
                    fDeltaTime = nFixedDelta ? nFixedDelta/1000.0f : 0.01f;
                }

                // Update time counter returned Timer_GetTime

                fTime += fDeltaTime;

                // Store current time for the next frame
                // and count FPS

                t0=timeGetTime();
                if(t0-t0fps <= 1000) cfps++;
                else
                {
                    nFPS=cfps; cfps=0; t0fps=t0;
                    _UpdatePowerStatus();
                }

                // Do user's stuff

                if(procFrameFunc()) break;
                if(procRenderFunc) procRenderFunc();
                
                // If if "child mode" - return after processing single frame

                if(hwndParent) break;

                // Clean up input events that were generated by
                // WindowProc and weren't handled by user's code

                _ClearQueue();

                // If we use VSYNC - we could afford a little
                // sleep to lower CPU usage

                // if(!bWindowed && nHGEFPS==HGEFPS_VSYNC) Sleep(1);
            }
fps

 

 Timer_GetTime()

  返回一个游戏已经运行的时间。

float CALL GEImpl::Timer_GetTime()
{
    return fTime;
} 

 

 Timer_GetDelta()

  返回时间间隔。

float CALL GEImpl::Timer_GetDelta()
{
    return fDeltaTime;
} 

 

 Timer_GetFPS()

  返回fps。

int CALL GEImpl::Timer_GetFPS()
{
    return nFPS;
} 

 

转载于:https://www.cnblogs.com/yoru/p/5515331.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值