Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (683)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (750)
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  
  Active rendering: configure TopLevel or all components?  (Read 1752 times)
0 Members and 1 Guest are viewing this topic.
Offline Serethos

Junior Devvie

Java games rock!

« Posted 2009-12-20 19:34:37 »

Hi all,

a lot of time has passed since I was into java game development, but now I need some update
(of the last years  Grin).
For the basics in active rendering and fullscreen/ windowed mode I looked into Kevs example of
Space Invaders. What confuses me is the way of using the graphic components. In his example
is basically this:

public class Game extends Canvas 
public Game()
      // create a frame to contain our game
      JFrame container = new JFrame("Space Invaders 101");
      // get hold the content of the frame and set up the resolution of the game
      JPanel panel = (JPanel) container.getContentPane();
      panel.setPreferredSize(new Dimension(800,600));
      // setup our canvas size and put it into the content of the frame
      // Tell AWT not to bother repainting our canvas since we're
      // going to do that our self in accelerated mode
                // create the buffering strategy which will allow AWT
      // to manage our accelerated graphics
      strategy = getBufferStrategy();

My main problem is to understand which component specifies the graphical configuration (rendering
method, acceleration etc). In the example the configuration is made for the canvas, not for the top
level Container. Is this enough to activate direct rendering? Should'nt the Jframe setIgnoreRepaint(true)?
Could something happen like an embedded component is configured for active rendering and creates
the suitable Bufferstrategy but the enclosing Component (in this case the JFrame) is running in passive
rendering mode? That would mess up both strategies ..

Offline trembovetski

Senior Devvie

If only I knew what I'm talking about!

« Reply #1 - Posted 2009-12-21 23:10:45 »

The example is OK. The BufferStrategy is created for the heavyweight component, in this case - Canvas. I'd also disable Swing's double buffering so that it doesn't maintain its own back buffer.

I don't know why would one use JFrame in this case at all actually - why pull swing classes if all you do is slap AWT's canvas on top of it. I'd just use Frame.

Offline broumbroum

Junior Devvie

« Reply #2 - Posted 2009-12-21 23:47:45 »


notice that this may only work in a full-screen exclusive mode. otherwise createBufferStrategy(1); is needed (which disables double buffer).

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @
on /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

orrenravid (163 views)
2016-07-16 03:57:23

theagentd (232 views)
2016-07-11 14:28:54

Hydroque (315 views)
2016-07-06 05:56:57

Hydroque (467 views)
2016-07-03 08:52:54

GrandCastle (350 views)
2016-07-01 09:13:47

GrandCastle (342 views)
2016-07-01 09:09:45

CopyableCougar4 (396 views)
2016-06-25 16:56:52

Hydroque (375 views)
2016-06-22 02:17:53

SwampChicken (346 views)
2016-06-20 13:22:57

SwampChicken (290 views)
2016-06-20 13:22:49
Making a Dynamic Plugin System
by Hydroque
2016-06-25 00:13:25

Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17 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‑
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!