michael@0: Name michael@0: michael@0: ANGLE_pack_reverse_row_order michael@0: michael@0: Name Strings michael@0: michael@0: GL_ANGLE_pack_reverse_row_order michael@0: michael@0: Contact michael@0: michael@0: Daniel Koch, TransGaming (daniel 'at' transgaming.com) michael@0: michael@0: Contributors michael@0: michael@0: Brian Salomon michael@0: Daniel Koch michael@0: michael@0: Status michael@0: michael@0: Implemented in ANGLE ES2 michael@0: michael@0: Version michael@0: michael@0: Last Modified Date: February 22, 2011 michael@0: Author Revision: 22 michael@0: michael@0: Number michael@0: michael@0: OpenGL ES Extension #110 michael@0: michael@0: Dependencies michael@0: michael@0: OpenGL 1.5 or OpenGL ES 1.0 are required. michael@0: michael@0: Some of the functionality of this extension is not supported michael@0: when implemented against OpenGL ES. michael@0: michael@0: EXT_texture_rg interacts with this extension. michael@0: michael@0: The extension is written against the OpenGL 3.2 Specification michael@0: (Core Profile). michael@0: michael@0: Overview michael@0: michael@0: This extension introduces a mechanism to allow reversing the order michael@0: in which image rows are written into a pack destination. This michael@0: effectively allows an application to flip the results of a ReadPixels michael@0: in the y direction operation without having to render upside down. michael@0: michael@0: The coordinate system of OpenGL is vertically reversed in comparison to a michael@0: number of other graphics systems such as native windowing APIs. Applications michael@0: that perform ReadPixels may have to either render to an intermediate color michael@0: buffer before calling ReadPixels or perform a flip in software after michael@0: ReadPixels. In some systems the GL can perform the row reversal during michael@0: ReadPixels without incurring additional cost. michael@0: michael@0: IP Status michael@0: michael@0: No known IP claims. michael@0: michael@0: New Procedures and Functions michael@0: michael@0: None michael@0: michael@0: New Types michael@0: michael@0: None michael@0: michael@0: New Tokens michael@0: michael@0: Accepted by the parameter of PixelStore{if}, GetIntegerv(), michael@0: GetBooleanv(), and GetFloatv(): michael@0: michael@0: PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 michael@0: michael@0: Additions to Chapter 3 of the OpenGL 3.2 Specification (Rasterization) michael@0: michael@0: In Section 4.3.1 (Reading Pixels) add a row to table 4.7: michael@0: michael@0: +------------------------------+---------+---------------+-------------+ michael@0: | Parameter Name | Type | Initial Value | Valid Range | michael@0: +------------------------------+---------+---------------+-------------+ michael@0: | PACK_REVERSE_ROW_ORDER_ANGLE | boolean | FALSE | TRUE/FALSE | michael@0: +------------------------------+---------+---------------+-------------+ michael@0: michael@0: In Section 4.3.1 (Reading Pixels) modify the second paragraph of subsection michael@0: "Placement in Pixel Pack Buffer or Client Memory" to read: michael@0: michael@0: When PACK_REVERSE_ROW_ORDER_ANGLE is FALSE groups of elements are placed michael@0: in memory just as they are taken from memory when transferring pixel michael@0: rectangles to the GL. That is, the ith group of the jth row michael@0: (corresponding to the ith pixel in the jth row) is placed in memory just michael@0: where the ith group of the jth row would be taken from when transferring michael@0: pixels. See Unpacking under section 3.7.2. The only difference is that michael@0: the storage mode parameters whose names begin with PACK_ are used michael@0: instead of those whose names begin with UNPACK_. If the format is RED, michael@0: GREEN, BLUE, or ALPHA, only the corresponding single element is written. michael@0: Likewise if the format is RG, RGB, or BGR, only the corresponding two or michael@0: three elements are written. Otherwise all the elements of each group are michael@0: written. When PACK_REVERSE_ROW_ORDER_ANGLE is TRUE the order of the rows michael@0: of elements is reversed before the data is packed. That is, the element michael@0: corresponding to pixel (x, y + height - 1) becomes the first element michael@0: packed, followed by (x + 1, y + height - 1), etc. Otherwise, pixel data michael@0: is packed in the same manner as when PACK_REVERSE_ROW_ORDER_ANGLE is michael@0: FALSE. michael@0: michael@0: Additions to Chapter 6 of the OpenGL 3.2 Specification (State and State Requests) michael@0: michael@0: In Section 6.1.4 add the following sentence to the fifth paragraph michael@0: (beginning with "For three-dimensional and two-dimensional array michael@0: textures..."): michael@0: When PACK_REVERSE_ROW_ORDER_ANGLE is TRUE the order of rows within michael@0: each image are reversed without reordering the images themselves. michael@0: michael@0: Dependencies on OpenGL ES michael@0: michael@0: If implemented for OpenGL ES, this extension behaves as specified, except: michael@0: michael@0: -Delete all references to formats RED, GREEN, BLUE, RG, and BGR. michael@0: michael@0: -The language about image order in Section 6.1.4 does not apply as OpenGL ES michael@0: does not have GetTexImage. michael@0: michael@0: Dependencies on EXT_texture_rg michael@0: michael@0: If EXT_texture_rg is present reinsert language about formats RED and RG michael@0: into the OpenGL ES 2.0 specification. michael@0: michael@0: Errors michael@0: michael@0: None michael@0: michael@0: New State michael@0: Initial michael@0: Get Value Type Get Command Value Description Sec. michael@0: --------- ---- ----------- ------- ----------- ---- michael@0: PACK_REVERSE_ROW_ORDER_ANGLE B GetIntegerv FALSE Pixel pack row order reversal 4.3.1 michael@0: michael@0: New Implementation Dependent State michael@0: michael@0: None michael@0: michael@0: Issues michael@0: michael@0: None michael@0: michael@0: Sample Code michael@0: michael@0: /* Allocate space to hold the pixel data */ michael@0: const GLvoid* pixels = malloc(width * height * 4); michael@0: michael@0: /* Bind the framebuffer object to be read */ michael@0: glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer); michael@0: michael@0: /* Enable row order reversal */ michael@0: glPixelStore(GL_PACK_REVERSE_ROW_ORDER_ANGLE, TRUE); michael@0: michael@0: /* The pixel data stored in pixels will be in top-down order, ready for michael@0: * use with a windowing system API that expects this order. michael@0: */ michael@0: glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); michael@0: michael@0: Revision History michael@0: michael@0: Revision 1, 2011/11/22 (Brian Salomon) michael@0: - First version michael@0: Revision 2, 2012/02/22 (dgkoch) michael@0: - prepare for publishing