renderelement2d texture loading

This commit is contained in:
Jorijn van der Graaf 2026-03-10 19:03:39 +01:00
commit 6eb23b88bd
3 changed files with 19 additions and 6 deletions

View file

@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module;
#include "../lib/stb_truetype.h"
export module Crafter.Graphics:RenderingElement2D;
import Crafter.Asset;
import std;
import :Transform2D;
import :Font;
@ -129,6 +130,12 @@ export namespace Crafter {
}
RenderingElement2D(Anchor2D anchor, OpaqueType opaque, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t rotation) requires(Owning && Rotating) : RenderingElement2DBase(anchor, opaque), ScalingBase<Scaling, Owning>(bufferWidth, bufferHeight) , RotatingBase<Rotating>(rotation) {
}
RenderingElement2D(Anchor2D anchor, TextureAsset<Vector<std::uint8_t, 4>> texture) requires(!Owning && Scaling) : RenderingElement2DBase(anchor, texture.opaque), ScalingBase<Scaling, Owning>(texture.sizeX, texture.sizeY, texture.pixels) {
}
RenderingElement2D(Anchor2D anchor, TextureAsset<Vector<std::uint8_t, 4>> texture, std::uint32_t rotation) requires(!Owning && Scaling && Rotating) : RenderingElement2DBase(anchor, texture.opaque), ScalingBase<Scaling, Owning>(texture.sizeX, texture.sizeY, texture.pixels), RotatingBase<Rotating>(rotation) {
}
RenderingElement2D(RenderingElement2D&) = delete;

View file

@ -49,12 +49,6 @@ export namespace Crafter {
std::chrono::duration<double> delta;
};
enum class OpaqueType {
FullyOpaque, // All pixels have A of 255
SemiOpaque, // All pixels have A of 0 or 255 (no blending needed)
Transparent // Color blending is used
};
enum class CrafterKeys {
// Alphabetic keys
A, B, C, D, E, F, G, H, I, J, K, L, M,

View file

@ -97,6 +97,10 @@
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
"configuration":"lib"
},
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
"configuration":"lib"
}
]
},
@ -110,6 +114,10 @@
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
"configuration":"lib"
},
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
"configuration":"lib"
}
],
"defines": [{ "name": "CRAFTER_TIMING" }]
@ -127,6 +135,10 @@
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
"pathh":"/home/jorijn/repos/Crafter/Crafter.Math/project.json",
"configuration":"lib-debug"
},
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
"configuration":"lib-debug"
}
]
},