Text-Renderer/main/main.cpp

60 lines
1.7 KiB
C++
Raw Normal View History

2019-12-17 12:06:44 +01:00
#include "../src/Bitmap.h"
#include "../src/Font.h"
#include "../src/TextRenderer.h"
#include <internal.hpp>
#include <iostream>
2019-10-15 14:00:06 +02:00
2019-12-17 12:06:44 +01:00
bool isQuit(const 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);
2019-10-15 14:00:06 +02:00
int main() {
vkvm::initialize(0);
std::string currentText;
2019-11-20 12:50:32 +01:00
/**************************get text and font from shared memory*******************************************/
TextRenderer textRenderer = TextRenderer();
textRenderer.setLeftMargin(1);
textRenderer.setBottomMargin(1);
/*************************get Text and update back to shared meomory********************************************/
2019-11-20 12:50:32 +01:00
vkvm::registerEvent(vkvm::EventType::RenderText, [&textRenderer]() {
2019-11-27 12:02:14 +01:00
std::string currentText = vkvm::getText();
textRenderer.update(currentText);
vkvm::callEvent(vkvm::EventType::Redraw);
});
2019-11-20 12:50:32 +01:00
std::string command;
std::cout << "TextRender: ";
std::getline(std::cin, command);
2019-12-17 12:06:44 +01:00
while (command != "quit") {
if (command == "clear") {
textRenderer.clear();
2019-12-17 12:06:44 +01:00
} if (command == "redblue") {
vkvm::setBackgroundColor(vkvm::red);
vkvm::setForegroundColor(vkvm::blue);
} else {
vkvm::setText(command);
currentText = vkvm::getText();
textRenderer.update(currentText);
}
std::cout << "TextRender: ";
std::getline(std::cin, command);
}
2019-11-27 12:02:14 +01:00
std::cout << "TextRender finished." << std::endl;
2019-10-15 14:00:06 +02:00
return 0;
2019-12-17 12:06:44 +01:00
}