~ use values from shared mem instead of hardcoded ones
~ update ci to latest version
This commit is contained in:
parent
62491ebc9d
commit
efe8c62493
|
@ -5,7 +5,7 @@ bool=false
|
||||||
# explicitly set IFS to contain only a line feed
|
# explicitly set IFS to contain only a line feed
|
||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
filelist="$(find . -not \( -path './*build*' -prune \) -type f ! -name "$(printf "*\n*")")"
|
filelist="$(find . -not \( -path './*build*' -prune \) -not \( -path './include' -prune \) -type f ! -name "$(printf "*\n*")")"
|
||||||
for file in $filelist; do
|
for file in $filelist; do
|
||||||
if echo "$file" | grep -q -E ".*(\.cpp|\.hpp)$" ; then
|
if echo "$file" | grep -q -E ".*(\.cpp|\.hpp)$" ; then
|
||||||
#Extra check missing dependencies due to clang-tidy doesn't toggle exit code.
|
#Extra check missing dependencies due to clang-tidy doesn't toggle exit code.
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
Checks: '*,-llvm-header-guard,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-modernize-use-trailing-return-type,-clang-diagnostic-error'
|
Checks: '*,-llvm-header-guard,-fuchsia*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init,-google-readability-namespace-comments,-llvm-namespace-comment,-cppcoreguidelines-pro-type-vararg,-hicpp-vararg,-modernize-use-trailing-return-type,-readability-magic-numbers,-cppcoreguidelines-avoid-magic-numbers'
|
||||||
WarningsAsErrors: 'true'
|
WarningsAsErrors: 'true'
|
||||||
|
|
|
@ -14,7 +14,15 @@ clang_tidy:
|
||||||
tags:
|
tags:
|
||||||
- docker-ci
|
- docker-ci
|
||||||
script:
|
script:
|
||||||
- sh .ci/clang-tidy.sh;
|
- mkdir current
|
||||||
|
- ls -d .[!.]* | grep -v current | xargs mv -t current
|
||||||
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.repo.digitech.hs-emden-leer.de/link/projekte/ws19/vkvm-new/library.git
|
||||||
|
- mkdir library/build
|
||||||
|
- cd library/build
|
||||||
|
- cmake ..
|
||||||
|
- make
|
||||||
|
- cd ../../current/.ci
|
||||||
|
- sh clang-tidy.sh
|
||||||
|
|
||||||
make_test:
|
make_test:
|
||||||
stage: test
|
stage: test
|
||||||
|
|
|
@ -20,52 +20,34 @@ int main() {
|
||||||
|
|
||||||
std::string currentText;
|
std::string currentText;
|
||||||
|
|
||||||
|
|
||||||
/*************************set back to shared memory(only for test)********************************************/
|
|
||||||
int windowWidth = vkvm::getWidth();
|
|
||||||
int windowHeight = vkvm::getHeight();
|
|
||||||
vkvm::setWidth(windowWidth);
|
|
||||||
vkvm::setHeight(windowHeight);
|
|
||||||
|
|
||||||
vkvm::Color fontColor1(0, 0, 0);
|
|
||||||
vkvm::Color backgroudColor1(255, 255, 255);
|
|
||||||
Font font1("../res/font3.bmp", "../res/font3.toml");
|
|
||||||
vkvm::setFont(vkvm::FontType(3, "font", font1.height(), font1.width()));
|
|
||||||
vkvm::setForegroundColor(fontColor1);
|
|
||||||
vkvm::setBackgroundColor(backgroudColor1);
|
|
||||||
/**************************get text and font from shared memory*******************************************/
|
/**************************get text and font from shared memory*******************************************/
|
||||||
std::string fontResourcePath = "../res/font" + std::to_string(vkvm::getFont().getId()) + ".bmp";
|
|
||||||
std::string fontConfigureFilePath = "../res/font" + std::to_string(vkvm::getFont().getId()) + ".toml";
|
TextRenderer textRenderer = TextRenderer();
|
||||||
Font font = Font(fontResourcePath, fontConfigureFilePath);
|
|
||||||
vkvm::Color fontColor = vkvm::getForegroundColor();
|
|
||||||
vkvm::Color backgroundColor = vkvm::getBackgroundColor();
|
|
||||||
TextRenderer textRenderer(windowWidth, windowHeight, backgroundColor, fontColor, font);
|
|
||||||
textRenderer.setLeftMargin(1);
|
textRenderer.setLeftMargin(1);
|
||||||
textRenderer.setBottomMargin(1);
|
textRenderer.setBottomMargin(1);
|
||||||
/*************************get Text and update back to shared meomory********************************************/
|
/*************************get Text and update back to shared meomory********************************************/
|
||||||
|
|
||||||
vkvm::registerEvent(vkvm::EventType::RenderText, [&textRenderer](){
|
vkvm::registerEvent(vkvm::EventType::RenderText, [&textRenderer]() {
|
||||||
std::string currentText = vkvm::getText();
|
std::string currentText = vkvm::getText();
|
||||||
textRenderer.update(currentText);
|
textRenderer.update(currentText);
|
||||||
vkvm::callEvent(vkvm::EventType::Redraw);
|
vkvm::callEvent(vkvm::EventType::Redraw);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string command;
|
std::string command;
|
||||||
std::cout << "TextRender: ";
|
std::cout << "TextRender: ";
|
||||||
std::getline(std::cin, command);
|
std::getline(std::cin, command);
|
||||||
while(!isQuit(command)) {
|
while (!isQuit(command)) {
|
||||||
if(command.compare("clear")) {
|
if (command == "clear") {
|
||||||
vkvm::setText(command);
|
|
||||||
currentText = vkvm::getText();
|
|
||||||
textRenderer.update(currentText);
|
|
||||||
outPutPixel(windowHeight, windowWidth, fontColor);
|
|
||||||
std::cout << "TextRender: ";
|
|
||||||
std::getline(std::cin, command);
|
|
||||||
} else {
|
|
||||||
textRenderer.clear();
|
textRenderer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vkvm::setText(command);
|
||||||
|
currentText = vkvm::getText();
|
||||||
|
textRenderer.update(currentText);
|
||||||
|
std::cout << "TextRender: ";
|
||||||
|
std::getline(std::cin, command);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,20 +56,6 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************read pixel in shared memory and test output in console******************************************/
|
|
||||||
void outPutPixel(int windowHeight, int windowWidth, vkvm::Color fontColor) {
|
|
||||||
for(int y = 0; y < windowHeight; y++) {
|
|
||||||
for(int x = 0; x < windowWidth; x++) {
|
|
||||||
if(vkvm::getPixel(x, y).getRed() == fontColor.getRed()) {
|
|
||||||
std::cout << "*";
|
|
||||||
} else {
|
|
||||||
std::cout << " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// std::string str;
|
// std::string str;
|
||||||
// std::cout << "string to draw: ";
|
// std::cout << "string to draw: ";
|
||||||
|
|
|
@ -3,26 +3,25 @@
|
||||||
//
|
//
|
||||||
#include "TextRenderer.h"
|
#include "TextRenderer.h"
|
||||||
|
|
||||||
TextRenderer::TextRenderer(int windowWidth, int windowHeight, vkvm::Color backgroundColor, vkvm::Color fontColor, Font font)
|
|
||||||
: backgroundColor(backgroundColor), fontColor(fontColor), font(font) {
|
TextRenderer::TextRenderer() {}
|
||||||
this-> windowWidth = windowWidth;
|
|
||||||
this-> windowHeight = windowHeight;
|
|
||||||
fontWidth = font.width();
|
|
||||||
fontHeight = font.height();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextRenderer::update(std::string newText) {
|
void TextRenderer::update(std::string newText) {
|
||||||
int startX = 0;
|
int startX = 0;
|
||||||
int startY = 0;
|
int startY = 0;
|
||||||
int i;
|
int i;
|
||||||
int fontNumbersInOneLine = windowWidth / (fontWidth + left_margin);
|
std::string fontResourcePath = "../res/font" + std::to_string(vkvm::getFont().getId()) + ".bmp";
|
||||||
|
std::string fontConfigureFilePath = "../res/font" + std::to_string(vkvm::getFont().getId()) + ".toml";
|
||||||
|
font = Font(fontResourcePath, fontConfigureFilePath);
|
||||||
|
int fontNumbersInOneLine = vkvm::getWidth() / (vkvm::getFont().getWidth() + left_margin);
|
||||||
std::vector<std::vector<bool>> characterBitmap;
|
std::vector<std::vector<bool>> characterBitmap;
|
||||||
|
|
||||||
for(i = 0; i < newText.size(); i++) {
|
for(i = 0; i < newText.size(); i++) {
|
||||||
if(i > oldText.size() || oldText[i] != newText[i]) {
|
if(i > oldText.size() || oldText[i] != newText[i]) {
|
||||||
startX = (i % fontNumbersInOneLine) * (fontWidth + left_margin);
|
startX = (i % fontNumbersInOneLine) * (font.width() + left_margin);
|
||||||
startY = (i / fontNumbersInOneLine) * (fontHeight + bottom_margin);
|
startY = (i / fontNumbersInOneLine) * (font.height() + bottom_margin);
|
||||||
characterBitmap = getCharacter(newText[i], font);
|
characterBitmap = getCharacter(newText[i]);
|
||||||
// fontProcessing(characterBitmap);
|
// fontProcessing(characterBitmap);
|
||||||
translateToSharedMemory(characterBitmap, startX, startY);
|
translateToSharedMemory(characterBitmap, startX, startY);
|
||||||
}
|
}
|
||||||
|
@ -33,9 +32,9 @@ void TextRenderer::update(std::string newText) {
|
||||||
|
|
||||||
void TextRenderer::clear() {
|
void TextRenderer::clear() {
|
||||||
int x, y;
|
int x, y;
|
||||||
for(y = 0; y < windowHeight; y++) {
|
for(y = 0; y < vkvm::getHeight(); y++) {
|
||||||
for(x = 0; x < windowWidth; x++) {
|
for(x = 0; x < vkvm::getWidth(); x++) {
|
||||||
vkvm::setPixel(x, y, backgroundColor);
|
vkvm::setPixel(x, y, vkvm::getBackgroundColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +43,7 @@ void TextRenderer::setOldText(std::string text) {
|
||||||
oldText = text;
|
oldText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::vector<bool>> TextRenderer::getCharacter(unsigned char character, Font font) {
|
std::vector<std::vector<bool>> TextRenderer::getCharacter(unsigned char character) {
|
||||||
int fontHeight = font.height();
|
int fontHeight = font.height();
|
||||||
int fontWidth = font.width();
|
int fontWidth = font.width();
|
||||||
std::vector<std::vector<bool>> bitmap_character;
|
std::vector<std::vector<bool>> bitmap_character;
|
||||||
|
@ -62,43 +61,18 @@ std::vector<std::vector<bool>> TextRenderer::getCharacter(unsigned char characte
|
||||||
return bitmap_character;
|
return bitmap_character;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextRenderer::fontProcessing(std::vector<std::vector<bool>> characterBitmap) {
|
|
||||||
// if(isBold()) {
|
|
||||||
for (int i = fontHeight - 1; i >= 0; i--) {
|
|
||||||
for (int j = fontWidth - 1; j >= 0; j--) {
|
|
||||||
if (i != fontHeight - 1 && j != fontWidth - 1 && characterBitmap[i][j]) {
|
|
||||||
characterBitmap[i + 1][j] = true;
|
|
||||||
characterBitmap[i][j + 1] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
// if(isUnderline()) {
|
|
||||||
// for (int j = 0; j < fontWidth; j++)
|
|
||||||
// characterBitmap[fontHeight - 1][j] = true;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextRenderer::isBold() {
|
|
||||||
return type & BOLD != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TextRenderer::isUnderline() {
|
|
||||||
return type & UNDERLINE != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextRenderer::translateToSharedMemory(std::vector<std::vector<bool>> characterBitmap, int startX, int startY) {
|
void TextRenderer::translateToSharedMemory(std::vector<std::vector<bool>> characterBitmap, int startX, int startY) {
|
||||||
int x, y;
|
int x, y;
|
||||||
int currentX = startX;
|
int currentX = startX;
|
||||||
int currentY = startY;
|
int currentY = startY;
|
||||||
|
|
||||||
for(y = 0; y < fontHeight; y++) {
|
for(y = 0; y < font.height(); y++) {
|
||||||
for(x = 0; x < fontWidth; x++) {
|
for(x = 0; x < font.width(); x++) {
|
||||||
if(characterBitmap[y][x]) {
|
if(characterBitmap[y][x]) {
|
||||||
vkvm::setPixel(currentX, currentY, fontColor);
|
vkvm::setPixel(currentX, currentY, vkvm::getForegroundColor());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vkvm::setPixel(currentX, currentY, backgroundColor);
|
vkvm::setPixel(currentX, currentY, vkvm::getBackgroundColor());
|
||||||
}
|
}
|
||||||
currentX++;
|
currentX++;
|
||||||
}
|
}
|
||||||
|
@ -107,14 +81,14 @@ void TextRenderer::translateToSharedMemory(std::vector<std::vector<bool>> charac
|
||||||
}
|
}
|
||||||
|
|
||||||
for(x = 0; x < left_margin; x++) {
|
for(x = 0; x < left_margin; x++) {
|
||||||
for(y = 0; y < fontHeight; y++) {
|
for(y = 0; y < font.height(); y++) {
|
||||||
vkvm::setPixel(startX + fontWidth + x, startY + y, backgroundColor);
|
vkvm::setPixel(startX + font.width() + x, startY + y, vkvm::getBackgroundColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(y = 0; y < bottom_margin; y++) {
|
for(y = 0; y < bottom_margin; y++) {
|
||||||
for(x = 0; x < fontWidth + left_margin; x++) {
|
for(x = 0; x < font.width() + left_margin; x++) {
|
||||||
vkvm::setPixel(startX + x, startY + fontHeight + y, backgroundColor);
|
vkvm::setPixel(startX + x, startY + font.height() + y, vkvm::getBackgroundColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,31 +22,21 @@
|
||||||
*/
|
*/
|
||||||
class TextRenderer {
|
class TextRenderer {
|
||||||
public:
|
public:
|
||||||
TextRenderer(int windowWidth, int windowHeight, vkvm::Color defaultBackgroundColor, vkvm::Color fontColor, Font font);
|
TextRenderer();
|
||||||
|
|
||||||
void update(std::string text);
|
void update(std::string text);
|
||||||
void setOldText(std::string text);
|
void setOldText(std::string text);
|
||||||
std::vector<std::vector<bool>> getCharacter(unsigned char character, Font font);
|
std::vector<std::vector<bool>> getCharacter(unsigned char character);
|
||||||
void setLeftMargin(int margin);
|
void setLeftMargin(int margin);
|
||||||
void setBottomMargin(int margin);
|
void setBottomMargin(int margin);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string oldText;
|
std::string oldText;
|
||||||
vkvm::Color backgroundColor;
|
|
||||||
vkvm::Color fontColor;
|
|
||||||
Font font;
|
|
||||||
int left_margin = 1;
|
int left_margin = 1;
|
||||||
int bottom_margin = 1;
|
int bottom_margin = 1;
|
||||||
int type;
|
int type;
|
||||||
int windowWidth;
|
Font font;
|
||||||
int windowHeight;
|
|
||||||
int fontWidth;
|
|
||||||
int fontHeight;
|
|
||||||
bool isBold();
|
|
||||||
bool isItalics();
|
|
||||||
bool isUnderline();
|
|
||||||
void fontProcessing(std::vector<std::vector<bool>> characterBitmap);
|
|
||||||
void translateToSharedMemory(std::vector<std::vector<bool>> characterBitmap, int startX, int startY);
|
void translateToSharedMemory(std::vector<std::vector<bool>> characterBitmap, int startX, int startY);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue