Skip to content

Your First Window

Ryan G edited this page Sep 9, 2017 · 2 revisions

Our first example using dgt is very simple:

import dgt;

void main()
{
    Window window = Window("Your First Window", 800, 600, WindowConfig());
}

Paste that into your app.d file and run it. A window should pop up but almost immediately close.

A line by line breakdown

Programmers experienced in D or a similar language may find the above snippet intuitive, but others may find the code less obvious.

import dgt; tells D to take all of the structures and functions from the D Game Toolkit and allow you to use them.

void main() is where the program starts executing.

Window window = Window("Your First Window", 800, 600, WindowConfig()); is the meat of this small program. "Your First Window" is the window title. 800 is the window width in pixels and 600 is the window height. Lastly, WindowConfig tells your window the configuration which informs things like the initial state of the window. We set no arguments so it uses the default configuration

Clone this wiki locally