60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
#include "../src/Bitmap.h"
|
|
#include "../src/Font.h"
|
|
#include "../src/TextRenderer.h"
|
|
#include <internal.hpp>
|
|
#include <iostream>
|
|
|
|
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);
|
|
|
|
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 (command != "quit") {
|
|
if (command == "clear") {
|
|
textRenderer.clear();
|
|
} 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);
|
|
|
|
}
|
|
|
|
|
|
std::cout << "TextRender finished." << std::endl;
|
|
|
|
return 0;
|
|
} |