Search code examples
openglshaderrendering

What is fragment in opengl? and other basic graphics questions


What's a frame buffer?

What's a back buffer?

Can a pixel have more than 1 color value?

What's a rendering?(what's the input and output of rendering?)


Solution

  • The frame buffer is some memory that holds the data that's currently be displayed on the screen. Whatever's written to the frame buffer will show up on the screen at the next screen update (which typically happens 60 times a second).

    The back buffer is normally some memory that can potentially be used as a frame buffer, but isn't currently. You normally draw the next frame of data into the back buffer, then tell the graphics card to use that part of memory as the frame buffer. When you do so, the memory that was previously being used as the frame buffer becomes your new back buffer, so you can draw the next frame you're going to display into it -- when it's ready, you tell the graphics card to swap buffers again so it gets displayed.

    A fragment is what I'd term a "potential pixel". For example, when you rasterize a line, you end up with some pixel-like data. If, however, part of that line is hidden behind something else, some of those fragments won't ever be shown on screen, so they won't ever become pixels. You might also have (for example) a line that's partially transparent, so it'll be blended with whatever's behind it before it gets shown on screen. To give a slightly different perspective, however, DirectX terms all of these as pixels, whether they ever get shown on screen or not.

    A pixel is the final result of all the processing, as it gets deposited into the back buffer, ready to display. It has exactly one color. That color will typically have three components: red, green and blue. Primarily for the sake of video playback, some graphics cards also support some YCrCb modes, in which case the three components are Y, Cr and Cb. Even if they're available, use of these is fairly rare (nearly the only time I've seen them used was generating overlays that would be mixed with YCrCb video).

    Rendering is one of those terms that's used for quite a few different things, so without some context, it's almost impossible to define precisely at all.