Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  0.95 - Setting display mode and fullscreen  (Read 3822 times)
0 Members and 1 Guest are viewing this topic.
Offline tom
« Posted 2005-03-19 16:50:32 »

I'm porting SH to 0.95 but I can't get the ingame mode switching to work flawlessly.

1) Switching between displaymodes retrieved from Display.getAvailableDisplayModes() results in windowed mode results in first a mode switch to 640x480 then back to desktop resolution. Then there seems to be 2 windows. A black undecorated window. Behind it a decorated with my game partially showing.

2) Staring in fullscreen and setting a displaymode created with the DisplayMode constructor do of course not work. But I get native crash wich is a bit unplesant. Fair enough.

3) Starting in fullscreen and later calling Display.setFullscreen(false) I get the following native crash:

Quote

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x0
Function=[Unknown.]
Library=(N/A)

NOTE: We are unable to locate the function name symbol for the error
     just occurred. Please refer to release documentation for possible
     reason and solutions.


Current Java thread:
     at org.lwjgl.opengl.Win32Display.makeCurrent(Native Method)
     at org.lwjgl.opengl.Display.makeCurrent(Display.java:491)
     at org.lwjgl.opengl.Display.createWindow(Display.java:219)
     at org.lwjgl.opengl.Display.setFullscreen(Display.java:369)
     at sh.SquareHeads.createWindow(SquareHeads.java:231)
     at sh.menu.BMainMenu.actionPerformed(BMainMenu.java:882)
     at trb.bgui.BImageButton.fireActionEvent(BImageButton.java:176)
     at trb.bgui.BImageButton.onMouseEvent(BImageButton.java:119)
     at trb.bgui.BScreen.doMouseEvent(BScreen.java:157)
     at trb.bgui.BScreen.handleMouse(BScreen.java:109)
     at sh.menu.BMainMenu.runMenu(BMainMenu.java:301)
     at sh.SquareHeads.runMenu(SquareHeads.java:403)
     at sh.SquareHeads.main(SquareHeads.java:1462)


4) Starting in fullscreen and later switching to displaymode I got using Display.getDisplayMode()  before Display was created the first time, I also get the same native crash as above.

At this point I gave up staring in fullscreen mode and trying to switch to windowed mode Sad

5) There is 2 mode switches when I need to switch between windowed/fullscreen and also change resolution. As both setFullscreen and setDisplayMode will change mode. This is a bit unpleasant on my monitor as it makes 2 loud sounds each time a mode is changed. Any chance of having a setDisplayMode(DisplayMode newMode, boolean fullscreen) that does it with only one mode change?

So I'm having great problems switching modes in game. Is this something you are willing to fix. How are you dealing with it?

Offline tom
« Reply #1 - Posted 2005-03-19 17:21:01 »

I've done a little more testing and it seems that all display mode changes fails in a native crash if I start in fullscreen with a different bit depth than the desktop.

Offline elias

Senior Duke





« Reply #2 - Posted 2005-03-21 08:53:40 »

Changing display mode color depth is not recommended, since most drivers seem to either crash or simply render garbage when tried. Use the same display mode depth or use Display.destroy()/Display.create() if you want to switch color depth.

As for the other bugs, please wait for 0.96 which should be out this weekend and test with that. There is simply too much internal restructuring for me to bother with trying to fix anything in 0.95 at the moment, sorry.

- elias

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tom
« Reply #3 - Posted 2005-03-21 11:47:46 »

Quote
Changing display mode color depth is not recommended, since most drivers seem to either crash or simply render garbage when tried. Use the same display mode depth or use Display.destroy()/Display.create() if you want to switch color depth.


Makes sence. I'll probably drop the bit depth option in my game. Or I can fall back on the context save/restore code that I already got working.

Quote
As for the other bugs, please wait for 0.96 which should be out this weekend and test with that. There is simply too much internal restructuring for me to bother with trying to fix anything in 0.95 at the moment, sorry.

No problem. I propose that a smal test app is written, similar to FullScreenWindowedTest, that will test ingame mode switching. Pressing the keys 1, 2, 3, 4 will swicth to:
1) Windowed 640x480
2) Fullscreen 640x480
3) Windowed 800x600
4) Fullscreen 800x600
It can be part of the lwjgl test package. It could replace the FullScreenWindowedTest. Or you can just use it internally before releasing new versions of lwjgl to make sure there is no regression bugs. I'd be happy to write the test app if you are interested in using it.

I know it don't have a high priority as I'm guessing I'm the only one doing ingame mode switching Smiley

Offline elias

Senior Duke





« Reply #4 - Posted 2005-03-21 12:01:54 »

You're wrong Smiley We're using runtime switching between windowed/fullscreen in TT with good results.

- elias

Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #5 - Posted 2005-03-21 14:12:26 »

Quote
I'd be happy to write the test app if you are interested in using it.
I'm on it - wife is out of town anyway Smiley

Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #6 - Posted 2005-03-21 18:33:09 »

New window creation test in. Definately bugs in mode switching.
randomly changing between fullscreen and windowed mode and display modes will make fullscreen stop working... sometimes Cry

I tried to completely destroy the display before changing modes - but still the same result

1  
2  
3  
4  
Display.destroy();
Display.create();
Display.setDisplayMode(fixed_modes[mode]);
Display.setFullscreen(fullscreen);

Offline aldacron

Senior Duke


Medals: 9
Exp: 16 years


Java games rock!


« Reply #7 - Posted 2005-03-22 00:56:38 »

I knocked up a little something on my system. Going from windowed->windowed, or windowed->fullscreen works well. Going from fullscreen to windowed causes some ugly side effects, such as a borderless window hanging around with the game window behind it. I assume it's the ghost of the window created by the fullscreen handling. This appears same effect occurs regardless of whether I destroy and recreate the display or if I call setFullscreen(false).

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
public class DisplayModeTest
{
    void run() throws Exception
    {
        setDisplayMode(640, 480);
        boolean running = true;
       
        while(running)
        {
            GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
            GL11.glBegin(GL11.GL_TRIANGLES);
            GL11.glVertex2i(400, 400);
            GL11.glVertex2i(300, 300);
            GL11.glVertex2i(500, 300);
            GL11.glEnd();
            Display.update();
           
            if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
            {
                running = false;
            }
            else if(Keyboard.isKeyDown(Keyboard.KEY_1))
            {
                setDisplayMode(640, 480);
                GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            }
            else if(Keyboard.isKeyDown(Keyboard.KEY_2))
            {
                setDisplayMode(640, 480, 32);
                GL11.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
            }
            else if(Keyboard.isKeyDown(Keyboard.KEY_3))
            {
                setDisplayMode(800, 600);
                GL11.glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
            }
            else if(Keyboard.isKeyDown(Keyboard.KEY_4))
            {
                setDisplayMode(800, 600, 16);
                GL11.glClearColor(0.0f, 0.0f, 10.0f, 0.0f);
            }
        }
       
        Keyboard.destroy();
        Display.destroy();
    }
   
    void setDisplayMode(int width, int height) throws Exception
    {
        if(Display.isFullscreen())
            Display.destroy();
        if(!Display.isCreated())
            Display.create();        
        /*
        if(Display.isFullscreen())
              Display.setFullscreen(false);
        */

        DisplayMode mode = new DisplayMode(width, height);
        Display.setDisplayMode(mode);
    }
   
    void setDisplayMode(int width, int height, int bpp) throws Exception
    {
        DisplayMode[] modes = Display.getAvailableDisplayModes();
        DisplayMode match = null;
       
        for(int i=0; i<modes.length; ++i)
        {
            if(modes[i].getWidth() == width && modes[i].getHeight() == height && modes[i].getBitsPerPixel() == bpp)
                match = modes[i];
        }
       
        if(null == match)
            match = new DisplayMode(width, height);
       
        if(Display.isCreated())
            Display.destroy();
        Display.create();
        Display.setDisplayMode(match);
        Display.setFullscreen(true);
    }

    public static void main(String[] args)
    {
        try
        {
            new DisplayModeTest().run();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
}

Offline elias

Senior Duke





« Reply #8 - Posted 2005-03-22 08:54:50 »

On what OS is this happening on? On my Windows XP SP 2 with an ATI gfx card it works fine.

- elias

Offline tom
« Reply #9 - Posted 2005-03-22 14:45:04 »

I get the same bugs as described by aldacron. I'm running XP sp 2, ATI 9500 Pro, Catalyst version 03.8 (from display properites), driver filename was "wxp-w2k-catalyst-7-94-030917m-011434c.exe".

I know it is not the latest drivers. But it is the only version that don't crash my computer on a regular basis.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #10 - Posted 2005-03-22 16:27:43 »

I'm getting it too on my Radeon 9700 XP SP2, Catalyst 4.10 (Omega).
My laptop at work (XP, SP2, GeForce 4400 Go) does not have any issues whatsoever.

I have mailed elias a video of whats happening, so he can get a clue as to whats going on. His latest commit did not help.

Offline aldacron

Senior Duke


Medals: 9
Exp: 16 years


Java games rock!


« Reply #11 - Posted 2005-03-23 03:50:43 »

Windows XP SP2, Geforce FX 5700 LE, Forceware 66.93 (which was the latest release prior to March 11) drivers. I'm downloading the newest release, 71.84, now and will see what that does for me.
Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #12 - Posted 2005-08-10 08:30:58 »

I've noticed that going from windowed to fullscreen sometimes causes a crash on my mac (Powerbook so ATI graphics).  It doesn't happen every time, but it's quite common.  Doesn't appear to be a problem on my pc.  There were some similar discussions surrounding Java2D. 

Is is issue still existing & is there any workaround? (Apart from not allowing to switch back to full screen from windowed

Alan

Time flies like a bird. Fruit flies like a banana.
Offline princec

JGO Kernel


Medals: 404
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2005-08-10 09:23:37 »

I get this too - I get an IllegalStateException when trying to read the keyboard afterwards, like the keyboard is being mucked around with in a race condition. At least, I think that's the problem.

Cas Smiley

Offline Alan_W

JGO Knight


Medals: 8
Projects: 3


Java tames rock!


« Reply #14 - Posted 2005-08-10 10:19:55 »

Cas, thanks for your reply, it confirms my suspicions.

Incidentally, there are a number of Java2D threads which have a suspiciously similar problem.  It appears to be related to setting windows decorations on/off, which you have to do when going windowed <=> fullscreen.  Basically you can't change the decorations while the window is displayed, and if you dispose() it, there appears to be a bug in the java disposer.  There is a stacktrace at the bottom of the thread.  It does have the keyboard handler in the trace, but I suspect that it might be that the setFullScreen() is in the keyboard callback so this might not mean anything.

Think this goes on the 'Too Hard' pile, so  I'll ignore this problem for the time being.

Alan

Time flies like a bird. Fruit flies like a banana.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (41 views)
2014-10-17 03:59:02

Norakomi (33 views)
2014-10-16 15:22:06

Norakomi (26 views)
2014-10-16 15:20:20

lcass (30 views)
2014-10-15 16:18:58

TehJavaDev (59 views)
2014-10-14 00:39:48

TehJavaDev (60 views)
2014-10-14 00:35:47

TehJavaDev (50 views)
2014-10-14 00:32:37

BurntPizza (66 views)
2014-10-11 23:24:42

BurntPizza (38 views)
2014-10-11 23:10:45

BurntPizza (80 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!