2011年1月10日月曜日

Processing サブディスプレイでフルスクリーン

ながらく謎のままだったProcessingでサブディスプレイにフルスクリーンで表示する方法を調査してみした。ひとまず動いたので共有します。


import java.awt.*;

Rectangle monitor = new Rectangle();
boolean bSubdisplay = true;

void setup() { 
  GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
  GraphicsDevice[] gs = ge.getScreenDevices();  
  GraphicsDevice gd = gs[0];
  
  //サブディスプレイがある場合は上書き
  if (gs.length == 2 && bSubdisplay)
  {
    gd = gs[1];
  }
  
  GraphicsConfiguration[] gc = gd.getConfigurations();
  monitor = gc[0].getBounds();

  println(monitor.x + " " + monitor.y + " " + monitor.width + " " + monitor.height);
  size(monitor.width, monitor.height);
  background(0);
}

void draw() {
  frame.setLocation(monitor.x, monitor.y);
  frame.setAlwaysOnTop(true); 
  stroke(255);
  line(0,0,width,height);
}  

public void init() {
  frame.removeNotify();
  frame.setUndecorated(true);
  super.init();
} 

0 件のコメント:

コメントを投稿