processing / processing4-javafx

JavaFX library for Processing 4
14 stars 5 forks source link

FX2D renderer behaves inconsistently using surface.setSize(), displayHeight, displayWidth #9

Open B3ret opened 6 years ago

B3ret commented 6 years ago

Description

Under the default Renderer, a combination of displayHeight, displayWidth and surface.setSize() can be used to set the window size to a specified portion of the screen size.

Under the FX2D-Renderer, displayHeight and displayWidth report the same values, but surface.setSize() seems to adhere to the Windows scaling factor on HighDPI displays, (similar to all other drawing calls, which seem to not work on screen pixels anymore).

Expected Behavior

surface.setSize() should work on the same pixel metric as displayHeight and displayWidth, or there should be another way to specify the window size as a portion of the screen size.

Current Behavior

There is no way from within processing to achieve a drawing size relative to the current screen size.

Steps to Reproduce

Execute the code below on highDPI Windows with a scaling factor >100%. The drawing height and width will be scaled by the windows scaling factor for FX2D, but not for the default renderer.

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

boolean _isFirstRun = true;

void draw()
{
  if(_isFirstRun)
  {
    _isFirstRun = false;
    setDefaultWindowSize();
  }

  textSize(20);
  text("Renderer: " + sketchRenderer(), 10, 20);

  text("displayWidth: " + displayWidth, 10, 70);
  text("displayHeight: " + displayHeight, 10, 90);
  text("displayDensity(): " + displayDensity(), 10, 110);

  text("width: " + width, 10, 170);
  text("height: " + height, 10, 190);
}

void setDefaultWindowSize() 
{
  surface.setSize(displayWidth / 3, displayHeight / 3);
}

I attached the output for Default/FX2D and scaling factors 100%/150% below.

Your Environment

Possible Causes / Solutions

displayDensity() could return a float instead of an int and capture this scaling factor as well. surface.setSizeInScreenPixels() could be introduced.

FX2D, 150% Windows scaling factor (KO): fx2drenderer_150percent

Default, 150% Windows scaling factor (OK): defaultrenderer_150percent

Default, 100% Windows scaling factor (OK): defaultrenderer_100percent

FX2D, 100% Windows scaling factor (OK): fx2drenderer_100percent

gohai commented 6 years ago

@B3ret I have yet to use the experimental FX2D renderer myself, but this looks like a thorough report - thanks for including the screenshots!

dgray001 commented 2 years ago

Got this issue today only after upgrading to processing 4.