« Go back

Create a Window

First we want to create a Window with a specific size (a width of 640 pixel and a height of 480 pixel) and a title. Then we like to display the window buffer for, let's say, 2 seconds (2000 milliseconds):

Show Raw
import Dgame.Window.Window;
import Dgame.Graphic.Color;
import Dgame.System.StopWatch;

void main() {
    Window wnd = Window(640, 480, "Dgame Test");
    wnd.setClearColor(Color4b.Blue); /// Default would be Color.White
    wnd.clear(); /// Clear the buffer and fill it with the clear Color
    wnd.display();
    
    StopWatch.wait(2000);
}

You should see (for 2 seconds) this view:

More constructors

With the other constructors of Window you can specify on which position the Window is shown (default is 100x, 100y), which Style is used, which DisplayMode is used or which OpenGL settings are used. The later is described in a other tutorial.

« Go back