Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  BufferStrategy.getDrawGraphics()  blocks AWTE  (Read 1287 times)
0 Members and 1 Guest are viewing this topic.
Offline johng

Senior Newbie




Bah.


« Posted 2004-12-10 02:35:05 »

I was playing with kevglass's space invaders code and managed to break it and can't quite figure out how.  

Here's the method in question:



1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
      private void gameLoop() {
            while (gameRunning) {
                  // Get hold of a graphics context for the accelerated
                 // surface and blank it out
                 g = strategy.getDrawGraphics();

                 
                  // give the application a chance to do its thing
                 if (listener != null) {
                        listener.frameRendering();
                  }

                  // finally, we've completed drawing so clear up the graphics
                 // and flip the buffer over
                 g.dispose();
                  strategy.show();
            }
      }      


And this line:
1  
 g = strategy.getDrawGraphics(); 


seems to block all AWTEvents from being dispatched.  A little debugging shows that all listeners are still properly attached and that nothing is changed on the Component that I'm subclassing (including event masks and the like).  It just doesn't seem to be dispatching the events.

Commenting out each line in turn led me to blame this line.

The code called by
1  
listener.frameRendering();

has no effect - it works if I use JOGL instead  and the effect is still present if I comment out that line altogether.

So, perhaps a busy CPU?   Adding Thread.sleep()s doesn't change anything either.  

Any hints, clues or tips much appreciated.  


There's just this and empty space...
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-12-12 09:48:30 »

What Java version you on?

Kev

Offline johng

Senior Newbie




Bah.


« Reply #2 - Posted 2004-12-12 18:58:14 »

PC, 1.4.2_04
Mac, 1.4.2_05

Btw, apologies if this should be in the Java2D forum...

Cheers,

John

There's just this and empty space...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #3 - Posted 2004-12-13 06:27:14 »

listener.frameRendering() from what I remember was just a callback to the application to render whatever it wanted to render. The application was responsible for performing a sleep of some sort.

So, if you've modified it not to sleep in frameRendering() it'll get in a tight loop preventing the AWT event thread running. If you remove the line all together there's no way it'd sleep so same effect.

I am surprised however that when you tried adding the sleep() directly into that loop it didn't resolve the issue. I guess the next question is how did you modify it, what did you add into frameRendering()?

Kev

Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2004-12-14 16:57:15 »

You on OSX or winblows at the moment?

Kev

Offline johng

Senior Newbie




Bah.


« Reply #5 - Posted 2004-12-14 18:17:04 »

Same on both - have them side by side here, so I test everything on each.

Just in case, and because I'm in some doubt as to what GAGE is actually up to on OS X, I modifed your SystemTimer class to just use System.currentTimeMillis() - again, no change.

There must still be a change of mine in there causing this, but I'm failing to see it.


John

There's just this and empty space...
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.

Dwinin (29 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (39 views)
2014-09-09 02:24:56

mitcheeb (58 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!