Loading...
Searching...
No Matches
RenderedISFSamplerUtils.hpp
1#pragma once
2#include <Gfx/Graph/RenderList.hpp>
3#include <Gfx/Graph/RenderedISFUtils.hpp>
4
5#include <score/tools/Debug.hpp>
6
7namespace score::gfx
8{
9
10namespace detail
11{
12inline QRhiSampler::Filter parseAudioFilter(const std::string& s)
13{
14 if(s.empty()) return QRhiSampler::Linear;
15 std::string v = s;
16 for(auto& c : v) c = (char)tolower(c);
17 if(v == "nearest") return QRhiSampler::Nearest;
18 return QRhiSampler::Linear;
19}
20inline QRhiSampler::AddressMode parseAudioWrap(const std::string& s)
21{
22 if(s.empty()) return QRhiSampler::ClampToEdge;
23 std::string v = s;
24 for(auto& c : v) c = (char)tolower(c);
25 for(auto& c : v) if(c == '-') c = '_';
26 if(v == "repeat") return QRhiSampler::Repeat;
27 if(v == "mirror" || v == "mirrored_repeat") return QRhiSampler::Mirror;
28 return QRhiSampler::ClampToEdge;
29}
30}
31
32inline std::vector<Sampler>
33initAudioTextures(RenderList& renderer, std::list<AudioTexture>& textures)
34{
35 std::vector<Sampler> samplers;
36 QRhi& rhi = *renderer.state.rhi;
37 for(auto& texture : textures)
38 {
39 const auto filter = detail::parseAudioFilter(texture.filter);
40 const auto wrap = detail::parseAudioWrap(texture.wrap);
41 auto sampler = rhi.newSampler(
42 filter, filter, QRhiSampler::None, wrap, wrap);
43 sampler->setName("ISFNode::initAudioTextures::sampler");
44 sampler->create();
45
46 samplers.push_back({sampler, nullptr});
47 texture.samplers[&renderer] = {sampler, nullptr};
48 }
49 return samplers;
50}
51
52}
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11