Hi there. I would like to write a program that only has text output. Is there a way to prevent processing from opening a graphics window?
Thanks for your help.
Cheers, Adrian.
Yes there is!
While it is possible to hide the window you can prevent it from opening in the first place! This would be an example:
NONERenderer.java
import processing.core.*;
public class NONERenderer extends processing.core.PGraphics {
public PApplet instance;
public NONERenderer() {
}
@Override
public void setParent(PApplet p) {
instance=p;
}
@Override
public void setPrimary(boolean b) {
}
@Override
public PSurface createSurface() {
return new EmptySurface(this);
}
class EmptySurface extends PSurfaceNone{
EmptySurface(PGraphics pg){
super(pg);
}
@Override
public void initFrame(PApplet sketch){
initOffscreen(sketch);
}
}
}
MainSketch.pde
void setup() {
size(100, 100, "NONERenderer");
}
void draw() {
println("text");
exit();
}
What this code does is creating a renderer that simmply doesn’t open a window. It is also ill-adviced to try and use graphics-commands on this as there is no window.
1 Like
Another option is to just not show the window (may see flash):
void setup(){
surface.setVisible(false);
}
2 Likes
Great, It works flawlessly.
Thanks guys!
Cheers,
Adrian.
This is what i use when crunching numbers, sometimes when you push escape to close the window and it doesn’t work until you click, use surface.setVisible(true) and it works every time