-1

I have a simple game made with LWJGL 2, and i want it to get the best resolution that's possible for a given window size.

It seems that there is something to do with the DisplayMod, but if i am not in FullScreen mod, it doesn't change game resolution, it just resize the window.

I am able to do what i want in FullScreen via: Display.setDisplayMode(DisplayMode), but as i said, if the Display is not in full screen mod, it just change the window size, but not the resolution.

So my question is, how to get a better resolution without fullscreen/resizing the window?

EDIT (04/08/2017):
To help you to understand my problem, i have recored a short video when a switch to FullScreen/Windowed: https://www.mediafire.com/file/j9t06qa3aaw9e59/Resolution%20bug.mov

2 Answers2

1

To change the game resolution in Fullscreen when you create your frame juste put

Display.setFullscreen(true);

and after create a new ArrayList of DisplayMode

ArrayList<DisplayMode> Mode = new ArrayList<DisplayMode>();

after create your new ArrayList get all screen size support by your graphic cards

    try {
    DisplayMode[] modes;
        modes = Display.getAvailableDisplayModes(); //get all resolution
    for (int i=0;i<modes.length;i++) {
        DisplayMode current = modes[i]; //add all DisplaMode to arraylist
        Resolutions.add(current);
    }
    } catch (LWJGLException e) {
        e.printStackTrace();
    }
    for (DisplayMode mode : Resolutions) { //optional just to see all resolution
        System.out.println(mode.getWidth() + "x" + mode.getHeight() + "x"+mode.getBitsPerPixel() + " " + mode.getFrequency() + "Hz");
    } 

And to load a DisplayMode

Display.setDisplayMode(Mode.get(int));
  • But if i set the best possible resolution given by Display.getAvailableDisplayModes(); but whithout FullScreen, i'll get the resolution in windowed mod ? (I can't test now) – E. Maurice Aug 09 '17 at 18:24
  • If Fullscreen = true All screen will be resized if Fullscreen = false only the windows will be resized [Like This (By me)](https://www.youtube.com/watch?v=-vw8QlHUHtI) I hope this will help you And if you only want a winowed in full size juste put Display.setResizable(true); and click on fullscreen button – Blackoutburst Aug 09 '17 at 20:38
  • So there is no way to get a better/change resolution with a fixed Windowed Display Size? – E. Maurice Aug 09 '17 at 21:17
  • What is a better resolution for you ? – Blackoutburst Aug 09 '17 at 21:18
  • I want to say that in fullscreen mod with the best DisplayMod, a get a good quality, even if i glScale my game. But in windowed mod, i'm getting pixels and the result is horrible – E. Maurice Aug 09 '17 at 21:22
  • We don't know how you code your game in my game i can switch fullscreen/winowed with F11 and i have same quality (exept in fullscreen with a DisplayMode like 300x200) – Blackoutburst Aug 09 '17 at 21:25
  • I'm modifying Mincraft game. Can it be linked with tha fact that i use a Macbook Pro with Retina display? – E. Maurice Aug 09 '17 at 21:28
  • I do not have Macbook i don't know if this is the reason of your problem Normally il you turn your game/app in winowed mode the quality won't change (like in the video i send you) – Blackoutburst Aug 09 '17 at 21:35
  • [Here](https://www.youtube.com/watch?v=Lj0XlkMIsaY) You have the difference between Fullscreen/Winowed quality (Project with LWJGL/SLICK) Nothing change just i didn't use glScale i think it's him your problem – Blackoutburst Aug 09 '17 at 21:52
0

In order to set the resolution, you will need to use frame buffers. You will need to render to a frame buffer, then when you are ready to send the framebuffer of the proper resolution to the screen, you will blit the framebuffer to the window's back buffer. Here is a tutorial, albeit in C++. This should get you pointed in the right direction!

Nick Clark
  • 1,414
  • 2
  • 16
  • 24