Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (576)
games submitted by our members
Games in WIP (497)
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  
  "Freezes" when focus lost  (Read 1962 times)
0 Members and 1 Guest are viewing this topic.
Offline renanse

Junior Member




Intelligence is light to a dark world.


« Posted 2003-12-30 23:14:21 »

I figured I'd find something on here to counter this eventually so I ignored it till now.  Whenever I change focus to something else and then back to the lwjgl app, the app becomes unresponsive.  It appears to use 99% of my CPU.  I thought perhaps the if (!Window.minimized()) stuff was meant to take care of this, and I also tried adding a sleep thread as an else to help take care of things, but to no avail...  Any recommendations?

Renanse  (ruh-NON-say)
Offline Matzon

JGO Knight


Medals: 19
Projects: 2


I'm gonna wring your pants!


« Reply #1 - Posted 2003-12-30 23:47:00 »

You are in complete control!
That means, that when you see that Window.isMinimized is true, you need to determine what you want to do when minimized (or out of focus). This typically means that you'd want to do something like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
if (Window.isMinimized()) {
  try {
    Thread.sleep(250);
  } catch (InterruptedException inte) {
  }
 
  if(Window.isDirty()) {
    render(); // Render To Screen
   Window.paint();
  }
} else {
  mainLoop(); // Launch The Main Loop
 render(); // Render To Screen
 Window.paint(); // Swap Opengl Buffers
}

Offline Matzon

JGO Knight


Medals: 19
Projects: 2


I'm gonna wring your pants!


« Reply #2 - Posted 2003-12-30 23:48:53 »

FWIW, this works fine here  Roll Eyes

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

Junior Member




Intelligence is light to a dark world.


« Reply #3 - Posted 2004-01-02 15:05:10 »

I've changed my main loop to be very similar to your example, but I get the same results:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
        while(!Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) && !Window.isCloseRequested()) {
            if (Window.isMinimized()) {
              try {
                Thread.sleep(250);
              } catch (InterruptedException inte) {
                inte.printStackTrace();
              }

              if(Window.isDirty()) {
                render(); // Render To Screen
               Window.paint();
              }

            } else {
                processKeyboard();                                                // Check keyboard input
               render();                                                            // Render opengl scene
//                Window.update();                                                // Update window graphics
               Window.paint();                                                      // Swap Opengl Buffers
       }
    }

Renanse  (ruh-NON-say)
Offline elias

Senior Member





« Reply #4 - Posted 2004-01-02 15:16:43 »

Please state your OS and LWJGL version. Also, how unresponsive are we talking? Does it show frames but fails to react to input or is it completely dead?

- elias

Offline renanse

Junior Member




Intelligence is light to a dark world.


« Reply #5 - Posted 2004-01-02 15:45:06 »

I've tried this under all 3 of my PCs and a friend's laptop.

OS: Win2000 Professional SP4
Card: ATI Radeon 9800XT  (Also happens on GF2 MX, GF4 ti4600 and a mobile GF FX -- that one under WinXP)
LWJGL: lwjgl-0.8-win32

By unresponsive, I mean if I alt-tab or click on another window and then try to switch back, the window will not come back to the fore-front.  If I hide all the other windows and wait for a bit, I eventually see a black unresponsive window (the title bar repaints ok) that can not be clicked on, closed, repositioned, etc...  In full screen mode, if I alt-tab out of my app, the resolution does not switch back to normal (I assume it should) and I can not alt-tab back to my app.  In Task Manager it doesn't claim to be using 99% of the CPU anymore, probably a product of adding in the sleep(250)...  But, the app is still listed as "Not Responding".  

So in summary, dead.

Renanse  (ruh-NON-say)
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2004-01-02 15:53:43 »

Your call to Window.update() is commented out during normal rendering and simply missing from minimized state. You must always call Window.update() every tick, minimized or not, as that's the call that processes operating system events.

Cas Smiley

Offline renanse

Junior Member




Intelligence is light to a dark world.


« Reply #7 - Posted 2004-01-02 16:33:48 »

Ah, that fixed the problem and makes sense now that I know what that command does...

Perhaps I can help write an LWJGL FAQ with all the questions I've been asking....  Cheesy

Renanse  (ruh-NON-say)
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2004-01-02 22:24:06 »

All documentation contribution gratefully received Smiley

Cas Smiley

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 (11 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (182 views)
2014-04-01 02:16:10
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

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