GRAPHICS / SYSTEMS NOTES
What Are Framebuffers?
Framebuffers can be a very confusing thing. When I first heard the term I assumed it was going to be something hard to understand and learn about but now that I have one myself, it is quite simple.
A framebuffer at heart is a collection of data that you don't want to show until it is ready. I would say that is the simplest definition you could give. Framebuffers exist because we want to draw a frame before we push it to the screen for the user to see. But, while we wait we want to keep the previous completed buffer. We call this double buffer because of the two buffers needed. This is how framebuffer gets its name because we hold off showing the rendering until we finish the render. This stops things like screen tearing or weird popping in and out graphics. In my 3D terminal renderer it helps by allowing me to not have the screen blink while I update the terminal screen with new object locations or new transformations. A framebuffer can be an array of 1 dimension, or an array of 2 dimensions. It can also be a collection of buffers such as a depth-buffer, light-buffer, and any other buffer that describes a certain frame. You split these buffers up to make the data easy to work with and move around and then are all collected and grouped under the framebuffer. All framebuffers conceptually describe two dimensional screen data, even though the buffer itself can be made as a 1D or 2D array.
My project uses a 1D array framebuffer because I currently have no depth or any other special features to draw. I simply take some light value between 0.0f -> 1.0f, I take an array of ASCII characters and map an ASCII character to some location on the gradient of 0.0f -> 1.0f. My 1D array is traversed through y * width + x which is able to get you the exact location in a 1D array that is better thought of as a 2D array.