Tutorials»Hello World

Hello World

Create a HelloWorld.d module, substituting "path/to/hybrid/common" with a path which is a parent to the themes directory:

module HelloWorld;

private {
    import xf.hybrid.Hybrid;
    import xf.hybrid.backend.GL;

    // for Thread.yield
    import tango.core.Thread;
}



void main() {
    scope cfg = loadHybridConfig(`./HelloWorld.cfg`);
    scope renderer = new Renderer;
    gui.vfsMountDir(`path/to/hybrid/common`);

    bool programRunning = true;
    while (programRunning) {
        gui.begin(cfg);
            if (gui().getProperty!(bool)("main.frame.closeClicked")) {
                programRunning = false;
            }
        gui.end();
        gui.render(renderer);
        Thread.yield();
    }
}

For explanations, please refer to APIOverview.


In the same directory, create a HelloWorld.cfg file containing:

import "themes/default.cfg"

new FramedTopLevelWindow main {
    frame.text = "Hello world";
    size = 160 120;
}


We'll use ReBuild in order to build the HelloWorld module. It needs to be given two -I options: One for the dir that contains the top-level xf package, another for the xf/ext directory, for instance:

rebuild -I/coding/d/ -I/coding/d/xf/ext HelloWorld