清屏操作
在開始繪製之前,需要通過idirect3ddevice9介面的clear方法將後台緩衝區中的內容進行清空
hresult clear(
[in]dword count,
[in]const d3drect *prects,
[in]dword flags,
[in]d3dcolor color,
[in]float z,
[in]dword stencil );
引數講解:
l dword count:指定了接下來的乙個引數prect指向的矩形陣列中矩形的數量。
l const d3drect *prects:指向乙個d3drect結構體的陣列指標,表明我們要清空的目標矩形區域
l dword flags:指定需要清空的緩衝區。它為d3dclear_stencil,d3dclear_target,d3dclear_zbuffer的任意組合,分別表示模板緩衝區,顏色緩衝區,深度緩衝區
l d3dcolor color:用於指定在清空顏色緩衝區之後每個畫素對應的顏色值
l float z:用於指定清空深度緩衝區後每個畫素對應的深度值
l dword stencil:用於指定清空模板緩衝區之後模板緩衝區每個畫素對應的模板值
開始場景
呼叫idirect3ddevice9::beginscene()
開始繪製
繪製**主要就是根據開發的需求來繪製圖形了
結束場景
呼叫idirect3ddevice9::endscene();
翻轉顯示
hresult present(
[in]const rect *psourcerect,
[in]const rect *pdestrect,
[in]hwnd hdestwindowoverride,
[in]const rgndata *pdirtyregion );
引數賞析
l const rect *psourcerect:表示指向複製源矩形區域的指標
l const rect *pdestrect:表示指向複製目標矩形區域的指標
l hwnd hdestwindowoverride:表示指向當前繪製的視窗控制代碼。如果我們取0或null表示取之前填充的d3dpresent_parameters結構體中的hdevicewindows的值
l const rgndata *pdirtyregion:表示指向最小更新區域的指標
渲染部分**:
hresult
objects_init(
hwnd
hwnd)
void
direct3d_render(
hwnd
hwnd)
void
direct3d_cleanup(
hwnd
hwnd)
float
get_fps()
return
fps;
return
0.0f; }