Added 2 new fonts (personally made) and now text looks much nicer.
This commit is contained in:
parent
8ef6931808
commit
d08e9f1078
@ -13,7 +13,7 @@ std::map<char, charcoal::Rectangle<int>> gen_font_stuff(const image_loader::Imag
|
|||||||
{
|
{
|
||||||
std::map<char, charcoal::Rectangle<int>> ret;
|
std::map<char, charcoal::Rectangle<int>> ret;
|
||||||
std::string alpha = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:\"<>?";
|
std::string alpha = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:\"<>?";
|
||||||
unsigned int delta_x = 9;
|
unsigned int delta_x = image.width / alpha.size();
|
||||||
unsigned int height = image.height;
|
unsigned int height = image.height;
|
||||||
for (unsigned int i = 0; i < alpha.size(); ++i)
|
for (unsigned int i = 0; i < alpha.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -24,7 +24,7 @@ std::map<char, charcoal::Rectangle<int>> gen_font_stuff(const image_loader::Imag
|
|||||||
|
|
||||||
MyTextTestScene::MyTextTestScene(Application& application)
|
MyTextTestScene::MyTextTestScene(Application& application)
|
||||||
: Scene(application),
|
: Scene(application),
|
||||||
m_font_image(image_loader::load_file(IMAGE_PATH "consolas-16px.png")),
|
m_font_image(image_loader::load_file(IMAGE_PATH "charcoal-thin-curve-16px.png")),
|
||||||
m_font(m_font_image, gen_font_stuff(m_font_image)),
|
m_font(m_font_image, gen_font_stuff(m_font_image)),
|
||||||
m_text_image(m_font.get_text_image(TEST_TEXT)),
|
m_text_image(m_font.get_text_image(TEST_TEXT)),
|
||||||
m_text(
|
m_text(
|
||||||
@ -51,14 +51,36 @@ void MyTextTestScene::init()
|
|||||||
|
|
||||||
m_text_batch.reset_rendered();
|
m_text_batch.reset_rendered();
|
||||||
m_text_batch.add_rendered(m_text_pose);
|
m_text_batch.add_rendered(m_text_pose);
|
||||||
|
|
||||||
m_text_pipeline.reset_text();
|
|
||||||
m_text_pipeline.add_text(vec3(0.0f, -30.0f, 0.0f), TEST_TEXT, RelativePosition::CENTER_CENTER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyTextTestScene::update(float delta_time, clock_t clock)
|
void MyTextTestScene::update(float delta_time, clock_t clock)
|
||||||
{
|
{
|
||||||
// Do Nothing
|
glm::vec3 translation(0.0f, 0.0f, 0.0f);
|
||||||
|
if (m_input_manager.is_key_down(GLFW_KEY_W))
|
||||||
|
{
|
||||||
|
translation.y += 1;
|
||||||
|
}
|
||||||
|
if (m_input_manager.is_key_down(GLFW_KEY_S))
|
||||||
|
{
|
||||||
|
translation.y -= 1;
|
||||||
|
}
|
||||||
|
if (m_input_manager.is_key_down(GLFW_KEY_A))
|
||||||
|
{
|
||||||
|
translation.x -= 1;
|
||||||
|
}
|
||||||
|
if (m_input_manager.is_key_down(GLFW_KEY_D))
|
||||||
|
{
|
||||||
|
translation.x += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_camera.translate(translation);
|
||||||
|
|
||||||
|
m_text_pipeline.reset_text();
|
||||||
|
m_text_pipeline.add_text(vec3(0.0f, -30.0f, 0.0f), TEST_TEXT, RelativePosition::TOP_CENTER);
|
||||||
|
m_text_pipeline.add_text(vec3(0.0f, -60.0f, 0.0f), "Delta Time: " + std::to_string(delta_time), RelativePosition::TOP_LEFT);
|
||||||
|
m_text_pipeline.add_text(vec3(0.0f, -90.0f, 0.0f), "Clock: " + std::to_string(clock), RelativePosition::TOP_LEFT);
|
||||||
|
m_text_pipeline.add_text(vec3(0.0f, -120.0f, 0.0f), "the quick brown fox jumps over the lazy dog.", RelativePosition::TOP_LEFT);
|
||||||
|
m_text_pipeline.add_text(vec3(0.0f, -150.0f, 0.0f), "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.", RelativePosition::TOP_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyTextTestScene::prerender()
|
void MyTextTestScene::prerender()
|
||||||
|
BIN
images/charcoal-thin-16px.png
Normal file
BIN
images/charcoal-thin-16px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
images/charcoal-thin-curve-16px.png
Normal file
BIN
images/charcoal-thin-curve-16px.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
Loading…
Reference in New Issue
Block a user