Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  Rebuilding Display  (Read 3330 times)
0 Members and 1 Guest are viewing this topic.
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Posted 2003-04-22 15:17:13 »

Hi,

I'm wanting to give the ability to dynamically change things such as resolution, depth and Screen title. I've tried changing the parameters, calling Display.destroy() and then Display.create() with the new parameters. It appears to *MOSTLY* work, ie the screen changes to reflect these new values, but there is not longer any rendering being done and the Keyboard class no longer responds to keyboard input. Any ideas?

Thank you,
Mark

Don't send a man to do a monkey's work.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #1 - Posted 2003-04-22 16:03:08 »

Just a thought, but have you tried recreating the GL context and recalling create() on the keyboard?

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #2 - Posted 2003-04-22 16:09:21 »

Yes, I tried that. Here's a code snippet:

1  
2  
3  
4  
5  
6  
7  
8  
9  
if (Keyboard.key == Keyboard.KEY_0) {
                DisplaySystem.getDisplaySystem().setResolution(1024,768);
                try{
                    Keyboard.create();
                    Keyboard.enableBuffer();
                } catch (Exception e) {
                    LoggingSystem.getLoggingSystem().getLogger().log(Level.WARNING,
                            "Lost Keyboard");
                }


where in the DisplaySystem class we have:

1  
2  
3  
4  
 //recreate the display
       Display.destroy();
        initDisplay();
        initGL();


where init display calls Display.create and initGL call gl.create.

Mark

Don't send a man to do a monkey's work.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline elias

Senior Member





« Reply #3 - Posted 2003-04-22 16:13:47 »

did you do a gl.destroy() too?

- elias

Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #4 - Posted 2003-04-22 16:16:10 »

No, I didn't. But I added it, and there was no change.

Don't send a man to do a monkey's work.
Offline elias

Senior Member





« Reply #5 - Posted 2003-04-23 07:15:26 »

Does any of the lwjgl examples work for you?

- elias

Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #6 - Posted 2003-04-23 13:16:31 »

All the examples run fine. LWJGL runs great for me, and I have been having a wonderful time using it. It's only the one problem of switching resolutions while running that I need to take care of. Is there a specific example that changes resolution that you want me to look at?

Don't send a man to do a monkey's work.
Offline Orangy Tang

JGO Kernel


Medals: 51
Projects: 11


Monkey for a head


« Reply #7 - Posted 2003-04-23 13:46:18 »

Some of the mouse creation/test examples destroy and recreate the display several times, they should be doing what you're after.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #8 - Posted 2003-04-23 15:40:05 »

Fixed. Had two problems: First I wasn't destroying the keyboard before recreating it. Secondly, I wasn't initializing the rendering states, i.e. setting the viewport, etc. Thanks for all the help!

Don't send a man to do a monkey's work.
Offline cfmdobbie

Senior Member




Who, me?


« Reply #9 - Posted 2003-04-23 16:03:42 »

As changing resolution, bit depth etc on the fly is something I expect a lot of people would be interested in, there should probably be an example to do just that.

That's a really cool feature of the library that should be advertised!

By the way, there are tricks you need to pull in MFC to let display lists etc survive a context rebuild.  How does LWJGL handle that?  Is there a cross-platform way of doing it, or is it better to just force people to rebuild all GL-held assets etc after recreating the GL context?

Hellomynameis Charlie Dobbie.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline darcone

Junior Member




Size matters


« Reply #10 - Posted 2003-04-24 00:21:10 »

I removed my fullscreen/windowed switch method when I noticed I had to upload all textures etc again when I destroyed the context and created a new one...
Offline Mojomonkey

Senior Member




ooh ooh eee eeee


« Reply #11 - Posted 2003-04-24 00:49:52 »

Heh, Yeah, that's exactly what led to my descovery of my problem with my TextureManager deletion. I added a method to the texture manager to "refresh" all textures. Which really means reload all of them when the gl object is recreated.

Don't send a man to do a monkey's work.
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.

xsi3rr4x (53 views)
2014-04-15 18:08:23

BurntPizza (51 views)
2014-04-15 03:46:01

UprightPath (65 views)
2014-04-14 17:39:50

UprightPath (47 views)
2014-04-14 17:35:47

Porlus (65 views)
2014-04-14 15:48:38

tom_mai78101 (89 views)
2014-04-10 04:04:31

BurntPizza (149 views)
2014-04-08 23:06:04

tom_mai78101 (245 views)
2014-04-05 13:34:39

trollwarrior1 (203 views)
2014-04-04 12:06:45

CJLetsGame (210 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!