[nostalgia] Add implementation of single tile sprites on OpenGL

This commit is contained in:
2023-01-03 03:37:51 -06:00
parent cf6c05f4c6
commit bb643bce42
11 changed files with 312 additions and 99 deletions
+17 -10
View File
@@ -120,7 +120,7 @@ struct TileSheet {
}
[[nodiscard]]
auto idx(const geo::Point &pt) const noexcept {
constexpr auto idx(const geo::Point &pt) const noexcept {
return ptToIdx(pt, columns);
}
@@ -275,6 +275,7 @@ struct TileSheet {
* @param pBpp bits per pixel, need for knowing how to count the pixels
* @return a count of the pixels in this sheet
*/
[[nodiscard]]
constexpr auto pixelCnt(int8_t pBpp) const noexcept {
return pBpp == 4 ? pixels.size() * 2 : pixels.size();
}
@@ -287,13 +288,9 @@ struct TileSheet {
SubSheet subsheet{"Root", 1, 1, bpp};
constexpr TileSheet() noexcept = default;
inline TileSheet(const TileSheet &other) noexcept:
bpp(other.bpp),
defaultPalette(other.defaultPalette),
subsheet(other.subsheet) {
}
TileSheet(const TileSheet &other) noexcept = default;
inline TileSheet(TileSheet &&other) noexcept:
bpp(std::move(other.bpp)),
bpp(other.bpp),
defaultPalette(std::move(other.defaultPalette)),
subsheet(std::move(other.subsheet)) {
}
@@ -468,14 +465,24 @@ oxModelEnd()
struct Sprite {
unsigned idx = 0;
unsigned x = 0;
unsigned y = 0;
int x = 0;
int y = 0;
unsigned tileIdx = 0;
unsigned spriteShape = 0;
unsigned spriteSize = 0;
unsigned flipX = 0;
};
oxModelBegin(Sprite)
oxModelField(idx)
oxModelField(x)
oxModelField(y)
oxModelField(tileIdx)
oxModelField(spriteShape)
oxModelField(spriteSize)
oxModelField(flipX)
oxModelEnd()
ox::Error initGfx(Context *ctx) noexcept;
void addCustomDrawer(Context *ctx, Drawer *cd) noexcept;
@@ -526,7 +533,7 @@ void clearTileLayer(Context *ctx, unsigned bgIdx) noexcept;
void hideSprite(Context *ctx, unsigned) noexcept;
void setSprite(Context *ctx, unsigned idx, unsigned x, unsigned y, unsigned tileIdx,
void setSprite(Context *ctx, unsigned idx, int x, int y, unsigned tileIdx,
unsigned spriteShape = 0, unsigned spriteSize = 0, unsigned flipX = 0) noexcept;
void setSprite(Context *ctx, const Sprite &s) noexcept;