NAP
nap
system_modules
naprender
src
snapshot.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 "surfacedescriptor.h"
9
#include "renderservice.h"
10
#include "bitmap.h"
11
#include "bitmapfilebuffer.h"
12
#include "perspcameracomponent.h"
13
14
// External Includes
15
#include <nap/resource.h>
16
#include <nap/core.h>
17
#include <nap/signalslot.h>
18
19
namespace
nap
20
{
21
// Forward Declares
22
class
SnapshotRenderTarget;
23
28
class
NAPAPI
Snapshot
:
public
Resource
29
{
30
friend
class
SnapshotRenderTarget
;
31
RTTI_ENABLE(
Resource
)
32
public
:
33
34
Snapshot
(
Core
& core);
35
40
virtual
bool
init(
utility::ErrorState
& errorState)
override
;
41
46
void
setClearColor(
const
RGBAColorFloat
& color);
47
65
void
snap(
PerspCameraComponentInstance
& camera, std::vector<RenderableComponentInstance*>& comps);
66
67
88
void
snap(
PerspCameraComponentInstance
& camera, std::function<
void
(
nap::SnapshotRenderTarget
&)> renderCallback);
89
94
glm::u32vec2
getSize
() {
return
{ mWidth, mHeight }; };
95
96
uint32
mWidth = 1920;
97
uint32
mHeight = 1080;
98
uint32
mDivisor = 1;
99
RGBAColorFloat
mClearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
100
RenderTexture2D::EFormat
mTextureFormat =
RenderTexture2D::EFormat::RGBA8
;
101
ERasterizationSamples
mRequestedSamples =
ERasterizationSamples::Four
;
102
bool
mSampleShading =
true
;
103
104
std::string mOutputDirectory =
"snapshots"
;
105
BitmapFileBuffer::EImageFileFormat
mImageFileFormat =
BitmapFileBuffer::EImageFileFormat::PNG
;
106
107
// Triggered when a snapshot is being processed
108
nap::Signal<>
onSnapshot
;
109
110
// Triggered when a snapshot is finished being written to disk
111
nap::Signal<std::string>
onSnapshotSaved
;
112
113
protected
:
114
RenderService
* mRenderService =
nullptr
;
115
116
private
:
123
bool
save();
124
nap::Slot<>
mSaveBitmapSlot = { [
this
]() ->
void
{ save(); } };
125
129
void
postSnap();
130
131
uint32
mNumRows = 1;
132
uint32
mNumColumns = 1;
133
134
uint32
mCellWidth = 1920;
135
uint32
mCellHeight = 1080;
136
137
uint32
mNumCells = 0;
138
glm::u32vec2 mCellSize = { 0, 0 };
139
140
std::vector<std::unique_ptr<RenderTexture2D>> mColorTextures;
141
std::unique_ptr<SnapshotRenderTarget> mRenderTarget;
142
143
std::vector<bool> mCellUpdateFlags;
//< List of update flags for each cell
144
nap::Signal<>
onCellsUpdated;
//< Triggered when all cells are updated
145
146
std::unique_ptr<BitmapFileBuffer> mDestBitmapFileBuffer;
//< The destination bitmap file buffer
147
};
148
}
nap::BitmapFileBuffer::EImageFileFormat::PNG
@ PNG
Portable Network Graphics (*.PNG)
nap::BitmapFileBuffer::EImageFileFormat
EImageFileFormat
Definition:
bitmapfilebuffer.h:22
nap::ERasterizationSamples::Four
@ Four
nap::Snapshot::getSize
glm::u32vec2 getSize()
Definition:
snapshot.h:94
nap::ERasterizationSamples
ERasterizationSamples
Definition:
renderutils.h:25
nap::Slot
Definition:
signalslot.h:21
nap::RGBAColor< float >
nap::utility::ErrorState
Definition:
errorstate.h:19
nap::Snapshot
Definition:
snapshot.h:28
nap::RenderTexture2D::EFormat::RGBA8
@ RGBA8
08 bit unsigned, 4 components
nap::Snapshot::onSnapshotSaved
nap::Signal< std::string > onSnapshotSaved
Definition:
snapshot.h:111
nap::uint32
uint32_t uint32
Definition:
numeric.h:20
nap::Signal
Definition:
signalslot.h:28
nap::RenderService
Definition:
renderservice.h:275
nap::Core
Definition:
core.h:82
nap::SnapshotRenderTarget
Definition:
snapshotrendertarget.h:28
nap::PerspCameraComponentInstance
Definition:
perspcameracomponent.h:46
nap
Definition:
templateapp.h:17
nap::Resource
Definition:
resource.h:19
nap::RenderTexture2D::EFormat
EFormat
Definition:
rendertexture2d.h:31
nap::Snapshot::onSnapshot
nap::Signal onSnapshot
Definition:
snapshot.h:108
Generated by doxygen