{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/cg-front-back-other-buffers/",
  "atlas": "https://www.pystone.net/?node=cg-front-back-other-buffers#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/cg-front-back-other-buffers.md",
  "context": "https://www.pystone.net/notes/cg-front-back-other-buffers.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:cg-front-back-other-buffers",
  "slug": "cg-front-back-other-buffers",
  "title": "【CG】Front, Back, and Other Buffers",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "【CG】Front, Back, and Other Buffers",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "9275ba12b12c04c691374b9a51faae6b2c74b2edef1944f23d488e42520b0b2c",
  "assets": [
    {
      "reference": "assets/1607333008619.png",
      "url": "/media/bdbe84e8a47a684a4f2e.png",
      "mediaType": "image/png",
      "contentHash": "bdbe84e8a47a684a4f2e2d3cd7b7ca193bbcaa564303343ac1b01e381d72428b",
      "byteLength": 8748,
      "width": 363,
      "height": 324
    }
  ],
  "headings": [
    {
      "depth": 1,
      "text": "【CG】Front, Back, and Other Buffers",
      "anchor": "cgfront-back-and-other-buffers",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#cgfront-back-and-other-buffers"
    },
    {
      "depth": 2,
      "text": "frame buffer",
      "anchor": "frame-buffer",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#frame-buffer"
    },
    {
      "depth": 2,
      "text": "color buffer",
      "anchor": "color-buffer",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#color-buffer"
    },
    {
      "depth": 3,
      "text": "double buffering",
      "anchor": "double-buffering",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#double-buffering"
    },
    {
      "depth": 2,
      "text": "Buffer Functions",
      "anchor": "buffer-functions",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#buffer-functions"
    },
    {
      "depth": 3,
      "text": "Creating a framebuffer",
      "anchor": "creating-a-framebuffer",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#creating-a-framebuffer"
    },
    {
      "depth": 2,
      "text": "related links",
      "anchor": "related-links",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#related-links"
    },
    {
      "depth": 2,
      "text": "Ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/cg-front-back-other-buffers/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "渲染基础中的“【CG】Front, Back, and Other Buffers”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#%E6%B8%B2%E6%9F%93%E5%9F%BA%E7%A1%80"
    }
  ],
  "contentMarkdown": "# 【CG】Front, Back, and Other Buffers\n\n> 创建时间：2020/12/7 17:14\n\n  * 【CG】Front, Back, and Other Buffers\n    * frame buffer\n    * color buffer\n      * double buffering\n    * Buffer Functions\n      * Creating a framebuffer\n    * related links\n    * Ref\n\nOpenGL stores and manipulates pixel data in a framebuffer.\n\n## frame buffer\n\nThe **framebuffer** consists of a set of logical buffers:\n\n  * color buffer - for writing color values\n\n  * depth - buffer to write and test depth information\n\n  * stencil buffers - allows us to discard certain fragments based on some condition.\n\nThe combination of these buffers is stored somewhere in **GPU memory** and is called a **framebuffer**.\n\n## color buffer\n\nThe **color buffer** itself consists of a set of logical buffers; this set can include a front-left, a front-right, a back-left, a back-right, and some number of auxiliary buffers.\n\n> A particular pixel format or OpenGL implementation may not supply all of these buffers. For example, the current version of Microsoft’s implementation of OpenGL in Windows does not support stereoscopic images, so a pixel format cannot have left and right color buffers.\n\n### double buffering\n\nTwo color buffers are available to applications that use double buffering: a front buffer and a back buffer.\nBy default, drawing commands are directed to the **back buffer** (the **off-screen buffer** ), while the **front buffer** is displayed on the screen. When the off-screen buffer is ready for display, you call SwapBuffers, and Windows copies the contents of the off-screen buffer to the on-screen buffer.\n\n> The generic implementation uses a device-independent bitmap (DIB) as the back buffer and the screen display as the front buffer. Hardware devices and their drivers may use different approaches.\n\nThe OpenGL core function, glDrawBuffer, selects buffers for writing and clearing.\n\n## Buffer Functions\n\nTo copy the contents of an off-screen buffer to an on-screen buffer, call SwapBuffers.\n\nThe following illustration shows how the contents of the buffers are copied when calling SwapBuffers.\n\n![Alt text](assets/1607333008619.png)\n\nThe following functions also affect buffers:\nglReadBuffer\nglReadPixels\nglCopyPixels\nglAccum\nglColorMask\nglDepthMask\nglIndexMask\nglStencilMask\nglClearAccum\nglClearColor\nglClearDepth\nglClearIndex\nglClearStencil\n\n### Creating a framebuffer\n\nJust like any other object in OpenGL we can create a framebuffer object (abbreviated to **FBO** ) by using a function called glGenFramebuffers:\n\n## related links\n\n<https://www.khronos.org/opengl/wiki/Default_Framebuffer>\n<https://learnopengl.com/Advanced-OpenGL/Framebuffers>\n\n## Ref\n\n[https://docs.microsoft.com/en-us/windows/win32/opengl/front–back–and-other-buffers](https://docs.microsoft.com/en-us/windows/win32/opengl/front--back--and-other-buffers)\n"
}
