dx中的BeginScene/EndScene

下面是msdn上的解释

Applications notify Microsoft® Direct3D® Mobile that scene rendering is about to begin by calling the IDirect3DMobileDevice::BeginScene method. BeginScene causes the system to check its internal data structures and the availability and validity of rendering surfaces. It also sets an internal flag to signal that a scene is in progress. After you begin a scene, you can call the various rendering methods to render the primitives or individual vertices that make up the objects in the scene. Attempts to call rendering methods when a scene is not in progress fail. For more information, see Rendering Primitives.

After you complete the scene, call the IDirect3DMobileDevice::EndScene method. The EndScene method flushes cached data, verifies the integrity of rendering surfaces, and clears an internal flag that signals when a scene is in progress.

All rendering methods must be bracketed by calls to the BeginScene and EndScene methods. If surfaces are lost or internal errors occur, the scene methods return error values. If BeginScene fails, the scene does not begin, and subsequent calls to EndScene will fail.

To summarize these cases:

  • If BeginScene returns any error, you must not call EndScene because the scene has not successfully begun.
  • If BeginScene succeeds, but you get an error while rendering the scene, you must call EndScene.
  • If EndScene fails, for any reason, you need not call it again.

For example, some simple scene code might look like the following example.

  1: HRESULT hr;
  2: 
  3: if(SUCCEEDED(pDevice->BeginScene()))
  4: {
  5:     // Render primitives only if the scene
  6:     // starts successfully.
  7:     
  8:     // Close the scene.
  9:     hr = pDevice->EndScene(); 
 10:     if(FAILED(hr))
 11:         return hr;
 12: }

You cannot embed scenes; that is, you must complete rendering a scene before you can begin another one. Calling EndScene when BeginScene has not been called returns an error value. Likewise, calling BeginScene when a previous scene has not been completed with the EndScene method results in an error.


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值