Hello Guys,
I’m not totally sure it is related to JME but maybe someone encountered this issue.
I’m getting different resolutions when running my JME scenes from IDE vs Outside the IDE (I’m using InteliJ).
The problem is that I get different screen size when using a given resolution (e.g. 1400x800). It looks correct when running from the IDE but bigger than it should be when running outside of the IDE…
Here is a sample video demonstrating the problem:
It’s the same code , same flow , same settings. Here is the setup code:
What is your desktop resolution? 1400x800? Because that’s what the second launch looks like.
Try to run it without the IDE by using gradlew.bat run (if you have a gradle wrapper laying around).
The difference here is the JVM: You compiled it somehow so it uses another JVM than gradle.
In case you did some native compilation, then this is probably doing something.
Are you also certain that setCanvasSize works, e.g. by printing it out?
The centering could also be key here, because I guess that is what your last line in the upper code block is supposed to do? If so, print our all the values there and see how they differ. If they don’t, then the native compilation somehow messes with the canvas.
I’m not doing any native compilation, just wrapping it as executable using launch4j.
I did printed the canvas size in run-time in both cases and in both it was the same 1400x800 , which is BTW smaller than my desktop resolution.
It’s like that the Swing window of the SimpleApplication (JME uses Swing window right?) is somehow created in bigger size and JME’s drawing canvas is stretched to fit that size.
I will do some more tests… maybe it’s something with the launch4j that messes things here.
Also, this behavior is not consistent on all computers I tested my app. On some of them it runs just fine
there’s also an example for that , here take a look ,but remember the code order is a very essential & there’s no need for Thread.sleep() you can remove it , its just for demostration
Copy the proper jre into a bin folder with the game & force launch4j to use it , it will increase the game size a little bit by 250-300mbs & encourage to copy only jre which you can found inside jdk in some cases if you donot have jre
Find the java.exe files, and right-click. (Windows only!) In the context menu, go Properties->compatibility There should be a checkbox for Override High DPI Scaling behavior, as well as an option field for Scaling performed by:
Do these settings match from one to the other?
Does changing them change the launch behavior?
The centering thing may just be Windows being weird with where it puts new windows. However, If the scaling settings are involved, it may be that the Offset that would center the normal size window is also getting scaled. From the video, it appears that the scaled window would be centered if the entire display had been scaled by the same amount.
This is interesting. I already deleted the 251 version so now the problem is gone but I will try to re-install and see if it changes the launch behavior.
regarding centering - I don’t think it a real problem because I’m trying to center according to the AppSettings but the window was actually scaled so it makes sense that the calculation were not correct in that case.