hibiscus/test/source/app.d

52 lines
1.3 KiB
D
Raw Normal View History

2023-05-20 21:27:42 +00:00
import std.stdio;
2023-05-21 21:20:09 +00:00
import std.format;
import std.conv;
2023-05-20 21:27:42 +00:00
2023-05-22 20:22:13 +00:00
import hibis.core.engine;
import hibis.math.types;
import hibis.renderer.renderer;
import hibis.logging.types;
import hibis.callback;
import hibis_rsdl.rsdl;
import hibis_rsdl.resources.font;
2023-05-20 21:27:42 +00:00
import core.thread;
2023-05-21 21:20:09 +00:00
void logger(LoggingSeverity severity, string message) {
writeln(format("[%s]: %s", to!string(severity), message));
}
2023-05-20 21:27:42 +00:00
void main() {
Renderer renderer = new RSDL("test", IntVec2(800, 600), &logger);
2023-05-21 21:20:09 +00:00
Engine engine = new Engine(renderer, &logger);
version(windows) {
Font font = new Font("C:\\Windows\\Fonts\\Arial.ttf", 16);
} else {
Font font = new Font("/usr/share/fonts/noto/NotoSans-Light.ttf", 16);
}
2023-05-21 20:55:02 +00:00
ubyte red = 0;
bool increase = true;
2023-05-23 14:06:13 +00:00
logger(LoggingSeverity.Information, "Started Hibis test app! BEHOLD: Colours.");
while (renderer.keepOpen) {
2023-05-20 21:27:42 +00:00
engine.runNodeProcesses();
2023-05-21 20:55:02 +00:00
// Colour changing background!
if ((red == 255 && increase) || (red == 0 && !increase)) {
increase = !increase;
}
if (increase) red += 1;
else red -= 1;
// Clear screen then sleep for ~16ms
renderer.clearScreen(Color(red, 0, 0, 255));
renderer.drawText(font, "TEST", IntRect(0, 0, 64, 64), Color(255, 255, 255, 255));
2023-05-21 20:55:02 +00:00
engine.drawNodes();
2023-05-21 13:02:53 +00:00
renderer.renderCurrent();
renderer.update();
2023-05-21 13:02:53 +00:00
Thread.sleep(16.msecs);
2023-05-20 21:27:42 +00:00
}
destroy(font);
2023-05-20 21:27:42 +00:00
}