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 :
all the children will rendered into this new target
#include <renderer/YiRenderTarget.h>
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 CYIViewport & | GetViewport () const |
std::shared_ptr< IYIGPUObject > | GetFramebuffer () const |
std::shared_ptr< CYIAssetFramebuffer > | GetFramebufferAsset () 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 CYIColor & | GetClearColor () const |
void | SetAttribute (Attribute attribute, bool value) |
bool | GetAttribute (Attribute attribute) const |
Static Public Member Functions | |
static std::unique_ptr< CYIScreenRenderTarget > | CreateScreenTarget (const CYIViewport &viewport) |
static std::unique_ptr< CYIOffscreenRenderTarget > | CreateOffscreenTarget (Type targetType, uint32_t targetWidth, uint32_t targetHeight) |
Protected Member Functions | |
CYIRenderTarget () | |
Protected Attributes | |
std::shared_ptr< CYIAssetFramebuffer > | m_pFramebuffer |
Friends | |
class | CYISceneBuilder |
|
strong |
|
strong |
Specifies the different types of Render Targets supported
|
virtual |
|
protected |
|
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).
|
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()
bool CYIRenderTarget::GetAttribute | ( | Attribute | attribute | ) | const |
const CYIColor& CYIRenderTarget::GetClearColor | ( | ) | const |
Returns the color to use for clearing the background.
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
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
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
std::shared_ptr<IYIGPUObject> CYIRenderTarget::GetFramebuffer | ( | ) | const |
Returns the framebuffer object for this render target.
std::shared_ptr<CYIAssetFramebuffer> CYIRenderTarget::GetFramebufferAsset | ( | ) | const |
Returns the asset that backs this render target's frame buffer object.
Type CYIRenderTarget::GetTargetType | ( | ) | const |
Returns the Render target buffer type.
const CYIViewport& CYIRenderTarget::GetViewport | ( | ) | const |
Returns the viewport.
void CYIRenderTarget::SetClearColor | ( | const CYIColor & | clearColor | ) |
Sets the color to use for clearing the background.
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
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
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
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.
|
friend |
|
protected |