NAP
Public Member Functions | Public Attributes | List of all members
RenderTag Class Reference

#include <rendertag.h>

Public Member Functions

 RenderTag (Core &core)
 
virtual ~RenderTag ()=default
 
virtual bool start (utility::ErrorState &errorState) override
 
virtual void stop () override
 
RenderMask getMask () const
 
RenderMask operator| (const RenderTag &other) const
 
RenderMask operator| (RenderMask other) const
 
 operator RenderMask () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

std::string mName
 Property: 'Name' The tag name. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Render tags can be used to categorize render components. Unlike render layers, tags are unordered and multiple of them can be assigned to a single render component. Each tag resource registers itself in the render service and is assigned a unique tag index on app initialization. This ensures tags can be composited into render masks, which are bit flags that are fast to compare.

One useful example would be to categorize specific components as "Debug", distinguishing objects used as visual aid for debugging purposes from standard objects (tag "Default"). They may be excluded from rendering based on settings or a window setup for instance. You could do the following:

// Consider caching the render mask
auto debug_tag = mResourceManager->findObject("DebugTag");
auto scene_tag = mResourceManager->findObject("SceneTag");
mRenderService->renderObjects(renderTarget, camera, render_comps, debug_tag | scene_tag);
Inheritance diagram for RenderTag:
[legend]
Collaboration diagram for RenderTag:
[legend]

Constructor & Destructor Documentation

◆ RenderTag()

RenderTag ( Core core)

◆ ~RenderTag()

virtual ~RenderTag ( )
virtualdefault

Member Function Documentation

◆ getMask()

RenderMask getMask ( ) const

Returns the mask assigned by the renderer to this tag. The mask can be composited together with masks of other tags to create a unique bit mask:

auto debug_mask = mResourceManager->findObject("DebugTag").getMask();
auto scene_mask = mResourceManager->findObject("SceneTag").getMask();
mRenderService->renderObjects(renderTarget, camera, render_comps, debug_mask | scene_mask);
Returns
the mask assigned to this tag

◆ operator RenderMask()

operator RenderMask ( ) const
Returns
The mask assigned to this tag

◆ operator|() [1/2]

RenderMask operator| ( const RenderTag other) const

Mask inclusion operator: Combines this tag with the given tag.

auto debug_tag = *mResourceManager->findObject("DebugTag");
auto scene_tag = *mResourceManager->findObject("SceneTag");
mRenderService->renderObjects(renderTarget, camera, render_comps, debug_tag | scene_tag);
Parameters
otherthe tag to composite
Returns
the composited mask

◆ operator|() [2/2]

RenderMask operator| ( RenderMask  other) const

Mask inclusion operator: Combines this tag with the given mask.

Parameters
otherthe mask to composite
Returns
the composited mask

◆ start()

virtual bool start ( utility::ErrorState errorState)
overridevirtual

Register the RenderTag with the RenderService

Reimplemented from Device.

◆ stop()

virtual void stop ( )
overridevirtual

Unregister the RenderTag with the RenderService

Reimplemented from Device.

Member Data Documentation

◆ mName

std::string mName

Property: 'Name' The tag name.

nap::RenderService::renderObjects
void renderObjects(IRenderTarget &renderTarget, CameraComponentInstance &camera, RenderMask renderMask=mask::all)