Changeset 21911 in vbox for trunk/src/VBox/GuestHost/OpenGL/packer/pack_client.c
- Timestamp:
- Jul 31, 2009 10:42:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/packer/pack_client.c
r21882 r21911 12 12 13 13 /*Convert from GLint to GLfloat in [-1.f,1.f]*/ 14 #define CRP_I2F_NORM(i) ((2.f*((GLint)(i))+1.f) * (1.f/4294967294.f))14 #define CRP_I2F_NORM(i) ((2.f*((GLint)(i))+1.f) * (1.f/4294967294.f)) 15 15 /*Convert from GLshort to GLfloat in [-1.f,1.f]*/ 16 #define CRP_S2F_NORM(s) ((2.f*((GLshort)(s))+1.f) * (1.f/65535.f)) 17 16 #define CRP_S2F_NORM(s) ((2.f*((GLshort)(s))+1.f) * (1.f/65535.f)) 17 /*Convert from GLbyte to GLfloat in [-1.f,1.f]*/ 18 #define CRP_B2F_NORM(b) ((2.f*((GLbyte)(b))+1.f) * (1.f/255.f)) 19 /*Convert from GLuint to GLfloat in [0.f,1.f]*/ 20 #define CRP_UI2F_NORM(i) ((GLfloat)(i) * (1.f/4294967295.f)) 21 /*Convert from GLushort to GLfloat in [0.f,1.f]*/ 22 #define CRP_US2F_NORM(s) ((GLfloat)(s) * (1.f/65535.f)) 23 /*Convert from GLubyte to GLfloat in [0.f,1.f]*/ 24 #define CRP_UB2F_NORM(b) ((GLfloat)(b) * (1.f/255.f)) 18 25 19 26 static void crPackVertexAttrib(const CRVertexArrays *array, unsigned int attr, GLint index) 20 27 { 21 GLint *iPtr;22 GLshort *sPtr;23 28 unsigned char *p = array->a[attr].p + index * array->a[attr].stride; 24 29 … … 29 34 } 30 35 #endif 36 37 if (!p) 38 { 39 crWarning("crPackVertexAttrib: NULL ptr!"); 40 return; 41 } 42 31 43 switch (array->a[attr].type) 32 44 { 33 45 case GL_SHORT: 34 sPtr = (GLshort*) p; 46 { 47 GLshort *sPtr = (GLshort*) p; 35 48 switch (array->a[attr].size) 36 49 { … … 61 74 } 62 75 break; 76 } 77 case GL_UNSIGNED_SHORT: 78 { 79 GLushort *usPtr = (GLushort*) p; 80 if (array->a[attr].normalized) 81 { 82 switch (array->a[attr].size) 83 { 84 case 1: 85 crPackVertexAttrib1fARB(attr, CRP_US2F_NORM(usPtr[0])); 86 break; 87 case 2: 88 crPackVertexAttrib2fARB(attr, CRP_US2F_NORM(usPtr[0]), CRP_US2F_NORM(usPtr[1])); 89 break; 90 case 3: 91 crPackVertexAttrib3fARB(attr, CRP_US2F_NORM(usPtr[0]), CRP_US2F_NORM(usPtr[1]), CRP_US2F_NORM(usPtr[2])); 92 break; 93 case 4: 94 crPackVertexAttrib4NusvARB(attr, usPtr); 95 break; 96 } 97 } 98 else 99 { 100 GLushort usv[4]; 101 switch (array->a[attr].size) 102 { 103 case 4: 104 crPackVertexAttrib4usvARB(attr, usPtr); 105 break; 106 case 3: usv[2] = usPtr[2]; 107 case 2: usv[1] = usPtr[1]; 108 case 1: 109 usv[0] = usPtr[0]; 110 crPackVertexAttrib4usvARB(attr, usv); 111 break; 112 } 113 } 114 break; 115 } 63 116 case GL_INT: 64 iPtr = (GLint*) p; 65 switch (array->a[attr].size) 66 { 67 case 1: 68 if (array->a[attr].normalized) 117 { 118 GLint *iPtr = (GLint*) p; 119 if (array->a[attr].normalized) 120 { 121 switch (array->a[attr].size) 122 { 123 case 1: 69 124 crPackVertexAttrib1fARB(attr, CRP_I2F_NORM(iPtr[0])); 70 else 71 crPackVertexAttrib1fARB(attr, iPtr[0]); 72 break; 73 case 2: 74 if (array->a[attr].normalized) 125 break; 126 case 2: 75 127 crPackVertexAttrib2fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1])); 76 else 77 crPackVertexAttrib2fARB(attr, iPtr[0], iPtr[1]); 78 break; 79 case 3: 80 if (array->a[attr].normalized) 128 break; 129 case 3: 81 130 crPackVertexAttrib3fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1]), CRP_I2F_NORM(iPtr[2])); 82 else 83 crPackVertexAttrib3fARB(attr, iPtr[0], iPtr[1], iPtr[2]); 84 break; 85 case 4: 86 if (array->a[attr].normalized) 131 break; 132 case 4: 87 133 crPackVertexAttrib4NivARB(attr, iPtr); 88 else 89 crPackVertexAttrib4fARB(attr, iPtr[0], iPtr[1], iPtr[2], iPtr[3]); 90 break; 91 } 92 break; 134 break; 135 } 136 } 137 else 138 { 139 GLint iv[4]; 140 switch (array->a[attr].size) 141 { 142 case 4: 143 crPackVertexAttrib4ivARB(attr, iPtr); 144 break; 145 case 3: iv[2] = iPtr[2]; 146 case 2: iv[1] = iPtr[1]; 147 case 1: 148 iv[0] = iPtr[0]; 149 crPackVertexAttrib4ivARB(attr, iv); 150 break; 151 } 152 } 153 break; 154 } 155 case GL_UNSIGNED_INT: 156 { 157 GLuint *uiPtr = (GLuint*) p; 158 if (array->a[attr].normalized) 159 { 160 switch (array->a[attr].size) 161 { 162 case 1: 163 crPackVertexAttrib1fARB(attr, CRP_UI2F_NORM(uiPtr[0])); 164 break; 165 case 2: 166 crPackVertexAttrib2fARB(attr, CRP_UI2F_NORM(uiPtr[0]), CRP_UI2F_NORM(uiPtr[1])); 167 break; 168 case 3: 169 crPackVertexAttrib3fARB(attr, CRP_UI2F_NORM(uiPtr[0]), CRP_UI2F_NORM(uiPtr[1]), CRP_UI2F_NORM(uiPtr[2])); 170 break; 171 case 4: 172 crPackVertexAttrib4NivARB(attr, uiPtr); 173 break; 174 } 175 } 176 else 177 { 178 GLuint uiv[4]; 179 switch (array->a[attr].size) 180 { 181 case 4: 182 crPackVertexAttrib4uivARB(attr, uiPtr); 183 break; 184 case 3: uiv[2] = uiPtr[2]; 185 case 2: uiv[1] = uiPtr[1]; 186 case 1: 187 uiv[0] = uiPtr[0]; 188 crPackVertexAttrib4uivARB(attr, uiv); 189 break; 190 } 191 } 192 break; 193 } 93 194 case GL_FLOAT: 94 195 switch (array->a[attr].size) … … 109 210 } 110 211 break; 212 case GL_BYTE: 213 { 214 GLbyte *bPtr = (GLbyte*) p; 215 if (array->a[attr].normalized) 216 { 217 switch (array->a[attr].size) 218 { 219 case 1: 220 crPackVertexAttrib1fARB(attr, CRP_B2F_NORM(bPtr[0])); 221 break; 222 case 2: 223 crPackVertexAttrib2fARB(attr, CRP_B2F_NORM(bPtr[0]), CRP_B2F_NORM(bPtr[1])); 224 break; 225 case 3: 226 crPackVertexAttrib3fARB(attr, CRP_B2F_NORM(bPtr[0]), CRP_B2F_NORM(bPtr[1]), CRP_B2F_NORM(bPtr[2])); 227 break; 228 case 4: 229 crPackVertexAttrib4NbvARB(attr, bPtr); 230 break; 231 } 232 } 233 else 234 { 235 GLbyte bv[4]; 236 switch (array->a[attr].size) 237 { 238 case 4: 239 crPackVertexAttrib4bvARB(attr, bPtr); 240 break; 241 case 3: bv[2] = bPtr[2]; 242 case 2: bv[1] = bPtr[1]; 243 case 1: 244 bv[0] = bPtr[0]; 245 crPackVertexAttrib4bvARB(attr, bv); 246 break; 247 } 248 } 249 break; 250 } 251 case GL_UNSIGNED_BYTE: 252 { 253 GLubyte *ubPtr = (GLubyte*) p; 254 if (array->a[attr].normalized) 255 { 256 switch (array->a[attr].size) 257 { 258 case 1: 259 crPackVertexAttrib1fARB(attr, CRP_UB2F_NORM(ubPtr[0])); 260 break; 261 case 2: 262 crPackVertexAttrib2fARB(attr, CRP_UB2F_NORM(ubPtr[0]), CRP_UB2F_NORM(ubPtr[1])); 263 break; 264 case 3: 265 crPackVertexAttrib3fARB(attr, CRP_UB2F_NORM(ubPtr[0]), CRP_UB2F_NORM(ubPtr[1]), CRP_UB2F_NORM(ubPtr[2])); 266 break; 267 case 4: 268 crPackVertexAttrib4NubvARB(attr, ubPtr); 269 break; 270 } 271 } 272 else 273 { 274 GLubyte ubv[4]; 275 switch (array->a[attr].size) 276 { 277 case 4: 278 crPackVertexAttrib4ubvARB(attr, ubPtr); 279 break; 280 case 3: ubv[2] = ubPtr[2]; 281 case 2: ubv[1] = ubPtr[1]; 282 case 1: 283 ubv[0] = ubPtr[0]; 284 crPackVertexAttrib4ubvARB(attr, ubv); 285 break; 286 } 287 } 288 break; 289 } 111 290 default: 112 291 crWarning("Bad datatype for vertex attribute [%d] array: 0x%x\n",
Note:
See TracChangeset
for help on using the changeset viewer.