52 lines
1.3 KiB
D
52 lines
1.3 KiB
D
import std.stdio;
|
|
import std.format;
|
|
import std.conv;
|
|
|
|
import hibis.core.engine;
|
|
import hibis.math.types;
|
|
import hibis.renderer.renderer;
|
|
import hibis.resources.font;
|
|
import hibis.logging.types;
|
|
import hibis.callback;
|
|
import hibis_rsdl;
|
|
|
|
import core.thread;
|
|
|
|
void logger(LoggingSeverity severity, string message) {
|
|
writeln(format("[%s]: %s", to!string(severity), message));
|
|
}
|
|
|
|
void main() {
|
|
Renderer renderer = new RSDL("test", IntVec2(800, 600));
|
|
Engine engine = new Engine(renderer, &logger);
|
|
version(windows) {
|
|
Font font = new Font(engine.freetypeLib, "C:\\Windows\\Fonts\\Arial.ttf");
|
|
} else {
|
|
Font font = new Font(engine.freetypeLib, "/usr/share/fonts/noto/NotoSans-Light.ttf");
|
|
}
|
|
ubyte red = 0;
|
|
bool increase = true;
|
|
|
|
logger(LoggingSeverity.Information, "Started Hibis test app! BEHOLD: Colours.");
|
|
while (renderer.keepOpen) {
|
|
engine.runNodeProcesses();
|
|
|
|
// 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", 16, IntVec2(0, 0));
|
|
|
|
engine.drawNodes();
|
|
renderer.renderCurrent();
|
|
renderer.update();
|
|
Thread.sleep(16.msecs);
|
|
}
|
|
destroy(font);
|
|
}
|