DirectX框架解析11(DXUT统计函数 DXUT时间函数 DXUT计时器函数)

 

DXUT统计函数

函数 描述
DXUTGetFPS获取当前每秒提交的帧数
DXUTGetFrameStats获取一个指向字符串的指针,该字符串包括每秒帧数、分辨率、后台缓冲区格式、深度缓冲区格式。
DXUTGetDeviceStats获取一个指向字符串的指针,该字符串包括当前设备类型、顶点运算行为和设备名。

 

DXUTGetFPS

Get the current number of frames being presented per second.

 FLOAT DXUTGetFPS() ;
Parameters

None.

Return Values

The current number of frames being presented per second.

 

DXUTGetFrameStats

Get a pointer to a string containing the current number of frames per second (optionally), resolution, back buffer format, and depth stencil format.

 LPCWSTR DXUTGetFrameStats( 
 bool bIncludeFPS 
) ;
Parameters
bIncludeFPS
[in] If true, the string returned will contain the frames per second. Otherwise, it will not.
Return Values

Pointer to a string containing the current number of frames per second (optionally), resolution, back buffer format, and depth stencil format.

 

DXUTGetDeviceStats

Get a pointer to a string containing the current device type, vertex processing behavior, and device name.

 LPCWSTR DXUTGetDeviceStats() ;
Parameters

None.

Return Values

Pointer to a string containing the current device type, vertex processing behavior, and device name.

 

DXUT时间函数

函数 描述
DXUTGetTime获取当前时间(秒)
DXUTGetElapsedTime获取从上一帧到当前帧所经过的时间
DXUTSetConstantFrameTime启用或禁用固定帧时间

 

DXUTGetTime

Get the current time, in seconds.

 DOUBLE DXUTGetTime() ;
Parameters

None.

Return Values

The current time, in seconds.

Remarks

DXUT internally uses the best practices for high resolution timing information as described in the "Game Timing and Multicore Processors" article in the DirectX SDK.

 

DXUTGetElapsedTime

Get the time elapsed since the last frame.

 FLOAT DXUTGetElapsedTime() ;
Parameters

None.

Return Values

Time elapsed, in seconds, since the last frame.

Remarks

DXUT internally uses the best practices for high resolution timing information as described in the "Game Timing and Multicore Processors" article in the DirectX SDK.

 

DXUTSetConstantFrameTime

Enables or disables a constant frame time.

 HRESULT DXUTSetConstantFrameTime( 
 BOOL bEnabled , 
 FLOAT fTimePerFrame 
) ;
Parameters
bEnabled
[in] If TRUE, a constant frame time will be enabled.
fTimePerFrame
[in] Time per frame, in seconds. The default value is 0.0333f, so the fTime parameter of LPDXUTCALLBACKFRAMEMOVE and the render callback functions will advance one second for every 30 frames.
Return Values

If the function succeeds, the return value is S_OK. If the function fails, the return value can be one of the error codes in DXUTERR.

Remarks

This function simulates a fixed-frame rate render loop by sending a constant value for elapsed time to the LPDXUTCALLBACKFRAMEMOVE and render callback functions. The default rate is one second for every 30 frames. The application itself will continue to render at an unregulated rate (which may be far higher than the specified frame rate).

This function is useful for saving the rendered output to a video format for playback, allowing animation at a rate independent of the actual rate at which frames were rendered.

 

DXUT计时器函数

函数 描述
DXUTSetTimer添加一个新的计时器
DXUTKillTimer卸载一个已有的计时器

DXUTSetTimer

Starts a DXUT timer that will trigger a callback function at regular intervals.

 HRESULT DXUTSetTimer( 
 LPDXUTCALLBACKTIMER pCallbackTimer , 
 FLOAT fTimeoutInSecs , 
 UINT * pnIDEvent , 
 void * pCallbackUserContext 
) ;
Parameters
pCallbackTimer
[in] Pointer to a timer callback function. The callback function is to be called at the specified fTimeoutInSecs timeout intervals. May not be NULL.
fTimeoutInSecs
[in] Interval, in seconds, between successive calls to the timer callback function. The default value is 1.0f.
pnIDEvent
[in] Optional pointer to a variable to receive the event ID for the new timer. This event ID will be passed to the timer callback function to indicate which timer generated the event, allowing the application to use a single callback function for multiple timers. The default value is NULL.
pCallbackUserContext
[in] Pointer to a user-defined value which is passed to the callback function. Typically used by an application to pass a pointer to a data structure that provides context information for the callback function. The default value is NULL
Return Values

If the function succeeds, the return value is S_OK. If the function fails, the return value can be one of the error codes in DXUTERR.

Remarks

Timers created with DXUTSetTimer can be destroyed with DXUTKillTimer.

 

LPDXUTCALLBACKTIMER

A timer to be called at specified time intervals by DXUT.

 VOID LPDXUTCALLBACKTIMER( 
 UINT idEvent , 
 void* pUserContext 
) ;
Parameters
idEvent
[in] Specifies a nonzero timer event ID. Indicates which timer generated the event, allowing the application to use a single callback function for multiple timers.
pUserContext
[in] Pointer to a user-defined value which is passed to the callback function. Typically used by an application to pass a pointer to a data structure that provides context information for the callback function. The default value is NULL
Return Values

No return value.

Remarks

DXUT will call this function at the start of the frame, before calling LPDXUTCALLBACKFRAMEMOVE or LPDXUTCALLBACKD3D10FRAMERENDER.

 

DXUTKillTimer

Uninstalls an existing timer.

 HRESULT DXUTKillTimer( 
 UINT nIDEvent 
) ;
Parameters
nIDEvent
[in] The event ID for the timer being destroyed. This ID is provided to the application by the DXUTSetTimer method.
Return Values

If the function succeeds, the return value is S_OK. If the function fails, the return value can be one of the error codes in DXUTERR.

Remarks

Timers created with DXUTSetTimer can be destroyed with DXUTKillTimer .

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DXUT框架剖析 DXUT框架剖析(14) 摘要: 控件是用户接口的重要组成部分,为了便于用户操作,为程序界面添加各种控件是非常好的方法。DXUT框架为在Direct3D程序中添加各种控件提供了支持。为了便于加载控件和处理各控件的消息,通常先在窗口中加载对话框,然后在对话框中添加响应的控件,由对话框来管理控件。为了统一管理各个对话框,还需要定义对话框资源管理器类CDXUTDialogResourceManager的一个对象,在程序开始时,调用各个对话框的Init函数和对话框资源管理对象进行初始化 DXUT框架剖析(13) 摘要: DXUT框架对文本绘制进行了封装,提供了类CDXUTHelper来简化文本显示,使用该接口大体分为3个步骤:初始化ID3DXSprite和ID3DXFont对象,显示文本,释放ID3DXSprite和ID3DXFont对象。 DXUT框架剖析(12) 摘要: DXUT暂停函数DXUTPause:将框架的内部计数器和(或)渲染过程设为暂停状态。 DXUTRenderingPaused:检查当前设备的渲染状态是否处在暂停状态。 DXUTIsTimePaused:检查当前设备的计时器是否处在暂停状态。 DXUT框架剖析(11) 摘要: DXUT统计函数: DXUTGetFPS: 获取当前每秒提交的帧数。 DXUTGetFrameStats:获取一个指向字符串的指针,该字符串包括每秒帧数、分辨率、后台缓冲区格式、深度缓冲区格式。 DXUTGetDeviceStats:获取一个指向字符串的指针,该字符串包括当前设备类型、顶点运算行为和设备名。 DXUT框架剖析(10) 摘要: 管理DXUT框架函数: DXUTResetFrameworkState: 将框架状态重置为初始默认状态,之前设置的框架状态改变将失效。 DXUTShutdown: 触发程序终止和清空框架DXUTGetExitCode: 获取框架的退出代码。 DXUT框架剖析(9) 摘要: 下面列出允许改变DXUT行为和获取内部变量的函数,这些函数在使用DXUT框架的Direct3D程序中是非常实用的。 DXUT框架剖析(8) 摘要: Direct3D API的设计使程序能比较容易地处理各种错误,尽管大多数Direct3D API函数返回HTRSULT值,但只有一部分函数返回设备错误,如D3DERR_DEVICELOST或 D3DERR_DRIVERINTERNALERROR。但是通常的Direct3D应用程序使用多种API函数,当传递的参数不合要求时,将返回 D3DERR_INVALIDCALL。 当开发Direct3D应用程序时,应该检查所有的API调用是否成功,如果出现一个没有预测到的失败调用,应用程序应立即给出通知或记录该错误。使用这种方法,开发人员能很快发现哪些API函数的调用是不正确的。一个正确调用Direct3D API函数的应用程序应能安全地忽略大多数Direct3D API函数的失败调用,除了一些关键性的API函数,如Present()或TestCooperativeLevel(),这些函数返回的错误应用程序不能忽略。 DXUT框架剖析(7) 摘要: 框架也提供了帧事件,它在渲染过程中的每一帧被调用,应用程序应该注册并实现这些回调函数DXUT框架剖析(6) 摘要: 在窗口和设备创建好之后,应用程序需要使用消息循环处理窗口消息、更新和渲染场景、处理设备事件。应用程序可以实现自己的消息循环,也可以使用DXUT消息循环,注册相应的回调函数,可以让DXUT处理设备、帧消息事件。 为使用DXUT框架的消息循环,可以调用DXUTMainLoop()函数. DXUT框架剖析(5) 摘要: 应用程序可以通过DXUTSetCallbackDeviceChanging()设置回调函数来修改Direct3D设备的创建设置。 回调函数ModifyDeviceSettings()返回一个布尔值,如果应用程序返回 TRUE,DXUT框架继续像在正常情况下那样进行设备创建。如果返回FALSE,框架不能改变设备,如果已有一个设备,则继续使用当前设备。如果框架提出的请求是改变到一个应用程序不能使用的设备,应用程序可以拒绝该请求。例如,在一个多显示器配置中,默认情况下在显示器之间拖动窗口将使框架改变设备。但如果应用程序不能使用其他设备,它就必须拒绝这种改变并继续使用当前设备。 DXUT框架剖析(4) 摘要: 通常可以用标准的Direct3D方法Creat

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值