1Name 2 3 ARB_transpose_matrix 4 5Name Strings 6 7 GL_ARB_transpose_matrix 8 9Contact 10 11 David Blythe (blythe 'at' sgi.com) 12 13Notice 14 15 Copyright (c) 1999-2013 The Khronos Group Inc. Copyright terms at 16 http://www.khronos.org/registry/speccopyright.html 17 18Status 19 20 Complete. Approved by ARB on 12/8/1999 21 22Version 23 24 Last Modified Date: January 3, 2000 25 Author Revision: 1.3 26 27Number 28 29 ARB Extension #3 30 31Dependencies 32 33 This extensions is written against the OpenGL 1.2 Specification. 34 May be implemented in any version of OpenGL. 35 36Overview 37 38 New functions and tokens are added allowing application matrices 39 stored in row major order rather than column major order to be 40 transferred to the OpenGL implementation. This allows an application 41 to use standard C-language 2-dimensional arrays (m[row][col]) and 42 have the array indices match the expected matrix row and column indexes. 43 These arrays are referred to as transpose matrices since they are 44 the transpose of the standard matrices passed to OpenGL. 45 46 This extension adds an interface for transfering data to and from the 47 OpenGL pipeline, it does not change any OpenGL processing or imply any 48 changes in state representation. 49 50IP Status 51 52 No IP is believed to be involved. 53 54Issues 55 56 * Why do this? 57 58 It's very useful for layered libraries that desire to use two 59 dimensional C arrays as matrices. It avoids having the layered 60 library perform the transpose itself before calling OpenGL since 61 most OpenGL implementations can efficiently perform the transpose 62 while reading the matrix from client memory. 63 64 * Why not add a mode? 65 66 It's substantially more confusing and complicated to add a mode. 67 Simply adding two new entry points saves considerable confusion 68 and avoids having layered libraries need to query the current mode 69 in order to send a matrix with the correct memory layout. 70 71 * Why not a utility routine in GLU 72 73 It costs some performance. It is believed that most OpenGL 74 implementations can perform the transpose in place with negligble 75 performance penalty. 76 77 * Why use the name transpose? 78 79 It's sure a lot less confusing than trying to ascribe unambiguous 80 meaning to terms like row and column. It could be matrix_transpose 81 rather than transpose_matrix though. 82 83 * Short Transpose to Trans? 84 85 86New Procedures and Functions 87 88 void LoadTransposeMatrix{fd}ARB(T m[16]); 89 void MultTransposeMatrix{fd}ARB(T m[16]); 90 91New Tokens 92 93 Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv, 94 and GetDoublev 95 96 TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 97 TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 98 TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 99 TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 100 101 102Additions to Chapter 2 of the 1.2 OpenGL Specification (OpenGL Operation) 103 104 Add to Section 2.10.2 Matrices <before LoadIdentity> 105 106 LoadTransposeMatrixARB takes a 4x4 matrix stored in row-major order as 107 108 Let transpose(m,n) be defined as 109 110 n[0] = m[0]; 111 n[1] = m[4]; 112 n[2] = m[8]; 113 n[3] = m[12]; 114 n[4] = m[1]; 115 n[5] = m[5]; 116 n[6] = m[9]; 117 n[7] = m[13]; 118 n[8] = m[2]; 119 n[9] = m[6]; 120 n[10] = m[10]; 121 n[11] = m[14]; 122 n[12] = m[3]; 123 n[13] = m[7]; 124 n[14] = m[11]; 125 n[15] = m[15]; 126 127 The effect of LoadTransposeMatrixARB(m) is then the same as the effect of 128 the command sequence 129 130 float n[16]; 131 transpose(m,n) 132 LoadMatrix(n); 133 134 The effect of MultTransposeMatrixARB(m) is then the same as the effect of 135 the command sequence 136 137 float n[16]; 138 transpose(m,n); 139 MultMatrix(n); 140 141 142Additions to Chapter 3 of the 1.2 OpenGL Specification (Rasterization) 143 144 None 145 146Additions to Chapter 4 of the 1.2 OpenGL Specification (Per-Fragment Operations 147and the Framebuffer) 148 149 None 150 151Additions to Chapter 5 of the 1.2 OpenGL Specification (Special Functions) 152 153 None 154 155Additions to Chapter 6 of the 1.2 OpenGL Specification (State and State Requests) 156 157 Matrices are queried and returned in their transposed form by calling 158 GetBooleanv, GetIntegerv, GetFloatv, and GetDoublev with <pname> set to 159 TRANSPOSE_MODELVIEW_MATRIX_ARB, TRANSPOSE_PROJECTION_MATRIX_ARB, 160 TRANSPOSE_TEXTURE_MATRIX_ARB, or TRANSPOSE_COLOR_MATRIX_ARB. 161 The effect of GetFloatv(TRANSPOSE_MODELVIEW_MATRIX_ARB,m) is then the same 162 as the effect of the command sequence 163 164 float n[16]; 165 GetFloatv(MODELVIEW_MATRIX_ARB,n); 166 transpose(n,m); 167 168 Similar results occur for TRANSPOSE_PROJECTION_MATRIX_ARB, 169 TRANSPOSE_TEXTURE_MATRIX_ARB, and TRANSPOSE_COLOR_MATRIX_ARB. 170 171 172Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance) 173 174 None 175 176Additions to the GLX Specification 177 178 None 179 180GLX Protocol 181 182 LoadTransposeMatrix and MultTransposeMatrix are layered 183 on top of LoadMatrix and MultMatrix protocol 184 performing client-side translation. The Get commands 185 are passed over the wire as part of the generic Get 186 protocol with no translation required. 187 188Errors 189 190 No new errors, but error behavoir is inherited by the commands 191 that the transpose commands are implemented on top of 192 (LoadMatrix, MultMatrix, and Get*). 193 194New State 195 196 None 197 198 TRANSPOSE_*_MATRIX_ARB refer to the same state as their non-transposed 199 counterparts. 200 201New Implementation Dependent State 202 203 None 204 205Revision History 206 207 * Revision 1.1 - initial draft (18 Mar 1999) 208 * Revision 1.2 - changed to use layered specification and ARB affix 209 (23 Nov 1999) 210 * Revision 1.3 - Minor tweaks to GLX protocol and Errors. (7 Dec 1999) 211 212Conformance Testing 213 214 Load and Multiply the modelview matrix (initialized to identity 215 each time) using LoadTransposeMatrixfARB and MultTransposeMatrixfARB 216 with the matrix: 217 218 ( 1 2 3 4 ) 219 ( 5 6 7 8 ) 220 ( 9 10 11 12 ) 221 (13 14 15 16 ) 222 223 and get the modelview matrix using TRANSPOSE_MODELVIEW_MATRIX_ARB and 224 validate that the matrix is correct. Get the matrix using 225 MODELVIEW_MATRIX and verify that it is the transpose of the above 226 matrix. Load and Multiply the modelview matrix using LoadMatrixf 227 and MultMatrixf with the above matrix and verify that the correct 228 matrix is on the modelview stack using gets of MODELVIEW_MATRIX 229 and TRANSPOSE_MODELVIEW_MATRIX_ARB. 230