Double Buffering: Difference between revisions

Jump to navigation Jump to search
Updated <pre> blocks (with C and C++ language <code> tags).
[unchecked revision][unchecked revision]
(changed to beginner rating)
(Updated <pre> blocks (with C and C++ language <code> tags).)
Line 23:
==== Buffer Creating In C ====
 
<source lang="c">
<pre>
/* Supposing the display is 800x600 with 32 bpp (meaning 32/8 = 4 bytes per pixel). */
byte *BackBuffer = ((byte *) (malloc(800 * 600 * 4)));
</presource>
 
==== Buffer Creating In C++ ====
 
<source lang="cpp">
<pre>
/* Supposing the display is 800x600 with 32 bpp (meaning 32/8 = 4 bytes per pixel). */
byte *BackBuffer = new byte[800 * 600 * 4];
</presource>
 
This implementation absorbs the same amount of memory the real video memory does, in this case, 800 * 600 * 4 = 1920000 bytes = about 1,83 MB. While using single-buffering needs 1,83 MB of RAM with our video resolution (only the display itself), double-buffering would require 2 * 1,83 MB = about 3,66 MB. The higher the resolution, the more memory is required. There are of course implementations that can usurp less than that with special techniques, but for some OS developers, high resolutions, and especially with double-buffering, are expensive features.
Line 41:
 
==== Example in C ====
<source lang="c">
<pre>
byte VidMem;
byte BackBuffer;
Line 108:
}
}
</presource>
 
==== Example in C++ ====
<source lang="cpp">
<pre>
byte VidMem;
byte BackBuffer;
Line 178:
}
}
</presource>
 
I believe this example is mostly clear. As there are too many different ways of changing video modes or putting pixels, I'm going to let you fill it in yourself. If you want more information, you can go to the [[GUI|GUI]] or the [[Drawing_In_Protected_Mode|Drawing In Protected Mode]] pages.
252

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu