Problem with surface.setResizable(true)

Hello,

surface.setResizable(true) : and the sketch window is resizable.

Problem : if width and height are used, they are not updated anymore when you resize the window

(Processing 4.4.4 + Linux Mint)

See this code :

float width2;
float height2;

void setup() {
  size(800, 600);
  surface.setResizable(true);
  textSize(20);
}

void draw() {
  width2=width;
  height2=height;
  background(color(0,0,255));
  rectMode(CENTER);
  stroke(255);
  text("Width : "+width,40,50);
  text("Height : "+height,40,100);

// This works :
  rect(width2/2,height2/2,100,100);
  
  // This doesn't work !!! WHY ?
  //rect(width/2,height/2,100,100);
}

and sometimes, it doesn’t work in any case !

It works for me on macOS, I will check on my linux mint VM

1 Like

with : rect(width/2,height/2,100,100); and not rect(width2/2,height2/2,100,100); ?

:slightly_smiling_face:

P.S. I know about : windowRatio() !

Ah, so it’s a different issue, the processing sketch crashes on resize, we have seen this issue before.

Can you use P2D for now? That is less likely to crash

2 Likes

Thank you very much !

Now it works in the tiny example (and in my PstarEngine project too !).

:heart_with_ribbon:

1 Like