full screen: active rendering in a canvas?

Hi,

I'm working at fullscreen, i've got a class that extends a Canvas, which will be used for showing graphics. I've found out that when i put code overriding the paint() method to draw images, the images are drawn.

But when i put code to draw images *outside* the paint method, these images are not drawn.

I've heard the first method is passive rendering, and the second one, active rendering. I've also heard that using fullscreen mode i need to use active rendering, because i'll never know when the paint() method of the canvas is gonna be called. (And of course i want control over the rendering, to draw frames only when it's needed).

How is this done? Should i use another class instead of the canvas?

thanks

[759 byte] By [f3rn4nd0] at [2007-9-27 16:45:35]
# 1

In order to use active rendering, you need to call your custom method from your game loop. You might also want to call the same method from paint() as well. For example,

public void run() {

BufferStrategy bs = createBufferStrategy();

while( running ){

// do stuff in your game loop

Graphics g = bs.getDrawGraphics();

render( g );

bs.show();

g.dispose();

}

}

public void render( Graphics g ){

// render your scene

}

public void paint( Graphics g ){

render(g);

}

rgeimer at 2007-7-6 1:03:40 > top of Java-index,Other Topics,Java Game Development...