Polyphase Game Engine
Loading...
Searching...
No Matches
TextureAtlasUtil.h
Go to the documentation of this file.
1#pragma once
2
3#include "PolyphaseAPI.h"
4#include "glm/glm.hpp"
5
6#include <cstdint>
7
8// Compute the [u0,v0]..[u1,v1] UV rectangle for a single cell in a regular grid
9// atlas, in [0,1] texture space. The grid is described by:
10// cols, rows — number of columns / rows in the atlas
11// cellW, cellH — pixel size of one cell
12// marginX, marginY — pixel margin around the entire grid (left/top edge)
13// spacingX, spacingY — pixel spacing between adjacent cells
14// cellIndex — row-major cell index (0 = top-left)
15// texW, texH — texture pixel dimensions
16//
17// Returns false if cellIndex is out of range or any dimension is non-positive.
18// outUV0/outUV1 are unmodified on failure.
19//
20// Used by TileSet (TileSet.cpp) and SpriteAnimation (atlas mode) so they share
21// one source of truth for the math.
23 int32_t cols,
24 int32_t rows,
25 int32_t cellW,
26 int32_t cellH,
27 int32_t marginX,
28 int32_t marginY,
29 int32_t spacingX,
30 int32_t spacingY,
31 int32_t cellIndex,
32 int32_t texW,
33 int32_t texH,
34 glm::vec2& outUV0,
35 glm::vec2& outUV1);
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
POLYPHASE_API bool ComputeAtlasCellUV(int32_t cols, int32_t rows, int32_t cellW, int32_t cellH, int32_t marginX, int32_t marginY, int32_t spacingX, int32_t spacingY, int32_t cellIndex, int32_t texW, int32_t texH, glm::vec2 &outUV0, glm::vec2 &outUV1)
Definition TextureAtlasUtil.cpp:3