You.i Engine
CYIRenderTarget Class Reference

Detailed Description

Defines a target for the rendering results to be sent to.

Screen and Offscreen types are supported and can be created using the factory methods in this class.

User will define a render target with its type and dimensions. In most cases, this will be handled during the AE import process.

After a render target object is created, it is attached to a CYISceneNode.The root of any composition imported from AE will automatically be given a render target.

For an offscreen target, even though it would be possible to calculate target dimensions based on the union of the bounding boxes of the children, it is better to set it directly by the specified AE composition size. Once this target is created, its dimensions will not change.

Users can also request the target buffer area to be cleared by setting the CLEAR attribute and the color to use. When this attribute is set, as soon as we switch to this new target, the contents of that target are cleared before rendering anything else into it.

At a high level, here is how the rendering process will look like :

  • Traverse the scene tree.
  • Upon hitting a render target, get the new viewport / target information and configure the renderer with this information.
  • all the children will rendered into this new target

    See also
    CYIOffscreenRenderTarget
    CYIScreenRenderTarget

#include <renderer/YiRenderTarget.h>

Inheritance diagram for CYIRenderTarget:

Public Types

enum  Attribute {
  Attribute::None = 0x00,
  Attribute::ClearColorBuffer = 0x01,
  Attribute::ClearDepthBuffer = 0x02,
  Attribute::ClearAll = ClearColorBuffer | ClearDepthBuffer
}
 
enum  Type {
  Type::Screen = 1,
  Type::OffscreenColorOnly,
  Type::OffscreenDepthOnly,
  Type::OffscreenColorAndDepth
}
 

Public Member Functions

virtual ~CYIRenderTarget ()
 
void SetViewport (const CYIViewport &viewport)
 
const CYIViewportGetViewport () const
 
std::shared_ptr< IYIGPUObjectGetFramebuffer () const
 
std::shared_ptr< CYIAssetFramebufferGetFramebufferAsset () const
 
Type GetTargetType () const
 
void SetDeviceHorizontalPixelRatio (float devicePixelRatio)
 
void SetDeviceVerticalPixelRatio (float devicePixelRatio)
 
void SetDeviceDiagonalPixelRatio (float devicePixelRatio)
 
float GetDeviceHorizontalPixelRatio () const
 
float GetDeviceVerticalPixelRatio () const
 
float GetDeviceDiagonalPixelRatio () const
 
void SetClearColor (const CYIColor &clearColor)
 
const CYIColorGetClearColor () const
 
void SetAttribute (Attribute attribute, bool value)
 
bool GetAttribute (Attribute attribute) const
 

Static Public Member Functions

static std::unique_ptr< CYIScreenRenderTargetCreateScreenTarget (const CYIViewport &viewport)
 
static std::unique_ptr< CYIOffscreenRenderTargetCreateOffscreenTarget (Type targetType, uint32_t targetWidth, uint32_t targetHeight)
 

Protected Member Functions

 CYIRenderTarget ()
 

Protected Attributes

std::shared_ptr< CYIAssetFramebufferm_pFramebuffer
 

Friends

class CYISceneBuilder
 

Member Enumeration Documentation

◆ Attribute

Enumerator
None 
ClearColorBuffer 
ClearDepthBuffer 
ClearAll 

◆ Type

enum CYIRenderTarget::Type
strong

Specifies the different types of Render Targets supported

Enumerator
Screen 

Rendering results are sent to the Display Back Buffer.

OffscreenColorOnly 

Rendering results are sent to an offscreen Buffer in GPU memory, no depth info.

OffscreenDepthOnly 

Rendering results are sent to an offscreen Buffer in GPU memory, no color info.

OffscreenColorAndDepth 

Rendering results are sent to an offscreen Buffer in GPU memory, both depth and color info.

Constructor & Destructor Documentation

◆ ~CYIRenderTarget()

virtual CYIRenderTarget::~CYIRenderTarget ( )
virtual

◆ CYIRenderTarget()

CYIRenderTarget::CYIRenderTarget ( )
protected

Member Function Documentation

◆ CreateOffscreenTarget()

static std::unique_ptr<CYIOffscreenRenderTarget> CYIRenderTarget::CreateOffscreenTarget ( Type  targetType,
uint32_t  targetWidth,
uint32_t  targetHeight 
)
static

Creates a new offscreen render target with type targetType. Initializes the target size to targetWidth and targetHeight. The viewport will be initialized to (0, 0, targetWidth, targetHeight).

Note
targetType must be one of the offscreen target types.
Deprecated:
This function is deprecated and will be removed in a future release, please use CYISceneBuilder::CreateOffscreenRenderTarget instead.
See also
CYISceneBuilder::CreateOffscreenRenderTarget

◆ CreateScreenTarget()

static std::unique_ptr<CYIScreenRenderTarget> CYIRenderTarget::CreateScreenTarget ( const CYIViewport viewport)
static

Creates a new screen render target and initializes it with viewport. To initialize the viewport, users should query the dimensions of the screen using GetSurface()->GetWidth(), GetSurface()->GetHeight()

Deprecated:
This function is deprecated and will be removed in a future release, please use CYISceneBuilder::CreateScreenRenderTarget instead.
See also
CYISceneBuilder::CreateScreenRenderTarget

◆ GetAttribute()

bool CYIRenderTarget::GetAttribute ( Attribute  attribute) const

◆ GetClearColor()

const CYIColor& CYIRenderTarget::GetClearColor ( ) const

Returns the color to use for clearing the background.

◆ GetDeviceDiagonalPixelRatio()

float CYIRenderTarget::GetDeviceDiagonalPixelRatio ( ) const

Get the device diagonal pixel ratio. Using the After Effects workflow, this value will represent the ratio between the designed scene dimensions and the application's surface dimensions.

For instance, a composition designed for 2048 x 1536 but rendered on a 1024 x 768 screen will have a horizontal pixel ratio of 0.5

◆ GetDeviceHorizontalPixelRatio()

float CYIRenderTarget::GetDeviceHorizontalPixelRatio ( ) const

Get the device horizontal pixel ratio. Using the After Effects workflow, this value will represent the ratio between the designed scene dimensions and the application's surface dimensions.

For instance, a composition designed for 2048 x 1536 but rendered on a 1024 x 768 screen will have a horizontal pixel ratio of 0.5

◆ GetDeviceVerticalPixelRatio()

float CYIRenderTarget::GetDeviceVerticalPixelRatio ( ) const

Get the device vertical pixel ratio. Using the After Effects workflow, this value will represent the ratio between the designed scene dimensions and the application's surface dimensions.

For instance, a composition designed for 2048 x 1536 but rendered on a 1024 x 768 screen will have a horizontal pixel ratio of 0.5

◆ GetFramebuffer()

std::shared_ptr<IYIGPUObject> CYIRenderTarget::GetFramebuffer ( ) const

Returns the framebuffer object for this render target.

◆ GetFramebufferAsset()

std::shared_ptr<CYIAssetFramebuffer> CYIRenderTarget::GetFramebufferAsset ( ) const

Returns the asset that backs this render target's frame buffer object.

◆ GetTargetType()

Type CYIRenderTarget::GetTargetType ( ) const

Returns the Render target buffer type.

◆ GetViewport()

const CYIViewport& CYIRenderTarget::GetViewport ( ) const

Returns the viewport.

◆ SetAttribute()

void CYIRenderTarget::SetAttribute ( Attribute  attribute,
bool  value 
)
See also
Attribute

◆ SetClearColor()

void CYIRenderTarget::SetClearColor ( const CYIColor clearColor)

Sets the color to use for clearing the background.

◆ SetDeviceDiagonalPixelRatio()

void CYIRenderTarget::SetDeviceDiagonalPixelRatio ( float  devicePixelRatio)

Set the device diagonal pixel ratio. Using the After Effects workflow, this value will represent the ratio between the designed scene dimensions and the application's surface dimensions.

For instance, a composition designed for 2048 x 1536 but rendered on a 1024 x 768 screen will have a horizontal pixel ratio of 0.5

◆ SetDeviceHorizontalPixelRatio()

void CYIRenderTarget::SetDeviceHorizontalPixelRatio ( float  devicePixelRatio)

Set the device horizontal pixel ratio. Using the After Effects workflow, this value will represent the ratio between the designed scene dimensions and the application's surface dimensions.

For instance, a composition designed for 2048 x 1536 but rendered on a 1024 x 768 screen will have a horizontal pixel ratio of 0.5

◆ SetDeviceVerticalPixelRatio()

void CYIRenderTarget::SetDeviceVerticalPixelRatio ( float  devicePixelRatio)

Set the device vertical pixel ratio Using the After Effects workflow, this value will represent the ratio between the designed scene dimensions and the application's surface dimensions.

For instance, a composition designed for 2048 x 1536 but rendered on a 1024 x 768 screen will have a vertical pixel ratio of 0.5

◆ SetViewport()

void CYIRenderTarget::SetViewport ( const CYIViewport viewport)

Sets the viewport. Values here are relative to the dimensions of where the rendering will happen. In case of a Screen target, users should query the dimensions of the screen using GetSurface()->GetWidth(), GetSurface()->GetHeight() and set an appropriate viewport. For an Offscreen target, viewport can be automatically set by using the information specified in the CreateOffscreenTarget() call since the FBO dimensions will match the dimension supplied in this call.

Friends And Related Function Documentation

◆ CYISceneBuilder

friend class CYISceneBuilder
friend

Member Data Documentation

◆ m_pFramebuffer

std::shared_ptr<CYIAssetFramebuffer> CYIRenderTarget::m_pFramebuffer
protected

The documentation for this class was generated from the following file: