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
39
40
41#define MAX_FONT_NAME_SIZE 128
42#define MAX_FONT_PATH_SIZE 256
43
44#define MAX_NUM_FONT_SIZES 32
45
47{
48 VECTOR(hSprite) frames;
49 float fps;
50};
51
52
54{
55 enum
56 {
60 float val;
61};
62
77
78void At_Init();
79void At_BeginAtlas();
80
81hSprite At_AddSprite(const char* imgPath, int topLeftXPx, int topRightYPx, int widthPx, int heightPx, const char* name);
82HFont At_AddFont(const struct FontAtlasAdditionSpec* pFontSpec);
83hAtlas At_EndAtlas(struct DrawContext* pDC);
84
92
93hAtlas At_EndAtlasEx(struct DrawContext* pDC, struct EndAtlasOptions* pOptions);
94void At_DestroyAtlas(hAtlas atlas, struct DrawContext* pDC);
95hSprite At_FindSprite(const char* name, hAtlas atlas);
98float At_PixelsToPts(float val);
99hAtlas At_LoadAtlas(xmlNode* child0, struct DrawContext* pDC);
100hAtlas At_LoadAtlasEx(xmlNode* child0, struct DrawContext* pDC, struct EndAtlasOptions* pOptions);
101
103
110void At_SerializeAtlas(struct BinarySerializer* pSerializer, hAtlas* atlas, struct DrawContext* pDC);
111
112void At_BeginTileset(int beginI);
113void At_EndTileset(int endI);
114
115void At_SetCurrent(hAtlas atlas, DrawContext* pDC);
116
117struct AtlasAnimation* At_FindAnim(hAtlas atlas, const char* name);
118
119HFont Fo_FindFont(hAtlas hAtlas, const char* fontName, float sizePts);
120float Fo_CharWidth(hAtlas hAtlas, HFont hFont, char c);
121float Fo_CharHeight(hAtlas hAtlas, HFont hFont, char c);
122float Fo_StringWidth(hAtlas hAtlas, HFont hFont, const char* stringVal);
123float Fo_StringHeight(hAtlas hAtlas, HFont hFont, const char* stringVal);
125float Fo_GetMaxYBearing(hAtlas hAtlas, HFont hFont, const char* str);
126
127bool Fo_TryGetCharBearing(hAtlas hAtlas, HFont hFont, char c, vec2 outBearing);
128bool Fo_TryGetCharAdvance(hAtlas hAtlas, HFont hFont, char c, float* outAdvance);
129
130#endif
void At_Init()
Definition Atlas.c:92
float Fo_StringHeight(hAtlas hAtlas, HFont hFont, const char *stringVal)
Definition Atlas.c:1551
hAtlas At_EndAtlas(struct DrawContext *pDC)
Definition Atlas.c:790
hAtlas At_LoadAtlas(xmlNode *child0, struct DrawContext *pDC)
Definition Atlas.c:1199
struct _AtlasSprite AtlasSprite
void At_BeginAtlas()
Definition Atlas.c:103
#define MAX_NUM_FONT_SIZES
Definition Atlas.h:44
void At_DestroyAtlas(hAtlas atlas, struct DrawContext *pDC)
Definition Atlas.c:902
AtlasSprite * At_GetSprite(hSprite sprite, hAtlas atlas)
Definition Atlas.c:976
void At_SerializeAtlas(struct BinarySerializer *pSerializer, hAtlas *atlas, struct DrawContext *pDC)
Definition Atlas.c:1445
void At_SetCurrent(hAtlas atlas, DrawContext *pDC)
Definition Atlas.c:85
float Fo_StringWidth(hAtlas hAtlas, HFont hFont, const char *stringVal)
Definition Atlas.c:1531
bool Fo_TryGetCharBearing(hAtlas hAtlas, HFont hFont, char c, vec2 outBearing)
Definition Atlas.c:1619
HFont Fo_FindFont(hAtlas hAtlas, const char *fontName, float sizePts)
Definition Atlas.c:1498
float Fo_CharWidth(hAtlas hAtlas, HFont hFont, char c)
Definition Atlas.c:1520
hAtlas At_EndAtlasEx(struct DrawContext *pDC, struct EndAtlasOptions *pOptions)
Definition Atlas.c:795
bool Fo_TryGetCharAdvance(hAtlas hAtlas, HFont hFont, char c, float *outAdvance)
Definition Atlas.c:1633
hTexture At_GetAtlasTexture(hAtlas atlas)
Definition Atlas.c:988
struct AtlasAnimation * At_FindAnim(hAtlas atlas, const char *name)
Definition Atlas.c:1660
void At_EndTileset(int endI)
Definition Atlas.c:1653
#define MAX_FONT_NAME_SIZE
Definition Atlas.h:41
HFont At_AddFont(const struct FontAtlasAdditionSpec *pFontSpec)
Definition Atlas.c:211
struct _xmlNode xmlNode
Definition Atlas.h:11
hSprite At_AddSprite(const char *imgPath, int topLeftXPx, int topRightYPx, int widthPx, int heightPx, const char *name)
Definition Atlas.c:122
float Fo_CharHeight(hAtlas hAtlas, HFont hFont, char c)
Definition Atlas.c:1525
hSprite At_FindSprite(const char *name, hAtlas atlas)
Definition Atlas.c:962
void At_BeginTileset(int beginI)
Definition Atlas.c:1646
float Fo_GetMaxYBearing(hAtlas hAtlas, HFont hFont, const char *str)
Definition Atlas.c:1596
#define MAX_FONT_PATH_SIZE
Definition Atlas.h:42
AtlasSprite * Fo_GetCharSprite(hAtlas hAtlas, HFont hFont, char c)
Definition Atlas.c:1588
hSprite At_TilemapIndexToSprite(hAtlas atlas, TileIndex tileIndex)
Definition Atlas.c:1258
hAtlas At_LoadAtlasEx(xmlNode *child0, struct DrawContext *pDC, struct EndAtlasOptions *pOptions)
Definition Atlas.c:1204
float At_PixelsToPts(float val)
Definition Atlas.c:203
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:47
float fps
Definition Atlas.h:49
VECTOR(hSprite) frames
Definition BinarySerializer.h:16
Definition DrawContext.h:59
Definition Atlas.h:86
bool bUseBiggestSpriteForInitialAtlasSize
Definition Atlas.h:90
char * outDebugBitmapPath
Definition Atlas.h:89
int initialAtlasHeight
Definition Atlas.h:88
int initialAtlasWidth
Definition Atlas.h:87
Definition Atlas.h:64
size_t numFontSizes
Definition Atlas.h:75
enum FontAtlasAdditionSpec::@3 fontOptions
char path[MAX_FONT_PATH_SIZE]
Definition Atlas.h:73
struct FontSize fontSizes[MAX_NUM_FONT_SIZES]
Definition Atlas.h:74
@ FS_Underline
Definition Atlas.h:70
@ FS_Normal
Definition Atlas.h:67
@ FS_Italic
Definition Atlas.h:68
@ FS_Bold
Definition Atlas.h:69
char name[MAX_FONT_NAME_SIZE]
Definition Atlas.h:72
Definition Atlas.h:54
float val
Definition Atlas.h:60
@ FOS_Pts
Definition Atlas.h:58
@ FOS_Pixels
Definition Atlas.h:57
enum FontSize::@2 type
Definition Atlas.h:17
int atlasTopLeftYPx
Definition Atlas.h:27
int atlasTopLeftXPx
Definition Atlas.h:26
float topLeftUV_U
Definition Atlas.h:29
int srcImageTopLeftYPx
Definition Atlas.h:22
int widthPx
Definition Atlas.h:23
hAtlas atlas
Definition Atlas.h:18
float topLeftUV_V
Definition Atlas.h:30
float bottomRightUV_U
Definition Atlas.h:31
HImage srcImage
Definition Atlas.h:19
float bottomRightUV_V
Definition Atlas.h:32
int srcImageTopLeftXPx
Definition Atlas.h:21
u8 * individualTileBytes
Definition Atlas.h:34
int heightPx
Definition Atlas.h:24
int id
Definition Atlas.h:37
char * name
Definition Atlas.h:20
bool bSet
Definition Atlas.h:35