From 52ead051731790283c3474754fa632e52f496114 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Wed, 8 Jan 2020 17:15:18 +0100 Subject: [PATCH] ~ removing unnecessary redraw calls ~ fixing "clang not found" on ci --- .gitlab-ci.yml | 4 ++-- main/main.cpp | 2 +- src/MathFunctions.cpp | 16 ++-------------- src/MathFunctions.hpp | 1 - 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c19629..26c1f76 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ make_test: - docker-ci script: - apt-get update - - apt-get install -y g++ make cmake clang-tidy + - apt-get install -y clang++ make cmake clang-tidy - mkdir current - ls | grep -v current | xargs mv -t current - git clone https://github.com/catchorg/Catch2.git @@ -56,7 +56,7 @@ cmake_build: - docker-ci script: - apt-get update - - apt-get install -y g++ make cmake clang-tidy + - apt-get install -y clang++ make cmake clang-tidy - mkdir current - ls | grep -v current | xargs mv -t current - git clone https://github.com/catchorg/Catch2.git diff --git a/main/main.cpp b/main/main.cpp index 8c6df60..445a9a6 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1 +1 @@ -#include "internal.hpp" #include "vkvm.hpp" #include "../src/Bitmap.hpp" #include "../src/MathFunctions.hpp" #include //time to sleep for in seconds constexpr int sleepTime = 3; void displayImage(const std::string &file, vkvm::GraphicMode graphicMode) { vkvm::setMode(graphicMode); Bitmap image(file); vkvm::setWidth(image.getWidth()); vkvm::setHeight(image.getHeight()); for (int x = 0; x < vkvm::getWidth(); x++) { for (int y = 0; y < vkvm::getHeight(); y++) { unsigned int hex = image.getPixel(x, y); vkvm::Color color = vkvm::Color(hex); vkvm::setPixel(x, y, color); } } } void setColor(vkvm::Color color) { for (int x = 0; x < vkvm::getWidth(); ++x) { for (int y = 0; y < vkvm::getHeight(); ++y) { vkvm::setPixel(x, y, color); } } } void displayImage(const std::string &file) { displayImage(file, vkvm::GraphicMode::RGB); vkvm::callEvent(vkvm::EventType::Redraw); sleep(sleepTime); vkvm::setMode(vkvm::GraphicMode::Gray_256); vkvm::callEvent(vkvm::EventType::Redraw); sleep(sleepTime); vkvm::setMode(vkvm::GraphicMode::TwoColors); vkvm::callEvent(vkvm::EventType::Redraw); sleep(sleepTime); } int main() { bool running = true; vkvm::initialize(0); while(running) { displayImage("../res/P6.bmp"); sleep(sleepTime); vkvm::setBackgroundColor(vkvm::red); vkvm::setForegroundColor(vkvm::blue); vkvm::callEvent(vkvm::EventType::Redraw); sleep(sleepTime); vkvm::setBackgroundColor(vkvm::black); vkvm::setForegroundColor(vkvm::white); vkvm::callEvent(vkvm::EventType::Redraw); displayImage("../res/P8.bmp"); displayImage("../res/P9.bmp"); displayImage("../res/P10.bmp"); vkvm::setText("Hello World"); sleep(sleepTime); vkvm::setFont(vkvm::FontType::FuturisticBlack); vkvm::callEvent(vkvm::EventType::RenderText); sleep(sleepTime); vkvm::setText("Hello World, lorem ipsum dolor sit amet"); sleep(sleepTime); vkvm::setFont(vkvm::FontType::ProFontIIX); vkvm::callEvent(vkvm::EventType::RenderText); sleep(sleepTime); vkvm::setFont(vkvm::FontType::Unifont); vkvm::callEvent(vkvm::EventType::RenderText); sleep(sleepTime); vkvm::setText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."); sleep(sleepTime); vkvm::setMode(vkvm::GraphicMode::RGB); mandelbrot(); sleep(sleepTime); sleep(sleepTime); setColor(vkvm::black); sleep(sleepTime); } } \ No newline at end of file +#include "../src/Bitmap.hpp" #include "../src/MathFunctions.hpp" #include "vkvm.hpp" #include "internal.hpp" #include //time to sleep for in seconds constexpr int sleepTime = 3; void displayImage(const std::string &file, vkvm::GraphicMode graphicMode) { vkvm::setMode(graphicMode); Bitmap image(file); vkvm::setWidth(image.getWidth()); vkvm::setHeight(image.getHeight()); for (int x = 0; x < vkvm::getWidth(); x++) { for (int y = 0; y < vkvm::getHeight(); y++) { unsigned int hex = image.getPixel(x, y); vkvm::Color color = vkvm::Color(hex); vkvm::setPixel(x, y, color); } } } void setColor(vkvm::Color color) { for (int x = 0; x < vkvm::getWidth(); ++x) { for (int y = 0; y < vkvm::getHeight(); ++y) { vkvm::setPixel(x, y, color); } } } void displayImage(const std::string &file) { displayImage(file, vkvm::GraphicMode::RGB); sleep(sleepTime); vkvm::setMode(vkvm::GraphicMode::Gray_256); sleep(sleepTime); vkvm::setMode(vkvm::GraphicMode::TwoColors); sleep(sleepTime); } int main() { bool running = true; vkvm::initialize(0); while(running) { displayImage("../res/P6.bmp"); sleep(sleepTime); vkvm::setBackgroundColor(vkvm::red); vkvm::setForegroundColor(vkvm::blue); sleep(sleepTime); vkvm::setBackgroundColor(vkvm::black); vkvm::setForegroundColor(vkvm::white); displayImage("../res/P8.bmp"); displayImage("../res/P9.bmp"); displayImage("../res/P10.bmp"); vkvm::setText("Hello World"); sleep(sleepTime); vkvm::setFont(vkvm::FontType::FuturisticBlack); vkvm::callEvent(vkvm::EventType::RenderText); sleep(sleepTime); vkvm::setText("Hello World, lorem ipsum dolor sit amet"); sleep(sleepTime); vkvm::setFont(vkvm::FontType::ProFontIIX); vkvm::callEvent(vkvm::EventType::RenderText); sleep(sleepTime); vkvm::setFont(vkvm::FontType::Unifont); vkvm::callEvent(vkvm::EventType::RenderText); sleep(sleepTime); vkvm::setText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."); sleep(sleepTime); vkvm::setMode(vkvm::GraphicMode::RGB); mandelbrot(); sleep(sleepTime); setColor(vkvm::black); sleep(sleepTime); } } \ No newline at end of file diff --git a/src/MathFunctions.cpp b/src/MathFunctions.cpp index 95ee270..9900ef4 100644 --- a/src/MathFunctions.cpp +++ b/src/MathFunctions.cpp @@ -1,18 +1,6 @@ #include "vkvm.hpp" #include -#include -#include -#include #include -#include - -void sinus() { - for (int x = 0; x < vkvm::getWidth(); ++x) { - double y = 300 * sin(x); - vkvm::log(vkvm::LogLevel::DEBUG, y); - vkvm::setPixel(x, static_cast(y), vkvm::getForegroundColor()); - } -} long double map(long double value, long double inputMin, long double inputMax, long double outputMin, long double outputMax) { return (value - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin; @@ -25,7 +13,7 @@ void mandelbrot() { vkvm::setWidth(width); vkvm::setHeight(height); - //vkvm::setRedrawInterval(999999); + vkvm::setRedrawInterval(-1); long double min = -2.84; long double max = 1; @@ -86,5 +74,5 @@ void mandelbrot() { vkvm::callEvent(vkvm::EventType::Redraw); } - //vkvm::setRedrawInterval(999999); + vkvm::setRedrawInterval(500); } diff --git a/src/MathFunctions.hpp b/src/MathFunctions.hpp index 5e6c111..bbfe32d 100644 --- a/src/MathFunctions.hpp +++ b/src/MathFunctions.hpp @@ -1,6 +1,5 @@ #ifndef DEMO_MATHFUNCTIONS_H #define DEMO_MATHFUNCTIONS_H -void sinus(); void mandelbrot(); #endif