I have a tile tile map array [50][50].
When I click the mouse to move the x and y of every single tile in that array I see white spaces between each tile - I believe this is called 'tearing', it isn't desired.
I googled double buffering and read the wiki, http://en.wikipedia.org/wiki/Multiple_buffering#Double_buffering_in_computer_graphics .
How is it done in SDL2, specifically with large tile arrays created from 'for loops'?
...I suspect you copy tile textures onto a buffer texture and copy that to the renderer once its fully loaded - though I couldn't get this to work, would love to see a full working example!
This is my previous post with current my current code: SDL2 double buffer not working, still tearing
The Double Buffer mode allows to set two different Memory addresses from/to which the DMA controller will access alternatively (after completing transfer to/from target memory 0, it will start transfer to/from target memory 1). This allows to reduce software overhead for double buffering and reduce the CPU access time.
Double buffering uses a memory buffer to address the flicker problems associated with multiple paint operations. When double buffering is enabled, all paint operations are first rendered to a memory buffer instead of the drawing surface on the screen.
Double buffering renders the next frame while displaying the current. That results in latency of 1 frame since input. Triple buffering adds another frame to the queue, resulting in a 2 frame lag.
SDL2 handles double buffering automatically for you:
SDL_RenderClear
will clear the current rendering buffer.SDL_RenderCopy
will render textures to the current rendering buffer.SDL_RenderPresent
will swap the buffers, showing everything that was rendered using SDL_RenderCopy
since the last SDL_RenderClear
call.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With