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