[Solved] Fullscreen 'screen size' - 640x480 vs 2048x2048

Hi everyone,

I decided to make my app fullscreen. However, setting the height and width actually influences the way things are rendered.

640x480:

2048x2048:

I can imagine you could use this for a Starcraft I look, but I would like one jME pixel to be one screen pixel. How can I get the height and width of my screen? Is there jME support for that or do I have to use some other library?

I saw nothing specific so far going through the wki, but I am not done yet.

Java.awt has Toolkit

Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
// screen width 
int x = d.width;
//screen height
int y = d.height;

https://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html

Edit: Corrected y=height variable,

I searched wiki and found this about Heads up displays, Nifty GUI looks like it may be the jme way to do what I showed.
https://jmonkeyengine.github.io/wiki/jme3/advanced/hud.html

specifically,
https://jmonkeyengine.github.io/wiki/jme3/advanced/hud.html#positioning-hud-elements

Im not there yet, its next on things to learn for me.

Use camera.getWidth() and camera.getHeight() for the window or screen dimensions.

1 Like

Used

GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
int w = gd.getDisplayMode().getWidth();
int h = gd.getDisplayMode().getHeight();

@mitm’s solution would probably also have worked.
Thanks for the input!

1 Like

Yet this one

Was the most straight forward…

No, that gives me the width and height of the jME window.
I needed to know what the width and height are of the screen (monitor), so I can set the width and height through the appsettings.
The application is fullscreen.

Then why not just use setFullScreen(boolean) in appSettings?

http://javadoc.jmonkeyengine.org/com/jme3/system/AppSettings.html#setFullscreen-boolean-

Here’s the class:

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;

import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;

public class Main extends SimpleApplication {

    public static void main( String... args ) {
    	System.out.println(Long.parseLong("2013224671"));
    	
    	GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    	int w = gd.getDisplayMode().getWidth();
    	int h = gd.getDisplayMode().getHeight();
    	
    	System.out.println("w,h: " + w + "," + h);
    	
    	AppSettings sets = new AppSettings(true);
    	sets.setTitle("LightNodeViewer");
        //Mess with these 2 values below:
    	sets.setWidth(w);
    	sets.setHeight(h);

    	sets.setFullscreen(true);
    	
    	Main main = new Main();
    	main.setSettings(sets);
        main.start();
    }
    
    public void simpleInitApp() {
    	System.out.println("w,h: " + cam.getWidth() + "," + cam.getHeight());
    	
    	Geometry geom = new Geometry("something", new Box(1, 1, 1));
    	Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    	geom.setMaterial(mat);
    	rootNode.attachChild(geom);
    }
}

If you mess with it a bit, you will notice that the values you set through the AppState (before camera is even accessible) change the resolution.

So, to be clear, you want to set the app full screen but at the resolution of the desktop when the app was started… regardless of what the user might actually want as their screen resolution?

Yes, then the way you’ve done it is the only way.

…and folks with hires desktops but medium-grade graphics cards will curse your name.

3 Likes