Text-Renderer/main/main.cpp

83 lines
2.1 KiB
C++

#include "Bitmap.h"
#include "Font.h"
#include "TextRenderer.h"
#include "internal.hpp"
#include <iostream>
bool isQuit(std::string command);
/**
* @author: Julian Hinxlage
* @since: v0.0.0
* @brief: An image is loaded and used as a font.
* A string is converted and displayed in the console.
* Currently only to test.
*/
void outPutPixel(int windowHeight, int windowWidth, vkvm::Color fontColor);
int main() {
vkvm::initialize(0);
std::string currentText;
/**************************get text and font from shared memory*******************************************/
TextRenderer textRenderer = TextRenderer();
textRenderer.setLeftMargin(1);
textRenderer.setBottomMargin(1);
/*************************get Text and update back to shared meomory********************************************/
vkvm::registerEvent(vkvm::EventType::RenderText, [&textRenderer]() {
std::string currentText = vkvm::getText();
textRenderer.update(currentText);
vkvm::callEvent(vkvm::EventType::Redraw);
});
std::string command;
std::cout << "TextRender: ";
std::getline(std::cin, command);
while (!isQuit(command)) {
if (command == "clear") {
textRenderer.clear();
}
vkvm::setText(command);
currentText = vkvm::getText();
textRenderer.update(currentText);
std::cout << "TextRender: ";
std::getline(std::cin, command);
}
std::cout << "TextRender finished." << std::endl;
return 0;
}
// std::string str;
// std::cout << "string to draw: ";
// std::getline(std::cin, str);
//
// for (int i = 0; i < font.height(); i++) {
// for (char c : str) {
// for (int j = 0; j < font.width(); j++) {
// if (font.getPixel(c,j,i)) {
// std::cout << "█";
// } else {
// std::cout << " ";
// }
// }
// std::cout << " ";
// }
// std::cout << std::endl;
// }
//
// return 0;
bool isQuit(std::string command) {
return command.compare("quit") == 0;
}