This commit is contained in:
Hartmut Seichter 2023-07-01 10:20:24 +02:00
parent 0eebe25ea9
commit b6691561e8
7 changed files with 58 additions and 51 deletions

View file

@ -38,8 +38,8 @@ struct RGBA final {
static constexpr RGBA from_rgba(uint8_t red, uint8_t green, uint8_t blue,
uint8_t alpha) noexcept {
return {.pixel =
(value_type)(((((red << 8) | green) << 8) | blue) << 8) |
alpha};
(value_type)(((((alpha << 8) | blue) << 8) | green) << 8) |
red};
}
constexpr void to_float(float rgba_f[4]) const noexcept {
@ -58,7 +58,10 @@ struct RGBA final {
constexpr uint8_t blue() const noexcept {
return uint8_t((pixel & 0xFF00) >> 8);
}
constexpr uint8_t alpha() const noexcept { return uint8_t(pixel & 0xFF); }
constexpr uint8_t alpha() const noexcept {
return uint8_t(pixel & 0xFF);
}
constexpr RGBA& set_red(uint8_t v) noexcept {
pixel = (pixel & 0x00FFFFFF) | (v << 24);

View file

@ -30,6 +30,13 @@
namespace paradiso {
// 0 3 | y
// +------+ | ^
// | \ | | -- + - > x
// | \ | | / |
// +------+ | z
// 1 2 |
struct Sprite final {
using ChangeCountType = std::uint64_t;
@ -39,7 +46,7 @@ struct Sprite final {
Vector2<float> pivot{Vector2<float>::zero()};
std::array<std::uint32_t, 6> indices{0, 3, 2, 2, 1, 0};
std::array<std::uint32_t, 6> indices{0, 2, 1, 0, 3, 2};
std::array<Vector3<float>, 4> vertices{
Vector3<float>::make(-1.0f, -1.0f, 0.0f),
@ -52,10 +59,10 @@ struct Sprite final {
Vector3<float>::z_axis(), Vector3<float>::z_axis()};
std::array<Vector2<float>, 4> texture_coordinates{
Vector2<float>::make(0.0f, 0.0f), /// 0
Vector2<float>::make(0.0f, 1.0f), /// 1
Vector2<float>::make(1.0f, 1.0f), /// 2
Vector2<float>::make(1.0f, 0.0f) /// 3
Vector2<float>::make(0.0f, 0.0f),
Vector2<float>::make(1.0f, 0.0f),
Vector2<float>::make(1.0f, 1.0f),
Vector2<float>::make(0.0f, 1.0f)
};
ChangeCountType change_count{};