Double buffering

The solution to our read/write problem is double buffering. Double buffering is exactly what it sounds like. Instead of using only one framebuffer, we will use two: one for reading and one for writing. Of course, since we now have two framebuffers, we need twice the memory. For a 1280 x 1024 display using 4 bytes per pixel, we need 5 megabytes per framebuffer for a total of 10 megabytes.

Everything up to this point could have been implemented in software by using operating system commands. However, as displays started requiring more memory and more complex images, special hardware was created. Modern graphics cards can contain gigabytes of memory used for framebuffers, textures, 3D triangle meshes, and much more. They can also contain hundreds or even thousands of cores to transform 3D points into pixel data simultaneously.

It is important to understand this because, as a programmer, you don't need to implement double buffering yourself. It is implemented at a hardware level and our games will be double buffered automatically by using a 3D graphics API such as DirectX or OpenGL. However, we still need to understand how this process works so we can understand the implications to our frame rate.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.237.29