Configure

The configure block is an optional block that is used to configure the run-time environment. Most commonly it is used to configure the size of the window.

An example configuration that sets the window size, window resizability and title is as follows:

import org.openrndr.Fullscreen
import org.openrndr.application
import org.openrndr.extra.noise.primitives.random
import org.openrndr.extra.noise.uniform
import org.openrndr.math.Vector2

fun main() = application {
    configure {
        width = 1280
        height = 720
        windowResizable = true
        title = "OPENRNDR Example"
    }
    program {
    }
}

An example for a full screen window on your second monitor with the mouse pointer hidden:

import org.openrndr.Fullscreen
import org.openrndr.application
import org.openrndr.extra.noise.primitives.random
import org.openrndr.extra.noise.uniform
import org.openrndr.math.Vector2

fun main() = application {
    configure {
        fullscreen = Fullscreen.CURRENT_DISPLAY_MODE
        display = displays[1]
        hideCursor = true
    }
    program {
    }
}

Starting your program with a custom configuration looks roughly like this.

import org.openrndr.Fullscreen
import org.openrndr.application
import org.openrndr.extra.noise.primitives.random
import org.openrndr.extra.noise.uniform
import org.openrndr.math.Vector2

fun main() = application {
    configure {
        // settings go here
    }
    program {
        // -- one time set-up code goes here
        extend {
            // -- drawing code goes here
        }
    }
}

Commonly used configuration options:

PropertyTypeDefault valueDescription
displayDisplay?null (primary display)The display on which to create the window. All detected displays are present in the displays list within the application {} block.
fullscreenFullscreenFullscreen.DISABLEDWhen specified, either Fullscreen.CURRENT_DISPLAY_MODE to make the window match the current display resolution, or Fullscreen.SET_DISPLAY_MODE to change the display resolution to match width and height.
heightInt480Initial window height
positionIntVector2?null (center of the primary display)Initial window position (top-left corner)
titleString"OPENRNDR"Window title
widthInt640Initial window width
multisampleWindowMultisampleWindowMultisample.DisabledCan be increased to a value like WindowMultisample.SampleCount(8) for a smoother rendering

Other available options:

PropertyTypeDefault valueDescription
hideCursorBooleanfalseHide the cursor?
hideWindowDecorationsBooleanfalseHide window decorations?
maximumHeightIntInt.MAX_VALUE / 8Maximum window height
maximumWidthIntInt.MAX_VALUE / 8Maximum window width
minimumHeightInt128Minimum window height
minimumWidthInt128Minimum window width
unfocusBehaviourUnfocusBehaviourUnfocusBehaviour.NORMALThe value UnfocusBehaviour.THROTTLE can be specified to throttle the program to 10Hz when unfocused.
vsyncBooleantrueShould the program wait for vertical retrace to avoid tearing?
windowTransparentBooleanfalseShould the window be transparent?
windowResizableBooleanfalseAllow resizing of window?
windowAlwaysOnTopBooleanfalseKeep the window floating above other windows?

See the API for an complete list.

Changing the configuration while the program runs

To modify the configuration after the program has started we can set various properties via application.

import org.openrndr.Fullscreen
import org.openrndr.application
import org.openrndr.extra.noise.primitives.random
import org.openrndr.extra.noise.uniform
import org.openrndr.math.Vector2

fun main() = application {
    program {
        extend {
            if (frameCount % 60 == 0) {
                application.cursorVisible = Boolean.random()
                application.windowPosition = Vector2.uniform(0.0, 200.0)
            }
        }
    }
}

edit on GitHub