2019-12-17 12:06:44 +01:00
|
|
|
#include "../src/Bitmap.h"
|
|
|
|
#include "../src/Font.h"
|
|
|
|
#include "../src/TextRenderer.h"
|
|
|
|
#include <internal.hpp>
|
2019-11-14 13:12:48 +01:00
|
|
|
#include <iostream>
|
2019-10-15 14:00:06 +02:00
|
|
|
|
2019-12-17 12:06:44 +01:00
|
|
|
bool isQuit(const std::string& command);
|
2019-11-19 13:27:18 +01:00
|
|
|
|
2019-10-16 15:44:13 +02:00
|
|
|
/**
|
2019-10-15 16:12:56 +02:00
|
|
|
* @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.
|
|
|
|
*/
|
2019-11-20 15:51:01 +01:00
|
|
|
void outPutPixel(int windowHeight, int windowWidth, vkvm::Color fontColor);
|
2019-11-19 13:27:18 +01:00
|
|
|
|
2019-10-15 14:00:06 +02:00
|
|
|
int main() {
|
2019-11-19 13:47:30 +01:00
|
|
|
vkvm::initialize(0);
|
|
|
|
|
2019-11-19 13:27:18 +01:00
|
|
|
std::string currentText;
|
|
|
|
|
2019-11-20 12:50:32 +01:00
|
|
|
/**************************get text and font from shared memory*******************************************/
|
2019-12-04 10:18:13 +01:00
|
|
|
|
|
|
|
TextRenderer textRenderer = TextRenderer();
|
2019-11-20 15:51:01 +01:00
|
|
|
textRenderer.setLeftMargin(1);
|
|
|
|
textRenderer.setBottomMargin(1);
|
|
|
|
/*************************get Text and update back to shared meomory********************************************/
|
2019-11-20 12:50:32 +01:00
|
|
|
|
2019-12-04 10:18:13 +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;
|
2019-11-20 15:51:01 +01:00
|
|
|
std::cout << "TextRender: ";
|
2019-11-19 13:27:18 +01:00
|
|
|
std::getline(std::cin, command);
|
2019-12-17 12:06:44 +01:00
|
|
|
while (command != "quit") {
|
2019-12-04 10:18:13 +01:00
|
|
|
if (command == "clear") {
|
2019-11-20 15:51:01 +01:00
|
|
|
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);
|
2019-10-15 16:12:56 +02:00
|
|
|
}
|
2019-12-04 10:18:13 +01:00
|
|
|
std::cout << "TextRender: ";
|
|
|
|
std::getline(std::cin, command);
|
|
|
|
|
2019-10-15 16:12:56 +02:00
|
|
|
}
|
|
|
|
|
2019-11-27 12:02:14 +01:00
|
|
|
|
2019-11-19 13:27:18 +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
|
|
|
}
|