benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.35k stars 237 forks source link

`fullScreen` Not Working as Expected in External Project #718

Open fullben opened 1 year ago

fullben commented 1 year ago
>Please note that I'm not entirely sure if this is a bug or a configuration issue on my end, since this is about the usage of Processing outside of the PDE context. ## Description

I have a basic Processing-based (4.2) project setup (Gradle 8.X as build tool, IntelliJ IDEA 2023.1 CE as IDE), running on Windows. Within this project, all I am doing right now is trying to open my Sketch in fullscreen mode. Whenever I launch the project from within my IDE, the Processing application window only occupies part of my screen. Note that this behavior only occurs when the display scaling is set to a value greater than or equal to 125% (Windows Settings -> Display -> Scale and Layout -> Change the size of text, apps, and other things). This behavior seems to be independent of the display resolution. I have been testing this on a laptop, running it just with the laptop's own display and while connected to two external displays with a higher resolution. Code looks as follows:

import processing.core.PApplet;

public class FullscreenApp extends PApplet {

  private int x = 0;

  @Override
  public void settings() {
    fullScreen(P3D, 2);
    smooth(2);
  }

  @Override
  public void setup() {
    background(0);
    noStroke();
    fill(102);
  }

  @Override
  public void draw() {
    rect(x, height * 0.2f, 1, height * 0.6f);
    x = x + 2;
  }

  public static void main(String[] args) {
    PApplet.main("FullscreenApp");
  }
}

At the same time, the basically identical Sketch executed from within the PDE (4.2) results in the proper fullscreen experience, regardless of the scaling or monitors used:

int x = 0;

void settings() {
  fullScreen(P3D, 2);
  smooth(2);
}

void setup() {
  background(0);
  noStroke();
  fill(102);
}

void draw() {
  rect(x, height*0.2, 1, height*0.6); 
  x = x + 2;
}

Expected Behavior

I would expect both my external Processing app and the PDE-launched app to also launch in fullscreen mode when having a display scaling of 125% or above.

Current Behavior

Only the Sketch launched from the PDE opens in fullscreen mode. The app launched from my external project only occupies part of my screen. It only occupies the full screen when I switch the display scaling in the Windows settings to 100%.

Note that this behavior is only reproducible with the newer Processing versions. When using an older version (in my case, Processing 3.5.3), fullscreen mode works as expected.

Steps to Reproduce

  1. Have a Windows machine, with a display that uses a scaling of 125% or more
  2. Make sure you have a JRE (language version 17) on your machine
  3. Ideally, IntelliJ IDEA should be installed
  4. Download the example from this repository: https://github.com/fullben/processing-fullscreen-issue
  5. Stay on the master branch (or switch to working-example if you want to verify that fullscreen apps work as expected with older Processing versions)
  6. Follow the instructions in the project README to include the Processing binaries and run the project

Your Environment

Possible Causes / Solutions

I think that this is either a configuration issue on my end or an anomaly introduced during changes made when going from Processing 3.X to 4.X (or a combination of both aspects).

Maybe I'm just missing some binaries or settings in my project? It also seems a bit suspicious to me that the Windows-related DLLs need to be in the <PROJECT_ROOT>/natives directory in order for the application to start (as opposed to being able to reside in a directory next to my Processing JARs).

I have tested this with Processing 3.5.3. When using this Processing version, fullScreen works as expected, regardless of the Windows display scaling settings (see the working-example branch in the example repository). I have also noticed that somewhere between 3.X and 4.X, the Processing core architecture must have changed, since in 3.5.3 I only need to include JARs for running the Sketch, while with 4.X I need to use some DLLs.

gravysauce481 commented 1 year ago

I have the same problem and I tried switching to processing version 3.5.3, but it still doesn't cover the screen.. How did you manage to get it to work?

fullben commented 1 year ago

Have you tried checking out the repository I linked above (https://github.com/fullben/processing-fullscreen-issue) and running the working-example branch? The approach described and implemented there worked for me (with Processing 3.5.3).

Also, as far as I can tell, you are using P2D, while I've just been playing around with P3D. Therefore, I'm not entirely sure if we are experiencing the same issue.

gravysauce481 commented 1 year ago

Well. It surely didn't work, even with the same code in settings. So I did some messing around with my libraries, using glugen and jogl but they had the same effect. Then changing back to jogamp-fat suddenly stopped working. Then I downloaded the latest jogamp-fat, and.. it worked. Coordinates are strangely pushed down a third of the screen though

gravysauce481 commented 1 year ago

Its still unworkable, because its still affected by the magnification in that it creates a strange bar with the colour of background on the top of the screen, height dependent on magnification. This bar blocks out anything drawn underneath, which I found out with text.

gravysauce481 commented 1 year ago

Sorry for the comment spam but its a bit absurd, in the fact that now it creates a proper fullscreen on processing version 4.2, however it still has the bar at the top of the screen.