NiRenderClick

来源:互联网 发布:韩语自学教材知乎 编辑:程序博客网 时间:2024/05/16 00:32
 

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 结束时调用。

原创粉丝点击