BufferStrategy?

Hi, Okay first, what is a BufferStrategy?And second how do you setup a bufferstrategy with a JFrame so that it's drawable?Thank you very much.
[171 byte] By [javatypo] at [2007-9-27 21:48:34]
# 1
BufferStrategy is a class for doing double buffering and page flipping. It's mainly used for fullscreen mode though, so it may not be a good idea for use with a JFrame.
JTeen at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 2
Oh yeah, there's a tutorial at http://java.sun.com/docs/books/tutorial/extra/fullscreen/bufferstrategy.html
JTeen at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 3
Kool thanx. I take it thats really useful for computer games?Does it work for an applet? If not, then what is a good equivalent method for BufferStrategy?
javatypo at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 4
Yes, It works in applets, but it works best in fullscreen mode.
Virum at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 5
BTW, it works fine with JFrames if they're fullscreen.
JTeen at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 6
Works fine with JFrames if they aren't too. My pong game uses BufferStrategy
Virum at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 7

However, it seems BufferStrategy doesn't like to draw on to a Canvas when in fullscreen mode. See my thread to see what I mean:

http://forum.java.sun.com/thread.jsp?forum=406&thread=307804

An alternative to BufferStrategy is to use VolatileImage and do your own double buffering on there. BufferStrategy actually uses VolatileImage to draw on to the screen, but it does all the "nasty" things you would need to do if you did double buffering manually.

Frumple

Frumple at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 8
OKay thanks people. I dont generally use canvases though. I use JPanels. Does BufferStrategy work there to?And can you display swing components, or awt components in fullscreen mode?
javatypo at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...
# 9

> OKay thanks people.

>

> I dont generally use canvases though. I use JPanels.

> Does BufferStrategy work there to?

No, only frames and canvases.

> And can you display swing components, or awt

> components in fullscreen mode?

Yes, though it is more complicated. I generally prefer to make my own components....

Virum at 2007-7-7 3:47:50 > top of Java-index,Other Topics,Java Game Development...