Loading...
Searching...
No Matches
TextureKind.hpp
1#pragma once
2#include <QSize>
3#include <QString>
4
5#include <score_plugin_gfx_export.h>
6
7#include <cstdint>
8
9class QRhi;
10class QRhiTexture;
11
12namespace score::gfx
13{
19enum class TextureKind : uint8_t
20{
21 Texture2D,
22 Texture3D,
23 Array,
24 Cube
25};
26inline constexpr int texture_kind_count = 4;
27
30struct SCORE_PLUGIN_GFX_EXPORT TextureShape
31{
32 TextureKind kind{TextureKind::Texture2D};
33 int width{};
34 int height{};
35 int layers{1};
36
37 static TextureShape of(const QRhiTexture& tex) noexcept;
38
39 bool empty() const noexcept { return width <= 0 || height <= 0; }
40
42 uint64_t pack() const noexcept;
43 static TextureShape unpack(uint64_t v) noexcept;
44
46 QString description() const;
48 QString layerName(int layer) const;
49
50 bool operator==(const TextureShape&) const noexcept = default;
51};
52
57enum class TextureLayout : uint8_t
58{
59 Single,
60 Overview
61};
62
76struct SCORE_PLUGIN_GFX_EXPORT ShownTexture
77{
78 static constexpr int max_tiles = 16;
79
80 TextureShape shape;
81 TextureLayout layout{TextureLayout::Single};
83 int index{};
84
87 static ShownTexture
88 of(TextureShape shape, TextureLayout layout, double slice, int layer) noexcept;
89
91 bool layered() const noexcept { return shape.kind != TextureKind::Texture2D; }
92 bool overview() const noexcept
93 {
94 return layered() && layout == TextureLayout::Overview;
95 }
96
98 int tiles() const noexcept;
99 int columns() const noexcept;
100 int rows() const noexcept;
102 int tileLayer(int i) const noexcept;
103
105 QSize size(int max_side) const noexcept;
106
109 struct Point
110 {
111 int layer{-1};
112 double u{}, v{};
113 };
115 Point locate(double u, double v) const noexcept;
116};
117
134SCORE_PLUGIN_GFX_EXPORT
135QString shownTextureGlsl(TextureKind kind, int binding, const char* name = "inTex");
136}
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
QString shownTextureGlsl(TextureKind kind, int binding, const char *name)
Definition TextureKind.cpp:179
TextureKind
Definition TextureKind.hpp:20
TextureLayout
Definition TextureKind.hpp:58
Definition TextureKind.hpp:110
Definition TextureKind.hpp:77
bool layered() const noexcept
Whether there is more than one image to lay out.
Definition TextureKind.hpp:91
Definition TextureKind.hpp:31