zoukankan      html  css  js  c++  java
  • 基于时间的渲染框架

    下面是一个基于时间的渲染框架

    代码
     1 // Get last time
     2 static float lastTime = (float)timeGetTime();
     3 
     4 while (msg.message != WM_QUIT)  
     5 {
     6     if( PeekMessage(&msg, NULL, 0U0U, PM_REMOVE) != 0)
     7     {
     8         TranslateMessage (&msg) ;
     9         DispatchMessage (&msg) ;
    10     }
    11     else // Render the game if there is no message to process
    12     {
    13         // Get current time
    14         float currTime  = (float)timeGetTime();
    15 
    16         // Calculate time elapsed
    17         float timeDelta = (currTime - lastTime)*0.001f;
    18 
    19         // Render
    20         Render(timeDelta) ;
    21 
    22         // Update last time to current time for next loop
    23         lastTime = currTime;
    24     }
    25 }
    26 

    这样,在Render函数中就可以调用各种对象的渲染函数了,所有这些函数都有一个时间参数,用来求速度,加速度,位移等,比如粒子系统,摄像机,地形等等渲染

  • 相关阅读:
    HDU 2509 nim博弈
    HDU 1907 nim博弈变形
    HDU 1568 double 快速幂
    HDU 5950 矩阵快速幂
    HDU 1796 容斥原理
    Linux raid信息 查看
    Linux Ubuntu 内核升级
    Ubuntu 14.04 为 root 帐号开启 SSH 登录
    Google 分布式关系型数据库 F1
    分布式事务实现-Spanner
  • 原文地址:https://www.cnblogs.com/graphics/p/1681458.html
Copyright © 2011-2022 走看看