mirror of https://github.com/bjornbytes/lovr.git
Pass:setFont;
This commit is contained in:
parent
24504d1719
commit
d9623a51a9
|
@ -239,6 +239,13 @@ static int l_lovrPassSetDepthClamp(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrPassSetFont(lua_State* L) {
|
||||
Pass* pass = luax_checktype(L, 1, Pass);
|
||||
Font* font = luax_totype(L, 2, Font);
|
||||
lovrPassSetFont(pass, font);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrPassSetMaterial(lua_State* L) {
|
||||
Pass* pass = luax_checktype(L, 1, Pass);
|
||||
Material* material = luax_totype(L, 2, Material);
|
||||
|
@ -589,17 +596,15 @@ static int l_lovrPassTorus(lua_State* L) {
|
|||
|
||||
static int l_lovrPassText(lua_State* L) {
|
||||
Pass* pass = luax_checktype(L, 1, Pass);
|
||||
Font* font = luax_totype(L, 2, Font);
|
||||
int index = font ? 3 : 2;
|
||||
uint32_t count;
|
||||
ColoredString stack;
|
||||
ColoredString* strings = luax_checkcoloredstrings(L, index++, &count, &stack);
|
||||
ColoredString* strings = luax_checkcoloredstrings(L, 2, &count, &stack);
|
||||
float transform[16];
|
||||
index = luax_readmat4(L, index++, transform, 1);
|
||||
int index = luax_readmat4(L, 3, transform, 1);
|
||||
float wrap = luax_optfloat(L, index++, 0.);
|
||||
HorizontalAlign halign = luax_checkenum(L, index++, HorizontalAlign, "center");
|
||||
VerticalAlign valign = luax_checkenum(L, index++, VerticalAlign, "middle");
|
||||
lovrPassText(pass, font, strings, count, transform, wrap, halign, valign);
|
||||
lovrPassText(pass, strings, count, transform, wrap, halign, valign);
|
||||
if (strings != &stack) free(strings);
|
||||
return 0;
|
||||
}
|
||||
|
@ -946,6 +951,7 @@ const luaL_Reg lovrPass[] = {
|
|||
{ "setDepthWrite", l_lovrPassSetDepthWrite },
|
||||
{ "setDepthOffset", l_lovrPassSetDepthOffset },
|
||||
{ "setDepthClamp", l_lovrPassSetDepthClamp },
|
||||
{ "setFont", l_lovrPassSetFont },
|
||||
{ "setMaterial", l_lovrPassSetMaterial },
|
||||
{ "setMeshMode", l_lovrPassSetMeshMode },
|
||||
{ "setSampler", l_lovrPassSetSampler },
|
||||
|
|
|
@ -242,7 +242,7 @@ typedef struct {
|
|||
} Camera;
|
||||
|
||||
typedef struct {
|
||||
float color[4];
|
||||
Font* font;
|
||||
Shader* shader;
|
||||
Sampler* sampler;
|
||||
Material* material;
|
||||
|
@ -251,6 +251,7 @@ typedef struct {
|
|||
float viewport[4];
|
||||
float depthRange[2];
|
||||
uint32_t scissor[4];
|
||||
float color[4];
|
||||
MeshMode mode;
|
||||
bool dirty;
|
||||
} Pipeline;
|
||||
|
@ -3290,6 +3291,7 @@ void lovrPassPush(Pass* pass, StackType stack) {
|
|||
pass->pipeline = &pass->pipelines[++pass->pipelineIndex];
|
||||
lovrCheck(pass->pipelineIndex < COUNTOF(pass->pipelines), "%s stack overflow (more pushes than pops?)", "Pipeline");
|
||||
memcpy(pass->pipeline, &pass->pipelines[pass->pipelineIndex - 1], sizeof(Pipeline));
|
||||
lovrRetain(pass->pipeline->font);
|
||||
lovrRetain(pass->pipeline->sampler);
|
||||
lovrRetain(pass->pipeline->shader);
|
||||
lovrRetain(pass->pipeline->material);
|
||||
|
@ -3305,6 +3307,7 @@ void lovrPassPop(Pass* pass, StackType stack) {
|
|||
lovrCheck(pass->transformIndex < COUNTOF(pass->transforms), "%s stack underflow (more pops than pushes?)", "Transform");
|
||||
break;
|
||||
case STACK_PIPELINE:
|
||||
lovrRelease(pass->pipeline->font, lovrFontDestroy);
|
||||
lovrRelease(pass->pipeline->sampler, lovrSamplerDestroy);
|
||||
lovrRelease(pass->pipeline->shader, lovrShaderDestroy);
|
||||
lovrRelease(pass->pipeline->material, lovrMaterialDestroy);
|
||||
|
@ -3463,6 +3466,14 @@ void lovrPassSetDepthClamp(Pass* pass, bool clamp) {
|
|||
}
|
||||
}
|
||||
|
||||
void lovrPassSetFont(Pass* pass, Font* font) {
|
||||
if (pass->pipeline->font != font) {
|
||||
lovrRetain(font);
|
||||
lovrRelease(pass->pipeline->font, lovrFontDestroy);
|
||||
pass->pipeline->font = font;
|
||||
}
|
||||
}
|
||||
|
||||
void lovrPassSetMaterial(Pass* pass, Material* material, Texture* texture) {
|
||||
if (texture) {
|
||||
material = lovrTextureGetMaterial(texture);
|
||||
|
@ -4645,8 +4656,8 @@ void lovrPassTorus(Pass* pass, float* transform, uint32_t segmentsT, uint32_t se
|
|||
}
|
||||
}
|
||||
|
||||
void lovrPassText(Pass* pass, Font* font, ColoredString* strings, uint32_t count, float* transform, float wrap, HorizontalAlign halign, VerticalAlign valign) {
|
||||
font = font ? font : lovrGraphicsGetDefaultFont();
|
||||
void lovrPassText(Pass* pass, ColoredString* strings, uint32_t count, float* transform, float wrap, HorizontalAlign halign, VerticalAlign valign) {
|
||||
Font* font = pass->pipeline->font ? pass->pipeline->font : lovrGraphicsGetDefaultFont();
|
||||
|
||||
size_t totalLength = 0;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
|
@ -5174,9 +5185,11 @@ static void cleanupPasses(void) {
|
|||
|
||||
if (pass->info.type == PASS_RENDER) {
|
||||
for (size_t j = 0; j <= pass->pipelineIndex; j++) {
|
||||
lovrRelease(pass->pipelines[j].font, lovrFontDestroy);
|
||||
lovrRelease(pass->pipelines[j].sampler, lovrSamplerDestroy);
|
||||
lovrRelease(pass->pipelines[j].shader, lovrShaderDestroy);
|
||||
lovrRelease(pass->pipelines[j].material, lovrMaterialDestroy);
|
||||
pass->pipelines[j].font = NULL;
|
||||
pass->pipelines[j].sampler = NULL;
|
||||
pass->pipelines[j].shader = NULL;
|
||||
pass->pipelines[j].material = NULL;
|
||||
|
|
|
@ -591,6 +591,7 @@ void lovrPassSetDepthTest(Pass* pass, CompareMode test);
|
|||
void lovrPassSetDepthWrite(Pass* pass, bool write);
|
||||
void lovrPassSetDepthOffset(Pass* pass, float offset, float sloped);
|
||||
void lovrPassSetDepthClamp(Pass* pass, bool clamp);
|
||||
void lovrPassSetFont(Pass* pass, Font* font);
|
||||
void lovrPassSetMaterial(Pass* pass, Material* material, Texture* texture);
|
||||
void lovrPassSetMeshMode(Pass* pass, MeshMode mode);
|
||||
void lovrPassSetSampler(Pass* pass, Sampler* sampler);
|
||||
|
@ -615,7 +616,7 @@ void lovrPassCylinder(Pass* pass, float* transform, bool capped, float angle1, f
|
|||
void lovrPassCone(Pass* pass, float* transform, uint32_t segments);
|
||||
void lovrPassCapsule(Pass* pass, float* transform, uint32_t segments);
|
||||
void lovrPassTorus(Pass* pass, float* transform, uint32_t segmentsT, uint32_t segmentsP);
|
||||
void lovrPassText(Pass* pass, Font* font, ColoredString* strings, uint32_t count, float* transform, float wrap, HorizontalAlign halign, VerticalAlign valign);
|
||||
void lovrPassText(Pass* pass, ColoredString* strings, uint32_t count, float* transform, float wrap, HorizontalAlign halign, VerticalAlign valign);
|
||||
void lovrPassSkybox(Pass* pass, Texture* texture);
|
||||
void lovrPassFill(Pass* pass, Texture* texture);
|
||||
void lovrPassMonkey(Pass* pass, float* transform);
|
||||
|
|
Loading…
Reference in New Issue