-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostProcessBase.cpp
51 lines (43 loc) · 1.66 KB
/
PostProcessBase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "PostProcessBase.h"
vec3 PostProcessBase::vMouseState = vec3();
std::vector<Texture::SharedPtr> PostProcessBase::gRencentFrames = std::vector<Texture::SharedPtr>();
Texture::SharedPtr PostProcessBase::gDepthTexture = nullptr;
void PostProcessBase::loadProgram(SampleCallbacks * Sample, RenderContext * Context, Gui * Gui)
{
bEnable = false;
pSample = Sample;
pContext = Context;
pGui = Gui;
Sampler::Desc samDesc;
samDesc.setAddressingMode(Sampler::AddressMode::Wrap, Sampler::AddressMode::Wrap, Sampler::AddressMode::Wrap);
samDesc.setComparisonMode(Sampler::ComparisonMode::Never);
samDesc.setFilterMode(Sampler::Filter::Linear, Sampler::Filter::Linear, Sampler::Filter::Linear);
pLineWarpSampler = Sampler::create(samDesc);
samDesc.setAddressingMode(Sampler::AddressMode::Border, Sampler::AddressMode::Border, Sampler::AddressMode::Border);
pLineBoardSampler = Sampler::create(samDesc);
}
void PostProcessBase::onGuiRender()
{
pGui->addCheckBox(sName.c_str(), bEnable);
if (bEnable) { gui(); }
}
void PostProcessBase::onFrameRender()
{
if (bEnable)execute();
}
Texture::SharedPtr PostProcessBase::getRecentFrame(uint index)
{
if (index == 0 || index >= gRencentFrames.size()) {
return pContext->getGraphicsState()->getFbo()->getColorTexture(0);
}
return gRencentFrames[HISTORY_FRAME_COUNT - 1 - index];
}
void PostProcessBase::loadImage(std::function<void(const std::string&filename)> f)
{
std::string filename;
FileDialogFilterVec filters = { {"bmp"}, {"jpg"}, {"dds"}, {"png"}, {"tiff"}, {"tif"}, {"tga"},{"gif"} };
if (openFileDialog(filters, filename))
{
f(filename);
}
}