mirror of https://github.com/bjornbytes/lovr.git
lovr.graphics.getDefaultFont;
This commit is contained in:
parent
cfc0f52449
commit
ad0595ff35
|
@ -687,6 +687,12 @@ static int l_lovrGraphicsSetBackground(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrGraphicsGetDefaultFont(lua_State* L) {
|
||||
Font* font = lovrGraphicsGetDefaultFont();
|
||||
luax_pushtype(L, Font, font);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrGraphicsGetBuffer(lua_State* L) {
|
||||
BufferInfo info = { 0 };
|
||||
|
||||
|
@ -1266,6 +1272,7 @@ static const luaL_Reg lovrGraphics[] = {
|
|||
{ "isFormatSupported", l_lovrGraphicsIsFormatSupported },
|
||||
{ "getBackground", l_lovrGraphicsGetBackground },
|
||||
{ "setBackground", l_lovrGraphicsSetBackground },
|
||||
{ "getDefaultFont", l_lovrGraphicsGetDefaultFont },
|
||||
{ "getBuffer", l_lovrGraphicsGetBuffer },
|
||||
{ "newBuffer", l_lovrGraphicsNewBuffer },
|
||||
{ "newTexture", l_lovrGraphicsNewTexture },
|
||||
|
|
|
@ -625,6 +625,18 @@ void lovrGraphicsSetBackground(float background[4]) {
|
|||
state.background[3] = background[3];
|
||||
}
|
||||
|
||||
Font* lovrGraphicsGetDefaultFont() {
|
||||
if (!state.defaultFont) {
|
||||
state.defaultFont = lovrFontCreate(&(FontInfo) {
|
||||
.rasterizer = lovrRasterizerCreate(NULL, 48),
|
||||
.padding = 1,
|
||||
.spread = 4.
|
||||
});
|
||||
}
|
||||
|
||||
return state.defaultFont;
|
||||
}
|
||||
|
||||
void lovrGraphicsSubmit(Pass** passes, uint32_t count) {
|
||||
if (!state.active) {
|
||||
return;
|
||||
|
@ -2818,15 +2830,7 @@ void lovrPassCircle(Pass* pass, float* transform, float angle1, float angle2, ui
|
|||
|
||||
void lovrPassText(Pass* pass, Font* font, const char* text, uint32_t length, float* transform, float wrap, HorizontalAlign halign, VerticalAlign valign) {
|
||||
if (!font) {
|
||||
if (!state.defaultFont) {
|
||||
state.defaultFont = lovrFontCreate(&(FontInfo) {
|
||||
.rasterizer = lovrRasterizerCreate(NULL, 48),
|
||||
.padding = 1,
|
||||
.spread = 4.
|
||||
});
|
||||
}
|
||||
|
||||
font = state.defaultFont;
|
||||
font = lovrGraphicsGetDefaultFont();
|
||||
}
|
||||
|
||||
uint32_t originalGlyphsLength = font->glyphs.length;
|
||||
|
|
|
@ -90,6 +90,7 @@ bool lovrGraphicsIsFormatSupported(uint32_t format, uint32_t features);
|
|||
|
||||
void lovrGraphicsGetBackground(float background[4]);
|
||||
void lovrGraphicsSetBackground(float background[4]);
|
||||
Font* lovrGraphicsGetDefaultFont(void);
|
||||
|
||||
void lovrGraphicsSubmit(Pass** passes, uint32_t count);
|
||||
void lovrGraphicsWait(void);
|
||||
|
|
Loading…
Reference in New Issue