processing / processing4-javafx

JavaFX library for Processing 4
14 stars 5 forks source link

Y-dimension origin and scaling differs between default/FX2D and P2D/P3D renderer #11

Open ghost opened 6 years ago

ghost commented 6 years ago

Description

When drawing 2d objects origin and scaling in y-dimension behaves differently depending on the renderer used.

Expected Behaviour

An object drawn at (0,0) should always be drawn at the top left corner of the window. An object drawn at (width, height) should always be drawn at the bottom right corner.

Current Behaviour

Using the default or the FX2D renderer the behaviour is correct.

Using the P2D or the P3D renderer objects drawn at (0,0) are drawn outside the window above the top left corner. An object drawn at (width, height) is drawn a little under the bottom right corner. So both the origin and the scale are incorrect. I don't expect this behaviour to be pixel perfect, because this isn't possible with OpenGL renderers. But the offset is about 30 pixels, which is a lot.

Steps to Reproduce

void settings() {
  size(400, 300, P3D);
}

void draw(){
  rect(0, 0, 50, 50);
  rect(width-100, 50, 50, 50);
  rect(width-50, height-50, 50, 50);
  rect(50, height-100, 50, 50);
}

renderer scaling problem

My Environment

Processing version: 3.3.6 Operating system: Windows 10 Pro (Version 1703, build 15063.786)

Possible Causes / Solutions

Translating and scaling provides a workaround:

translate(0, 29);
scale(1, height/(height+33.0));

Translation and scaling values are from observations.

JakubValtar commented 6 years ago

Hi, thanks for reporting, I will need some more information.

If you go into display settings, what is your display scale? Do you have a custom scale or one from the dropdown (100%, 125%, 150%, ...)?

Do you run the sketch on integrated graphics card (intel) or dedicated (radeon/geforce)?

Is there anything unusual about your machine (multiple monitors, VR headset...)?

vormplus commented 6 years ago

One of my students ran into a similar error on Windows 10. Screenshots below show what's going on.

The first thing I've checked is if the windows have the correct size with the default renderer and with the P3D renderer. This seems to be ok (see blue overlay).

In the P3D renderer, the red rectangle is drawn just behind the title bar. The area below the title bar is 800 x 600 pixels, as defined in size(). When I measured the red rectangle, it is looks like the (0,0) coordinate is located at the top-left corner of the title bar.

default-renderer-ok

p3d-renderer-error