Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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 1750 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
« League of Dukes »

JGO Knight


Medals: 13
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
« League of Dukes »

JGO Knight


Medals: 13
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
« League of Dukes »

JGO Kernel


Medals: 196
Projects: 3


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
« League of Dukes »

JGO Kernel


Medals: 196
Projects: 3


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.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (84 views)
2013-05-17 21:29:12

alaslipknot (92 views)
2013-05-16 21:24:48

gouessej (123 views)
2013-05-16 00:53:38

gouessej (115 views)
2013-05-16 00:17:58

theagentd (127 views)
2013-05-15 15:01:13

theagentd (114 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (187 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.23 seconds with 21 queries.