Fullscreen/Windowed -- possible noob question

Started by Lareon, October 15, 2004, 02:47:21

Previous topic - Next topic

Lareon

I have an example which runs fine in an 800x600 window which is made and shown using the following code:
DisplayMode temp = new DisplayMode(800, 600);
//windowed mode
Display.setDisplayMode(temp);
Display.setTitle("Test LWJGL App");
Display.setFullscreen(true);
Display.create();


This works fine.  I don't know if it's GOOD or not, but it works pretty darn well.

What I CANNOT figure out for the life of me is HOW do I specify a fullscreen resolution for a game?!?  I want to specify the resolution, and the depth.  MAYBE the refresh rate, but basically I want the one resolution, and if it can't hack it, I want an error.  (I realize that I should accept the CLOSEST I can get, but that can wait for me just yet.)

So, um...  I KNOW I'm missing something here because everyone else seems to get fullscreen really well.  Please help me out?

--Lareon

FWIW, I saw something that looks promising in [org.lwjgl.util.Display], but I imported that, and got all sorts of fun errors about the conflicing "Display"s (one from util, the other from opengl).  PLEASE help me?

Matzon

The easiest way is to use the util Display.
1 - get the display modes that fit your needs using getAvailableDisplayModes
2 - set the mode using setDisplayMode

This could all be done using the following code from WindowCreationTest, which is supplied in the source package.
DisplayMode[] dm = org.lwjgl.util.Display.getAvailableDisplayModes(640, 480, -1, -1, -1, -1, 60, 60);
    
    try {
      org.lwjgl.util.Display.setDisplayMode(dm, new String[] {
          "width=" + 640,
          "height=" + 480,
          "freq=" + 60,
          "bpp=" + org.lwjgl.opengl.Display.getDisplayMode().getBitsPerPixel()
         });