2023-05-26 21:41:51 +00:00
|
|
|
#include <logging/types.hpp>
|
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <renderer/renderer.hpp>
|
|
|
|
#include <rsdl.hpp>
|
|
|
|
#include <resources/font.hpp>
|
|
|
|
#include <resources/font.hpp>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <chrono>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
#include <engine/engine.hpp>
|
|
|
|
|
2023-05-27 17:11:46 +00:00
|
|
|
#include <pragmautil.hpp>
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) || defined(_MSC_FULL_VER)
|
|
|
|
WARNING("Please avoid using MSVC in C++ projects utilising std::chrono due to frame timing issues")
|
|
|
|
#endif
|
|
|
|
|
2023-05-26 21:41:51 +00:00
|
|
|
using namespace hibis;
|
|
|
|
using namespace hibis::rsdl;
|
|
|
|
|
|
|
|
void logger(LoggingSeverity severity, std::string message) {
|
|
|
|
std::string sevString;
|
|
|
|
switch (severity) {
|
|
|
|
case Message:
|
|
|
|
sevString = "Message";
|
|
|
|
break;
|
|
|
|
case Information:
|
|
|
|
sevString = "Information";
|
|
|
|
break;
|
|
|
|
case Warning:
|
|
|
|
sevString = "Warning";
|
|
|
|
break;
|
|
|
|
case Error:
|
|
|
|
sevString = "Error";
|
|
|
|
break;
|
|
|
|
case Fatal:
|
|
|
|
sevString = "Fatal";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-05-27 17:11:46 +00:00
|
|
|
std::cout << fmt::format("[{}]: {}", sevString, message) << std::endl;
|
2023-05-26 21:41:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
RSDL renderer = RSDL("test", IntVec2 {800, 600}, &logger);
|
|
|
|
Engine engine = Engine(&renderer, &logger);
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
Font font = Font("C:\\Windows\\Fonts\\Arial.ttf", 16);
|
|
|
|
#else
|
|
|
|
Font font = Font("/usr/share/fonts/noto/NotoSans-Light.ttf", 16);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
unsigned char red = 0;
|
|
|
|
bool increaseRed = true;
|
|
|
|
bool increaseSize = true;
|
|
|
|
uint size = 16;
|
|
|
|
uint f = 0;
|
|
|
|
|
|
|
|
logger(Information, "Started Hibis test app! BEHOLD: Colours.");
|
2023-05-27 19:47:34 +00:00
|
|
|
while (renderer.mKeepOpen) {
|
2023-05-26 21:41:51 +00:00
|
|
|
engine.runNodeProcesses();
|
|
|
|
|
|
|
|
// Colour changing background!
|
|
|
|
if ((red == 255 && increaseRed) || (red == 0 && !increaseRed)) {
|
|
|
|
increaseRed = !increaseRed;
|
|
|
|
}
|
|
|
|
if (increaseRed) red += 1;
|
|
|
|
else red -= 1;
|
|
|
|
|
|
|
|
f++;
|
|
|
|
if (f == 16) {
|
|
|
|
f = 0;
|
|
|
|
if ((size == 64 && increaseSize) || (size == 16 && !increaseSize)) {
|
|
|
|
increaseSize = !increaseSize;
|
|
|
|
}
|
|
|
|
if (increaseSize) size += 2;
|
|
|
|
else size -= 2;
|
|
|
|
font.setFontSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear screen then sleep for ~16ms
|
|
|
|
renderer.clearScreen(Color {red, 0, 0, 255});
|
|
|
|
renderer.drawText(&font, "Testing Text", IntVec2 {0, 0}, Color {255, 255, 255, 255});
|
|
|
|
|
|
|
|
engine.drawNodes();
|
|
|
|
renderer.renderCurrent();
|
|
|
|
renderer.update();
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|