Changing display mode frequency crashes

Started by LWJGLUser_9348, March 28, 2013, 12:40:00

Previous topic - Next topic

LWJGLUser_9348

Hello, this is my first post. I have a problem where LWJGL keeps throwing an LWJGLException and crashing, I think it may be a bug:
org.lwjgl.LWJGLException: Failed to set display mode (-2).

I'll explain when this happens.
I have a Toshiba laptop (Windows 7 64-bit) that has 24 display modes, all are 60hz frequency and 1366x768 is the maximum resolution. When I plug my laptop to my Sony Bravia TV using HDMI LWJGL says now I have 72 display modes; I have more frequencies: 24hz, 25hz, 30hz, 59hz and 60hz, and I have more resolutions, up to 1920x1080.
Now, if my desktop display mode is '1366x768 60hz' and I use LWJGL to change it to '1920x1080 30hz' it crashes. If my desktop display mode is '1920x1080 30hz' and I change it to '1920x1080 59hz' it crashes. However, it doesn't crash if I change a 60hz display mode to a 25hz and viceversa.

The odd thing is, I have another computer with a monitor that supports 60hz, 72hz and 75hz frequencies. Changing from one to the other doesn't crash at all. I only get crashes when changing display modes with different frequencies using the Sony TV.

Is this a bug?

Thanks for your time.

princec

The exception is caused by Windows saying DISP_CHANGE_BADMODE. That is, the mode given is one that Windows doesn't like (see here) I'm having the same problem myself with a couple of my users.

Cas :)

LWJGLUser_9348

It's strange that Windows doesn't let me. I just rememberd that the videogame Bionic Commando Rearmed does let you change refresh rates. I plugged my laptop to the TV, opened the game, and changed display modes. Not a single crash. I do the same thing with LWJGL in Java, crash.

Here's a guy saying he has a similar problem getting DISP_CHANGE_BADMODE in C++ when changing resolutions that are actually supported.
He says he found a way to fix it. Could the solution be to make a dll in C++ and call it from Java?

http://www.cplusplus.com/forum/windows/31195/

princec

Well, the solution would be to fix it in LWJGL...

Cas :)

LWJGLUser_9348

Thanks for the replies. Let's hope they fix it.

Matzon

if you have a problem, and you say you want to make a dll to fix it, why not just pull the source and fix it there and provide us a patch to apply?
This is probably a very hard issue to debug unless you have the specific hardware that produces this issue...

and fwiw, we are setting these fields: display.c::switchDisplayMode
ZeroMemory(&devmode, sizeof(DEVMODE));
devmode.dmSize = sizeof(DEVMODE);
devmode.dmBitsPerPel = bpp;
devmode.dmPelsWidth = width;
devmode.dmPelsHeight = height;
devmode.dmDisplayFrequency = freq;
devmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
if (freq != 0)
	devmode.dmFields |= DM_DISPLAYFREQUENCY;
cdsret = ChangeDisplaySettings(&devmode, CDS_FULLSCREEN);

princec

The problem may stem from also attempting to set frequency at the same time. Also, maybe we want to call ChangeDisplayModeEx.

Cas :)