Render text on load

This commit is contained in:
J-D-K 2018-06-18 17:11:34 -04:00
parent 9f0aa5044d
commit be8803fb03
6 changed files with 32 additions and 16 deletions

View File

@ -6,7 +6,7 @@
namespace gfx
{
//Inits graphics and shared font. Code for shared font is from switch-portlibs examples
bool init(const uint32_t& _fontSize);
bool init();
bool fini();
//Changes gfx mode to linear double
@ -48,6 +48,9 @@ namespace gfx
~tex();
void draw(uint32_t x, uint32_t y);
//This is specifically for the topbar.
void drawRepeatHori(uint32_t x, uint32_t y, uint32_t w);
private:
uint32_t sz;
uint16_t width, height;

View File

@ -8,10 +8,10 @@ namespace util
//Returns string with date + time
std::string getDateTime();
//Creates Dir 'JKSV/[user]/[title]
//Creates Dir 'JKSV/[title]
void makeTitleDir(data::user& u, data::titledata& t);
//Returns 'JKSV/[user]/[title]/'
//Returns 'JKSV/[title]/'
std::string getTitleDir(data::user& u, data::titledata& t);
//Just returns string with '\n' inserted.

Binary file not shown.

View File

@ -16,7 +16,7 @@ static uint32_t frameBufWidth = 0;
namespace gfx
{
bool init(const uint32_t& _fontSize)
bool init()
{
Result res = 0;
@ -149,11 +149,7 @@ namespace gfx
}
glyphIndex = FT_Get_Char_Index(face, tmpChr);
ret = FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
if(ret == 0)
{
ret = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
}
ret = FT_Load_Glyph(face, glyphIndex, FT_LOAD_RENDER);
if(ret)
return;
@ -187,11 +183,7 @@ namespace gfx
i += unitCount;
glyphIndex = FT_Get_Char_Index(face, tmpChr);
ret = FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
if(ret == 0)
{
ret = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
}
ret = FT_Load_Glyph(face, glyphIndex, FT_LOAD_RENDER);
if(ret)
return 0;
@ -304,4 +296,22 @@ namespace gfx
}
}
}
void tex::drawRepeatHori(uint32_t x, uint32_t y, uint32_t w)
{
if(data != NULL)
{
uint32_t tY, tX, i = 0;
uint32_t *fb = (uint32_t *)gfxGetFramebuffer(NULL, NULL);
for(tY = y; tY < y + height; tY++, i++)
{
for(tX = x; tX < x + w; tX++)
{
uint32_t fbPx = fb[tY * frameBufWidth + tX];
fb[tY * frameBufWidth + tX] = blend(data[i], fbPx);
}
}
}
}
}

View File

@ -12,7 +12,7 @@ int main(int argc, const char *argv[])
{
bool init = false;
init = gfx::init(64);
init = gfx::init();
if(init)
init = sys::init();
if(init)
@ -39,7 +39,10 @@ int main(int argc, const char *argv[])
gfx::clearBufferColor(0xFF3B3B3B);
ui::drawTitleBar("JKSV - 06/17/2018");
gfx::drawRectangle(448, 64, 1, 592, 0xFF7B7B7B);
gfx::drawRectangle(449, 64, 2, 592, 0xFF2B2B2B);
gfx::drawRectangle(16, 656, 1248, 1, 0xFF7B7B7B);
gfx::drawRectangle(16, 657, 1248, 2, 0xFF2B2B2B);
ui::runApp(down, held);

View File

@ -567,7 +567,7 @@ namespace ui
void drawTitleBar(const std::string& txt)
{
titleBar.draw(0, 0);
titleBar.drawRepeatHori(0, 0, 1280);
gfx::drawText(txt, 16, 16, 64, 0xFFFFFFFF);
}