Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1222 lines
34 KiB

  1. /*
  2. ** Copyright 1995-2095, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. */
  17. #include "glslib.h"
  18. // DrewB - Changed size functions to take contexts
  19. // DrewB
  20. GLint __glsTypeSize(GLenum type)
  21. {
  22. switch(type)
  23. {
  24. case __GLS_BOOLEAN:
  25. case GL_BYTE:
  26. case GL_UNSIGNED_BYTE:
  27. return 1;
  28. case GL_SHORT:
  29. case GL_UNSIGNED_SHORT:
  30. return 2;
  31. case GL_INT:
  32. case GL_UNSIGNED_INT:
  33. case GL_FLOAT:
  34. return 4;
  35. case GL_DOUBLE_EXT:
  36. return 8;
  37. default:
  38. return 0;
  39. }
  40. }
  41. GLint __glsEvalComputeK(GLenum inTarget) {
  42. switch(inTarget) {
  43. case GL_MAP1_INDEX:
  44. case GL_MAP1_TEXTURE_COORD_1:
  45. case GL_MAP2_INDEX:
  46. case GL_MAP2_TEXTURE_COORD_1:
  47. return 1;
  48. case GL_MAP1_TEXTURE_COORD_2:
  49. case GL_MAP2_TEXTURE_COORD_2:
  50. return 2;
  51. case GL_MAP1_NORMAL:
  52. case GL_MAP1_TEXTURE_COORD_3:
  53. case GL_MAP1_VERTEX_3:
  54. case GL_MAP2_NORMAL:
  55. case GL_MAP2_TEXTURE_COORD_3:
  56. case GL_MAP2_VERTEX_3:
  57. return 3;
  58. case GL_MAP1_COLOR_4:
  59. case GL_MAP1_TEXTURE_COORD_4:
  60. case GL_MAP1_VERTEX_4:
  61. case GL_MAP2_COLOR_4:
  62. case GL_MAP2_TEXTURE_COORD_4:
  63. case GL_MAP2_VERTEX_4:
  64. return 4;
  65. }
  66. return 0;
  67. }
  68. static GLint __glsGetMapSize(__GLScontext *ctx, GLenum inTarget, GLenum inQuery) {
  69. GLint order[2];
  70. order[0] = order[1] = 0;
  71. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetMapiv);
  72. glGetMapiv(inTarget, GL_ORDER, order);
  73. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetMapiv);
  74. if (order[0] < 0 || order[1] < 0) return 0;
  75. switch (inTarget) {
  76. case GL_MAP1_COLOR_4:
  77. case GL_MAP1_INDEX:
  78. case GL_MAP1_NORMAL:
  79. case GL_MAP1_TEXTURE_COORD_1:
  80. case GL_MAP1_TEXTURE_COORD_2:
  81. case GL_MAP1_TEXTURE_COORD_3:
  82. case GL_MAP1_TEXTURE_COORD_4:
  83. case GL_MAP1_VERTEX_3:
  84. case GL_MAP1_VERTEX_4:
  85. switch (inQuery) {
  86. case GL_COEFF:
  87. return __glsEvalComputeK(inTarget) * order[0];
  88. case GL_DOMAIN:
  89. return 2;
  90. case GL_ORDER:
  91. return 1;
  92. }
  93. break;
  94. case GL_MAP2_COLOR_4:
  95. case GL_MAP2_INDEX:
  96. case GL_MAP2_NORMAL:
  97. case GL_MAP2_TEXTURE_COORD_1:
  98. case GL_MAP2_TEXTURE_COORD_2:
  99. case GL_MAP2_TEXTURE_COORD_3:
  100. case GL_MAP2_TEXTURE_COORD_4:
  101. case GL_MAP2_VERTEX_3:
  102. case GL_MAP2_VERTEX_4:
  103. switch (inQuery) {
  104. case GL_COEFF:
  105. return (
  106. __glsEvalComputeK(inTarget) * order[0] * order[1]
  107. );
  108. case GL_DOMAIN:
  109. return 4;
  110. case GL_ORDER:
  111. return 2;
  112. }
  113. break;
  114. }
  115. return 0;
  116. }
  117. static GLint __glsGetPixelMapSize(__GLScontext *ctx, GLenum inMap) {
  118. GLint size = 0;
  119. GLenum query;
  120. switch (inMap) {
  121. case GL_PIXEL_MAP_I_TO_I:
  122. query = GL_PIXEL_MAP_I_TO_I_SIZE;
  123. break;
  124. case GL_PIXEL_MAP_S_TO_S:
  125. query = GL_PIXEL_MAP_S_TO_S_SIZE;
  126. break;
  127. case GL_PIXEL_MAP_I_TO_R:
  128. query = GL_PIXEL_MAP_I_TO_R_SIZE;
  129. break;
  130. case GL_PIXEL_MAP_I_TO_G:
  131. query = GL_PIXEL_MAP_I_TO_G_SIZE;
  132. break;
  133. case GL_PIXEL_MAP_I_TO_B:
  134. query = GL_PIXEL_MAP_I_TO_B_SIZE;
  135. break;
  136. case GL_PIXEL_MAP_I_TO_A:
  137. query = GL_PIXEL_MAP_I_TO_A_SIZE;
  138. break;
  139. case GL_PIXEL_MAP_R_TO_R:
  140. query = GL_PIXEL_MAP_R_TO_R_SIZE;
  141. break;
  142. case GL_PIXEL_MAP_G_TO_G:
  143. query = GL_PIXEL_MAP_G_TO_G_SIZE;
  144. break;
  145. case GL_PIXEL_MAP_B_TO_B:
  146. query = GL_PIXEL_MAP_B_TO_B_SIZE;
  147. break;
  148. case GL_PIXEL_MAP_A_TO_A:
  149. query = GL_PIXEL_MAP_A_TO_A_SIZE;
  150. break;
  151. default:
  152. return 0;
  153. }
  154. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetIntegerv);
  155. glGetIntegerv(query, &size);
  156. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetIntegerv);
  157. return size;
  158. }
  159. static GLint __glsGetSize(GLenum inPname) {
  160. switch (inPname) {
  161. default:
  162. return 16;
  163. }
  164. }
  165. static GLint __glsImageSize(
  166. GLenum inFormat, GLenum inType, GLint inWidth, GLint inHeight
  167. ) {
  168. GLint elemCount;
  169. if (inWidth < 0 || inHeight < 0) return 0;
  170. switch (inFormat) {
  171. case GL_ALPHA:
  172. case GL_BLUE:
  173. case GL_COLOR_INDEX:
  174. case GL_DEPTH_COMPONENT:
  175. case GL_GREEN:
  176. case GL_LUMINANCE:
  177. case GL_RED:
  178. case GL_STENCIL_INDEX:
  179. elemCount = 1;
  180. break;
  181. case GL_LUMINANCE_ALPHA:
  182. elemCount = 2;
  183. break;
  184. case GL_RGB:
  185. #if __GL_EXT_bgra
  186. case GL_BGR_EXT:
  187. #endif
  188. elemCount = 3;
  189. break;
  190. case GL_RGBA:
  191. #if __GL_EXT_bgra
  192. case GL_BGRA_EXT:
  193. #endif
  194. elemCount = 4;
  195. break;
  196. #if __GL_EXT_abgr
  197. case GL_ABGR_EXT:
  198. elemCount = 4;
  199. break;
  200. #endif /* __GL_EXT_abgr */
  201. #if __GL_EXT_cmyka
  202. case GL_CMYK_EXT:
  203. elemCount = 4;
  204. break;
  205. case GL_CMYKA_EXT:
  206. elemCount = 5;
  207. break;
  208. #endif /* __GL_EXT_cmyka */
  209. default:
  210. return 0;
  211. }
  212. #if __GL_EXT_packed_pixels
  213. switch (inType) {
  214. case GL_UNSIGNED_BYTE_3_3_2_EXT:
  215. if (elemCount != 3) return 0;
  216. break;
  217. case GL_UNSIGNED_SHORT_4_4_4_4_EXT:
  218. case GL_UNSIGNED_SHORT_5_5_5_1_EXT:
  219. case GL_UNSIGNED_INT_8_8_8_8_EXT:
  220. case GL_UNSIGNED_INT_10_10_10_2_EXT:
  221. if (elemCount != 4) return 0;
  222. break;
  223. }
  224. #endif /* __GL_EXT_packed_pixels */
  225. switch (inType) {
  226. case GL_BITMAP:
  227. if (inFormat != GL_COLOR_INDEX && inFormat != GL_STENCIL_INDEX) {
  228. return 0;
  229. }
  230. return inHeight * ((inWidth + 7) / 8);
  231. case GL_BYTE:
  232. case GL_UNSIGNED_BYTE:
  233. #if __GL_EXT_packed_pixels
  234. case GL_UNSIGNED_BYTE_3_3_2_EXT:
  235. #endif /* __GL_EXT_packed_pixels */
  236. return elemCount * inWidth * inHeight;
  237. case GL_SHORT:
  238. case GL_UNSIGNED_SHORT:
  239. #if __GL_EXT_packed_pixels
  240. case GL_UNSIGNED_SHORT_4_4_4_4_EXT:
  241. case GL_UNSIGNED_SHORT_5_5_5_1_EXT:
  242. #endif /* __GL_EXT_packed_pixels */
  243. return elemCount * 2 * inWidth * inHeight;
  244. case GL_FLOAT:
  245. case GL_INT:
  246. case GL_UNSIGNED_INT:
  247. #if __GL_EXT_packed_pixels
  248. case GL_UNSIGNED_INT_8_8_8_8_EXT:
  249. case GL_UNSIGNED_INT_10_10_10_2_EXT:
  250. #endif /* __GL_EXT_packed_pixels */
  251. return elemCount * 4 * inWidth * inHeight;
  252. }
  253. return 0;
  254. }
  255. static GLint __glsTextureSize(
  256. GLenum inFormat, GLenum inType, GLint inWidth, GLint inHeight
  257. ) {
  258. switch (inFormat) {
  259. case GL_DEPTH_COMPONENT:
  260. case GL_STENCIL_INDEX:
  261. return 0;
  262. }
  263. if (inType == GL_BITMAP) return 0;
  264. return __glsImageSize(inFormat, inType, inWidth, inHeight);
  265. }
  266. GLint __gls_glBitmap_bitmap_size(GLint inWidth, GLint inHeight) {
  267. return __glsImageSize(GL_COLOR_INDEX, GL_BITMAP, inWidth, inHeight);
  268. }
  269. GLint __gls_glCallLists_lists_size(GLint inCount, GLenum inType) {
  270. if (inCount < 0) return 0;
  271. switch (inType) {
  272. case GL_BYTE:
  273. case GL_UNSIGNED_BYTE:
  274. return inCount;
  275. case GL_2_BYTES:
  276. case GL_SHORT:
  277. case GL_UNSIGNED_SHORT:
  278. return 2 * inCount;
  279. case GL_3_BYTES:
  280. return 3 * inCount;
  281. case GL_4_BYTES:
  282. case GL_FLOAT:
  283. case GL_INT:
  284. case GL_UNSIGNED_INT:
  285. return 4 * inCount;
  286. }
  287. return 0;
  288. }
  289. GLint __gls_glDrawPixels_pixels_size(
  290. GLenum inFormat, GLenum inType, GLint inWidth, GLint inHeight
  291. ) {
  292. return __glsImageSize(inFormat, inType, inWidth, inHeight);
  293. }
  294. GLint __gls_glFogfv_params_size(GLenum inPname) {
  295. switch (inPname) {
  296. case GL_FOG_DENSITY:
  297. case GL_FOG_END:
  298. case GL_FOG_INDEX:
  299. case GL_FOG_MODE:
  300. case GL_FOG_START:
  301. return 1;
  302. case GL_FOG_COLOR:
  303. return 4;
  304. }
  305. return 0;
  306. }
  307. GLint __gls_glFogiv_params_size(GLenum inPname) {
  308. return __gls_glFogfv_params_size(inPname);
  309. }
  310. GLint __gls_glGetBooleanv_params_size(GLenum inPname) {
  311. return __glsGetSize(inPname);
  312. }
  313. GLint __gls_glGetDoublev_params_size(GLenum inPname) {
  314. return __glsGetSize(inPname);
  315. }
  316. GLint __gls_glGetFloatv_params_size(GLenum inPname) {
  317. return __glsGetSize(inPname);
  318. }
  319. GLint __gls_glGetIntegerv_params_size(GLenum inPname) {
  320. return __glsGetSize(inPname);
  321. }
  322. GLint __gls_glGetLightfv_params_size(GLenum inPname) {
  323. switch (inPname) {
  324. default:
  325. return 16;
  326. }
  327. }
  328. GLint __gls_glGetLightiv_params_size(GLenum inPname) {
  329. return __gls_glGetLightfv_params_size(inPname);
  330. }
  331. GLint __gls_glGetMapdv_v_size(__GLScontext *ctx, GLenum inTarget, GLenum inQuery) {
  332. return __glsGetMapSize(ctx, inTarget, inQuery);
  333. }
  334. GLint __gls_glGetMapfv_v_size(__GLScontext *ctx, GLenum inTarget, GLenum inQuery) {
  335. return __glsGetMapSize(ctx, inTarget, inQuery);
  336. }
  337. GLint __gls_glGetMapiv_v_size(__GLScontext *ctx, GLenum inTarget, GLenum inQuery) {
  338. return __glsGetMapSize(ctx, inTarget, inQuery);
  339. }
  340. GLint __gls_glGetMaterialfv_params_size(GLenum inPname) {
  341. switch (inPname) {
  342. default:
  343. return 16;
  344. }
  345. }
  346. GLint __gls_glGetMaterialiv_params_size(GLenum inPname) {
  347. return __gls_glGetMaterialfv_params_size(inPname);
  348. }
  349. GLint __gls_glGetPixelMapfv_values_size(__GLScontext *ctx, GLenum inMap) {
  350. return __glsGetPixelMapSize(ctx, inMap);
  351. }
  352. GLint __gls_glGetPixelMapuiv_values_size(__GLScontext *ctx, GLenum inMap) {
  353. return __glsGetPixelMapSize(ctx, inMap);
  354. }
  355. GLint __gls_glGetPixelMapusv_values_size(__GLScontext *ctx, GLenum inMap) {
  356. return __glsGetPixelMapSize(ctx, inMap);
  357. }
  358. GLint __gls_glGetPolygonStipple_mask_size(void) {
  359. return 128;
  360. }
  361. GLint __gls_glGetTexEnvfv_params_size(GLenum inPname) {
  362. switch (inPname) {
  363. default:
  364. return 16;
  365. }
  366. }
  367. GLint __gls_glGetTexEnviv_params_size(GLenum inPname) {
  368. return __gls_glGetTexEnvfv_params_size(inPname);
  369. }
  370. GLint __gls_glGetTexGendv_params_size(GLenum inPname) {
  371. switch (inPname) {
  372. default:
  373. return 16;
  374. }
  375. }
  376. GLint __gls_glGetTexGenfv_params_size(GLenum inPname) {
  377. return __gls_glGetTexGendv_params_size(inPname);
  378. }
  379. GLint __gls_glGetTexGeniv_params_size(GLenum inPname) {
  380. return __gls_glGetTexGendv_params_size(inPname);
  381. }
  382. GLint __gls_glGetTexImage_pixels_size(
  383. __GLScontext *ctx,
  384. GLenum inTarget, GLint inLevel, GLenum inFormat, GLenum inType
  385. ) {
  386. GLint width, height, depth, size4d;
  387. switch (inTarget) {
  388. case GL_TEXTURE_1D:
  389. case GL_TEXTURE_2D:
  390. #if __GL_EXT_texture3D
  391. case GL_TEXTURE_3D_EXT:
  392. #endif /* __GL_EXT_texture3D */
  393. #if __GL_SGIS_detail_texture
  394. case GL_DETAIL_TEXTURE_2D_SGIS:
  395. #endif /* __GL_SGIS_detail_texture */
  396. #if __GL_SGIS_texture4D
  397. case GL_TEXTURE_4D_SGIS:
  398. #endif /* __GL_SGIS_texture4D */
  399. break;
  400. default:
  401. return 0;
  402. }
  403. if (inLevel < 0) return 0;
  404. width = height = 0;
  405. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetTexLevelParameteriv);
  406. glGetTexLevelParameteriv(inTarget, inLevel, GL_TEXTURE_WIDTH, &width);
  407. glGetTexLevelParameteriv(inTarget, inLevel, GL_TEXTURE_HEIGHT, &height);
  408. #if __GL_EXT_texture3D
  409. depth = 0;
  410. glGetTexLevelParameteriv(
  411. inTarget, inLevel, GL_TEXTURE_DEPTH_EXT, &depth
  412. );
  413. #else /* !__GL_EXT_texture3D */
  414. depth = 1;
  415. #endif /* __GL_EXT_texture3D */
  416. #if __GL_SGIS_texture4D
  417. size4d = 0;
  418. glGetTexLevelParameteriv(
  419. inTarget, inLevel, GL_TEXTURE_4DSIZE_SGIS, &size4d
  420. );
  421. #else /* !__GL_SGIS_texture4D */
  422. size4d = 1;
  423. #endif /* __GL_SGIS_texture4D */
  424. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetTexLevelParameteriv);
  425. return __glsTextureSize(inFormat, inType, width, height) * depth * size4d;
  426. }
  427. GLint __gls_glGetTexLevelParameterfv_params_size(GLenum inPname) {
  428. switch (inPname) {
  429. default:
  430. return 16;
  431. }
  432. }
  433. GLint __gls_glGetTexLevelParameteriv_params_size(GLenum inPname) {
  434. return __gls_glGetTexLevelParameterfv_params_size(inPname);
  435. }
  436. GLint __gls_glGetTexParameterfv_params_size(GLenum inPname) {
  437. switch (inPname) {
  438. default:
  439. return 16;
  440. }
  441. }
  442. GLint __gls_glGetTexParameteriv_params_size(GLenum inPname) {
  443. return __gls_glGetTexParameterfv_params_size(inPname);
  444. }
  445. GLint __gls_glLightfv_params_size(GLenum inPname) {
  446. switch (inPname) {
  447. case GL_CONSTANT_ATTENUATION:
  448. case GL_LINEAR_ATTENUATION:
  449. case GL_QUADRATIC_ATTENUATION:
  450. case GL_SPOT_CUTOFF:
  451. case GL_SPOT_EXPONENT:
  452. return 1;
  453. case GL_SPOT_DIRECTION:
  454. return 3;
  455. case GL_AMBIENT:
  456. case GL_DIFFUSE:
  457. case GL_POSITION:
  458. case GL_SPECULAR:
  459. return 4;
  460. }
  461. return 0;
  462. }
  463. GLint __gls_glLightiv_params_size(GLenum inPname) {
  464. return __gls_glLightfv_params_size(inPname);
  465. }
  466. GLint __gls_glLightModelfv_params_size(GLenum inPname) {
  467. switch (inPname) {
  468. case GL_LIGHT_MODEL_LOCAL_VIEWER:
  469. case GL_LIGHT_MODEL_TWO_SIDE:
  470. return 1;
  471. case GL_LIGHT_MODEL_AMBIENT:
  472. return 4;
  473. }
  474. return 0;
  475. }
  476. GLint __gls_glLightModeliv_params_size(GLenum inPname) {
  477. return __gls_glLightModelfv_params_size(inPname);
  478. }
  479. GLint __gls_glMap1d_points_size(
  480. GLenum inTarget, GLint inStride, GLint inOrder
  481. ) {
  482. const GLint k = __glsEvalComputeK(inTarget);
  483. if (inStride < k || inOrder < 0) return 0;
  484. return k * inOrder;
  485. }
  486. GLint __gls_glMap1f_points_size(
  487. GLenum inTarget, GLint inStride, GLint inOrder
  488. ) {
  489. const GLint k = __glsEvalComputeK(inTarget);
  490. if (inStride < k || inOrder < 0) return 0;
  491. return k * inOrder;
  492. }
  493. GLint __gls_glMap2d_points_size(
  494. GLenum inTarget, GLint inUstride, GLint inUorder, GLint inVstride,
  495. GLint inVorder
  496. ) {
  497. const GLint k = __glsEvalComputeK(inTarget);
  498. if (inUstride < k || inUorder < 0 || inVstride < k || inVorder < 0) {
  499. return 0;
  500. }
  501. return k * inUorder * inVorder;
  502. }
  503. GLint __gls_glMap2f_points_size(
  504. GLenum inTarget, GLint inUstride, GLint inUorder, GLint inVstride,
  505. GLint inVorder
  506. ) {
  507. const GLint k = __glsEvalComputeK(inTarget);
  508. if (inUstride < k || inUorder < 0 || inVstride < k || inVorder < 0) {
  509. return 0;
  510. }
  511. return k * inUorder * inVorder;
  512. }
  513. GLint __gls_glMaterialfv_params_size(GLenum inPname) {
  514. switch (inPname) {
  515. case GL_SHININESS:
  516. return 1;
  517. case GL_COLOR_INDEXES:
  518. return 3;
  519. case GL_AMBIENT:
  520. case GL_AMBIENT_AND_DIFFUSE:
  521. case GL_DIFFUSE:
  522. case GL_EMISSION:
  523. case GL_SPECULAR:
  524. return 4;
  525. }
  526. return 0;
  527. }
  528. GLint __gls_glMaterialiv_params_size(GLenum inPname) {
  529. return __gls_glMaterialfv_params_size(inPname);
  530. }
  531. GLint __gls_glPolygonStipple_mask_size(void) {
  532. return 128;
  533. }
  534. GLint __gls_glReadPixels_pixels_size(
  535. GLenum inFormat, GLenum inType, GLint inWidth, GLint inHeight
  536. ) {
  537. return __glsImageSize(inFormat, inType, inWidth, inHeight);
  538. }
  539. GLint __gls_glTexEnvfv_params_size(GLenum inPname) {
  540. switch (inPname) {
  541. case GL_TEXTURE_ENV_MODE:
  542. return 1;
  543. case GL_TEXTURE_ENV_COLOR:
  544. return 4;
  545. }
  546. return 0;
  547. }
  548. GLint __gls_glTexEnviv_params_size(GLenum inPname) {
  549. return __gls_glTexEnvfv_params_size(inPname);
  550. }
  551. GLint __gls_glTexGendv_params_size(GLenum inPname) {
  552. switch (inPname) {
  553. case GL_TEXTURE_GEN_MODE:
  554. return 1;
  555. case GL_EYE_PLANE:
  556. case GL_OBJECT_PLANE:
  557. return 4;
  558. }
  559. return 0;
  560. }
  561. GLint __gls_glTexGenfv_params_size(GLenum inPname) {
  562. return __gls_glTexGendv_params_size(inPname);
  563. }
  564. GLint __gls_glTexGeniv_params_size(GLenum inPname) {
  565. return __gls_glTexGendv_params_size(inPname);
  566. }
  567. GLint __gls_glTexImage1D_pixels_size(
  568. GLenum inFormat, GLenum inType, GLint inWidth
  569. ) {
  570. return __glsTextureSize(inFormat, inType, inWidth, 1);
  571. }
  572. GLint __gls_glTexImage2D_pixels_size(
  573. GLenum inFormat, GLenum inType, GLint inWidth, GLint inHeight
  574. ) {
  575. return __glsTextureSize(inFormat, inType, inWidth, inHeight);
  576. }
  577. GLint __gls_glColorSubTableEXT_entries_size(
  578. GLenum inFormat, GLenum inType, GLint inCount
  579. ) {
  580. return __glsTextureSize(inFormat, inType, inCount, 1);
  581. }
  582. GLint __gls_glTexParameterfv_params_size(GLenum inPname) {
  583. switch (inPname) {
  584. case GL_TEXTURE_MAG_FILTER:
  585. case GL_TEXTURE_MIN_FILTER:
  586. case GL_TEXTURE_WRAP_S:
  587. case GL_TEXTURE_WRAP_T:
  588. return 1;
  589. case GL_TEXTURE_BORDER_COLOR:
  590. return 4;
  591. #if __GL_SGIS_component_select
  592. case GL_TEXTURE_SS_SELECT_SGIS:
  593. case GL_TEXTURE_SSSS_SELECT_SGIS:
  594. return 1;
  595. #endif /* __GL_SGIS_component_select */
  596. #if __GL_SGIS_detail_texture
  597. case GL_DETAIL_TEXTURE_LEVEL_SGIS:
  598. case GL_DETAIL_TEXTURE_MODE_SGIS:
  599. return 1;
  600. #endif /* __GL_SGIS_detail_texture */
  601. #if __GL_EXT_texture_object
  602. case GL_TEXTURE_PRIORITY_EXT:
  603. return 1;
  604. #endif /* __GL_EXT_texture_object */
  605. #if __GL_EXT_texture3D
  606. case GL_TEXTURE_WRAP_R_EXT:
  607. return 1;
  608. #endif /* __GL_EXT_texture3D */
  609. #if __GL_SGIS_texture_lod
  610. case GL_TEXTURE_MIN_LOD_SGIS:
  611. case GL_TEXTURE_MAX_LOD_SGIS:
  612. case GL_TEXTURE_BASE_LEVEL_SGIS:
  613. case GL_TEXTURE_MAX_LEVEL_SGIS:
  614. return 1;
  615. #endif /* __GL_SGIS_texture_lod */
  616. #if __GL_SGIS_texture4D
  617. case GL_TEXTURE_WRAP_Q_SGIS:
  618. return 1;
  619. #endif /* __GL_SGIS_texture4D */
  620. }
  621. return 0;
  622. }
  623. GLint __gls_glTexParameteriv_params_size(GLenum inPname) {
  624. return __gls_glTexParameterfv_params_size(inPname);
  625. }
  626. GLint __gls_glsHeaderfv_inVec_size(GLenum inAttrib) {
  627. switch (inAttrib) {
  628. case GLS_ORIGIN:
  629. case GLS_PAGE_SIZE:
  630. case GLS_RED_POINT:
  631. case GLS_GREEN_POINT:
  632. case GLS_BLUE_POINT:
  633. case GLS_WHITE_POINT:
  634. return 2;
  635. case GLS_BORDER_COLOR:
  636. case GLS_GAMMA:
  637. case GLS_PAGE_COLOR:
  638. return 4;
  639. }
  640. return 0;
  641. }
  642. GLint __gls_glsHeaderiv_inVec_size(GLenum inAttrib) {
  643. switch (inAttrib) {
  644. case GLS_CREATE_TIME:
  645. case GLS_MODIFY_TIME:
  646. return 6;
  647. }
  648. return 0;
  649. }
  650. #if __GL_EXT_convolution
  651. GLint __gls_glConvolutionFilter1DEXT_image_size(
  652. GLenum inFormat, GLenum inType, GLint inWidth
  653. ) {
  654. return __glsTextureSize(inFormat, inType, inWidth, 1);
  655. }
  656. GLint __gls_glConvolutionFilter2DEXT_image_size(
  657. GLenum inFormat, GLenum inType, GLint inWidth, GLint inHeight
  658. ) {
  659. return __glsTextureSize(inFormat, inType, inWidth, inHeight);
  660. }
  661. GLint __gls_glConvolutionParameterfvEXT_params_size(GLenum inPname) {
  662. switch (inPname) {
  663. case GL_CONVOLUTION_BORDER_MODE_EXT:
  664. return 1;
  665. case GL_CONVOLUTION_FILTER_SCALE_EXT:
  666. case GL_CONVOLUTION_FILTER_BIAS_EXT:
  667. return 4;
  668. }
  669. return 0;
  670. }
  671. GLint __gls_glConvolutionParameterivEXT_params_size(GLenum inPname) {
  672. return __gls_glConvolutionParameterfvEXT_params_size(inPname);
  673. }
  674. GLint __gls_glGetConvolutionFilterEXT_image_size(
  675. __GLScontext *ctx,
  676. GLenum inTarget, GLenum inFormat, GLenum inType
  677. ) {
  678. GLint width, height;
  679. switch (inTarget) {
  680. case GL_CONVOLUTION_1D_EXT:
  681. case GL_CONVOLUTION_2D_EXT:
  682. break;
  683. default:
  684. return 0;
  685. }
  686. width = height = 0;
  687. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetConvolutionParameterivEXT);
  688. glGetConvolutionParameterivEXT(
  689. inTarget, GL_CONVOLUTION_WIDTH_EXT, &width
  690. );
  691. glGetConvolutionParameterivEXT(
  692. inTarget, GL_CONVOLUTION_HEIGHT_EXT, &height
  693. );
  694. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetConvolutionParameterivEXT);
  695. return __glsTextureSize(inFormat, inType, width, height);
  696. }
  697. GLint __gls_glGetConvolutionParameterfvEXT_params_size(GLenum inPname) {
  698. switch (inPname) {
  699. default:
  700. return 16;
  701. }
  702. }
  703. GLint __gls_glGetConvolutionParameterivEXT_params_size(GLenum inPname) {
  704. return __gls_glGetConvolutionParameterfvEXT_params_size(inPname);
  705. }
  706. GLint __gls_glGetSeparableFilterEXT_row_size(
  707. __GLScontext *ctx,
  708. GLenum inTarget, GLenum inFormat, GLenum inType
  709. ) {
  710. GLint width = 0;
  711. if (inTarget != GL_SEPARABLE_2D_EXT) return 0;
  712. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetConvolutionParameterivEXT);
  713. glGetConvolutionParameterivEXT(inTarget, GL_CONVOLUTION_WIDTH_EXT, &width);
  714. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetConvolutionParameterivEXT);
  715. return __glsTextureSize(inFormat, inType, width, 1);
  716. }
  717. GLint __gls_glGetSeparableFilterEXT_column_size(
  718. __GLScontext *ctx,
  719. GLenum inTarget, GLenum inFormat, GLenum inType
  720. ) {
  721. GLint height = 0;
  722. if (inTarget != GL_SEPARABLE_2D_EXT) return 0;
  723. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetConvolutionParameterivEXT);
  724. glGetConvolutionParameterivEXT(
  725. inTarget, GL_CONVOLUTION_HEIGHT_EXT, &height
  726. );
  727. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetConvolutionParameterivEXT);
  728. return __glsTextureSize(inFormat, inType, 1, height);
  729. }
  730. GLint __gls_glGetSeparableFilterEXT_span_size(
  731. GLenum inTarget, GLenum inFormat, GLenum inType
  732. ) {
  733. return 0;
  734. }
  735. GLint __gls_glSeparableFilter2DEXT_row_size(
  736. GLenum inTarget, GLenum inFormat, GLenum inType, GLint inWidth
  737. ) {
  738. return __glsTextureSize(inFormat, inType, inWidth, 1);
  739. }
  740. GLint __gls_glSeparableFilter2DEXT_column_size(
  741. GLenum inTarget, GLenum inFormat, GLenum inType, GLint inHeight
  742. ) {
  743. return __glsTextureSize(inFormat, inType, 1, inHeight);
  744. }
  745. #endif /* __GL_EXT_convolution */
  746. #if __GL_EXT_histogram
  747. GLint __gls_glGetHistogramEXT_values_size(
  748. __GLScontext *ctx,
  749. GLenum inTarget, GLenum inFormat, GLenum inType
  750. ) {
  751. GLint width = 0;
  752. if (inTarget != GL_HISTOGRAM_EXT) return 0;
  753. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetHistogramParameterivEXT);
  754. glGetHistogramParameterivEXT(inTarget, GL_HISTOGRAM_WIDTH_EXT, &width);
  755. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetHistogramParameterivEXT);
  756. return __glsTextureSize(inFormat, inType, width, 1);
  757. }
  758. GLint __gls_glGetHistogramParameterfvEXT_params_size(GLenum inPname) {
  759. switch (inPname) {
  760. default:
  761. return 16;
  762. }
  763. }
  764. GLint __gls_glGetHistogramParameterivEXT_params_size(GLenum inPname) {
  765. return __gls_glGetHistogramParameterfvEXT_params_size(inPname);
  766. }
  767. GLint __gls_glGetMinmaxEXT_values_size(
  768. GLenum inTarget, GLenum inFormat, GLenum inType
  769. ) {
  770. return __glsTextureSize(inFormat, inType, 2, 1);
  771. }
  772. GLint __gls_glGetMinmaxParameterfvEXT_params_size(GLenum inPname) {
  773. switch (inPname) {
  774. default:
  775. return 16;
  776. }
  777. }
  778. GLint __gls_glGetMinmaxParameterivEXT_params_size(GLenum inPname) {
  779. return __gls_glGetMinmaxParameterfvEXT_params_size(inPname);
  780. }
  781. #endif /* __GL_EXT_histogram */
  782. GLint __gls_glTexSubImage1D_pixels_size(
  783. GLenum inFormat,
  784. GLenum inType,
  785. GLint inWidth
  786. ) {
  787. return __glsTextureSize(inFormat, inType, inWidth, 1);
  788. }
  789. GLint __gls_glTexSubImage2D_pixels_size(
  790. GLenum inFormat,
  791. GLenum inType,
  792. GLint inWidth,
  793. GLint inHeight
  794. ) {
  795. return __glsTextureSize(inFormat, inType, inWidth, inHeight);
  796. }
  797. #if __GL_EXT_subtexture
  798. GLint __gls_glTexSubImage1DEXT_pixels_size(
  799. GLenum inFormat,
  800. GLenum inType,
  801. GLint inWidth
  802. ) {
  803. return __glsTextureSize(inFormat, inType, inWidth, 1);
  804. }
  805. GLint __gls_glTexSubImage2DEXT_pixels_size(
  806. GLenum inFormat,
  807. GLenum inType,
  808. GLint inWidth,
  809. GLint inHeight
  810. ) {
  811. return __glsTextureSize(inFormat, inType, inWidth, inHeight);
  812. }
  813. GLint __gls_glTexSubImage3DEXT_pixels_size(
  814. GLenum inFormat,
  815. GLenum inType,
  816. GLint inWidth,
  817. GLint inHeight,
  818. GLint inDepth
  819. ) {
  820. if (inDepth < 0) return 0;
  821. return __glsTextureSize(inFormat, inType, inWidth, inHeight) * inDepth;
  822. }
  823. #endif /* __GL_EXT_subtexture */
  824. #if __GL_EXT_texture3D
  825. GLint __gls_glTexImage3DEXT_pixels_size(
  826. GLenum inFormat,
  827. GLenum inType,
  828. GLint inWidth,
  829. GLint inHeight,
  830. GLint inDepth
  831. ) {
  832. if (inDepth < 0) return 0;
  833. return __glsTextureSize(inFormat, inType, inWidth, inHeight) * inDepth;
  834. }
  835. #endif /* __GL_EXT_texture3D */
  836. #if __GL_EXT_vertex_array
  837. GLint __gls_glColorPointerEXT_pointer_size(
  838. GLint inSize, GLenum inType, GLint inStride, GLint inCount
  839. ) {
  840. if (inSize < 3 || inSize > 4) return 0;
  841. if (inStride < 0) return 0;
  842. if (inCount < 0) return 0;
  843. switch (inType) {
  844. case GL_BYTE:
  845. case GL_UNSIGNED_BYTE:
  846. return inSize * inCount;
  847. case GL_SHORT:
  848. case GL_UNSIGNED_SHORT:
  849. return 2 * inSize * inCount;
  850. case GL_FLOAT:
  851. case GL_INT:
  852. case GL_UNSIGNED_INT:
  853. return 4 * inSize * inCount;
  854. case GL_DOUBLE_EXT:
  855. return 8 * inSize * inCount;
  856. }
  857. return 0;
  858. }
  859. GLint __gls_glEdgeFlagPointerEXT_pointer_size(
  860. GLint inStride, GLint inCount
  861. ) {
  862. if (inStride < 0) return 0;
  863. if (inCount < 0) return 0;
  864. return inCount;
  865. }
  866. GLint __gls_glIndexPointerEXT_pointer_size(
  867. GLenum inType, GLint inStride, GLint inCount
  868. ) {
  869. if (inStride < 0) return 0;
  870. if (inCount < 0) return 0;
  871. switch (inType) {
  872. case GL_SHORT:
  873. return 2 * inCount;
  874. case GL_FLOAT:
  875. case GL_INT:
  876. return 4 * inCount;
  877. case GL_DOUBLE_EXT:
  878. return 8 * inCount;
  879. }
  880. return 0;
  881. }
  882. GLint __gls_glNormalPointerEXT_pointer_size(
  883. GLenum inType, GLint inStride, GLint inCount
  884. ) {
  885. if (inStride < 0) return 0;
  886. if (inCount < 0) return 0;
  887. switch (inType) {
  888. case GL_BYTE:
  889. return 3 * inCount;
  890. case GL_SHORT:
  891. return 2 * 3 * inCount;
  892. case GL_FLOAT:
  893. case GL_INT:
  894. return 4 * 3 * inCount;
  895. case GL_DOUBLE_EXT:
  896. return 8 * 3 * inCount;
  897. }
  898. return 0;
  899. }
  900. GLint __gls_glTexCoordPointerEXT_pointer_size(
  901. GLint inSize, GLenum inType, GLint inStride, GLint inCount
  902. ) {
  903. if (inSize < 1 || inSize > 4) return 0;
  904. if (inStride < 0) return 0;
  905. if (inCount < 0) return 0;
  906. switch (inType) {
  907. case GL_SHORT:
  908. return 2 * inSize * inCount;
  909. case GL_FLOAT:
  910. case GL_INT:
  911. return 4 * inSize * inCount;
  912. case GL_DOUBLE_EXT:
  913. return 8 * inSize * inCount;
  914. }
  915. return 0;
  916. }
  917. GLint __gls_glVertexPointerEXT_pointer_size(
  918. GLint inSize, GLenum inType, GLint inStride, GLint inCount
  919. ) {
  920. if (inSize < 2 || inSize > 4) return 0;
  921. if (inStride < 0) return 0;
  922. if (inCount < 0) return 0;
  923. switch (inType) {
  924. case GL_SHORT:
  925. return 2 * inSize * inCount;
  926. case GL_FLOAT:
  927. case GL_INT:
  928. return 4 * inSize * inCount;
  929. case GL_DOUBLE_EXT:
  930. return 8 * inSize * inCount;
  931. }
  932. return 0;
  933. }
  934. #endif /* __GL_EXT_vertex_array */
  935. #if __GL_SGI_color_table
  936. GLint __gls_glColorTableParameterfvSGI_params_size(GLenum inPname) {
  937. switch (inPname) {
  938. case GL_COLOR_TABLE_BIAS_SGI:
  939. case GL_COLOR_TABLE_SCALE_SGI:
  940. return 4;
  941. }
  942. return 0;
  943. }
  944. GLint __gls_glColorTableParameterivSGI_params_size(GLenum inPname) {
  945. return __gls_glColorTableParameterfvSGI_params_size(inPname);
  946. }
  947. #endif // __GL_SGI_color_table
  948. #if __GL_EXT_paletted_texture
  949. GLint __gls_glColorTableEXT_table_size(
  950. GLenum inFormat, GLenum inType, GLint inWidth
  951. ) {
  952. return __glsTextureSize(inFormat, inType, inWidth, 1);
  953. }
  954. void glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint *params);
  955. GLint __gls_glGetColorTableEXT_table_size(
  956. __GLScontext *ctx,
  957. GLenum inTarget, GLenum inFormat, GLenum inType
  958. ) {
  959. GLint width = 0;
  960. switch (inTarget) {
  961. #if __GL_SGI_color_table
  962. case GL_COLOR_TABLE_SGI:
  963. case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
  964. case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
  965. #endif
  966. #if __GL_SGI_texture_color_table
  967. case GL_TEXTURE_COLOR_TABLE_SGI:
  968. #endif /* __GL_SGI_texture_color_table */
  969. #if __GL_EXT_paletted_texture
  970. case GL_TEXTURE_1D:
  971. case GL_TEXTURE_2D:
  972. case GL_PROXY_TEXTURE_1D:
  973. case GL_PROXY_TEXTURE_2D:
  974. #endif
  975. break;
  976. default:
  977. return 0;
  978. }
  979. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetColorTableParameterivEXT);
  980. glGetColorTableParameterivEXT(inTarget, GL_COLOR_TABLE_WIDTH_EXT, &width);
  981. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetColorTableParameterivEXT);
  982. return __glsTextureSize(inFormat, inType, width, 1);
  983. }
  984. GLint __gls_glGetColorTableParameterfvEXT_params_size(GLenum inPname) {
  985. switch (inPname) {
  986. default:
  987. return 16;
  988. }
  989. }
  990. GLint __gls_glGetColorTableParameterivEXT_params_size(GLenum inPname) {
  991. return __gls_glGetColorTableParameterfvEXT_params_size(inPname);
  992. }
  993. #endif /* __GL_EXT_paletted_texture */
  994. #if __GL_SGI_texture_color_table
  995. GLint __gls_glTexColorTableParameterfvSGI_params_size(GLenum inPname) {
  996. switch (inPname) {
  997. case GL_TEXTURE_COLOR_TABLE_BIAS_SGI:
  998. case GL_TEXTURE_COLOR_TABLE_SCALE_SGI:
  999. return 4;
  1000. }
  1001. return 0;
  1002. }
  1003. GLint __gls_glTexColorTableParameterivSGI_params_size(GLenum inPname) {
  1004. return __gls_glTexColorTableParameterfvSGI_params_size(inPname);
  1005. }
  1006. GLint __gls_glGetTexColorTableParameterfvSGI_params_size(GLenum inPname) {
  1007. switch (inPname) {
  1008. default:
  1009. return 16;
  1010. }
  1011. }
  1012. GLint __gls_glGetTexColorTableParameterivSGI_params_size(GLenum inPname) {
  1013. return __gls_glGetColorTableParameterfvSGI_params_size(inPname);
  1014. }
  1015. #endif /* __GL_SGI_texture_color_table */
  1016. #if __GL_SGIS_detail_texture
  1017. GLint __gls_glGetDetailTexFuncSGIS_points_size(__GLScontext *ctx, GLenum inTarget) {
  1018. GLint points = 0;
  1019. switch (inTarget) {
  1020. case GL_TEXTURE_2D:
  1021. break;
  1022. default:
  1023. return 0;
  1024. }
  1025. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetTexParameteriv);
  1026. glGetTexParameteriv(inTarget, GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS, &points);
  1027. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetTexParameteriv);
  1028. return points * 2;
  1029. }
  1030. #endif /* __GL_SGIS_detail_texture */
  1031. #if __GL_SGIS_sharpen_texture
  1032. GLint __gls_glGetSharpenTexFuncSGIS_points_size(__GLScontext *ctx, GLenum inTarget) {
  1033. GLint points = 0;
  1034. switch (inTarget) {
  1035. case GL_TEXTURE_1D:
  1036. case GL_TEXTURE_2D:
  1037. #if __GL_EXT_texture3D
  1038. case GL_TEXTURE_3D_EXT:
  1039. #endif /* __GL_EXT_texture3D */
  1040. break;
  1041. default:
  1042. return 0;
  1043. }
  1044. __GLS_BEGIN_CAPTURE_EXEC(ctx, GLS_OP_glGetTexParameteriv);
  1045. glGetTexParameteriv(
  1046. inTarget, GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS, &points
  1047. );
  1048. __GLS_END_CAPTURE_EXEC(ctx, GLS_OP_glGetTexParameteriv);
  1049. return points * 2;
  1050. }
  1051. #endif /* __GL_SGIS_sharpen_texture */
  1052. #if __GL_SGIS_texture4D
  1053. GLint __gls_glTexImage4DSGIS_pixels_size(
  1054. GLenum inFormat,
  1055. GLenum inType,
  1056. GLint inWidth,
  1057. GLint inHeight,
  1058. GLint inDepth,
  1059. GLint inSize4d
  1060. ) {
  1061. if (inDepth < 0 || inSize4d < 0) return 0;
  1062. return (
  1063. __glsTextureSize(inFormat, inType, inWidth, inHeight) *
  1064. inDepth *
  1065. inSize4d
  1066. );
  1067. }
  1068. GLint __gls_glTexSubImage4DSGIS_pixels_size(
  1069. GLenum inFormat,
  1070. GLenum inType,
  1071. GLint inWidth,
  1072. GLint inHeight,
  1073. GLint inDepth,
  1074. GLint inSize4d
  1075. ) {
  1076. if (inDepth < 0 || inSize4d < 0) return 0;
  1077. return (
  1078. __glsTextureSize(inFormat, inType, inWidth, inHeight) *
  1079. inDepth *
  1080. inSize4d
  1081. );
  1082. }
  1083. #endif /* __GL_SGIS_texture4D */