LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: JToto on October 17, 2013, 11:33:08

Title: General Question: Double Buffering
Post by: JToto on October 17, 2013, 11:33:08
Hey,

First of all: I'm German. Sorry if my english is wrong.


I've got a general question about double buffering using the LWJGL.
Let's say I have to draw a huge Boardgame (or a Map) with x and y Coordinates. For example 500x500 Fields.
If I implement the "Game Loop" that updates/renders the Display I have to iterate over every single field of the board. (To get the single textures of the fields)
That does not make sense when nothing really happened. I simply want to redraw the Display as it was. But when I call Display.update() without clearing the Screen everything is flickering...

I want to have something like this:

public void render() {
       if (this.updated) {
             renderNew(); /* Render new, if anything changed. */
       }
       Display.update();


}
Title: Re: General Question: Double Buffering
Post by: spasi on October 17, 2013, 12:42:30
Try this:

public void render() {
       if (this.updated || Display.isDirty()) {
             renderNew(); /* Render new, if anything changed. */
             Display.update(false); // Swap buffers but don't process messages
       }
       Display.processMessages(); // Always process messages
}
Title: Re: General Question: Double Buffering
Post by: JToto on October 17, 2013, 14:09:24
This works fine!

Thank you very much.
Toto