![]() | FramebufferReadPixelsT Method |
Namespace: Ooogles
public void ReadPixels<T>( int left, int bottom, int width, int height, T[] data, glPixelFormat format = glPixelFormat.Rgba, glPixelDataType dataType = glPixelDataType.UnsignedByte ) where T : struct, new()
Exception | Condition |
---|---|
GLException | InvalidEnum if format or dataType is not an accepted value. |
GLException | InvalidValue if either width or height is negative. |
GLException | InvalidOperation if dataType is UnsignedShort565 and format is not RGB. |
GLException | InvalidOperation if dataType is UnsignedShort4444 or UnsignedShort5551 and format is not RGBA. |
GLException | InvalidOperation if format and dataType are neither RGBA UnsignedByte, respectively, nor the format/dataType pair returned by calling ColorReadFormat and ColorReadType. |
GLException | InvalidFramebufferOperation if the framebuffer is not framebuffer complete. |
Pixels are returned in row order from the lowest to the highest row, left to right in each row.
format specifies the format for the returned pixel values. RGBA color components are read from the color buffer. Each color component is converted to floating point such that zero intensity maps to 0.0 and full intensity maps to 1.0.
Unneeded data is then discarded. For example, Alpha discards the red, green, and blue components, while Rgb discards only the alpha component. The final values are clamped to the range 0..1.
Finally, the components are converted to the proper format, as specified by dataType. When type is UnsignedByte (the default), each component is multiplied by 255. When dataType is UnsignedShort565, UnsignedShort4444 or UnsignedShort5551, each component is multiplied accordingly.
Note: if the currently bound framebuffer is not the default framebuffer object, color components are read from the color image attached to the Color attachment point.
Note: only two format/dataType parameter pairs are accepted. Rgba/UnsignedByte is always accepted, and the other acceptable pair can be discovered by calling ColorReadFormat and ColorReadType.
Note: values for pixels that lie outside the window connected to the current GL context are undefined.
Note: if an error is generated, no change is made to the contents of data.
Note: in DEBUG mode with assertions enabled, an error will be logged to the debug console if this framebuffer is not bound.
OpenGL API: glReadPixels