Click or drag to resize

FramebufferReadPixelsT Method

Read a block of pixels from the frame buffer.

Namespace:  Ooogles
Assembly:  Ooogles (in Ooogles.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
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()

Parameters

left
Type: SystemInt32
left window coordinate of the first pixel that is read from the framebuffer.
bottom
Type: SystemInt32
bottom window coordinate of the first pixel that is read from the framebuffer.
width
Type: SystemInt32
width of the rectangle in pixels.
height
Type: SystemInt32
height of the rectangle in pixels.
data
Type: T
the pixel data to be filled.
format (Optional)
Type: OooglesglPixelFormat
(optional) format of the pixels to return. Only Alpha, RGB and RGBA are supported. Defaults to RGBA.
dataType (Optional)
Type: OooglesglPixelDataType
(optional) data type of the pixels to return. Defaults to UnsignedByte.

Type Parameters

T
the type of the elements in the data array.
Exceptions
ExceptionCondition
GLExceptionInvalidEnum if format or dataType is not an accepted value.
GLExceptionInvalidValue if either width or height is negative.
GLExceptionInvalidOperation if dataType is UnsignedShort565 and format is not RGB.
GLExceptionInvalidOperation if dataType is UnsignedShort4444 or UnsignedShort5551 and format is not RGBA.
GLExceptionInvalidOperation if format and dataType are neither RGBA UnsignedByte, respectively, nor the format/dataType pair returned by calling ColorReadFormat and ColorReadType.
GLExceptionInvalidFramebufferOperation if the framebuffer is not framebuffer complete.
Remarks
This method returns pixel data from the frame buffer, starting with the pixel whose lower left corner is at location (left, bottom), into client memory starting at location data. The PackAlignment, set with the PixelStore(glPixelStoreMode, glPixelStoreValue) command, affects the processing of the pixel data before it is placed into client memory.

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

See Also