0

Basicly, I have an falling sand type game that is getting pretty complex and laggy, and my friend which is also working on it keep saying me that the double buffering is the main source of lag. I know that without double buffering, the game would be totally unplayable. So, is there another way to have smooth graphic and better performances, or this is impossible and I should just deal with it?

Thanks

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
  • Without knowing more it's difficult to help. Double-buffering itself will not cause lag or (undue) complexity. – Dave Newton Nov 22 '11 at 01:00
  • 1
    Your friend should back up statements like that with benchmarks. (Which is also what you should do to find the source of your lag. Point VisualVM at your game before trying to fix what might not be the issue.) – millimoose Nov 22 '11 at 01:05
  • Sorry for my ignorance, but how do I see what is wrong using VisualVM? I tried it, but I am clueless about what to do. –  Nov 22 '11 at 02:08

1 Answers1

1

I assume you currently use Java2D. You can easily run into trouble regarding performance. Sometimes simply changing the image format is sufficient to make your application run twice as fast. You are probably looking for something like this: What are some faster alternatives to Java2d?

For a real computer game (more complex graphics or not) you could entirely switch to openGL. There is LWJGL that also provides input and audio playback for games: http://lwjgl.org/

Community
  • 1
  • 1
foowtf
  • 399
  • 1
  • 9
  • Considering I'm only drawing a bunch of little squares, would OpenGL be a good choice or not? –  Nov 22 '11 at 01:09
  • OpenGL is no limitation, it's also platform independent, perhaps a little harder to deploy. But it's not more difficult to use than java2D even if you only draw a few simple polygons (at least once you know how to do it...). It also requires hardware support but if you aren't going to run your program on really old machines that shouldn't be a problem. – foowtf Nov 22 '11 at 01:12