NiRenderClick

 

NiRenderClick

: public NiRefObject

<NiRenderClick.h>

Description

該類是所有render clicks的基類,它提供了一個可以被其派生類重載來實現用戶渲染的PerformRendering 純虛函數接口,NiRenderClick 保有一個指針指向render click的驗證器,一個渲染目標組,一個視口,及清空模式的renderer,這些都在Render 函數裏被用到。另外pre- and post-processing 回調函數也被註冊,在Render 函數的開始和結尾處調用。

構造函數

NiRenderClick()

唯一的構造函數內實現1.把視口viewport 設置爲 (0, 1, 1, 0), 清空模式設置爲NiRenderer::CLEAR_NONE,激活狀態設置爲True,默認名字設置爲"Render Click".它也設置驗證器 和渲染目標組爲NULL,這表明將使用默認的渲染目標組default render target group。

提供的虛函數接口:

virtual unsigned int GetNumObjectsDrawn() const = 0;

virtual float GetCullTime() const = 0;

virtual float GetRenderTime() const = 0;

 virtual void PerformRendering(unsigned int uiFrameID) = 0

這些純虛函數由派生類重載來實現用戶渲染,在Render 函數執行了pre-processing 回調函數後the render target group 渲染目標組需要正確的打開,NiRenderer::GetFrameID可以返回frame ID ;

 void SetName(const NiFixedString& kName)

const NiFixedString& GetName() const

These functions set and get the name of the render click. The name defaults to "Render Click".

void Render(unsigned int uiFrameID)

先調用pre-processing 回調函數,然後爲render target group調用BeginUsingRenderTargetGroup 函數。

只有render target group 還沒有打開時纔會調用BeginUsingRenderTargetGroup ,渲染器將會使用已設置的清除模式來清除緩存.

如果render target group 是激活的,PerformRendering 將會被調用,並通過NiRenderer::GetFrameID函數獲得當前的frame ID ,接着post-processing 函數會被調用。

 bool ShouldPerformRendering(unsigned int uiFrameID)

這個函數是用已設置的render click 驗證器validator 和 render click 的激活狀態來判斷該render click 是否應該被調用渲染。如果不是激活的,則不能被渲染,如果是激活的則還要看驗證器ValidateClick 驗證。

void SetValidator(NiRenderClickValidator* pkValidator)

NiRenderClickValidator* GetValidator() const

設置和獲得click 驗證器,以在ShouldPerformRendering 函數裏調用。

 

 void SetRenderTargetGroup(NiRenderTargetGroup* pkRenderTargetGroup)

NiRenderTargetGroup* GetRenderTargetGroup() const

設置和獲得在rendering函數中使用的render target group

 

void SetClearAllBuffers(bool bClearAllBuffers)

void SetClearColorBuffers(bool bClearBuffers)

bool GetClearColorBuffers() const

void SetClearDepthBuffer(bool bClearBuffer)

bool GetClearDepthBuffer() const

void SetClearStencilBuffer(bool bClearBuffer)

bool GetClearStencilBuffer() const

定義了buffer的清除狀態,當Render 函數裏render target group是激活狀態時 會使用到這些函數來清除buffer。

 

void RequestClearAllBuffersOnce()

void RequestClearColorBuffersOnce()

void RequestClearDepthBufferOnce()

void RequestClearStencilBufferOnce()

這些函數定義的渲染狀態將且僅將在下次調用Render函數時生效。這些函數的任何一個的調用,他們都將重載提供state 的SetClear... 系列函數。

當在全屏效果需要一個特定的邊框值時這些函數會很有用。DX9 設備創建或reset後,顯存將是隨即值。

 

void SetViewport(const NiRect<float>& kViewport)

const NiRect<float>& GetViewport() const

These functions set and get the viewport to use for the render click. Derived classes can make use of this viewport value to render to the appropriate section of the screen.

這些函數設置和獲得渲染render click時的視口。派生類可以利用視口的值正確在屏幕上合適的部位渲染物件。

void SetActive(bool bActive)

bool GetActive() const

設置和獲得target的激活狀態

 

void SetBackgroundColor(const NiColorA& kColor)

void GetBackgroundColor(NiColorA& kColor)

void SetUseRendererBackgroundColor(bool bUseRendererBG)

bool GetUseRendererBackgroundColor()

void SetPersistBackgroundColorToRenderer(bool bPersist)

bool GetPersistBackgroundColorToRenderer()

設置和獲得被清空的render target 顏色。

 

void SetPreProcessingCallbackFunc(Callback pfnCallback, void* pvCallbackData = NULL)

Callback GetPreProcessingCallbackFunc() const

void* GetPreProcessingCallbackFuncData() const

Render 開始時調用。

 

void SetPostProcessingCallbackFunc(Callback pfnCallback, void* pvCallbackData = NULL)

Callback GetPostProcessingCallbackFunc() const

void* GetPostProcessingCallbackFuncData() const

Render 結束時調用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章