106 lines
2.6 KiB
C++
106 lines
2.6 KiB
C++
#include <logging/types.hpp>
|
|
#include <fmt/format.h>
|
|
#include <renderer/renderer.hpp>
|
|
#include <rwgpu.hpp>
|
|
#include <resources/font.hpp>
|
|
#include <string>
|
|
#include <iostream>
|
|
#include <chrono>
|
|
#include <thread>
|
|
|
|
#include <engine/engine.hpp>
|
|
|
|
#include <pragmautil.hpp>
|
|
|
|
#if defined(_MSC_VER) || defined(_MSC_FULL_VER)
|
|
WARNING("Please avoid using MSVC in C++ projects utilising std::chrono and std::this_thread due to unfixed frame timing issues in the MSVC C++ implementation")
|
|
#endif
|
|
|
|
using namespace hibis;
|
|
using namespace hibis::rwgpu;
|
|
|
|
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;
|
|
}
|
|
|
|
std::cout << fmt::format("[{}]: {}", sevString, message) << std::endl;
|
|
}
|
|
|
|
int main() {
|
|
logger(Information, fmt::format("PWD: {}", std::getenv("PWD")));
|
|
RWGPU renderer = RWGPU("test", IntVec2 {800, 600}, &logger);
|
|
Engine engine = Engine(&renderer, &logger);
|
|
/*
|
|
|
|
#ifdef _WIN32
|
|
Font font = Font(engine.mFreeTypeLibrary, "C:\\Windows\\Fonts\\Arial.ttf", 16);
|
|
#else
|
|
Font font = Font(engine.mFreeTypeLibrary, "/usr/share/fonts/noto/NotoSans-Light.ttf", 16);
|
|
#endif
|
|
|
|
Texture image = Texture((char*)"test.png");
|
|
|
|
system("cp ../test/test.vert ./ && cp ../test/test.frag ./");
|
|
Shader shader = Shader("test.vert", "test.frag");
|
|
renderer.compileShader(&shader);
|
|
|
|
uint8_t red = 0;
|
|
bool increaseRed = true;
|
|
bool increaseSize = true;
|
|
uint size = 16;
|
|
uint f = 0;
|
|
|
|
Point2D points[3] = {{-0.5f, -0.5f}, {0.5f, -0.5f}, {0.0f, 0.5f}};
|
|
*/
|
|
logger(Information, "Started Hibis test app! BEHOLD: Colours.");
|
|
while (renderer.mKeepOpen) {
|
|
/*
|
|
// 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.useShader(&shader, points);
|
|
//renderer.drawText(&font, "Testing Text", IntVec2 {0, 0}, Color {255, 255, 255, 255});
|
|
//renderer.drawTexture(&image, 1.0f, IntVec2 {10, 10});
|
|
|
|
renderer.renderCurrent();
|
|
renderer.update();
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
}
|
|
|
|
return 0;
|
|
}
|