NAP
nap
system_modules
napvideo
src
rendervideocomponent.h
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5
#pragma once
6
7
// Local Includes
8
#include "videoplayer.h"
9
10
// External Includes
11
#include <component.h>
12
#include <rendercomponent.h>
13
#include <nap/resourceptr.h>
14
#include <rendertexture2d.h>
15
#include <planemesh.h>
16
#include <rendertarget.h>
17
#include <color.h>
18
#include <materialinstance.h>
19
#include <renderablemesh.h>
20
21
namespace
nap
22
{
23
// Forward Declares
24
class
RenderVideoComponentInstance;
25
34
class
NAPAPI
RenderVideoComponent
:
public
RenderableComponent
35
{
36
RTTI_ENABLE(
RenderableComponent
)
37
DECLARE_COMPONENT(
RenderVideoComponent
,
RenderVideoComponentInstance
)
38
public
:
39
ResourcePtr<VideoPlayer>
mVideoPlayer =
nullptr
;
40
ResourcePtr<RenderTexture2D>
mOutputTexture =
nullptr
;
41
ERasterizationSamples
mRequestedSamples =
ERasterizationSamples::One
;
42
RGBAColor8
mClearColor = { 255, 255, 255, 255 };
43
};
44
45
54
class
NAPAPI
RenderVideoComponentInstance
:
public
RenderableComponentInstance
55
{
56
RTTI_ENABLE(
RenderableComponentInstance
)
57
public
:
58
RenderVideoComponentInstance
(
EntityInstance
& entity,
Component
& resource);
59
65
virtual
bool
init(
utility::ErrorState
& errorState)
override
;
66
70
virtual
bool
isSupported(
nap::CameraComponentInstance
& camera)
const override
;
71
76
Texture2D
& getOutputTexture();
77
86
void
draw();
87
88
protected
:
97
virtual
void
onDraw(
IRenderTarget
& renderTarget, VkCommandBuffer commandBuffer,
const
glm::mat4& viewMatrix,
const
glm::mat4& projectionMatrix)
override
;
98
99
private
:
100
VideoPlayer
* mPlayer =
nullptr
;
101
RenderTexture2D
* mOutputTexture =
nullptr
;
102
RGBColorFloat
mClearColor = { 0.0f, 0.0f, 0.0f };
103
RenderTarget
mTarget;
104
PlaneMesh
mPlane;
105
MaterialInstance
mMaterialInstance;
106
MaterialInstanceResource
mMaterialInstanceResource;
107
RenderableMesh
mRenderableMesh;
108
RenderService
* mRenderService =
nullptr
;
109
UniformMat4Instance
* mModelMatrixUniform =
nullptr
;
110
UniformMat4Instance
* mProjectMatrixUniform =
nullptr
;
111
UniformMat4Instance
* mViewMatrixUniform =
nullptr
;
112
UniformStructInstance
* mMVPStruct =
nullptr
;
113
Sampler2DInstance
* mYSampler =
nullptr
;
114
Sampler2DInstance
* mUSampler =
nullptr
;
115
Sampler2DInstance
* mVSampler =
nullptr
;
116
glm::mat4x4 mModelMatrix;
117
bool
mDirty =
true
;
118
123
UniformMat4Instance
* ensureUniform(
const
std::string& uniformName,
utility::ErrorState
& error);
124
129
Sampler2DInstance
* ensureSampler(
const
std::string& samplerName,
utility::ErrorState
& error);
130
136
void
videoChanged(
VideoPlayer
& player);
137
138
// Called when video selection changes
139
nap::Slot<VideoPlayer&>
mVideoChangedSlot = {
this
, &RenderVideoComponentInstance::videoChanged };
140
};
141
}
nap::RenderableComponentInstance
Definition:
rendercomponent.h:46
nap::IRenderTarget
Definition:
irendertarget.h:21
nap::RGBColor< float >
nap::ERasterizationSamples::One
@ One
nap::ERasterizationSamples
ERasterizationSamples
Definition:
renderutils.h:25
nap::Slot
Definition:
signalslot.h:21
nap::RenderVideoComponent
Definition:
rendervideocomponent.h:34
nap::RGBAColor< uint8 >
nap::CameraComponentInstance
Definition:
cameracomponent.h:38
nap::rtti::ObjectPtr
Definition:
objectptr.h:154
nap::RenderVideoComponentInstance
Definition:
rendervideocomponent.h:54
nap::utility::ErrorState
Definition:
errorstate.h:19
nap::Texture2D
Definition:
texture.h:128
nap::RenderService
Definition:
renderservice.h:275
nap::EntityInstance
Definition:
entity.h:34
nap::RenderableComponent
Definition:
rendercomponent.h:29
nap::Component
Definition:
component.h:151
nap::RenderableMesh
Definition:
renderablemesh.h:22
nap::MaterialInstance
Definition:
materialinstance.h:297
nap::RenderTarget
Definition:
rendertarget.h:53
nap::VideoPlayer
Definition:
videoplayer.h:58
nap
Definition:
templateapp.h:17
nap::UniformStructInstance
Definition:
uniforminstance.h:53
nap::TypedUniformValueInstance
Definition:
uniforminstance.h:243
nap::Sampler2DInstance
Definition:
samplerinstance.h:93
nap::PlaneMesh
Definition:
planemesh.h:26
nap::MaterialInstanceResource
Definition:
materialinstance.h:68
nap::RenderTexture2D
Definition:
rendertexture2d.h:24
Generated by doxygen