#include "MyTextTestScene.h" #include #include #include #include std::map> gen_font_stuff(const image_loader::ImageRGBA& image) { std::map> ret; std::string alpha = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`1234567890-=[]\\;',./~!@#$%^&*()_+{}|:\"<>?"; unsigned int delta_x = 9; unsigned int height = image.height; for (unsigned int i = 0; i < alpha.size(); ++i) { ret.emplace(alpha[i], charcoal::Rectangle(0, height, i * delta_x, (i + 1) * delta_x)); } return ret; } MyTextTestScene::MyTextTestScene(Application& application) : Scene(application), m_font_image(image_loader::load_file(IMAGE_PATH "consolas-16px.png")), m_font(m_font_image, gen_font_stuff(m_font_image)), m_text_image(m_font.get_text_image("The difference between me (and you) is that 2 + 2 = 4!")), m_text( meshgenerator::gen_rect_pt(DRAW_TRIANGLES, (float)m_text_image.width, (float)m_text_image.height), DRAW_TRIANGLES, TextureFactory::gen_image_texture(m_text_image), texturegenerator::gen_quick_sampler() ), m_camera(m_screen_size), m_text_batch(&m_text) { m_pipeline.set_camera(&m_camera); m_pipeline.add_batch(&m_text_batch); } void MyTextTestScene::init() { m_text_batch.init(); m_text_batch.reset_rendered(); m_text_batch.add_rendered(m_text_pose); } void MyTextTestScene::update(float delta_time, clock_t clock) { // Do Nothing } void MyTextTestScene::prerender() { m_camera.prerender(); m_text_batch.prerender(); } void MyTextTestScene::render() { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glutil::clear_screen(); m_pipeline.render(); }