Stardew Engine
Loading...
Searching...
No Matches
Atlas.h
Go to the documentation of this file.
1#ifndef ATLAS_H
2#define ATLAS_H
3
4#include "IntTypes.h"
5#include "HandleDefs.h"
6#include <cglm/cglm.h>
7#include <stdbool.h>
8
9struct DrawContext;
10typedef struct DrawContext DrawContext;
11typedef struct _xmlNode xmlNode;
12struct BinarySerializer;
13
14#define VECTOR(a) a*
15
56
57
58#define MAX_FONT_NAME_SIZE 128
59#define MAX_FONT_PATH_SIZE 256
60
61#define MAX_NUM_FONT_SIZES 32
62
64{
65 VECTOR(hSprite) frames;
66 float fps;
67};
68
69
71{
72 enum
73 {
77 float val;
78};
79
94
95void At_Init();
96void At_BeginAtlas();
97
107hSprite At_AddSprite(const char* imgPath, int topLeftXPx, int topRightYPx, int widthPx, int heightPx, const char* name, bool bMinimizeSpace);
108HFont At_AddFont(const struct FontAtlasAdditionSpec* pFontSpec);
109hAtlas At_EndAtlas(struct DrawContext* pDC);
110
118
119hAtlas At_EndAtlasEx(struct DrawContext* pDC, struct EndAtlasOptions* pOptions);
120void At_DestroyAtlas(hAtlas atlas, struct DrawContext* pDC);
121hSprite At_FindSprite(const char* name, hAtlas atlas);
122AtlasSprite* At_GetSprite(hSprite sprite, hAtlas atlas);
124float At_PixelsToPts(float val);
125hAtlas At_LoadAtlas(xmlNode* child0, struct DrawContext* pDC);
126hAtlas At_LoadAtlasEx(xmlNode* child0, struct DrawContext* pDC, struct EndAtlasOptions* pOptions);
127
129
136void At_SerializeAtlas(struct BinarySerializer* pSerializer, hAtlas* atlas, struct DrawContext* pDC);
137
138void At_BeginTileset(int beginI);
139void At_EndTileset(int endI);
140
141void At_SetCurrent(hAtlas atlas, DrawContext* pDC);
142
143struct AtlasAnimation* At_FindAnim(hAtlas atlas, const char* name);
144
145HFont Fo_FindFont(hAtlas hAtlas, const char* fontName, float sizePts);
146float Fo_CharWidth(hAtlas hAtlas, HFont hFont, char c);
147float Fo_CharHeight(hAtlas hAtlas, HFont hFont, char c);
148float Fo_StringWidth(hAtlas hAtlas, HFont hFont, const char* stringVal);
149
150float Fo_StringHeightSingleLine(hAtlas hAtlas, HFont hFont, const char* stringVal);
151float Fo_StringHeight(hAtlas hAtlas, HFont hFont, const char* stringVal);
153
160float Fo_GetMaxYBearing(hAtlas hAtlas, HFont hFont, const char* str);
161
169float Fo_GetMinYBearing(hAtlas hAtlas, HFont hFont, const char* str);
170
171bool Fo_TryGetCharBearing(hAtlas hAtlas, HFont hFont, char c, vec2 outBearing);
172bool Fo_TryGetCharAdvance(hAtlas hAtlas, HFont hFont, char c, float* outAdvance);
173
174#endif
void At_Init()
Definition Atlas.c:93
float Fo_GetMinYBearing(hAtlas hAtlas, HFont hFont, const char *str)
get the minimum y bearing value for a string:
Definition Atlas.c:1821
float Fo_StringHeight(hAtlas hAtlas, HFont hFont, const char *stringVal)
Definition Atlas.c:1775
hAtlas At_EndAtlas(struct DrawContext *pDC)
Definition Atlas.c:947
hAtlas At_LoadAtlas(xmlNode *child0, struct DrawContext *pDC)
Definition Atlas.c:1376
struct _AtlasSprite AtlasSprite
A sprite stored in the atlas.
void At_BeginAtlas()
Definition Atlas.c:104
#define MAX_NUM_FONT_SIZES
Definition Atlas.h:61
void At_DestroyAtlas(hAtlas atlas, struct DrawContext *pDC)
Definition Atlas.c:1059
AtlasSprite * At_GetSprite(hSprite sprite, hAtlas atlas)
Definition Atlas.c:1133
void At_SerializeAtlas(struct BinarySerializer *pSerializer, hAtlas *atlas, struct DrawContext *pDC)
Definition Atlas.c:1632
void At_SetCurrent(hAtlas atlas, DrawContext *pDC)
Definition Atlas.c:86
float Fo_StringWidth(hAtlas hAtlas, HFont hFont, const char *stringVal)
Definition Atlas.c:1718
bool Fo_TryGetCharBearing(hAtlas hAtlas, HFont hFont, char c, vec2 outBearing)
Definition Atlas.c:1845
HFont Fo_FindFont(hAtlas hAtlas, const char *fontName, float sizePts)
Definition Atlas.c:1685
float Fo_CharWidth(hAtlas hAtlas, HFont hFont, char c)
Definition Atlas.c:1707
hAtlas At_EndAtlasEx(struct DrawContext *pDC, struct EndAtlasOptions *pOptions)
Definition Atlas.c:952
hSprite At_AddSprite(const char *imgPath, int topLeftXPx, int topRightYPx, int widthPx, int heightPx, const char *name, bool bMinimizeSpace)
Add a sprite to the atlas, cuts out the pixels for that specific sprite to be nested when At_EndAtlas...
Definition Atlas.c:254
bool Fo_TryGetCharAdvance(hAtlas hAtlas, HFont hFont, char c, float *outAdvance)
Definition Atlas.c:1859
hTexture At_GetAtlasTexture(hAtlas atlas)
Definition Atlas.c:1145
struct AtlasAnimation * At_FindAnim(hAtlas atlas, const char *name)
Definition Atlas.c:1883
void At_EndTileset(int endI)
Definition Atlas.c:1876
#define MAX_FONT_NAME_SIZE
Definition Atlas.h:58
HFont At_AddFont(const struct FontAtlasAdditionSpec *pFontSpec)
Definition Atlas.c:366
struct _xmlNode xmlNode
Definition Atlas.h:11
float Fo_CharHeight(hAtlas hAtlas, HFont hFont, char c)
Definition Atlas.c:1712
hSprite At_FindSprite(const char *name, hAtlas atlas)
Definition Atlas.c:1119
float Fo_StringHeightSingleLine(hAtlas hAtlas, HFont hFont, const char *stringVal)
Definition Atlas.c:1738
void At_BeginTileset(int beginI)
Definition Atlas.c:1869
float Fo_GetMaxYBearing(hAtlas hAtlas, HFont hFont, const char *str)
get the maximum y bearing value for a string:
Definition Atlas.c:1798
#define MAX_FONT_PATH_SIZE
Definition Atlas.h:59
AtlasSprite * Fo_GetCharSprite(hAtlas hAtlas, HFont hFont, char c)
Definition Atlas.c:1790
hSprite At_TilemapIndexToSprite(hAtlas atlas, TileIndex tileIndex)
Definition Atlas.c:1435
hAtlas At_LoadAtlasEx(xmlNode *child0, struct DrawContext *pDC, struct EndAtlasOptions *pOptions)
Definition Atlas.c:1381
float At_PixelsToPts(float val)
Definition Atlas.c:358
HGeneric hTexture
Definition HandleDefs.h:20
HGeneric HImage
Definition HandleDefs.h:11
HGeneric hSprite
Definition HandleDefs.h:17
HGeneric HFont
Definition HandleDefs.h:28
HGeneric hAtlas
Definition HandleDefs.h:14
u16 TileIndex
Definition IntTypes.h:18
uint8_t u8
Definition IntTypes.h:6
const char *const name
Definition cJSON.h:270
Definition Atlas.h:64
float fps
Definition Atlas.h:66
VECTOR(hSprite) frames
Definition BinarySerializer.h:17
Definition DrawContext.h:59
Definition Atlas.h:112
bool bUseBiggestSpriteForInitialAtlasSize
Definition Atlas.h:116
char * outDebugBitmapPath
Definition Atlas.h:115
int initialAtlasHeight
Definition Atlas.h:114
int initialAtlasWidth
Definition Atlas.h:113
Definition Atlas.h:81
size_t numFontSizes
Definition Atlas.h:92
enum FontAtlasAdditionSpec::@3 fontOptions
char path[MAX_FONT_PATH_SIZE]
Definition Atlas.h:90
struct FontSize fontSizes[MAX_NUM_FONT_SIZES]
Definition Atlas.h:91
@ FS_Underline
Definition Atlas.h:87
@ FS_Normal
Definition Atlas.h:84
@ FS_Italic
Definition Atlas.h:85
@ FS_Bold
Definition Atlas.h:86
char name[MAX_FONT_NAME_SIZE]
Definition Atlas.h:89
Definition Atlas.h:71
float val
Definition Atlas.h:77
@ FOS_Pts
Definition Atlas.h:75
@ FOS_Pixels
Definition Atlas.h:74
enum FontSize::@2 type
A sprite stored in the atlas.
Definition Atlas.h:18
int atlasTopLeftYPx
Definition Atlas.h:44
int actualHeightPX
the actual height of the sprite stored in the atlas - used by low level rendering code
Definition Atlas.h:35
int atlasTopLeftXPx
Definition Atlas.h:43
float topLeftUV_U
Definition Atlas.h:46
float xOffsetToActual
the X offset from the point to draw the sprite to the point where it should "actually" be drawn - use...
Definition Atlas.h:38
int srcImageTopLeftYPx
Definition Atlas.h:23
int widthPx
the "notional" width that gameplay code should use
Definition Atlas.h:26
hAtlas atlas
Definition Atlas.h:19
float topLeftUV_V
Definition Atlas.h:47
float yOffsetToActual
the Y offset from the point to draw the sprite to the point where it should "actually" be drawn - use...
Definition Atlas.h:41
float bottomRightUV_U
Definition Atlas.h:48
HImage srcImage
Definition Atlas.h:20
float bottomRightUV_V
Definition Atlas.h:49
int actualWidthPX
the actual width of the sprite stored in the atlas - used by low level rendering code
Definition Atlas.h:32
int srcImageTopLeftXPx
Definition Atlas.h:22
u8 * individualTileBytes
Definition Atlas.h:51
int heightPx
the "notional" height that gameplay code should use
Definition Atlas.h:29
int id
Definition Atlas.h:54
char * name
Definition Atlas.h:21
bool bSet
Definition Atlas.h:52