GLACCUM(3G)

πŸ“¦ version 24.3.3, in opensuse-leap 16.0

πŸ’– GLACCUM(3G) πŸ’–

okay bestie, sit DOWN, because today we're talking about glAccum from the GLACCUM(3G) manual, and honestly? she's iconic. this is the accumulation buffer girlie. let's get into it ✨


🌈 NAME 🌈

glAccum β€” operate on the accumulation buffer πŸŽ€


πŸ¦‹ C SPECIFICATION πŸ¦‹

void glAccum( GLenum op,
              GLfloat value )

that's it. two args. she's simple, she's powerful, she ate πŸ’…


🌸 PARAMETERS 🌸

  • op β€” specifies the accumulation buffer operation, aka which vibe we're doing. the symbolic constants it accepts are GL_ACCUM, GL_LOAD, GL_ADD, GL_MULT, and GL_RETURN. periodt.
  • value β€” a floating-point value that gets used in the accumulation buffer operation. op is the one who decides how value gets used, so like… value is just here for the plot, and op is the director. 🎬

✨ DESCRIPTION ✨

so the accumulation buffer is an extended-range color buffer. and here's the thing β€” images are not rendered into it. nope! instead, images rendered into one of the color buffers get added to the contents of the accumulation buffer after rendering. it's giving backstage crew, not main character. 🫢

and the way you get effects like antialiasing (of points, lines, and polygons), motion blur, and depth of field? by accumulating images generated with different transformation matrices. literally that's the whole trick. no cap.

every pixel in the accumulation buffer is made up of red, green, blue, and alpha values. how many bits per component you get depends on the implementation β€” it's not a fixed thing, bestie. you can peek at that number by calling glGetIntegerv four times, with arguments GL_ACCUM_RED_BITS, GL_ACCUM_GREEN_BITS, GL_ACCUM_BLUE_BITS, and GL_ACCUM_ALPHA_BITS.

but here's the slay: regardless of the number of bits per component, the range of values stored by each component is [-1, 1]. always. and the accumulation buffer pixels are mapped one-to-one with frame buffer pixels. πŸ’―

glAccum operates on the accumulation buffer. the first argument, op, is a symbolic constant that selects an accumulation buffer operation. the second argument, value, is a floating-point value to be used in that operation. five operations are specified: GL_ACCUM, GL_LOAD, GL_ADD, GL_MULT, and GL_RETURN. πŸ‘‘

all accumulation buffer operations are limited to the area of the current scissor box, and they're applied identically to the red, green, blue, and alpha components of each pixel. so no cherry-picking components, she's fair. πŸŽ€

⚠️ and now the scary part: if a glAccum operation results in a value outside the range [-1, 1], the contents of an accumulation buffer pixel component are undefined. undefined!! not "clamped", not "fixed up", just undefined. so stay in your lane, range-wise. 😭

the operations are as follows:

πŸ“ the five operations πŸ“

  • GL_ACCUM β€” obtains R, G, B, and A values from the buffer currently selected for reading (see glReadBuffer). each component value is divided by 2nβˆ’1, where n is the number of bits allocated to each color component in the currently selected buffer. the result is a floating-point value in the range [0, 1], which is multiplied by value and added to the corresponding pixel component in the accumulation buffer, thereby updating the accumulation buffer. so it's an accumulate, shocking, I know. ✨
  • GL_LOAD β€” similar to GL_ACCUM, except that the current value in the accumulation buffer is not used in the calculation of the new value. that is, the R, G, B, and A values from the currently selected buffer are divided by 2nβˆ’1, multiplied by value, and then stored in the corresponding accumulation buffer cell, overwriting the current value. out with the old, in with the new, no nostalgia allowed. πŸ’…
  • GL_ADD β€” adds value to each R, G, B, and A in the accumulation buffer. simple. clean. no notes.
  • GL_MULT β€” multiplies each R, G, B, and A in the accumulation buffer by value and returns the scaled component to its corresponding accumulation buffer location. math girl summer 🌈
  • GL_RETURN β€” transfers accumulation buffer values to the color buffer or buffers currently selected for writing. each R, G, B, and A component is multiplied by value, then multiplied by 2nβˆ’1, clamped to the range [0,2nβˆ’1], and stored in the corresponding display buffer cell. and the only fragment operations that are applied to this transfer are pixel ownership, scissor, dithering, and color writemasks. that's the whole list, don't add to it. 🎯

and if you want to clear the accumulation buffer? call glClearAccum with R, G, B, and A values to set it to, then call glClear with the accumulation buffer enabled. two-step routine, she's a ritual fr fr. πŸ•―οΈ


πŸ‘‘ NOTES πŸ‘‘

only pixels within the current scissor box are updated by a glAccum operation. everything outside the box? untouched. minding her own business. πŸ™ˆ


πŸ’€ ERRORS πŸ’€

  • GL_INVALID_ENUM is generated if op is not an accepted value. wrong name, no entry. πŸ’…
  • GL_INVALID_OPERATION is generated if there is no accumulation buffer. you can't operate on a buffer that doesn't exist bestie, that's just physics. 😭
  • GL_INVALID_OPERATION is generated if glAccum is executed between the execution of glBegin and the corresponding execution of glEnd. do NOT do your accum business mid-primitive, it's giving chaos. 🚫

πŸ”₯ ASSOCIATED GETS πŸ”₯

these are the ways to peek at the numbers, iykyk:

  • glGet with argument GL_ACCUM_RED_BITS
  • glGet with argument GL_ACCUM_GREEN_BITS
  • glGet with argument GL_ACCUM_BLUE_BITS
  • glGet with argument GL_ACCUM_ALPHA_BITS

🌟 SEE ALSO 🌟

the extended universe, go read these next:

  • glClear(3G)
  • glClearAccum(3G)
  • glCopyPixels(3G)
  • glDrawBuffer(3G)
  • glGet(3G)
  • glReadBuffer(3G)
  • glReadPixels(3G)
  • glScissor(3G)
  • glStencilOp(3G)

okay that's the whole page, bestie!! you officially understand the accumulation buffer and honestly? you're doing amazing. πŸ₯ΉπŸ’– this was glAccum from the GLACCUM(3G) manual β€” mwah, go forth and accumulate. πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from