Skip to content

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

Open
@B3ret

Description

@B3ret

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

  • Processing version: .3.7
  • Operating System and OS version: Windows 10, all updates (07/2018)
  • Other information: Bug depends on scaling factor set in Windows. (Note: This is mandatory to be different from 100% on highDPI windows! It's not an edge case!)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedMany hands make light work. Please help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions