summaryrefslogtreecommitdiffhomepage
path: root/loader/error-tex.cpp
blob: c3a0a58bf2143421b104444310bc7887d1a75854 (plain)
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
#include "impl.hpp"
#include "compat/assert.hpp"
#include <Corrade/Containers/Array.h>
#include <Magnum/Math/Vector4.h>
#include <Magnum/PixelFormat.h>
#include <Magnum/Trade/ImageData.h>

namespace floormat::loader_detail {

Trade::ImageData2D loader_impl::make_error_texture(Vector2ui size)
{
    fm_assert(size.product() != 0);
    constexpr auto magenta = Vector4ub{255, 0, 255, 255};
    auto array = Array<char>{NoInit, 4 * size.product()};
    auto data = array.data(), end = data + array.size();
    while (data != end)
    {
        *(Vector4ub*)data = magenta;
        data += 4;
    }
    auto img = Trade::ImageData2D{PixelFormat::RGBA8Unorm, Vector2i(size), std::move(array)};
    return img;
}

} // namespace floormat::loader_detail