GLACCUM(3G)
π 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 areGL_ACCUM,GL_LOAD,GL_ADD,GL_MULT, andGL_RETURN. periodt.valueβ a floating-point value that gets used in the accumulation buffer operation.opis the one who decides howvaluegets used, so likeβ¦valueis just here for the plot, andopis 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 aglAccumoperation 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 (seeglReadBuffer). each component value is divided by2nβ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 byvalueand 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 toGL_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 by2nβ1, multiplied byvalue, 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β addsvalueto 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 byvalueand 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 byvalue, then multiplied by2nβ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_ENUMis generated ifopis not an accepted value. wrong name, no entry. πGL_INVALID_OPERATIONis 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_OPERATIONis generated ifglAccumis executed between the execution ofglBeginand the corresponding execution ofglEnd. do NOT do your accum business mid-primitive, it's giving chaos. π«
π₯ ASSOCIATED GETS π₯
these are the ways to peek at the numbers, iykyk:
glGetwith argumentGL_ACCUM_RED_BITSglGetwith argumentGL_ACCUM_GREEN_BITSglGetwith argumentGL_ACCUM_BLUE_BITSglGetwith argumentGL_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
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- fedora 43: gl-manpages 1.1-34.20190306.fc43 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- fedora 44: gl-manpages 1.1-35.20190306.fc44 Β· Apache-2.0 AND HPND AND HPND-sell-variant AND MIT AND OpenPBS-2.3 AND SGI-B-2.0 AND W3C-19980720 AND X11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms