33 using uninitialized_bytes = boost::container::vector<unsigned char>;
37 enum texture_format : uint8_t
60 static constexpr int component_size(texture_format format)
noexcept
97 static constexpr int components(texture_format format)
noexcept
135 int bytes_per_pixel()
const noexcept
137 return component_size(format) * components(format);
139 auto bytesize()
const noexcept {
return bytes_per_pixel() * width * height; }
140 auto component_size()
const noexcept {
return bytes_per_pixel() * width * height; }
142 auto allocate(
int width,
int height)
144 using namespace boost::container;
145 return uninitialized_bytes(bytesize(), default_init);
148 void update(
unsigned char* data,
int w,
int h)
noexcept
159 halp_meta(name,
"Array to texture")
160 halp_meta(category,
"Visuals/Textures")
161 halp_meta(c_name,
"array_to_texture")
162 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/array-to-texture.html")
163 halp_meta(uuid,
"bb5dc513-3430-4671-8c74-2bba78e53709")
167 struct : halp::val_port<
"Input", std::vector<float>>
171 struct : halp::xy_spinboxes_i32<
"Size">
175 struct : halp::enum_t<custom_texture::texture_format,
"Format">
188 const auto format = inputs.format;
189 const auto sz = inputs.size.value;
190 outputs.main.texture.format = format;
191 outputs.main.create(sz.x, sz.y);
192 std::size_t to_copy = sz.x * sz.y * outputs.main.texture.components(format);
193 const auto& value = inputs.in.value;
194 to_copy = std::min(to_copy, value.size());
196 auto* out = outputs.main.texture.bytes;
197 using enum custom_texture::texture_format;
206 std::copy_n(value.data(), to_copy, (uint8_t*)out);
211 std::copy_n(value.data(), to_copy, (uint16_t*)out);
217 std::copy_n(value.data(), to_copy, (uint32_t*)out);
222 std::copy_n(value.data(), to_copy, (
float*)out);
228#if (SCORE_LIBC_HAS_FLOAT16 && SCORE_COMPILER_HAS_FLOAT16)
229 std::copy_n(value.data(), to_copy, (_Float16*)out);
236 outputs.main.upload();
Definition ArrayToBuffer.hpp:157
Definition ArrayToBuffer.hpp:166
Definition ArrayToBuffer.hpp:32