<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../style.css">
<title>
Gambas Documentation - Gl.Accum
 (gb.opengl)</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../../../help+en"><img class="flag" alt="Home" border="0" src="../../../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../gl+en">Up</a>&nbsp;
<a href="../gl+en">Previous</a>&nbsp;
<a href="alphafunc+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Gl.Accum
 (gb.opengl)</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><font color="blue">STATIC</font> <font color="blue">SUB</font> <b>Accum</b> <font color="blue">(</font> <u>Operation</u> <font color="blue">AS</font> <font color="#0080FF">Integer</font><font color="blue">,</font> <u>Value</u> <font color="blue">AS</font> <font color="#0080FF">Float</font> <font color="blue">)</font></pre>
<h3>Accum - Operate on the accumulation buffer</h3>
<p>
The accumulation buffer is an extended-range color buffer. Images are not rendered into it. Rather, images rendered into one of the color buffers are added to the contents of the accumulation buffer after rendering. Effects such as antialiasing (of points, lines, and polygons), motion blur, and depth of field can be created by accumulating images generated with different transformation matrices.
<p>
Each pixel in the accumulation buffer consists of red, green, blue, and alpha values. The number of bits per component in the accumulation buffer depends on the implementation. You can examine this number by calling <a href="getaccumredbits+en">Gl.GetAccumRedBits</a>, <a href="getaccumgreenbits+en">Gl.GetAccumGreenBits</a>, <a href="getaccumbluebits+en">Gl.GetAccumBlueBits</a> and <a href="getaccumalphabits+en">Gl.GetAccumAlphaBits</a>, respectively. Regardless of the number of bits per component, however, the range of values stored by each component is [-1, 1]. The accumulation buffer pixels are mapped one-to-one with frame buffer pixels.
<p>
Gl.Accum operates on the accumulation buffer. The first argument, <u>Operation</u>, is a constant that selects an accumulation buffer operation. The second argument, <u>Value</u>, is a floating-point value to be used in that operation. Five operations are specified: <a href="gl_accum+en">Gl.GL_ACCUM</a>, <a href="gl_load+en">Gl.GL_LOAD</a>, <a href="gl_add+en">Gl.GL_ADD</a>, <a href="gl_mult+en">Gl.GL_MULT</a>, and <a href="gl_return+en">Gl.GL_RETURN</a>.
<p>
All accumulation buffer operations are limited to the area of the current scissor box and are applied identically to the red, green, blue, and alpha components of each pixel. The contents of an accumulation buffer pixel component are undefined if the Gl.Accum operation results in a value outside the range [-1,1].
<p>
<h4><a href="gl_accum+en">Gl.GL_ACCUM</a></h4>
<p>
&nbsp;&nbsp;Obtains Red, Green, Blue, and Alpha values from the buffer currently selected for reading (see Gl.ReadBuffer) Each component value is divided by 2<sup>n</sup> - 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.
<p>
<h4>Gl.GL_LOAD</h4>
<p>
&nbsp;&nbsp;Similar to <a href="gl_accum+en">Gl.GL_ACCUM</a>, except that the current value in the accumulation buffer is not used in the calculation of the new value. That is, the Red, Green, Blue, and Alpha values from the currently selected buffer are divided by 2<sup>n</sup> - 1, multiplied by value, and then stored in the corresponding accumulation buffer cell, overwriting the current value.
<p>
<h4>Gl.GL_ADD</h4>
<p>
&nbsp;&nbsp;Adds value to each Red, Green, Blue, and Alpha in the accumulation buffer.
<p>
<h4>Gl.GL_MULT</h4>
<p>
&nbsp;&nbsp;Multiplies each Red, Green, Blue, and Alpha in the accumulation buffer by value and returns the scaled component to its corresponding accumulation buffer location.
<p>
<h4>Gl.GL_RETURN</h4>
<p>
&nbsp;&nbsp;Transfers accumulation buffer values to the color buffer or buffers currently selected for writing. Each Red, Green, Blue, and Alpha component is multiplied by value, then multiplied by 2<sup>n</sup> - 1, clamped to the range [0, 2<sup>n</sup> - 1 ], and stored in the corresponding display buffer cell. The only fragment operations that are applied to this transfer are pixel ownership, scissor, dithering, and color writemasks.
<p>
The accumulation buffer is cleared by specifying Red, Green, Blue, and Alpha values to set it to with the Gl.ClearAccum directive, and issuing a Gl.Clear command with the accumulation buffer enabled.
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../../../img/info.png" align="center"></td><td valign="top">
Only those pixels within the current scissor box are updated by any Gl.Accum operation.
</td></tr></table></div>
<p>
<h4>Errors</h4>
<p>
Gl.GL_INVALID_ENUM is generated if <u>Operation</u> is not an accepted value.<br>
Gl.GL_INVALID_OPERATION is generated if there is no accumulation buffer.<br>
Gl.GL_INVALID_OPERATION is generated if Gl.Accum is called between a call to Gl.Begin and the corresponding call to Gl.End.
<p>
<h4>Associated Gets</h4>
<p>
<a href="getaccumredbits+en">Gl.GetAccumRedBits</a><br>
<a href="getaccumgreenbits+en">Gl.GetAccumGreenBits</a><br>
<a href="getaccumbluebits+en">Gl.GetAccumBlueBits</a><br>
<a href="getaccumalphabits+en">Gl.GetAccumAlphaBits</a>
<p>
<hr><b>See also</b><br>
Gl.BlendFunc, Gl.Clear, Gl.ClearAccum, Gl.CopyPixels, Gl.LogicOp, Gl.PixelStore,
Gl.PixelTransfer, Gl.ReadPixels, Gl.ReadBuffer, Gl.Scissor, Gl.StencilOp.

</div>
</body>
</html>

