NAP
Public Types | Public Attributes | List of all members
RenderToWindowComponent Class Reference

#include <rendertowindowcomponent.h>

Public Types

enum  EScaleMode : uint8 { Window = 0, Square = 1, Custom = 2 }
 

Public Attributes

ResourcePtr< RenderWindowmWindow = nullptr
 Property: 'Window' the window target. More...
 
MaterialInstanceResource mMaterialInstanceResource
 Property: 'MaterialInstance' material instance. More...
 
EScaleMode mMode = EScaleMode::Window
 Property: 'ScaleMode' canvas scaling method. More...
 
glm::vec2 mRatio = { 1.0f, 1.0f }
 Property: 'Ratio' ratio to use when mode is set to 'Custom'. More...
 
- Public Attributes inherited from RenderableComponent
bool mVisible = true
 Property: 'Visible' if this object is rendered to target by the render service. More...
 
ResourcePtr< RenderLayermLayer
 Property: 'Layer' the render layer assigned to this component. More...
 
std::vector< ResourcePtr< RenderTag > > mTags
 Property: 'Tags' List of tags specifying the category this render component belongs to. 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

- Public Member Functions inherited from Component
virtual void getDependentComponents (std::vector< rtti::TypeInfo > &components) const
 
virtual const rtti::TypeInfo getInstanceType () const =0
 
- 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
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Renders a plane directly to a window using a custom material, centering and scaling it based on the selected mode. Use this component to, for example, present the output of a render-pass to screen.

Simply declare the component in json and call RenderToWindowComponent::draw() in the render part of your application. This component manages its own nap::PlaneMesh to render with, you only have to provide it with a material.

This component expects a material with a shader that contains both a model and projection matrix uniform. The view matrix uniform is optional. It will be set if found, otherwise bypassed. If you don't care about view space (camera) transformation, don't declare it.

uniform nap
{
uniform mat4 projectionMatrix;
uniform mat4 modelMatrix;
} mvp;
...
void main(void)
{
gl_Position = mvp.projectionMatrix * mvp.modelMatrix;
}
Inheritance diagram for RenderToWindowComponent:
[legend]
Collaboration diagram for RenderToWindowComponent:
[legend]

Member Enumeration Documentation

◆ EScaleMode

enum EScaleMode : uint8
strong
Enumerator
Window 

Canvas is scaled to fit window.

Square 

Canvas is squared (1:1) and scaled to fit window.

Custom 

Canvas is scaled using the provided 'Ratio' and fit to window.

Member Data Documentation

◆ mMaterialInstanceResource

MaterialInstanceResource mMaterialInstanceResource

Property: 'MaterialInstance' material instance.

◆ mMode

Property: 'ScaleMode' canvas scaling method.

◆ mRatio

glm::vec2 mRatio = { 1.0f, 1.0f }

Property: 'Ratio' ratio to use when mode is set to 'Custom'.

◆ mWindow

ResourcePtr<RenderWindow> mWindow = nullptr

Property: 'Window' the window target.

nap::shader::main
constexpr const char * main
Definition: renderglobals.h:29
nap::uniform::modelMatrix
constexpr const char * modelMatrix
uniform model matrix name
Definition: renderglobals.h:56
nap
Definition: templateapp.h:17
nap::uniform::projectionMatrix
constexpr const char * projectionMatrix
uniform projection matrix name
Definition: renderglobals.h:58