FullScreen by void draw() in Processing 3.0b6

I try to go in fullscreen mode when I'm in void draw() but with the latest Processing is not possible - just in the setup :(, so I try to use the old method to go in the fullscreen but the methode frame don't support frame.setUndecorated(true); plus now it's a surface method :)

// Fullscreen by the void draw for Processing 3
// 2015 september
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment ;
import java.awt.Rectangle ;

// maybe you must change this var, it depends on the number of screen
int whichScreen = 0 ;
boolean undecorated = true ;

void settings() {
  size(150,150) ;
}

void setup() {
  fullscreen(whichScreen, undecorated) ;
}

void draw() {
  sketchPosition(whichScreen) ;
}

//ANNEXE
GraphicsEnvironment g = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screenDevice = g.getScreenDevices();
PVector[] screenInfo ;


void fullscreen(int whichOne, boolean decor) {
  initNumberScreen() ;
  infoScreen() ;
  screenMode(decor, screenInfo[whichOne]) ;
}

void sketchPosition(int whichScreen) {
  if (whichScreen > screenDevice.length ) whichScreen = 0 ;
  GraphicsDevice displayOnThisDevice = screenDevice[whichScreen];
  GraphicsConfiguration[] graphicsConfigurationOfThisDevice = displayOnThisDevice.getConfigurations();


  // loop with a single element the screen selected above
  for ( int i = 0 ; i < graphicsConfigurationOfThisDevice.length ; i++ ) {
    Rectangle gcBounds = graphicsConfigurationOfThisDevice[i].getBounds() ;
    frame.setLocation(gcBounds.x, gcBounds.y) ;
  }
}



void screenMode(boolean fullscreen, PVector size) {
  if(fullscreen) removeBorder() ;
  surface.setSize((int)size.x,(int)size.y);
}


public void initNumberScreen() {
  screenInfo = new PVector [screenDevice.length] ;
  for ( int i = 0 ; i < screenInfo.length ; i++)  screenInfo [i] = new PVector (0,0,0 ) ;
}

public void infoScreen() {
  for (int i = 0; i < screenInfo.length; i++) {
    // String ID = screenDevice[i].getIDstring() ;
    screenInfo [i].x =  screenDevice[i].getDisplayMode().getWidth() ;
    screenInfo [i].y =  screenDevice[i].getDisplayMode().getHeight() ;
  }
}

void removeBorder() {
  frame.removeNotify();
  frame.setUndecorated(true);
  frame.addNotify();
}
Sign In or Register to comment.