Created
August 14, 2013 05:52
-
-
Save comoc/6228354 to your computer and use it in GitHub Desktop.
An example of fullscreen sketch under multi-screen environment for Processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fullscreen sketch example under multi-screen environment | |
// @see http://processing.org/discourse/beta/num_1185318989.html | |
import java.awt.*; | |
static final int PREFERRED_GRAPHICS_DEVICE_INDEX = 1; //< This value represents the target monitor. | |
Rectangle monitorBounds = new Rectangle(); | |
public void init() { | |
frame.removeNotify(); | |
frame.setUndecorated(true); | |
frame.addNotify(); | |
super.init(); | |
} | |
void setup() { | |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
GraphicsDevice[] gs = ge.getScreenDevices(); | |
int realScreenIndex = PREFERRED_GRAPHICS_DEVICE_INDEX; | |
if (gs.length <= 1) | |
realScreenIndex = 0; | |
GraphicsDevice gd = gs[realScreenIndex]; | |
GraphicsConfiguration gc = gd.getDefaultConfiguration(); | |
monitorBounds = gc.getBounds(); | |
size(monitorBounds.width, monitorBounds.height); | |
frame.setLocation(monitorBounds.x, monitorBounds.y); | |
} | |
void draw() { | |
frame.setLocation(monitorBounds.x, monitorBounds.y); | |
frame.setAlwaysOnTop(true); | |
background(0); | |
text("FPS:" + frameRate, 20, 20); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment