LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Schnitter on November 26, 2007, 14:20:15

Title: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Schnitter on November 26, 2007, 14:20:15
I'm trying to do this:

for(int i = 0; i < Display.getAvailableDisplayModes().length; i++){
DisplayMode dm = Display.getAvailableDisplayModes()[i];
dmList.addItem(dm.toString());
if(pp.width == dm.getWidth() && pp.height == dm.getHeight() && pp.bpp == dm.getBitsPerPixel() && pp.frequency == dm.getFrequency())
dmList.setSelectedIndex(i);
waitBar.setValue(i);
}

I'm creating a little dialog with swing to configure the display-settings in my game. For this, I wrote a "PresentParameters"-class(s.o. already know the name from D3D).
In Linux, it's "normal" fast, I can see the JFrame in a fwe seconds. But in Windows, it's very slow. It need's ~30sek. Because of that, I added a JProgressBar(waitBar).
It's better now, but I'm wondering, why it takes so long just to read out all of the displaymodes.


Hope for an answer ;)


MfG
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Matzon on November 26, 2007, 14:27:36
 :o
how many modes do you get ?

this shouldn't take longer than a fraction of a second.
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Schnitter on November 26, 2007, 14:33:17
I added a timer to my application to stop, how much seconds it needs.
Output: The initialisation took 36 seconds
(!)
I get 220 DisplayModes.



Edit: Did I write "Initialisation" correctly? I dont' think so :-/
Edit2: Would it be better for you, when I upload the application?
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Matzon on November 26, 2007, 14:59:33
sure, but I suspect that its the checking of the display modes validity in the win32 api that is slow, for some non-apparent reason.
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Schnitter on November 26, 2007, 15:16:50
So I can't do anyting against it?
I mean, it's no problem, but it's a little bit strange :/



MfG
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: elias on November 26, 2007, 15:18:05
This thread describes a similar problem:

http://www.javagaming.org/forums/index.php?topic=15579.0

The only suggested fix is updating your drivers (or replacing the graphics card ;))

- elias
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Fool Running on November 26, 2007, 15:43:13
A suggestion:
Don't call Display.getAvailableDisplayModes() more then once. You call it 2 times each time through the loop.
Do something like DisplayMode[] modes = Display.getAvailableDisplayModes() and just use that array.
That should help a lot with the speed.

Hope that helps ;D

EDIT: I still have LWJGL v1.1, but it looks like the windows implementation re-gets the display mode list each time Display.getAvailableDisplayModes() is called, so you should notice a significant improvement in speed doing it that way. ;)
Title: Re: Very slow Display.getAvailableDisplayModes() at windows?
Post by: Schnitter on November 26, 2007, 17:09:27
Hey, it works!
"The initialisation took 0 seconds"
:D

Thank you, I never thought that way :/