Loading...
Logo
Processing Forum
P3D call causes setup to be executed 2 times!


Replies(5)

Always place size() at the very top of setup():
Copy code
    final static int WX = 640, WY = 520;
    
    void setup() {
      size(WX, WY, P3D);
      println("Setup");
    }
    
    void draw() {
      noLoop();
    }
    
setup is supposed to be called twice which is why you put the size as the first line - as GotoLoop shows in his post
thanks, works now,
but i was just confused because
when i used not P3D it did not happen ??? hmmm


Processing uses JAVA2D by default. Choosing another 1 @ size() apparently forces it to re-invoke setup()
That's why we repeat the recommendation (given in the reference of size(), obviously rarely read...) of putting size() at the top of setup(), in all cases (including the default mode where it can be less useful): it is a good practice to do it systematically.

I have seen people doing their loadImage() before setup(), resulting in a double loading, or even worse, initializing a library like Minim before size(), getting init errors!