Skip to content

Window Size and Full Screen

Casey Reas edited this page Sep 21, 2015 · 21 revisions

This page is currently in progress. Don't trust anything here yet -- we're working on it. Right now, this is the document for Processing 2.0 and we're working through it.


This page covers window sizing with sketches as well as full screen mode. In Processing 3.0, there are improvements and changes to how full screen is handled, as well as improved multiple monitor support.

Making Sketches Resizable

This section only pertains to the desktop version of Processing (not JavaScript or Android), because it's the only one to use windows and frames.

It's possible to make the sketch window resizable. To do this, use the following:

void setup() {
  size(400, 400);  // size always goes first!
  if (surface != null) {
    surface.setResizable(true);
  }
}

This is not enabled by default because most sketches won't behave well when resized. If a sketch is running inside a web browser, the surface variable will be null.

You can also change the size of the window using the Java method surface.setSize(w, h). Note that you must first set the frame to be resizable.

Running at Full Screen

With Processing 3.0, use the fullScreen() function to run at full screen. Alternately, use Sketch → Present as an alternative to Sketch → Run to enter full screen mode.

The displayWidth and displayHeight variables

The displayWidth and displayHeight variables contain the width and height of the screen where the sketch was launched. So to run a sketch that uses the full width and height of the screen, use the following:

void setup() {
  size(displayWidth, displayHeight);
}

You'll still need to use Present to start the sketch, otherwise the window will have a frame around it, unless you use sketchFullScreen(), described below.

Note that if you move the sketch to another display while it's running, these variables will not update.

In Ubuntu Linux under Unity, the default desktop environment, it's often not possible to cover the screen completely with your Processing sketch. You can use a second desktop environment which does full screen just fine.

By using this mode, Processing doesn't have to guess whether you're going to run full screen, which can simplify things a little.

Disabling Full Screen Mode

You can use the Java method surface.setSize(w, h) to change the size of the window, even one that has started at full screen. However, this window will not have a title bar. It's just too problematic and prone to bugs to toggle between the two types of windows (full screen with no extra edges, and a smaller window with title bar and grow box).

Using Multiple Monitors

A lot of effort has gone into fixing up support for multiple displays in 3.0.

By default, a full screen application doesn't cover multiple displays. This is often the preferred solution (for instance, when coding on one monitor and displaying on another). In some cases (usually involving OpenGL), using a single sketch across multiple displays may cause it to run more slowly. This depends on the graphics card, drivers, etc. and is out of our control.

fullScreen() on any display

The fullScreen() function has parameters to define on which screen to run the software and to span the software across multiple displays as a continuous surface. For example, to display full screen on the second display, use this code:

void setup() {
  fullScreen(2);
  ellipse(width/2, height/2, height, height);
}

Running a sketch across multiple displays

If you want to use multiple monitors as a continuous window, use fullScreen() and use SPAN as the parameter instead of the number of an individual screen.

void setup() {
  fullScreen(SPAN);
  ellipse(width/2, height/2, height, height);
}

See the fullScreen() reference for more information.

“Run sketches on display” option in Preferences

A new option has been added to the Preferences window that sets the display where sketches are initially placed. As usual, if the sketch window is moved, it will re-open at the same location, however when running in full screen mode through Sketch → Present, the display selected here will always be used.

When exporting an application, that display preference will be saved into the exported application.

Clone this wiki locally