surface.setVisible() on different renderers

My idea is to have a fullscreen sketch controlled by a "allwaysontop" G4P GWindow. Sometimes there won't be 2 screens and the main window and GWindow will be on the same screen, and sometimes I will need to access the desktop to drop files. I want to turn the fullscreen window invisible.

int nFrame = 0;
boolean visible = true;

void setup() {
  size(300, 200);
}

void draw() {
  background(255);
  nFrame++;
  println(nFrame);
  if(nFrame % 60 == 0) {
    surface.setVisible(visible = !visible);
  }
}

This test shows that setVisible works as expected with the default renderer. On Linux, the invisible window behave as a minimized application. With P2D, P3D and FX2D, frame count stops the moment the window is invisible. The behavior is erratic: sometimes it looks minimized, later it disappears. If it looks minimized you can click on the indicator to "turn it on". Usually crashes if you try setVisible(true) enough times. For now I will continue with JAVA2D, but P2D has better fullscreen support and speed. Any idea?

Tagged:

Answers

  • I use Windows 8.1 and have so far not had any problem with surface.setVisible(false) on any of the renderers. However, I shall try the newest Processing this weekend and check. Perhaps this is a Linux only problem.

  • Processing 3.3 and Win 10. Works fine for default renderer by it doesn't for P2D/OPENGL. Using the code above, the sketch starts visible and when its visibility is set to false, then it becomes unresponsive.

    I observed this in Linux recently as well: https://forum.processing.org/two/discussion/comment/93970/#Comment_93970

    Kf

  • It looks like the loop is interrupted when doing setVisible(false) on OPENGL renderers. A way to avoid or reduce instability is to call noLoop() before setVisible(false) and turn it on after setVisible(true). Of course you need a 2nd thread (like a G4P window) to make this work.

  • Processing 3.3.3 and Windows 8.1. No problem for JAVA2D, but the other renderers (FX2D, P2D and P3D) don't work.

  • edited May 2017

    @linuxman You refer to a G4P window as a thread, but I hope you know that a new thread can be created quite easily, and doesn't require G4P?

  • It was just a practical example.

Sign In or Register to comment.