Support Forums
Double Buffering with applet - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Java Programming (https://www.supportforums.net/forumdisplay.php?fid=22)
+---- Thread: Double Buffering with applet (/showthread.php?tid=3543)



Double Buffering with applet - 1337 - 12-11-2009

Hey so i am trying to get my game to work and I have to double buffer to reduce screen flickering

I have a vague idea of how this works. I know you have to get the Graphics object of an image and override the update() method of applet, but other than that i do not understand.

mainly if i have multiple images that do not need to change how do i not update them all, without clearing them from the screen?


RE: Double Buffering with applet - MrD. - 12-12-2009

I'm not sure how this works exactly in Java, but I'll tell you the general method of double-buffering.

You create a texture the same size as the thing you want to buffer (in this case your screen) and then instead of drawing your objects directly to your screen, you draw them to your texture and then when you have finished you draw the whole texture to the screen in one go. Since drawing the whole texture is a single call, it should remove the flickering.

Generally in a game you will clear and re-draw the whole screen every update, it leads to less problems in the long run (such as alpha and Z-sort issues).