GlReadPixels

From QB64 Phoenix Edition Wiki
Revision as of 06:08, 1 May 2022 by SMcNeill (talk | contribs) (Created page with "'''_glReadPixels:''' read a block of pixels from the frame buffer {{PageSyntax}} SUB _glReadPixels (BYVAL x AS LONG, BYVAL y AS LONG, BYVAL width AS LONG, BYVAL height AS LONG, BYVAL format AS _UNSIGNED LONG, BYVAL type AS _UNSIGNED LONG, pixels AS _OFFSET) void '''_glReadPixels'''(GLint {{Parameter|x}}, GLint {{Parameter|y}}, GLsizei {{Parameter|width}}, GLsizei {{Parameter|height}}, GLenum {{Parameter|format}}, GLenum {{Parameter|type}}, GLvoid * {{Parameter|dat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

_glReadPixels: read a block of pixels from the frame buffer


Syntax

 SUB _glReadPixels (BYVAL x AS LONG, BYVAL y AS LONG, BYVAL width AS LONG, BYVAL height AS LONG, BYVAL format AS _UNSIGNED LONG, BYVAL type AS _UNSIGNED LONG, pixels AS _OFFSET)
 void _glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * data);


x, y
Specify the window coordinates of the first pixel that is read from the frame buffer. This location is the lower left corner of a rectangular block of pixels.
width, height
Specify the dimensions of the pixel rectangle. width and height of one correspond to a single pixel.

Template:Glapi pixeltransferupparams


Description

_glReadPixels returns pixel data from the frame buffer, starting with the pixel whose lower left corner is at location (x, y), into client memory starting at location data. Several parameters control the processing of the pixel data before it is placed into client memory. These parameters are set with Template:KW. This reference page describes the effects on _glReadPixels of most, but not all of the parameters specified by these three commands.

If a non-zero named buffer object is bound to the Template:KW target (see Template:KW) while a block of pixels is requested, data is treated as a byte offset into the buffer object's data store rather than a pointer to client memory.

_glReadPixels returns values from each pixel with lower left corner at (x + i, y + j) for 0 &le; i < width and 0 &le; j < height. This pixel is said to be the ith pixel in the jth row. 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; accepted values are:

Template:KW
Stencil values are read from the stencil buffer. Each index is converted to fixed point, shifted left or right depending on the value and sign of Template:KW, and added to Template:KW. If Template:KW is Template:KW, indices are replaced by their mappings in the table Template:KW.
Template:KW
Depth values are read from the depth buffer. Each component is converted to floating point such that the minimum depth value maps to 0 and the maximum value maps to 1. Each component is then multiplied by Template:KW, added to Template:KW, and finally clamped to the range [0, 1].
Template:KW
Values are taken from both the depth and stencil buffers. The type parameter must be Template:KW or Template:KW.
Template:KW
Template:KW
Template:KW
Template:KW
Template:KW
Template:KW
Template:KW
Finally, the indices or components are converted to the proper format, as specified by type. If format is Template:KW and type is not Template:KW, each index is masked with the mask value given in the following table. If type is Template:KW, then each integer index is converted to single-precision floating-point format.

If format is Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, or Template:KW and type is not Template:KW, each component is multiplied by the multiplier shown in the following table. If type is Template:KW, then each component is passed as is (or converted to the client's single-precision floating-point format if it is different from the one used by the GL).

type Index Mask Component Conversion
Template:KW 2<sup>8</sup> - 1 <math>(2^8 - 1)c</math>
Template:KW 2<sup>7</sup> - 1 <math>\tfrac{(2^8 - 1)c - 1}{2}</math>
Template:KW 2<sup>16</sup> - 1 <math>(2^{16} - 1)c</math>
Template:KW 2<sup>15</sup> - 1 <math>\tfrac{(2^{16} - 1)c - 1}{2}</math>
Template:KW 2<sup>32</sup> - 1 <math>(2^{32} - 1)c</math>
Template:KW 2<sup>31</sup> - 1 <math>\tfrac{(2^{32} - 1)c - 1}{2}</math>
Template:KW none c
Template:KW none c
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW 2<sup>N</sup> - 1 <math>(2^N - 1)c</math>
Template:KW -- Special
Template:KW -- Special
Template:KW none c (Depth Only)

Return values are placed in memory as follows. If format is Template:KW, Template:KW, Template:KW, Template:KW, or Template:KW, a single value is returned and the data for the ith pixel in the jth row is placed in location j * width + i. Template:KW and Template:KW return three values, Template:KW and Template:KW return four values for each pixel, with all values corresponding to a single pixel occupying contiguous space in data. Storage parameters set by Template:KW, such as Template:KW and Template:KW, affect the way that data is written into memory. See Template:KW for a description.


Template:PageNotes

Values for pixels that lie outside the window connected to the current GL context are undefined.

If an error is generated, no change is made to the contents of data.


Template:PageErrors

Template:KW is generated if format or type is not an accepted value.

Template:KW is generated if either width or height is negative.

Template:KW is generated if format is Template:KW and there is no stencil buffer.

Template:KW is generated if format is Template:KW and there is no depth buffer.

Template:KW is generated if format is Template:KW and there is no depth buffer or if there is no stencil buffer.

Template:KW is generated if format is Template:KW and type is not Template:KW or Template:KW.

Template:KW is generated if type is one of Template:KW, Template:KW, Template:KW, or Template:KW and format is not Template:KW.

Template:KW is generated if type is one of Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, Template:KW, or Template:KW and format is neither Template:KW nor Template:KW.

Template:KW is generated if a non-zero buffer object name is bound to the Template:KW target and the buffer object's data store is currently mapped.

Template:KW is generated if a non-zero buffer object name is bound to the Template:KW target and the data would be packed to the buffer object such that the memory writes required would exceed the data store size.

Template:KW is generated if a non-zero buffer object name is bound to the Template:KW target and data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type.

Template:KW is generated if Template:KW is non-zero, the read framebuffer is complete, and the value of Template:KW for the read framebuffer is greater than zero.


Template:PageUseWith

Template:KW with argument Template:KW

Template:KW with argument Template:KW


See also

SUB _GL Template:KW, Template:KW, Template:KW, Template:KW, Template:KW

Pixel Transfer, Pixel Buffer Object


Template:PageCopyright

Copyright 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.