Source code of Windows XP (NT5)
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.

2254 lines
60 KiB

  1. /*
  2. ** Copyright 1991, 1992, 1993, 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 "precomp.h"
  18. #pragma hdrstop
  19. #include <devlock.h>
  20. #define __GL_FLOAT 0 /* __GLfloat */
  21. #define __GL_FLOAT32 1 /* api 32 bit float */
  22. #define __GL_FLOAT64 2 /* api 64 bit float */
  23. #define __GL_INT32 3 /* api 32 bit int */
  24. #define __GL_BOOLEAN 4 /* api 8 bit boolean */
  25. #define __GL_COLOR 5 /* unscaled color in __GLfloat */
  26. #define __GL_SCOLOR 6 /* scaled color in __GLfloat */
  27. void __glConvertResult(__GLcontext *gc, GLint fromType, const void *rawdata,
  28. GLint toType, void *result, GLint size);
  29. void APIPRIVATE __glim_GetTexEnvfv(GLenum target,
  30. GLenum pname, GLfloat v[])
  31. {
  32. __GL_SETUP_NOT_IN_BEGIN();
  33. if (target != GL_TEXTURE_ENV) {
  34. __glSetError(GL_INVALID_ENUM);
  35. return;
  36. }
  37. switch (pname) {
  38. case GL_TEXTURE_ENV_MODE:
  39. v[0] = gc->state.texture.env[0].mode;
  40. break;
  41. case GL_TEXTURE_ENV_COLOR:
  42. __glUnScaleColorf(gc, v, &gc->state.texture.env[0].color);
  43. break;
  44. default:
  45. __glSetError(GL_INVALID_ENUM);
  46. return;
  47. }
  48. }
  49. void APIPRIVATE __glim_GetTexEnviv(GLenum target,
  50. GLenum pname, GLint v[])
  51. {
  52. __GL_SETUP_NOT_IN_BEGIN();
  53. if (target != GL_TEXTURE_ENV) {
  54. __glSetError(GL_INVALID_ENUM);
  55. return;
  56. }
  57. switch (pname) {
  58. case GL_TEXTURE_ENV_MODE:
  59. v[0] = gc->state.texture.env[0].mode;
  60. break;
  61. case GL_TEXTURE_ENV_COLOR:
  62. __glUnScaleColori(gc, v, &gc->state.texture.env[0].color);
  63. break;
  64. default:
  65. __glSetError(GL_INVALID_ENUM);
  66. return;
  67. }
  68. }
  69. /************************************************************************/
  70. void APIPRIVATE __glim_GetTexGenfv(GLenum coord, GLenum pname,
  71. GLfloat v[])
  72. {
  73. __GLtextureCoordState* tcs;
  74. __GL_SETUP_NOT_IN_BEGIN();
  75. switch (coord) {
  76. case GL_S:
  77. tcs = &gc->state.texture.s;
  78. break;
  79. case GL_T:
  80. tcs = &gc->state.texture.t;
  81. break;
  82. case GL_R:
  83. tcs = &gc->state.texture.r;
  84. break;
  85. case GL_Q:
  86. tcs = &gc->state.texture.q;
  87. break;
  88. default:
  89. __glSetError(GL_INVALID_ENUM);
  90. return;
  91. }
  92. switch (pname) {
  93. case GL_TEXTURE_GEN_MODE:
  94. v[0] = tcs->mode;
  95. break;
  96. case GL_OBJECT_PLANE:
  97. v[0] = tcs->objectPlaneEquation.x;
  98. v[1] = tcs->objectPlaneEquation.y;
  99. v[2] = tcs->objectPlaneEquation.z;
  100. v[3] = tcs->objectPlaneEquation.w;
  101. break;
  102. case GL_EYE_PLANE:
  103. v[0] = tcs->eyePlaneEquation.x;
  104. v[1] = tcs->eyePlaneEquation.y;
  105. v[2] = tcs->eyePlaneEquation.z;
  106. v[3] = tcs->eyePlaneEquation.w;
  107. break;
  108. default:
  109. __glSetError(GL_INVALID_ENUM);
  110. return;
  111. }
  112. }
  113. void APIPRIVATE __glim_GetTexGendv(GLenum coord, GLenum pname,
  114. GLdouble v[])
  115. {
  116. __GLtextureCoordState* tcs;
  117. __GL_SETUP_NOT_IN_BEGIN();
  118. switch (coord) {
  119. case GL_S:
  120. tcs = &gc->state.texture.s;
  121. break;
  122. case GL_T:
  123. tcs = &gc->state.texture.t;
  124. break;
  125. case GL_R:
  126. tcs = &gc->state.texture.r;
  127. break;
  128. case GL_Q:
  129. tcs = &gc->state.texture.q;
  130. break;
  131. default:
  132. __glSetError(GL_INVALID_ENUM);
  133. return;
  134. }
  135. switch (pname) {
  136. case GL_TEXTURE_GEN_MODE:
  137. v[0] = tcs->mode;
  138. break;
  139. case GL_OBJECT_PLANE:
  140. v[0] = tcs->objectPlaneEquation.x;
  141. v[1] = tcs->objectPlaneEquation.y;
  142. v[2] = tcs->objectPlaneEquation.z;
  143. v[3] = tcs->objectPlaneEquation.w;
  144. break;
  145. case GL_EYE_PLANE:
  146. v[0] = tcs->eyePlaneEquation.x;
  147. v[1] = tcs->eyePlaneEquation.y;
  148. v[2] = tcs->eyePlaneEquation.z;
  149. v[3] = tcs->eyePlaneEquation.w;
  150. break;
  151. default:
  152. __glSetError(GL_INVALID_ENUM);
  153. return;
  154. }
  155. }
  156. void APIPRIVATE __glim_GetTexGeniv(GLenum coord, GLenum pname,
  157. GLint v[])
  158. {
  159. __GLtextureCoordState* tcs;
  160. __GL_SETUP_NOT_IN_BEGIN();
  161. switch (coord) {
  162. case GL_S:
  163. tcs = &gc->state.texture.s;
  164. break;
  165. case GL_T:
  166. tcs = &gc->state.texture.t;
  167. break;
  168. case GL_R:
  169. tcs = &gc->state.texture.r;
  170. break;
  171. case GL_Q:
  172. tcs = &gc->state.texture.q;
  173. break;
  174. default:
  175. __glSetError(GL_INVALID_ENUM);
  176. return;
  177. }
  178. switch (pname) {
  179. case GL_TEXTURE_GEN_MODE:
  180. v[0] = tcs->mode;
  181. break;
  182. case GL_OBJECT_PLANE:
  183. __glConvertResult(gc, __GL_FLOAT, &tcs->objectPlaneEquation.x,
  184. __GL_INT32, v, 4);
  185. break;
  186. case GL_EYE_PLANE:
  187. __glConvertResult(gc, __GL_FLOAT, &tcs->eyePlaneEquation.x,
  188. __GL_INT32, v, 4);
  189. break;
  190. default:
  191. __glSetError(GL_INVALID_ENUM);
  192. return;
  193. }
  194. }
  195. /************************************************************************/
  196. void APIPRIVATE __glim_GetTexParameterfv(GLenum target,
  197. GLenum pname, GLfloat v[])
  198. {
  199. __GLtextureParamState *pts;
  200. __GL_SETUP_NOT_IN_BEGIN();
  201. pts = __glLookUpTextureParams(gc, target);
  202. if (!pts) {
  203. __glSetError(GL_INVALID_ENUM);
  204. return;
  205. }
  206. switch (pname) {
  207. case GL_TEXTURE_WRAP_S:
  208. v[0] = pts->sWrapMode;
  209. break;
  210. case GL_TEXTURE_WRAP_T:
  211. v[0] = pts->tWrapMode;
  212. break;
  213. case GL_TEXTURE_MIN_FILTER:
  214. v[0] = pts->minFilter;
  215. break;
  216. case GL_TEXTURE_MAG_FILTER:
  217. v[0] = pts->magFilter;
  218. break;
  219. case GL_TEXTURE_BORDER_COLOR:
  220. v[0] = pts->borderColor.r;
  221. v[1] = pts->borderColor.g;
  222. v[2] = pts->borderColor.b;
  223. v[3] = pts->borderColor.a;
  224. break;
  225. case GL_TEXTURE_PRIORITY:
  226. {
  227. __GLtextureObjectState *ptos;
  228. ptos = __glLookUpTextureTexobjs(gc, target);
  229. v[0] = ptos->priority;
  230. }
  231. break;
  232. case GL_TEXTURE_RESIDENT:
  233. {
  234. __GLtextureObject *pto;
  235. pto = __glLookUpTextureObject(gc, target);
  236. v[0] = (GLfloat)(pto->resident);
  237. }
  238. break;
  239. default:
  240. __glSetError(GL_INVALID_ENUM);
  241. return;
  242. }
  243. }
  244. void APIPRIVATE __glim_GetTexParameteriv(GLenum target,
  245. GLenum pname, GLint v[])
  246. {
  247. __GLtextureParamState *pts;
  248. __GL_SETUP_NOT_IN_BEGIN();
  249. pts = __glLookUpTextureParams(gc, target);
  250. if (!pts) {
  251. __glSetError(GL_INVALID_ENUM);
  252. return;
  253. }
  254. switch (pname) {
  255. case GL_TEXTURE_WRAP_S:
  256. v[0] = pts->sWrapMode;
  257. break;
  258. case GL_TEXTURE_WRAP_T:
  259. v[0] = pts->tWrapMode;
  260. break;
  261. case GL_TEXTURE_MIN_FILTER:
  262. v[0] = pts->minFilter;
  263. break;
  264. case GL_TEXTURE_MAG_FILTER:
  265. v[0] = pts->magFilter;
  266. break;
  267. case GL_TEXTURE_BORDER_COLOR:
  268. v[0] = __GL_FLOAT_TO_I(pts->borderColor.r);
  269. v[1] = __GL_FLOAT_TO_I(pts->borderColor.g);
  270. v[2] = __GL_FLOAT_TO_I(pts->borderColor.b);
  271. v[3] = __GL_FLOAT_TO_I(pts->borderColor.a);
  272. break;
  273. case GL_TEXTURE_PRIORITY:
  274. {
  275. __GLtextureObjectState *ptos;
  276. ptos = __glLookUpTextureTexobjs(gc, target);
  277. v[0] = __GL_FLOAT_TO_I(ptos->priority);
  278. }
  279. break;
  280. case GL_TEXTURE_RESIDENT:
  281. {
  282. __GLtextureObject *pto;
  283. pto = __glLookUpTextureObject(gc, target);
  284. v[0] = (GLint)(pto->resident);
  285. }
  286. break;
  287. default:
  288. __glSetError(GL_INVALID_ENUM);
  289. return;
  290. }
  291. }
  292. /************************************************************************/
  293. void APIPRIVATE __glim_GetTexLevelParameterfv(GLenum target, GLint level,
  294. GLenum pname, GLfloat v[])
  295. {
  296. __GLtexture *tex;
  297. __GLmipMapLevel *lp;
  298. __GL_SETUP_NOT_IN_BEGIN();
  299. tex = __glLookUpTexture(gc, target);
  300. if (!tex) {
  301. bad_enum:
  302. __glSetError(GL_INVALID_ENUM);
  303. return;
  304. }
  305. if ((level < 0) || (level >= gc->constants.maxMipMapLevel)) {
  306. __glSetError(GL_INVALID_VALUE);
  307. return;
  308. }
  309. lp = &tex->level[level];
  310. switch (pname) {
  311. case GL_TEXTURE_WIDTH:
  312. v[0] = lp->width;
  313. break;
  314. case GL_TEXTURE_HEIGHT:
  315. if (tex->dim == 1) {
  316. v[0] = lp->height - lp->border*2;
  317. } else {
  318. v[0] = lp->height;
  319. }
  320. break;
  321. case GL_TEXTURE_COMPONENTS:
  322. v[0] = lp->requestedFormat;
  323. break;
  324. case GL_TEXTURE_BORDER:
  325. v[0] = lp->border;
  326. break;
  327. case GL_TEXTURE_RED_SIZE:
  328. v[0] = lp->redSize;
  329. break;
  330. case GL_TEXTURE_GREEN_SIZE:
  331. v[0] = lp->greenSize;
  332. break;
  333. case GL_TEXTURE_BLUE_SIZE:
  334. v[0] = lp->blueSize;
  335. break;
  336. case GL_TEXTURE_ALPHA_SIZE:
  337. v[0] = lp->alphaSize;
  338. break;
  339. case GL_TEXTURE_LUMINANCE_SIZE:
  340. v[0] = lp->luminanceSize;
  341. break;
  342. case GL_TEXTURE_INTENSITY_SIZE:
  343. v[0] = lp->intensitySize;
  344. break;
  345. default:
  346. goto bad_enum;
  347. }
  348. }
  349. void APIPRIVATE __glim_GetTexLevelParameteriv(GLenum target, GLint level,
  350. GLenum pname, GLint v[])
  351. {
  352. __GLtexture *tex;
  353. __GLmipMapLevel *lp;
  354. __GL_SETUP_NOT_IN_BEGIN();
  355. tex = __glLookUpTexture(gc, target);
  356. if (!tex) {
  357. bad_enum:
  358. __glSetError(GL_INVALID_ENUM);
  359. return;
  360. }
  361. if ((level < 0) || (level >= gc->constants.maxMipMapLevel)) {
  362. __glSetError(GL_INVALID_VALUE);
  363. return;
  364. }
  365. lp = &tex->level[level];
  366. switch (pname) {
  367. case GL_TEXTURE_WIDTH:
  368. v[0] = lp->width;
  369. break;
  370. case GL_TEXTURE_HEIGHT:
  371. if (tex->dim == 1) {
  372. v[0] = lp->height - lp->border*2;
  373. } else {
  374. v[0] = lp->height;
  375. }
  376. break;
  377. case GL_TEXTURE_COMPONENTS:
  378. v[0] = lp->requestedFormat;
  379. break;
  380. case GL_TEXTURE_BORDER:
  381. v[0] = lp->border;
  382. break;
  383. case GL_TEXTURE_RED_SIZE:
  384. v[0] = lp->redSize;
  385. break;
  386. case GL_TEXTURE_GREEN_SIZE:
  387. v[0] = lp->greenSize;
  388. break;
  389. case GL_TEXTURE_BLUE_SIZE:
  390. v[0] = lp->blueSize;
  391. break;
  392. case GL_TEXTURE_ALPHA_SIZE:
  393. v[0] = lp->alphaSize;
  394. break;
  395. case GL_TEXTURE_LUMINANCE_SIZE:
  396. v[0] = lp->luminanceSize;
  397. break;
  398. case GL_TEXTURE_INTENSITY_SIZE:
  399. v[0] = lp->intensitySize;
  400. break;
  401. default:
  402. goto bad_enum;
  403. }
  404. }
  405. /************************************************************************/
  406. void APIPRIVATE __glim_GetClipPlane(GLenum plane, GLdouble eqn[4])
  407. {
  408. GLint index;
  409. __GL_SETUP_NOT_IN_BEGIN();
  410. index = plane - GL_CLIP_PLANE0;
  411. if ((index < 0) || (index >= gc->constants.numberOfClipPlanes)) {
  412. __glSetError(GL_INVALID_ENUM);
  413. return;
  414. }
  415. eqn[0] = gc->state.transform.eyeClipPlanes[index].x;
  416. eqn[1] = gc->state.transform.eyeClipPlanes[index].y;
  417. eqn[2] = gc->state.transform.eyeClipPlanes[index].z;
  418. eqn[3] = gc->state.transform.eyeClipPlanes[index].w;
  419. }
  420. /************************************************************************/
  421. void FASTCALL __glInitImagePack(__GLcontext *gc, __GLpixelSpanInfo *spanInfo,
  422. GLint width, GLint height, GLenum format, GLenum type,
  423. const GLvoid *buf)
  424. {
  425. spanInfo->x = __glZero;
  426. spanInfo->zoomx = __glOne;
  427. spanInfo->realWidth = spanInfo->width = width;
  428. spanInfo->height = height;
  429. spanInfo->srcSkipPixels = 0;
  430. spanInfo->srcSkipLines = 0;
  431. spanInfo->srcSwapBytes = GL_FALSE;
  432. #ifdef __GL_STIPPLE_MSB
  433. spanInfo->srcLsbFirst = GL_FALSE;
  434. #else
  435. spanInfo->srcLsbFirst = GL_TRUE;
  436. #endif
  437. spanInfo->srcLineLength = width;
  438. spanInfo->dstFormat = format;
  439. spanInfo->dstType = type;
  440. spanInfo->dstImage = buf;
  441. __glLoadPackModes(gc, spanInfo);
  442. }
  443. void APIPRIVATE __glim_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type,
  444. GLvoid *texels)
  445. {
  446. GLint width, height;
  447. GLint internalFormat;
  448. __GLtexture *tex;
  449. __GLmipMapLevel *lp;
  450. __GLpixelSpanInfo spanInfo;
  451. __GL_SETUP_NOT_IN_BEGIN();
  452. tex = __glLookUpTexture(gc, target);
  453. if (!tex || (target == GL_PROXY_TEXTURE_1D) ||
  454. (target == GL_PROXY_TEXTURE_2D))
  455. {
  456. bad_enum:
  457. __glSetError(GL_INVALID_ENUM);
  458. return;
  459. }
  460. if ((level < 0) || (level >= gc->constants.maxMipMapLevel)) {
  461. __glSetError(GL_INVALID_VALUE);
  462. return;
  463. }
  464. switch (format) {
  465. case GL_RGBA:
  466. case GL_RGB:
  467. case GL_RED:
  468. case GL_GREEN:
  469. case GL_BLUE:
  470. case GL_ALPHA:
  471. case GL_LUMINANCE:
  472. case GL_LUMINANCE_ALPHA:
  473. #ifdef GL_EXT_bgra
  474. case GL_BGRA_EXT:
  475. case GL_BGR_EXT:
  476. #endif
  477. #ifdef GL_EXT_paletted_texture
  478. case GL_COLOR_INDEX:
  479. #endif
  480. break;
  481. default:
  482. goto bad_enum;
  483. }
  484. switch (type) {
  485. case GL_BYTE:
  486. case GL_UNSIGNED_BYTE:
  487. case GL_SHORT:
  488. case GL_UNSIGNED_SHORT:
  489. case GL_INT:
  490. case GL_UNSIGNED_INT:
  491. case GL_FLOAT:
  492. break;
  493. default:
  494. goto bad_enum;
  495. }
  496. lp = &tex->level[level];
  497. internalFormat = lp->internalFormat;
  498. #ifdef NT
  499. if (internalFormat == GL_NONE)
  500. {
  501. // No texture defined so don't return any data
  502. // Note: This cannot be an error case because
  503. // covgl calls GetTexImage without an image
  504. // and expects success
  505. return;
  506. }
  507. #endif
  508. #ifdef GL_EXT_paletted_texture
  509. // If the request is for color index data then the source
  510. // must be color indices
  511. if (format == GL_COLOR_INDEX &&
  512. internalFormat != GL_COLOR_INDEX8_EXT &&
  513. internalFormat != GL_COLOR_INDEX16_EXT)
  514. {
  515. __glSetError(GL_INVALID_OPERATION);
  516. return;
  517. }
  518. #endif
  519. width = lp->width;
  520. if (tex->dim == 1) {
  521. height = lp->height - lp->border*2;
  522. } else {
  523. height = lp->height;
  524. }
  525. spanInfo.srcImage = lp->buffer;
  526. switch (internalFormat) {
  527. case GL_LUMINANCE:
  528. spanInfo.srcFormat = GL_RED;
  529. spanInfo.srcType = GL_FLOAT;
  530. spanInfo.srcAlignment = 4;
  531. break;
  532. case GL_LUMINANCE_ALPHA:
  533. spanInfo.srcFormat = __GL_RED_ALPHA;
  534. spanInfo.srcType = GL_FLOAT;
  535. spanInfo.srcAlignment = 4;
  536. break;
  537. case GL_RGB:
  538. spanInfo.srcFormat = GL_RGB;
  539. spanInfo.srcType = GL_FLOAT;
  540. spanInfo.srcAlignment = 4;
  541. break;
  542. case GL_RGBA:
  543. spanInfo.srcFormat = GL_RGBA;
  544. spanInfo.srcType = GL_FLOAT;
  545. spanInfo.srcAlignment = 4;
  546. break;
  547. case GL_ALPHA:
  548. spanInfo.srcFormat = GL_ALPHA;
  549. spanInfo.srcType = GL_FLOAT;
  550. spanInfo.srcAlignment = 4;
  551. break;
  552. case GL_INTENSITY:
  553. spanInfo.srcFormat = GL_RED;
  554. spanInfo.srcType = GL_FLOAT;
  555. spanInfo.srcAlignment = 4;
  556. break;
  557. #ifdef GL_EXT_bgra
  558. case GL_BGR_EXT:
  559. // Be a little tricky here because the internal format
  560. // is padded to 32 bits
  561. spanInfo.srcFormat = GL_BGRA_EXT;
  562. spanInfo.srcType = GL_UNSIGNED_BYTE;
  563. spanInfo.srcAlignment = 4;
  564. break;
  565. case GL_BGRA_EXT:
  566. spanInfo.srcFormat = GL_BGRA_EXT;
  567. spanInfo.srcType = GL_UNSIGNED_BYTE;
  568. spanInfo.srcAlignment = 4;
  569. break;
  570. #endif
  571. #ifdef GL_EXT_paletted_texture
  572. case GL_COLOR_INDEX8_EXT:
  573. case GL_COLOR_INDEX16_EXT:
  574. // We're copying out an indexed texture
  575. // If the destination format is color index then we want the
  576. // indices to go through the normal color index processing
  577. // If the desination isn't color index then we do not want
  578. // the normal color index processing to occur because the
  579. // I_TO_? maps will be used. Instead we want the texture's
  580. // palette to be used, so use a different format to force
  581. // the new code path
  582. if (format == GL_COLOR_INDEX)
  583. {
  584. spanInfo.srcFormat = GL_COLOR_INDEX;
  585. }
  586. else
  587. {
  588. spanInfo.srcFormat = __GL_PALETTE_INDEX;
  589. }
  590. if (internalFormat == GL_COLOR_INDEX8_EXT)
  591. {
  592. // We can't just use tex->paletteSize because
  593. // this value is used to scale float items of srcType
  594. // to srcType's range, not to the palette range
  595. spanInfo.srcPaletteSize = 255;
  596. spanInfo.srcType = GL_UNSIGNED_BYTE;
  597. }
  598. else
  599. {
  600. ASSERTOPENGL(internalFormat == GL_COLOR_INDEX16_EXT,
  601. "Unexpected internalFormat\n");
  602. spanInfo.srcPaletteSize = 65535;
  603. spanInfo.srcType = GL_UNSIGNED_SHORT;
  604. }
  605. spanInfo.srcAlignment = 1;
  606. spanInfo.srcPalette = tex->paletteData;
  607. break;
  608. #endif
  609. #ifdef NT
  610. default:
  611. ASSERTOPENGL(FALSE, "Unhandled internalFormat in GetTexImage\n");
  612. break;
  613. #endif
  614. }
  615. // If we don't currently have the texture lock, take it.
  616. if (!glsrvLazyGrabSurfaces((__GLGENcontext *)gc, TEXTURE_LOCK_FLAGS))
  617. {
  618. return;
  619. }
  620. __glInitImagePack(gc, &spanInfo, width, height, format, type, texels);
  621. if (tex->dim == 1) {
  622. spanInfo.srcSkipLines += lp->border;
  623. }
  624. __glInitPacker(gc, &spanInfo);
  625. __glInitUnpacker(gc, &spanInfo);
  626. (*gc->procs.copyImage)(gc, &spanInfo, GL_TRUE);
  627. }
  628. /************************************************************************/
  629. void APIPRIVATE __glim_GetPolygonStipple(GLubyte *outImage)
  630. {
  631. __GLpixelSpanInfo spanInfo;
  632. __GL_SETUP_NOT_IN_BEGIN();
  633. spanInfo.srcImage = &(gc->state.polygonStipple.stipple[0]);
  634. spanInfo.srcType = GL_BITMAP;
  635. spanInfo.srcFormat = GL_COLOR_INDEX;
  636. spanInfo.srcAlignment = 4;
  637. __glInitImagePack(gc, &spanInfo, 32, 32, GL_COLOR_INDEX, GL_BITMAP,
  638. outImage);
  639. __glInitPacker(gc, &spanInfo);
  640. __glInitUnpacker(gc, &spanInfo);
  641. (*gc->procs.copyImage)(gc, &spanInfo, GL_TRUE);
  642. }
  643. /************************************************************************/
  644. void APIPRIVATE __glim_GetLightfv(GLenum light, GLenum pname,
  645. GLfloat result[])
  646. {
  647. GLint index;
  648. __GLlightSourceState *src;
  649. __GL_SETUP_NOT_IN_BEGIN();
  650. index = light - GL_LIGHT0;
  651. if ((index < 0) || (index >= gc->constants.numberOfLights)) {
  652. __glSetError(GL_INVALID_ENUM);
  653. return;
  654. }
  655. src = &gc->state.light.source[index];
  656. switch (pname) {
  657. case GL_AMBIENT:
  658. __glUnScaleColorf(gc, result, &src->ambient);
  659. break;
  660. case GL_DIFFUSE:
  661. __glUnScaleColorf(gc, result, &src->diffuse);
  662. break;
  663. case GL_SPECULAR:
  664. __glUnScaleColorf(gc, result, &src->specular);
  665. break;
  666. case GL_POSITION:
  667. result[0] = src->positionEye.x;
  668. result[1] = src->positionEye.y;
  669. result[2] = src->positionEye.z;
  670. result[3] = src->positionEye.w;
  671. break;
  672. case GL_SPOT_DIRECTION:
  673. result[0] = src->directionEye.x;
  674. result[1] = src->directionEye.y;
  675. result[2] = src->directionEye.z;
  676. break;
  677. case GL_SPOT_EXPONENT:
  678. result[0] = src->spotLightExponent;
  679. break;
  680. case GL_SPOT_CUTOFF:
  681. result[0] = src->spotLightCutOffAngle;
  682. break;
  683. case GL_CONSTANT_ATTENUATION:
  684. result[0] = src->constantAttenuation;
  685. break;
  686. case GL_LINEAR_ATTENUATION:
  687. result[0] = src->linearAttenuation;
  688. break;
  689. case GL_QUADRATIC_ATTENUATION:
  690. result[0] = src->quadraticAttenuation;
  691. break;
  692. default:
  693. __glSetError(GL_INVALID_ENUM);
  694. return;
  695. }
  696. }
  697. void APIPRIVATE __glim_GetLightiv(GLenum light, GLenum pname,
  698. GLint result[])
  699. {
  700. GLint index;
  701. __GLlightSourceState *src;
  702. __GL_SETUP_NOT_IN_BEGIN();
  703. index = light - GL_LIGHT0;
  704. if ((index < 0) || (index >= gc->constants.numberOfLights)) {
  705. __glSetError(GL_INVALID_ENUM);
  706. return;
  707. }
  708. src = &gc->state.light.source[index];
  709. switch (pname) {
  710. case GL_AMBIENT:
  711. __glUnScaleColori(gc, result, &src->ambient);
  712. break;
  713. case GL_DIFFUSE:
  714. __glUnScaleColori(gc, result, &src->diffuse);
  715. break;
  716. case GL_SPECULAR:
  717. __glUnScaleColori(gc, result, &src->specular);
  718. break;
  719. case GL_POSITION:
  720. __glConvertResult(gc, __GL_FLOAT, &src->positionEye.x,
  721. __GL_INT32, result, 4);
  722. break;
  723. case GL_SPOT_DIRECTION:
  724. __glConvertResult(gc, __GL_FLOAT, &src->directionEye.x,
  725. __GL_INT32, result, 3);
  726. break;
  727. case GL_SPOT_EXPONENT:
  728. __glConvertResult(gc, __GL_FLOAT, &src->spotLightExponent,
  729. __GL_INT32, result, 1);
  730. break;
  731. case GL_SPOT_CUTOFF:
  732. __glConvertResult(gc, __GL_FLOAT, &src->spotLightCutOffAngle,
  733. __GL_INT32, result, 1);
  734. break;
  735. case GL_CONSTANT_ATTENUATION:
  736. __glConvertResult(gc, __GL_FLOAT, &src->constantAttenuation,
  737. __GL_INT32, result, 1);
  738. break;
  739. case GL_LINEAR_ATTENUATION:
  740. __glConvertResult(gc, __GL_FLOAT, &src->linearAttenuation,
  741. __GL_INT32, result, 1);
  742. break;
  743. case GL_QUADRATIC_ATTENUATION:
  744. __glConvertResult(gc, __GL_FLOAT, &src->quadraticAttenuation,
  745. __GL_INT32, result, 1);
  746. break;
  747. default:
  748. __glSetError(GL_INVALID_ENUM);
  749. return;
  750. }
  751. }
  752. /************************************************************************/
  753. void APIPRIVATE __glim_GetMaterialfv(GLenum face, GLenum pname,
  754. GLfloat result[])
  755. {
  756. __GLmaterialState *mat;
  757. __GL_SETUP_NOT_IN_BEGIN();
  758. switch (face) {
  759. case GL_FRONT:
  760. mat = &gc->state.light.front;
  761. break;
  762. case GL_BACK:
  763. mat = &gc->state.light.back;
  764. break;
  765. default:
  766. __glSetError(GL_INVALID_ENUM);
  767. return;
  768. }
  769. switch (pname) {
  770. case GL_COLOR_INDEXES:
  771. result[0] = mat->cmapa;
  772. result[1] = mat->cmapd;
  773. result[2] = mat->cmaps;
  774. break;
  775. case GL_SHININESS:
  776. result[0] = mat->specularExponent;
  777. break;
  778. case GL_EMISSION:
  779. __glUnScaleColorf(gc, result, &mat->emissive);
  780. break;
  781. case GL_AMBIENT:
  782. result[0] = mat->ambient.r;
  783. result[1] = mat->ambient.g;
  784. result[2] = mat->ambient.b;
  785. result[3] = mat->ambient.a;
  786. break;
  787. case GL_DIFFUSE:
  788. result[0] = mat->diffuse.r;
  789. result[1] = mat->diffuse.g;
  790. result[2] = mat->diffuse.b;
  791. result[3] = mat->diffuse.a;
  792. break;
  793. case GL_SPECULAR:
  794. result[0] = mat->specular.r;
  795. result[1] = mat->specular.g;
  796. result[2] = mat->specular.b;
  797. result[3] = mat->specular.a;
  798. break;
  799. default:
  800. __glSetError(GL_INVALID_ENUM);
  801. return;
  802. }
  803. }
  804. void APIPRIVATE __glim_GetMaterialiv(GLenum face, GLenum pname,
  805. GLint result[])
  806. {
  807. __GLmaterialState *mat;
  808. __GL_SETUP_NOT_IN_BEGIN();
  809. switch (face) {
  810. case GL_FRONT:
  811. mat = &gc->state.light.front;
  812. break;
  813. case GL_BACK:
  814. mat = &gc->state.light.back;
  815. break;
  816. default:
  817. __glSetError(GL_INVALID_ENUM);
  818. return;
  819. }
  820. switch (pname) {
  821. case GL_COLOR_INDEXES:
  822. __glConvertResult(gc, __GL_FLOAT, &mat->cmapa,
  823. __GL_INT32, result, 3);
  824. break;
  825. case GL_SHININESS:
  826. __glConvertResult(gc, __GL_FLOAT, &mat->specularExponent,
  827. __GL_INT32, result, 1);
  828. break;
  829. case GL_EMISSION:
  830. __glUnScaleColori(gc, result, &mat->emissive);
  831. break;
  832. case GL_AMBIENT:
  833. result[0] = __GL_FLOAT_TO_I(mat->ambient.r);
  834. result[1] = __GL_FLOAT_TO_I(mat->ambient.g);
  835. result[2] = __GL_FLOAT_TO_I(mat->ambient.b);
  836. result[3] = __GL_FLOAT_TO_I(mat->ambient.a);
  837. break;
  838. case GL_DIFFUSE:
  839. result[0] = __GL_FLOAT_TO_I(mat->diffuse.r);
  840. result[1] = __GL_FLOAT_TO_I(mat->diffuse.g);
  841. result[2] = __GL_FLOAT_TO_I(mat->diffuse.b);
  842. result[3] = __GL_FLOAT_TO_I(mat->diffuse.a);
  843. break;
  844. case GL_SPECULAR:
  845. result[0] = __GL_FLOAT_TO_I(mat->specular.r);
  846. result[1] = __GL_FLOAT_TO_I(mat->specular.g);
  847. result[2] = __GL_FLOAT_TO_I(mat->specular.b);
  848. result[3] = __GL_FLOAT_TO_I(mat->specular.a);
  849. break;
  850. default:
  851. __glSetError(GL_INVALID_ENUM);
  852. return;
  853. }
  854. }
  855. /************************************************************************/
  856. void APIPRIVATE __glim_GetMapfv(GLenum target, GLenum query, GLfloat buf[])
  857. {
  858. __GLevaluator1 *eval1;
  859. __GLevaluator2 *eval2;
  860. __GLfloat *eval1Data, *eval2Data;
  861. GLfloat *rp;
  862. GLint index, i, t;
  863. __GL_SETUP_NOT_IN_BEGIN();
  864. /*
  865. ** Check if target is valid.
  866. */
  867. rp = buf;
  868. switch (target) {
  869. case GL_MAP1_COLOR_4:
  870. case GL_MAP1_INDEX:
  871. case GL_MAP1_NORMAL:
  872. case GL_MAP1_TEXTURE_COORD_1:
  873. case GL_MAP1_TEXTURE_COORD_2:
  874. case GL_MAP1_TEXTURE_COORD_3:
  875. case GL_MAP1_TEXTURE_COORD_4:
  876. case GL_MAP1_VERTEX_3:
  877. case GL_MAP1_VERTEX_4:
  878. index = __GL_EVAL1D_INDEX(target);
  879. eval1 = &gc->eval.eval1[index];
  880. switch (query) {
  881. case GL_COEFF:
  882. t = eval1->order * eval1->k;
  883. eval1Data = gc->eval.eval1Data[index];
  884. for (i = 0; i < t; i++) {
  885. *rp++ = eval1Data[i];
  886. }
  887. break;
  888. case GL_DOMAIN:
  889. *rp++ = eval1->u1;
  890. *rp++ = eval1->u2;
  891. break;
  892. case GL_ORDER:
  893. *rp++ = gc->eval.eval1[index].order;
  894. break;
  895. default:
  896. __glSetError(GL_INVALID_ENUM);
  897. return;
  898. }
  899. break;
  900. case GL_MAP2_COLOR_4:
  901. case GL_MAP2_INDEX:
  902. case GL_MAP2_NORMAL:
  903. case GL_MAP2_TEXTURE_COORD_1:
  904. case GL_MAP2_TEXTURE_COORD_2:
  905. case GL_MAP2_TEXTURE_COORD_3:
  906. case GL_MAP2_TEXTURE_COORD_4:
  907. case GL_MAP2_VERTEX_3:
  908. case GL_MAP2_VERTEX_4:
  909. index = __GL_EVAL2D_INDEX(target);
  910. eval2 = &gc->eval.eval2[index];
  911. switch (query) {
  912. case GL_COEFF:
  913. eval2Data = gc->eval.eval2Data[index];
  914. t = eval2->majorOrder * eval2->minorOrder * eval2->k;
  915. for (i = 0; i < t; i++) {
  916. *rp++ = eval2Data[i];
  917. }
  918. break;
  919. case GL_DOMAIN:
  920. *rp++ = eval2->u1;
  921. *rp++ = eval2->u2;
  922. *rp++ = eval2->v1;
  923. *rp++ = eval2->v2;
  924. break;
  925. case GL_ORDER:
  926. *rp++ = gc->eval.eval2[index].majorOrder;
  927. *rp++ = gc->eval.eval2[index].minorOrder;
  928. break;
  929. default:
  930. __glSetError(GL_INVALID_ENUM);
  931. return;
  932. }
  933. break;
  934. default:
  935. __glSetError(GL_INVALID_ENUM);
  936. return;
  937. }
  938. }
  939. void APIPRIVATE __glim_GetMapdv(GLenum target, GLenum query, GLdouble buf[])
  940. {
  941. __GLevaluator1 *eval1;
  942. __GLevaluator2 *eval2;
  943. __GLfloat *eval1Data, *eval2Data;
  944. GLdouble *rp;
  945. GLint index, i, t;
  946. __GL_SETUP_NOT_IN_BEGIN();
  947. /*
  948. ** Check if target is valid.
  949. */
  950. rp = buf;
  951. switch (target) {
  952. case GL_MAP1_COLOR_4:
  953. case GL_MAP1_INDEX:
  954. case GL_MAP1_NORMAL:
  955. case GL_MAP1_TEXTURE_COORD_1:
  956. case GL_MAP1_TEXTURE_COORD_2:
  957. case GL_MAP1_TEXTURE_COORD_3:
  958. case GL_MAP1_TEXTURE_COORD_4:
  959. case GL_MAP1_VERTEX_3:
  960. case GL_MAP1_VERTEX_4:
  961. index = __GL_EVAL1D_INDEX(target);
  962. eval1 = &gc->eval.eval1[index];
  963. switch (query) {
  964. case GL_COEFF:
  965. eval1Data = gc->eval.eval1Data[index];
  966. t = eval1->order * eval1->k;
  967. for (i = 0; i < t; i++) {
  968. *rp++ = eval1Data[i];
  969. }
  970. break;
  971. case GL_DOMAIN:
  972. *rp++ = eval1->u1;
  973. *rp++ = eval1->u2;
  974. break;
  975. case GL_ORDER:
  976. *rp++ = gc->eval.eval1[index].order;
  977. break;
  978. default:
  979. __glSetError(GL_INVALID_ENUM);
  980. return;
  981. }
  982. break;
  983. case GL_MAP2_COLOR_4:
  984. case GL_MAP2_INDEX:
  985. case GL_MAP2_NORMAL:
  986. case GL_MAP2_TEXTURE_COORD_1:
  987. case GL_MAP2_TEXTURE_COORD_2:
  988. case GL_MAP2_TEXTURE_COORD_3:
  989. case GL_MAP2_TEXTURE_COORD_4:
  990. case GL_MAP2_VERTEX_3:
  991. case GL_MAP2_VERTEX_4:
  992. index = __GL_EVAL2D_INDEX(target);
  993. eval2 = &gc->eval.eval2[index];
  994. switch (query) {
  995. case GL_COEFF:
  996. eval2Data = gc->eval.eval2Data[index];
  997. t = eval2->majorOrder * eval2->minorOrder * eval2->k;
  998. for (i = 0; i < t; i++) {
  999. *rp++ = eval2Data[i];
  1000. }
  1001. break;
  1002. case GL_DOMAIN:
  1003. *rp++ = eval2->u1;
  1004. *rp++ = eval2->u2;
  1005. *rp++ = eval2->v1;
  1006. *rp++ = eval2->v2;
  1007. break;
  1008. case GL_ORDER:
  1009. *rp++ = gc->eval.eval2[index].majorOrder;
  1010. *rp++ = gc->eval.eval2[index].minorOrder;
  1011. break;
  1012. default:
  1013. __glSetError(GL_INVALID_ENUM);
  1014. return;
  1015. }
  1016. break;
  1017. default:
  1018. __glSetError(GL_INVALID_ENUM);
  1019. return;
  1020. }
  1021. }
  1022. void APIPRIVATE __glim_GetMapiv(GLenum target, GLenum query, GLint buf[])
  1023. {
  1024. __GLevaluator1 *eval1;
  1025. __GLevaluator2 *eval2;
  1026. __GLfloat *eval1Data, *eval2Data;
  1027. GLint *rp;
  1028. GLint index, t;
  1029. __GL_SETUP_NOT_IN_BEGIN();
  1030. /*
  1031. ** Check if target is valid.
  1032. */
  1033. rp = buf;
  1034. switch (target) {
  1035. case GL_MAP1_COLOR_4:
  1036. case GL_MAP1_INDEX:
  1037. case GL_MAP1_NORMAL:
  1038. case GL_MAP1_TEXTURE_COORD_1:
  1039. case GL_MAP1_TEXTURE_COORD_2:
  1040. case GL_MAP1_TEXTURE_COORD_3:
  1041. case GL_MAP1_TEXTURE_COORD_4:
  1042. case GL_MAP1_VERTEX_3:
  1043. case GL_MAP1_VERTEX_4:
  1044. index = __GL_EVAL1D_INDEX(target);
  1045. eval1 = &gc->eval.eval1[index];
  1046. switch (query) {
  1047. case GL_COEFF:
  1048. eval1Data = gc->eval.eval1Data[index];
  1049. t = eval1->order * eval1->k;
  1050. __glConvertResult(gc, __GL_FLOAT, eval1Data,
  1051. __GL_INT32, rp, t);
  1052. break;
  1053. case GL_DOMAIN:
  1054. __glConvertResult(gc, __GL_FLOAT, &eval1->u1,
  1055. __GL_INT32, rp, 2);
  1056. break;
  1057. case GL_ORDER:
  1058. *rp++ = gc->eval.eval1[index].order;
  1059. break;
  1060. default:
  1061. __glSetError(GL_INVALID_ENUM);
  1062. return;
  1063. }
  1064. break;
  1065. case GL_MAP2_COLOR_4:
  1066. case GL_MAP2_INDEX:
  1067. case GL_MAP2_NORMAL:
  1068. case GL_MAP2_TEXTURE_COORD_1:
  1069. case GL_MAP2_TEXTURE_COORD_2:
  1070. case GL_MAP2_TEXTURE_COORD_3:
  1071. case GL_MAP2_TEXTURE_COORD_4:
  1072. case GL_MAP2_VERTEX_3:
  1073. case GL_MAP2_VERTEX_4:
  1074. index = __GL_EVAL2D_INDEX(target);
  1075. eval2 = &gc->eval.eval2[index];
  1076. switch (query) {
  1077. case GL_COEFF:
  1078. eval2Data = gc->eval.eval2Data[index];
  1079. t = eval2->majorOrder * eval2->minorOrder * eval2->k;
  1080. __glConvertResult(gc, __GL_FLOAT, eval2Data,
  1081. __GL_INT32, rp, t);
  1082. break;
  1083. case GL_DOMAIN:
  1084. __glConvertResult(gc, __GL_FLOAT, &eval2->u1,
  1085. __GL_INT32, rp, 4);
  1086. break;
  1087. case GL_ORDER:
  1088. *rp++ = gc->eval.eval2[index].majorOrder;
  1089. *rp++ = gc->eval.eval2[index].minorOrder;
  1090. break;
  1091. default:
  1092. __glSetError(GL_INVALID_ENUM);
  1093. return;
  1094. }
  1095. break;
  1096. default:
  1097. __glSetError(GL_INVALID_ENUM);
  1098. return;
  1099. }
  1100. }
  1101. /*****************************************************************************/
  1102. void APIPRIVATE __glim_GetPixelMapfv(GLenum map, GLfloat buf[])
  1103. {
  1104. GLint index;
  1105. GLint limit;
  1106. GLfloat *rp;
  1107. __GLpixelMapHead *pMap;
  1108. __GL_SETUP_NOT_IN_BEGIN();
  1109. pMap = gc->state.pixel.pixelMap;
  1110. index = map - GL_PIXEL_MAP_I_TO_I;
  1111. rp = buf;
  1112. switch (map) {
  1113. case GL_PIXEL_MAP_I_TO_I:
  1114. case GL_PIXEL_MAP_S_TO_S:
  1115. {
  1116. GLint *fromp = pMap[index].base.mapI;
  1117. limit = pMap[index].size;
  1118. while (--limit >= 0) {
  1119. *rp++ = *fromp++;
  1120. }
  1121. }
  1122. break;
  1123. case GL_PIXEL_MAP_I_TO_R: case GL_PIXEL_MAP_I_TO_G:
  1124. case GL_PIXEL_MAP_I_TO_B: case GL_PIXEL_MAP_I_TO_A:
  1125. case GL_PIXEL_MAP_R_TO_R: case GL_PIXEL_MAP_G_TO_G:
  1126. case GL_PIXEL_MAP_B_TO_B: case GL_PIXEL_MAP_A_TO_A:
  1127. {
  1128. __GLfloat *fromp = pMap[index].base.mapF;
  1129. limit = pMap[index].size;
  1130. while (--limit >= 0) {
  1131. *rp++ = *fromp++;
  1132. }
  1133. }
  1134. break;
  1135. default:
  1136. __glSetError(GL_INVALID_ENUM);
  1137. return;
  1138. }
  1139. }
  1140. void APIPRIVATE __glim_GetPixelMapuiv(GLenum map, GLuint buf[])
  1141. {
  1142. GLint index;
  1143. GLint limit;
  1144. GLuint *rp;
  1145. __GLpixelMapHead *pMap;
  1146. __GL_SETUP_NOT_IN_BEGIN();
  1147. pMap = gc->state.pixel.pixelMap;
  1148. index = map - GL_PIXEL_MAP_I_TO_I;
  1149. rp = buf;
  1150. switch (map) {
  1151. case GL_PIXEL_MAP_I_TO_I:
  1152. case GL_PIXEL_MAP_S_TO_S:
  1153. {
  1154. GLint *fromp = pMap[index].base.mapI;
  1155. limit = pMap[index].size;
  1156. while (--limit >= 0) {
  1157. *rp++ = *fromp++;
  1158. }
  1159. }
  1160. break;
  1161. case GL_PIXEL_MAP_I_TO_R: case GL_PIXEL_MAP_I_TO_G:
  1162. case GL_PIXEL_MAP_I_TO_B: case GL_PIXEL_MAP_I_TO_A:
  1163. case GL_PIXEL_MAP_R_TO_R: case GL_PIXEL_MAP_G_TO_G:
  1164. case GL_PIXEL_MAP_B_TO_B: case GL_PIXEL_MAP_A_TO_A:
  1165. {
  1166. __GLfloat *fromp = pMap[index].base.mapF;
  1167. limit = pMap[index].size;
  1168. while (--limit >= 0) {
  1169. *rp++ = (GLuint) *fromp++;
  1170. }
  1171. }
  1172. break;
  1173. default:
  1174. __glSetError(GL_INVALID_ENUM);
  1175. return;
  1176. }
  1177. }
  1178. void APIPRIVATE __glim_GetPixelMapusv(GLenum map, GLushort buf[])
  1179. {
  1180. GLint index;
  1181. GLint limit;
  1182. GLushort *rp;
  1183. __GLpixelMapHead *pMap;
  1184. __GL_SETUP_NOT_IN_BEGIN();
  1185. pMap = gc->state.pixel.pixelMap;
  1186. index = map - GL_PIXEL_MAP_I_TO_I;
  1187. rp = buf;
  1188. switch (map) {
  1189. case GL_PIXEL_MAP_I_TO_I:
  1190. case GL_PIXEL_MAP_S_TO_S:
  1191. {
  1192. GLint *fromp = pMap[index].base.mapI;
  1193. limit = pMap[index].size;
  1194. while (--limit >= 0) {
  1195. *rp++ = (GLushort) *fromp++;
  1196. }
  1197. }
  1198. break;
  1199. case GL_PIXEL_MAP_I_TO_R: case GL_PIXEL_MAP_I_TO_G:
  1200. case GL_PIXEL_MAP_I_TO_B: case GL_PIXEL_MAP_I_TO_A:
  1201. case GL_PIXEL_MAP_R_TO_R: case GL_PIXEL_MAP_G_TO_G:
  1202. case GL_PIXEL_MAP_B_TO_B: case GL_PIXEL_MAP_A_TO_A:
  1203. {
  1204. __GLfloat *fromp = pMap[index].base.mapF;
  1205. limit = pMap[index].size;
  1206. while (--limit >= 0) {
  1207. *rp++ = (GLushort) *fromp++;
  1208. }
  1209. }
  1210. break;
  1211. default:
  1212. __glSetError(GL_INVALID_ENUM);
  1213. return;
  1214. }
  1215. }
  1216. /************************************************************************/
  1217. /*
  1218. ** Convert the results of a query from one type to another.
  1219. */
  1220. void __glConvertResult(__GLcontext *gc, GLint fromType, const void *rawdata,
  1221. GLint toType, void *result, GLint size)
  1222. {
  1223. GLint i;
  1224. switch (fromType) {
  1225. case __GL_FLOAT:
  1226. switch (toType) {
  1227. case __GL_FLOAT32:
  1228. for (i=0; i < size; i++) {
  1229. ((GLfloat *)result)[i] = ((const __GLfloat *)rawdata)[i];
  1230. }
  1231. break;
  1232. case __GL_FLOAT64:
  1233. for (i=0; i < size; i++) {
  1234. ((GLdouble *)result)[i] = ((const __GLfloat *)rawdata)[i];
  1235. }
  1236. break;
  1237. case __GL_INT32:
  1238. for (i=0; i < size; i++) {
  1239. ((GLint *)result)[i] =
  1240. (GLint)(((const __GLfloat *)rawdata)[i] >= (__GLfloat) 0.0 ?
  1241. ((const __GLfloat *)rawdata)[i] + __glHalf:
  1242. ((const __GLfloat *)rawdata)[i] - __glHalf);
  1243. }
  1244. break;
  1245. case __GL_BOOLEAN:
  1246. for (i=0; i < size; i++) {
  1247. ((GLboolean *)result)[i] =
  1248. ((const __GLfloat *)rawdata)[i] ? 1 : 0;
  1249. }
  1250. break;
  1251. }
  1252. break;
  1253. case __GL_COLOR:
  1254. switch (toType) {
  1255. case __GL_FLOAT32:
  1256. for (i=0; i < size; i++) {
  1257. ((GLfloat *)result)[i] = ((const __GLfloat *)rawdata)[i];
  1258. }
  1259. break;
  1260. case __GL_FLOAT64:
  1261. for (i=0; i < size; i++) {
  1262. ((GLdouble *)result)[i] = ((const __GLfloat *)rawdata)[i];
  1263. }
  1264. break;
  1265. case __GL_INT32:
  1266. for (i=0; i < size; i++) {
  1267. ((GLint *)result)[i] =
  1268. __GL_FLOAT_TO_I(((const __GLfloat *)rawdata)[i]);
  1269. }
  1270. break;
  1271. case __GL_BOOLEAN:
  1272. for (i=0; i < size; i++) {
  1273. ((GLboolean *)result)[i] =
  1274. ((const __GLfloat *)rawdata)[i] ? 1 : 0;
  1275. }
  1276. break;
  1277. }
  1278. break;
  1279. case __GL_SCOLOR:
  1280. switch (toType) {
  1281. case __GL_FLOAT32:
  1282. ((GLfloat *)result)[0] =
  1283. ((const __GLfloat *)rawdata)[0] * gc->oneOverRedVertexScale;
  1284. ((GLfloat *)result)[1] =
  1285. ((const __GLfloat *)rawdata)[1] * gc->oneOverGreenVertexScale;
  1286. ((GLfloat *)result)[2] =
  1287. ((const __GLfloat *)rawdata)[2] * gc->oneOverBlueVertexScale;
  1288. ((GLfloat *)result)[3] =
  1289. ((const __GLfloat *)rawdata)[3] * gc->oneOverAlphaVertexScale;
  1290. break;
  1291. case __GL_FLOAT64:
  1292. ((GLdouble *)result)[0] =
  1293. ((const __GLfloat *)rawdata)[0] * gc->oneOverRedVertexScale;
  1294. ((GLdouble *)result)[1] =
  1295. ((const __GLfloat *)rawdata)[1] * gc->oneOverGreenVertexScale;
  1296. ((GLdouble *)result)[2] =
  1297. ((const __GLfloat *)rawdata)[2] * gc->oneOverBlueVertexScale;
  1298. ((GLdouble *)result)[3] =
  1299. ((const __GLfloat *)rawdata)[3] * gc->oneOverAlphaVertexScale;
  1300. break;
  1301. case __GL_INT32:
  1302. ((GLint *)result)[0] =
  1303. __GL_FLOAT_TO_I(((const __GLfloat *)rawdata)[0] *
  1304. gc->oneOverRedVertexScale);
  1305. ((GLint *)result)[1] =
  1306. __GL_FLOAT_TO_I(((const __GLfloat *)rawdata)[1] *
  1307. gc->oneOverGreenVertexScale);
  1308. ((GLint *)result)[2] =
  1309. __GL_FLOAT_TO_I(((const __GLfloat *)rawdata)[2] *
  1310. gc->oneOverBlueVertexScale);
  1311. ((GLint *)result)[3] =
  1312. __GL_FLOAT_TO_I(((const __GLfloat *)rawdata)[3] *
  1313. gc->oneOverAlphaVertexScale);
  1314. break;
  1315. case __GL_BOOLEAN:
  1316. for (i=0; i < size; i++) {
  1317. ((GLboolean *)result)[i] =
  1318. ((const __GLfloat *)rawdata)[i] ? 1 : 0;
  1319. }
  1320. break;
  1321. }
  1322. break;
  1323. case __GL_INT32:
  1324. switch (toType) {
  1325. case __GL_FLOAT32:
  1326. for (i=0; i < size; i++) {
  1327. ((GLfloat *)result)[i] = ((const GLint *)rawdata)[i];
  1328. }
  1329. break;
  1330. case __GL_FLOAT64:
  1331. for (i=0; i < size; i++) {
  1332. ((GLdouble *)result)[i] = ((const GLint *)rawdata)[i];
  1333. }
  1334. break;
  1335. case __GL_INT32:
  1336. for (i=0; i < size; i++) {
  1337. ((GLint *)result)[i] = ((const GLint *)rawdata)[i];
  1338. }
  1339. break;
  1340. case __GL_BOOLEAN:
  1341. for (i=0; i < size; i++) {
  1342. ((GLboolean *)result)[i] = ((const GLint *)rawdata)[i] ? 1 : 0;
  1343. }
  1344. break;
  1345. }
  1346. break;
  1347. case __GL_BOOLEAN:
  1348. switch (toType) {
  1349. case __GL_FLOAT32:
  1350. for (i=0; i < size; i++) {
  1351. ((GLfloat *)result)[i] = ((const GLboolean *)rawdata)[i];
  1352. }
  1353. break;
  1354. case __GL_FLOAT64:
  1355. for (i=0; i < size; i++) {
  1356. ((GLdouble *)result)[i] = ((const GLboolean *)rawdata)[i];
  1357. }
  1358. break;
  1359. case __GL_INT32:
  1360. for (i=0; i < size; i++) {
  1361. ((GLint *)result)[i] = ((const GLboolean *)rawdata)[i];
  1362. }
  1363. break;
  1364. case __GL_BOOLEAN:
  1365. for (i=0; i < size; i++) {
  1366. ((GLboolean *)result)[i] =
  1367. ((const GLboolean *)rawdata)[i] ? 1 : 0;
  1368. }
  1369. break;
  1370. }
  1371. break;
  1372. }
  1373. }
  1374. /*
  1375. ** Fetch the data for a query in its internal type, then convert it to the
  1376. ** type that the user asked for.
  1377. */
  1378. void __glDoGet(GLenum sq, void *result, GLint type, const char *procName)
  1379. {
  1380. GLint index;
  1381. __GLfloat ftemp[100], *fp = ftemp; /* NOTE: for floats */
  1382. __GLfloat ctemp[100], *cp = ctemp; /* NOTE: for colors */
  1383. __GLfloat sctemp[100], *scp = sctemp; /* NOTE: for scaled colors */
  1384. GLint itemp[100], *ip = itemp; /* NOTE: for ints */
  1385. GLboolean ltemp[100], *lp = ltemp; /* NOTE: for logicals */
  1386. __GLfloat *mp;
  1387. __GL_SETUP_NOT_IN_BEGIN();
  1388. #ifdef __GL_LINT
  1389. procName = procName;
  1390. #endif
  1391. switch (sq) {
  1392. case GL_ALPHA_TEST:
  1393. case GL_BLEND:
  1394. case GL_COLOR_MATERIAL:
  1395. case GL_CULL_FACE:
  1396. case GL_DEPTH_TEST:
  1397. case GL_DITHER:
  1398. #ifdef GL_WIN_specular_fog
  1399. case GL_FOG_SPECULAR_TEXTURE_WIN:
  1400. #endif //GL_WIN_specular_fog
  1401. case GL_FOG:
  1402. case GL_LIGHTING:
  1403. case GL_LINE_SMOOTH:
  1404. case GL_LINE_STIPPLE:
  1405. case GL_INDEX_LOGIC_OP:
  1406. case GL_COLOR_LOGIC_OP:
  1407. case GL_NORMALIZE:
  1408. case GL_POINT_SMOOTH:
  1409. case GL_POLYGON_SMOOTH:
  1410. case GL_POLYGON_STIPPLE:
  1411. case GL_SCISSOR_TEST:
  1412. case GL_STENCIL_TEST:
  1413. case GL_TEXTURE_1D:
  1414. case GL_TEXTURE_2D:
  1415. case GL_AUTO_NORMAL:
  1416. case GL_TEXTURE_GEN_S:
  1417. case GL_TEXTURE_GEN_T:
  1418. case GL_TEXTURE_GEN_R:
  1419. case GL_TEXTURE_GEN_Q:
  1420. #ifdef GL_WIN_multiple_textures
  1421. case GL_TEXCOMBINE_CLAMP_WIN:
  1422. #endif // GL_WIN_multiple_textures
  1423. #ifdef GL_EXT_flat_paletted_lighting
  1424. case GL_PALETTED_LIGHTING_EXT:
  1425. #endif // GL_EXT_flat_paletted_lighting
  1426. case GL_CLIP_PLANE0: case GL_CLIP_PLANE1:
  1427. case GL_CLIP_PLANE2: case GL_CLIP_PLANE3:
  1428. case GL_CLIP_PLANE4: case GL_CLIP_PLANE5:
  1429. case GL_LIGHT0: case GL_LIGHT1:
  1430. case GL_LIGHT2: case GL_LIGHT3:
  1431. case GL_LIGHT4: case GL_LIGHT5:
  1432. case GL_LIGHT6: case GL_LIGHT7:
  1433. case GL_MAP1_COLOR_4:
  1434. case GL_MAP1_NORMAL:
  1435. case GL_MAP1_INDEX:
  1436. case GL_MAP1_TEXTURE_COORD_1: case GL_MAP1_TEXTURE_COORD_2:
  1437. case GL_MAP1_TEXTURE_COORD_3: case GL_MAP1_TEXTURE_COORD_4:
  1438. case GL_MAP1_VERTEX_3: case GL_MAP1_VERTEX_4:
  1439. case GL_MAP2_COLOR_4:
  1440. case GL_MAP2_NORMAL:
  1441. case GL_MAP2_INDEX:
  1442. case GL_MAP2_TEXTURE_COORD_1: case GL_MAP2_TEXTURE_COORD_2:
  1443. case GL_MAP2_TEXTURE_COORD_3: case GL_MAP2_TEXTURE_COORD_4:
  1444. case GL_MAP2_VERTEX_3: case GL_MAP2_VERTEX_4:
  1445. case GL_VERTEX_ARRAY:
  1446. case GL_NORMAL_ARRAY:
  1447. case GL_COLOR_ARRAY:
  1448. case GL_INDEX_ARRAY:
  1449. case GL_TEXTURE_COORD_ARRAY:
  1450. case GL_EDGE_FLAG_ARRAY:
  1451. case GL_POLYGON_OFFSET_POINT:
  1452. case GL_POLYGON_OFFSET_LINE:
  1453. case GL_POLYGON_OFFSET_FILL:
  1454. *lp++ = __glim_IsEnabled(sq);
  1455. break;
  1456. case GL_MAX_TEXTURE_SIZE:
  1457. *ip++ = gc->constants.maxTextureSize;
  1458. break;
  1459. #ifdef GL_WIN_multiple_textures
  1460. case GL_MAX_CURRENT_TEXTURES_WIN:
  1461. *ip++ = (int)gc->constants.numberOfCurrentTextures;
  1462. break;
  1463. case GL_TEXCOMBINE_NATURAL_CLAMP_WIN:
  1464. *ip++ = (int)gc->constants.texCombineNaturalClamp;
  1465. break;
  1466. case GL_CURRENT_TEXTURE_INDEX_WIN:
  1467. *ip++ = (int)gc->texture.texIndex;
  1468. break;
  1469. #endif // GL_WIN_multiple_textures
  1470. case GL_SUBPIXEL_BITS:
  1471. *ip++ = gc->constants.subpixelBits;
  1472. break;
  1473. case GL_MAX_LIST_NESTING:
  1474. *ip++ = __GL_MAX_LIST_NESTING;
  1475. break;
  1476. case GL_CURRENT_COLOR:
  1477. *cp++ = gc->state.current.userColor.r;
  1478. *cp++ = gc->state.current.userColor.g;
  1479. *cp++ = gc->state.current.userColor.b;
  1480. *cp++ = gc->state.current.userColor.a;
  1481. break;
  1482. case GL_CURRENT_INDEX:
  1483. *fp++ = gc->state.current.userColorIndex;
  1484. break;
  1485. case GL_CURRENT_NORMAL:
  1486. *cp++ = gc->state.current.normal.x;
  1487. *cp++ = gc->state.current.normal.y;
  1488. *cp++ = gc->state.current.normal.z;
  1489. break;
  1490. case GL_CURRENT_TEXTURE_COORDS:
  1491. *fp++ = gc->state.current.texture.x;
  1492. *fp++ = gc->state.current.texture.y;
  1493. *fp++ = gc->state.current.texture.z;
  1494. *fp++ = gc->state.current.texture.w;
  1495. break;
  1496. case GL_CURRENT_RASTER_INDEX:
  1497. if (gc->modes.rgbMode) {
  1498. /* Always return 1 */
  1499. *fp++ = (__GLfloat) 1.0;
  1500. } else {
  1501. *fp++ = gc->state.current.rasterPos.colors[__GL_FRONTFACE].r;
  1502. }
  1503. break;
  1504. case GL_CURRENT_RASTER_COLOR:
  1505. if (gc->modes.colorIndexMode) {
  1506. /* Always return 1,1,1,1 */
  1507. *fp++ = (__GLfloat) 1.0;
  1508. *fp++ = (__GLfloat) 1.0;
  1509. *fp++ = (__GLfloat) 1.0;
  1510. *fp++ = (__GLfloat) 1.0;
  1511. } else {
  1512. *scp++ = gc->state.current.rasterPos.colors[__GL_FRONTFACE].r;
  1513. *scp++ = gc->state.current.rasterPos.colors[__GL_FRONTFACE].g;
  1514. *scp++ = gc->state.current.rasterPos.colors[__GL_FRONTFACE].b;
  1515. *scp++ = gc->state.current.rasterPos.colors[__GL_FRONTFACE].a;
  1516. }
  1517. break;
  1518. case GL_CURRENT_RASTER_TEXTURE_COORDS:
  1519. *fp++ = gc->state.current.rasterPos.texture.x;
  1520. *fp++ = gc->state.current.rasterPos.texture.y;
  1521. *fp++ = gc->state.current.rasterPos.texture.z;
  1522. *fp++ = gc->state.current.rasterPos.texture.w;
  1523. break;
  1524. case GL_CURRENT_RASTER_POSITION:
  1525. *fp++ = gc->state.current.rasterPos.window.x
  1526. - gc->constants.fviewportXAdjust;
  1527. if (gc->constants.yInverted) {
  1528. *fp++ = gc->constants.height -
  1529. (gc->state.current.rasterPos.window.y -
  1530. gc->constants.fviewportYAdjust) -
  1531. gc->constants.viewportEpsilon;
  1532. } else {
  1533. *fp++ = gc->state.current.rasterPos.window.y
  1534. - gc->constants.fviewportYAdjust;
  1535. }
  1536. *fp++ = gc->state.current.rasterPos.window.z / gc->depthBuffer.scale;
  1537. *fp++ = gc->state.current.rasterPos.clip.w;
  1538. break;
  1539. case GL_CURRENT_RASTER_POSITION_VALID:
  1540. *lp++ = gc->state.current.validRasterPos;
  1541. break;
  1542. case GL_CURRENT_RASTER_DISTANCE:
  1543. *fp++ = gc->state.current.rasterPos.eyeZ;
  1544. break;
  1545. case GL_POINT_SIZE:
  1546. *fp++ = gc->state.point.requestedSize;
  1547. break;
  1548. case GL_POINT_SIZE_RANGE:
  1549. *fp++ = gc->constants.pointSizeMinimum;
  1550. *fp++ = gc->constants.pointSizeMaximum;
  1551. break;
  1552. case GL_POINT_SIZE_GRANULARITY:
  1553. *fp++ = gc->constants.pointSizeGranularity;
  1554. break;
  1555. case GL_LINE_WIDTH:
  1556. *fp++ = gc->state.line.requestedWidth;
  1557. break;
  1558. case GL_LINE_WIDTH_RANGE:
  1559. *fp++ = gc->constants.lineWidthMinimum;
  1560. *fp++ = gc->constants.lineWidthMaximum;
  1561. break;
  1562. case GL_LINE_WIDTH_GRANULARITY:
  1563. *fp++ = gc->constants.lineWidthGranularity;
  1564. break;
  1565. case GL_LINE_STIPPLE_PATTERN:
  1566. *ip++ = gc->state.line.stipple;
  1567. break;
  1568. case GL_LINE_STIPPLE_REPEAT:
  1569. *ip++ = gc->state.line.stippleRepeat;
  1570. break;
  1571. case GL_POLYGON_MODE:
  1572. *ip++ = gc->state.polygon.frontMode;
  1573. *ip++ = gc->state.polygon.backMode;
  1574. break;
  1575. case GL_EDGE_FLAG:
  1576. *lp++ = gc->state.current.edgeTag;
  1577. break;
  1578. case GL_CULL_FACE_MODE:
  1579. *ip++ = gc->state.polygon.cull;
  1580. break;
  1581. case GL_FRONT_FACE:
  1582. *ip++ = gc->state.polygon.frontFaceDirection;
  1583. break;
  1584. case GL_LIGHT_MODEL_LOCAL_VIEWER:
  1585. *lp++ = gc->state.light.model.localViewer;
  1586. break;
  1587. case GL_LIGHT_MODEL_TWO_SIDE:
  1588. *lp++ = gc->state.light.model.twoSided;
  1589. break;
  1590. case GL_LIGHT_MODEL_AMBIENT:
  1591. __glUnScaleColorf(gc, cp, &gc->state.light.model.ambient);
  1592. cp += 4;
  1593. break;
  1594. case GL_COLOR_MATERIAL_FACE:
  1595. *ip++ = gc->state.light.colorMaterialFace;
  1596. break;
  1597. case GL_COLOR_MATERIAL_PARAMETER:
  1598. *ip++ = gc->state.light.colorMaterialParam;
  1599. break;
  1600. case GL_SHADE_MODEL:
  1601. *ip++ = gc->state.light.shadingModel;
  1602. break;
  1603. case GL_FOG_INDEX:
  1604. *fp++ = gc->state.fog.index;
  1605. break;
  1606. case GL_FOG_DENSITY:
  1607. *fp++ = gc->state.fog.density;
  1608. break;
  1609. case GL_FOG_START:
  1610. *fp++ = gc->state.fog.start;
  1611. break;
  1612. case GL_FOG_END:
  1613. *fp++ = gc->state.fog.end;
  1614. break;
  1615. case GL_FOG_MODE:
  1616. *ip++ = gc->state.fog.mode;
  1617. break;
  1618. case GL_FOG_COLOR:
  1619. *scp++ = gc->state.fog.color.r;
  1620. *scp++ = gc->state.fog.color.g;
  1621. *scp++ = gc->state.fog.color.b;
  1622. *scp++ = gc->state.fog.color.a;
  1623. break;
  1624. case GL_DEPTH_RANGE:
  1625. /* These get scaled like colors, to [0, 2^31-1] */
  1626. *cp++ = gc->state.viewport.zNear;
  1627. *cp++ = gc->state.viewport.zFar;
  1628. break;
  1629. case GL_DEPTH_WRITEMASK:
  1630. *lp++ = gc->state.depth.writeEnable;
  1631. break;
  1632. case GL_DEPTH_CLEAR_VALUE:
  1633. /* This gets scaled like colors, to [0, 2^31-1] */
  1634. *cp++ = gc->state.depth.clear;
  1635. break;
  1636. case GL_DEPTH_FUNC:
  1637. *ip++ = gc->state.depth.testFunc;
  1638. break;
  1639. case GL_ACCUM_CLEAR_VALUE:
  1640. *cp++ = gc->state.accum.clear.r;
  1641. *cp++ = gc->state.accum.clear.g;
  1642. *cp++ = gc->state.accum.clear.b;
  1643. *cp++ = gc->state.accum.clear.a;
  1644. break;
  1645. case GL_STENCIL_CLEAR_VALUE:
  1646. *ip++ = gc->state.stencil.clear;
  1647. break;
  1648. case GL_STENCIL_FUNC:
  1649. *ip++ = gc->state.stencil.testFunc;
  1650. break;
  1651. case GL_STENCIL_VALUE_MASK:
  1652. *ip++ = gc->state.stencil.mask;
  1653. break;
  1654. case GL_STENCIL_FAIL:
  1655. *ip++ = gc->state.stencil.fail;
  1656. break;
  1657. case GL_STENCIL_PASS_DEPTH_FAIL:
  1658. *ip++ = gc->state.stencil.depthFail;
  1659. break;
  1660. case GL_STENCIL_PASS_DEPTH_PASS:
  1661. *ip++ = gc->state.stencil.depthPass;
  1662. break;
  1663. case GL_STENCIL_REF:
  1664. *ip++ = gc->state.stencil.reference;
  1665. break;
  1666. case GL_STENCIL_WRITEMASK:
  1667. *ip++ = gc->state.stencil.writeMask;
  1668. break;
  1669. case GL_MATRIX_MODE:
  1670. *ip++ = gc->state.transform.matrixMode;
  1671. break;
  1672. case GL_VIEWPORT:
  1673. *ip++ = gc->state.viewport.x;
  1674. *ip++ = gc->state.viewport.y;
  1675. *ip++ = gc->state.viewport.width;
  1676. *ip++ = gc->state.viewport.height;
  1677. break;
  1678. case GL_ATTRIB_STACK_DEPTH:
  1679. *ip++ = (GLint)((ULONG_PTR)(gc->attributes.stackPointer - gc->attributes.stack));
  1680. break;
  1681. case GL_CLIENT_ATTRIB_STACK_DEPTH:
  1682. *ip++ = (GLint)((ULONG_PTR)(gc->clientAttributes.stackPointer - gc->clientAttributes.stack));
  1683. break;
  1684. case GL_MODELVIEW_STACK_DEPTH:
  1685. *ip++ = 1 + (GLint)((ULONG_PTR)(gc->transform.modelView - gc->transform.modelViewStack));
  1686. break;
  1687. case GL_PROJECTION_STACK_DEPTH:
  1688. *ip++ = 1 + (GLint)((ULONG_PTR)(gc->transform.projection - gc->transform.projectionStack));
  1689. break;
  1690. case GL_TEXTURE_STACK_DEPTH:
  1691. *ip++ = 1 + (GLint)((ULONG_PTR)(gc->transform.texture - gc->transform.textureStack));
  1692. break;
  1693. case GL_MODELVIEW_MATRIX:
  1694. mp = &gc->transform.modelView->matrix.matrix[0][0];
  1695. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1696. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1697. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1698. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1699. break;
  1700. case GL_PROJECTION_MATRIX:
  1701. mp = &gc->transform.projection->matrix.matrix[0][0];
  1702. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1703. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1704. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1705. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1706. break;
  1707. case GL_TEXTURE_MATRIX:
  1708. mp = &gc->transform.texture->matrix.matrix[0][0];
  1709. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1710. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1711. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1712. *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++; *fp++ = *mp++;
  1713. break;
  1714. case GL_ALPHA_TEST_FUNC:
  1715. *ip++ = gc->state.raster.alphaFunction;
  1716. break;
  1717. case GL_ALPHA_TEST_REF:
  1718. *fp++ = gc->state.raster.alphaReference;
  1719. break;
  1720. case GL_BLEND_DST:
  1721. *ip++ = gc->state.raster.blendDst;
  1722. break;
  1723. case GL_BLEND_SRC:
  1724. *ip++ = gc->state.raster.blendSrc;
  1725. break;
  1726. case GL_LOGIC_OP_MODE:
  1727. *ip++ = gc->state.raster.logicOp;
  1728. break;
  1729. case GL_DRAW_BUFFER:
  1730. *ip++ = gc->state.raster.drawBufferReturn;
  1731. break;
  1732. case GL_READ_BUFFER:
  1733. *ip++ = gc->state.pixel.readBufferReturn;
  1734. break;
  1735. case GL_SCISSOR_BOX:
  1736. *ip++ = gc->state.scissor.scissorX;
  1737. *ip++ = gc->state.scissor.scissorY;
  1738. *ip++ = gc->state.scissor.scissorWidth;
  1739. *ip++ = gc->state.scissor.scissorHeight;
  1740. break;
  1741. case GL_INDEX_CLEAR_VALUE:
  1742. *fp++ = gc->state.raster.clearIndex;
  1743. break;
  1744. case GL_INDEX_MODE:
  1745. *lp++ = gc->modes.colorIndexMode ? GL_TRUE : GL_FALSE;
  1746. break;
  1747. case GL_INDEX_WRITEMASK:
  1748. *ip++ = gc->state.raster.writeMask;
  1749. break;
  1750. case GL_COLOR_CLEAR_VALUE:
  1751. *cp++ = gc->state.raster.clear.r;
  1752. *cp++ = gc->state.raster.clear.g;
  1753. *cp++ = gc->state.raster.clear.b;
  1754. *cp++ = gc->state.raster.clear.a;
  1755. break;
  1756. case GL_RGBA_MODE:
  1757. *lp++ = gc->modes.rgbMode ? GL_TRUE : GL_FALSE;
  1758. break;
  1759. case GL_COLOR_WRITEMASK:
  1760. *lp++ = gc->state.raster.rMask;
  1761. *lp++ = gc->state.raster.gMask;
  1762. *lp++ = gc->state.raster.bMask;
  1763. *lp++ = gc->state.raster.aMask;
  1764. break;
  1765. case GL_RENDER_MODE:
  1766. *ip++ = gc->renderMode;
  1767. break;
  1768. case GL_PERSPECTIVE_CORRECTION_HINT:
  1769. *ip++ = gc->state.hints.perspectiveCorrection;
  1770. break;
  1771. case GL_POINT_SMOOTH_HINT:
  1772. *ip++ = gc->state.hints.pointSmooth;
  1773. break;
  1774. case GL_LINE_SMOOTH_HINT:
  1775. *ip++ = gc->state.hints.lineSmooth;
  1776. break;
  1777. case GL_POLYGON_SMOOTH_HINT:
  1778. *ip++ = gc->state.hints.polygonSmooth;
  1779. break;
  1780. case GL_FOG_HINT:
  1781. *ip++ = gc->state.hints.fog;
  1782. break;
  1783. #ifdef GL_WIN_phong_shading
  1784. case GL_PHONG_HINT_WIN:
  1785. *ip++ = gc->state.hints.phong;
  1786. break;
  1787. #endif //GL_WIN_phong_shading
  1788. case GL_LIST_BASE:
  1789. *ip++ = gc->state.list.listBase;
  1790. break;
  1791. case GL_LIST_INDEX:
  1792. *ip++ = gc->dlist.currentList;
  1793. break;
  1794. case GL_LIST_MODE:
  1795. *ip++ = gc->dlist.mode;
  1796. break;
  1797. case GL_PACK_SWAP_BYTES:
  1798. *lp++ = gc->state.pixel.packModes.swapEndian;
  1799. break;
  1800. case GL_PACK_LSB_FIRST:
  1801. *lp++ = gc->state.pixel.packModes.lsbFirst;
  1802. break;
  1803. case GL_PACK_ROW_LENGTH:
  1804. *ip++ = gc->state.pixel.packModes.lineLength;
  1805. break;
  1806. case GL_PACK_SKIP_ROWS:
  1807. *ip++ = gc->state.pixel.packModes.skipLines;
  1808. break;
  1809. case GL_PACK_SKIP_PIXELS:
  1810. *ip++ = gc->state.pixel.packModes.skipPixels;
  1811. break;
  1812. case GL_PACK_ALIGNMENT:
  1813. *ip++ = gc->state.pixel.packModes.alignment;
  1814. break;
  1815. case GL_UNPACK_SWAP_BYTES:
  1816. *lp++ = gc->state.pixel.unpackModes.swapEndian;
  1817. break;
  1818. case GL_UNPACK_LSB_FIRST:
  1819. *lp++ = gc->state.pixel.unpackModes.lsbFirst;
  1820. break;
  1821. case GL_UNPACK_ROW_LENGTH:
  1822. *ip++ = gc->state.pixel.unpackModes.lineLength;
  1823. break;
  1824. case GL_UNPACK_SKIP_ROWS:
  1825. *ip++ = gc->state.pixel.unpackModes.skipLines;
  1826. break;
  1827. case GL_UNPACK_SKIP_PIXELS:
  1828. *ip++ = gc->state.pixel.unpackModes.skipPixels;
  1829. break;
  1830. case GL_UNPACK_ALIGNMENT:
  1831. *ip++ = gc->state.pixel.unpackModes.alignment;
  1832. break;
  1833. case GL_MAP_COLOR:
  1834. *lp++ = gc->state.pixel.transferMode.mapColor;
  1835. break;
  1836. case GL_MAP_STENCIL:
  1837. *lp++ = gc->state.pixel.transferMode.mapStencil;
  1838. break;
  1839. case GL_INDEX_SHIFT:
  1840. *ip++ = gc->state.pixel.transferMode.indexShift;
  1841. break;
  1842. case GL_INDEX_OFFSET:
  1843. *ip++ = gc->state.pixel.transferMode.indexOffset;
  1844. break;
  1845. case GL_RED_SCALE:
  1846. *fp++ = gc->state.pixel.transferMode.r_scale;
  1847. break;
  1848. case GL_GREEN_SCALE:
  1849. *fp++ = gc->state.pixel.transferMode.g_scale;
  1850. break;
  1851. case GL_BLUE_SCALE:
  1852. *fp++ = gc->state.pixel.transferMode.b_scale;
  1853. break;
  1854. case GL_ALPHA_SCALE:
  1855. *fp++ = gc->state.pixel.transferMode.a_scale;
  1856. break;
  1857. case GL_DEPTH_SCALE:
  1858. *fp++ = gc->state.pixel.transferMode.d_scale;
  1859. break;
  1860. case GL_RED_BIAS:
  1861. *fp++ = gc->state.pixel.transferMode.r_bias;
  1862. break;
  1863. case GL_GREEN_BIAS:
  1864. *fp++ = gc->state.pixel.transferMode.g_bias;
  1865. break;
  1866. case GL_BLUE_BIAS:
  1867. *fp++ = gc->state.pixel.transferMode.b_bias;
  1868. break;
  1869. case GL_ALPHA_BIAS:
  1870. *fp++ = gc->state.pixel.transferMode.a_bias;
  1871. break;
  1872. case GL_DEPTH_BIAS:
  1873. *fp++ = gc->state.pixel.transferMode.d_bias;
  1874. break;
  1875. case GL_ZOOM_X:
  1876. *fp++ = gc->state.pixel.transferMode.zoomX;
  1877. break;
  1878. case GL_ZOOM_Y:
  1879. *fp++ = gc->state.pixel.transferMode.zoomY;
  1880. break;
  1881. case GL_PIXEL_MAP_I_TO_I_SIZE: case GL_PIXEL_MAP_S_TO_S_SIZE:
  1882. case GL_PIXEL_MAP_I_TO_R_SIZE: case GL_PIXEL_MAP_I_TO_G_SIZE:
  1883. case GL_PIXEL_MAP_I_TO_B_SIZE: case GL_PIXEL_MAP_I_TO_A_SIZE:
  1884. case GL_PIXEL_MAP_R_TO_R_SIZE: case GL_PIXEL_MAP_G_TO_G_SIZE:
  1885. case GL_PIXEL_MAP_B_TO_B_SIZE: case GL_PIXEL_MAP_A_TO_A_SIZE:
  1886. index = sq - GL_PIXEL_MAP_I_TO_I_SIZE;
  1887. *ip++ = gc->state.pixel.pixelMap[index].size;
  1888. break;
  1889. case GL_MAX_EVAL_ORDER:
  1890. *ip++ = gc->constants.maxEvalOrder;
  1891. break;
  1892. case GL_MAX_LIGHTS:
  1893. *ip++ = gc->constants.numberOfLights;
  1894. break;
  1895. case GL_MAX_CLIP_PLANES:
  1896. *ip++ = gc->constants.numberOfClipPlanes;
  1897. break;
  1898. case GL_MAX_PIXEL_MAP_TABLE:
  1899. *ip++ = gc->constants.maxPixelMapTable;
  1900. break;
  1901. case GL_MAX_ATTRIB_STACK_DEPTH:
  1902. *ip++ = gc->constants.maxAttribStackDepth;
  1903. break;
  1904. case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
  1905. *ip++ = gc->constants.maxClientAttribStackDepth;
  1906. break;
  1907. case GL_MAX_MODELVIEW_STACK_DEPTH:
  1908. #ifdef NT
  1909. *ip++ = __GL_WGL_MAX_MODELVIEW_STACK_DEPTH;
  1910. #else
  1911. *ip++ = gc->constants.maxModelViewStackDepth;
  1912. #endif
  1913. break;
  1914. case GL_MAX_NAME_STACK_DEPTH:
  1915. *ip++ = gc->constants.maxNameStackDepth;
  1916. break;
  1917. case GL_MAX_PROJECTION_STACK_DEPTH:
  1918. #ifdef NT
  1919. *ip++ = __GL_WGL_MAX_PROJECTION_STACK_DEPTH;
  1920. #else
  1921. *ip++ = gc->constants.maxProjectionStackDepth;
  1922. #endif
  1923. break;
  1924. case GL_MAX_TEXTURE_STACK_DEPTH:
  1925. #ifdef NT
  1926. *ip++ = __GL_WGL_MAX_TEXTURE_STACK_DEPTH;
  1927. #else
  1928. *ip++ = gc->constants.maxTextureStackDepth;
  1929. #endif
  1930. break;
  1931. case GL_INDEX_BITS:
  1932. *ip++ = gc->modes.indexBits;
  1933. break;
  1934. case GL_RED_BITS:
  1935. *ip++ = gc->modes.redBits;
  1936. break;
  1937. case GL_GREEN_BITS:
  1938. *ip++ = gc->modes.greenBits;
  1939. break;
  1940. case GL_BLUE_BITS:
  1941. *ip++ = gc->modes.blueBits;
  1942. break;
  1943. case GL_ALPHA_BITS:
  1944. *ip++ = gc->modes.alphaBits;
  1945. break;
  1946. case GL_DEPTH_BITS:
  1947. // gc->modes.depthBits is the number of bits in the total
  1948. // depth pixel, not just the number of active bits.
  1949. // Usually these quantities are the same, but not always
  1950. // for MCD.
  1951. *ip++ = ((__GLGENcontext *)gc)->gsurf.pfd.cDepthBits;
  1952. break;
  1953. case GL_STENCIL_BITS:
  1954. *ip++ = gc->modes.stencilBits;
  1955. break;
  1956. case GL_ACCUM_RED_BITS:
  1957. case GL_ACCUM_GREEN_BITS:
  1958. case GL_ACCUM_BLUE_BITS:
  1959. case GL_ACCUM_ALPHA_BITS:
  1960. *ip++ = gc->modes.accumBits;
  1961. break;
  1962. case GL_MAP1_GRID_DOMAIN:
  1963. *fp++ = gc->state.evaluator.u1.start;
  1964. *fp++ = gc->state.evaluator.u1.finish;
  1965. break;
  1966. case GL_MAP1_GRID_SEGMENTS:
  1967. *ip++ = gc->state.evaluator.u1.n;
  1968. break;
  1969. case GL_MAP2_GRID_DOMAIN:
  1970. *fp++ = gc->state.evaluator.u2.start;
  1971. *fp++ = gc->state.evaluator.u2.finish;
  1972. *fp++ = gc->state.evaluator.v2.start;
  1973. *fp++ = gc->state.evaluator.v2.finish;
  1974. break;
  1975. case GL_MAP2_GRID_SEGMENTS:
  1976. *ip++ = gc->state.evaluator.u2.n;
  1977. *ip++ = gc->state.evaluator.v2.n;
  1978. break;
  1979. case GL_NAME_STACK_DEPTH:
  1980. *ip++ = (GLint)((ULONG_PTR)(gc->select.sp - gc->select.stack));
  1981. break;
  1982. case GL_MAX_VIEWPORT_DIMS:
  1983. *ip++ = gc->constants.maxViewportWidth;
  1984. *ip++ = gc->constants.maxViewportHeight;
  1985. break;
  1986. case GL_DOUBLEBUFFER:
  1987. *lp++ = gc->modes.doubleBufferMode ? GL_TRUE : GL_FALSE;
  1988. break;
  1989. case GL_AUX_BUFFERS:
  1990. *ip++ = gc->modes.maxAuxBuffers;
  1991. break;
  1992. case GL_STEREO:
  1993. *lp++ = GL_FALSE;
  1994. break;
  1995. case GL_TEXTURE_BINDING_1D:
  1996. {
  1997. __GLtextureObjectState *ptos;
  1998. ptos = __glLookUpTextureTexobjs(gc, GL_TEXTURE_1D);
  1999. *ip++ = ptos->name;
  2000. }
  2001. break;
  2002. case GL_TEXTURE_BINDING_2D:
  2003. {
  2004. __GLtextureObjectState *ptos;
  2005. ptos = __glLookUpTextureTexobjs(gc, GL_TEXTURE_2D);
  2006. *ip++ = ptos->name;
  2007. }
  2008. break;
  2009. case GL_POLYGON_OFFSET_FACTOR:
  2010. *fp++ = gc->state.polygon.factor;
  2011. break;
  2012. case GL_POLYGON_OFFSET_UNITS:
  2013. *fp++ = gc->state.polygon.units;
  2014. break;
  2015. case GL_VERTEX_ARRAY_SIZE:
  2016. *ip++ = gc->vertexArray.vertex.size;
  2017. break;
  2018. case GL_VERTEX_ARRAY_TYPE:
  2019. *ip++ = gc->vertexArray.vertex.type;
  2020. break;
  2021. case GL_VERTEX_ARRAY_STRIDE:
  2022. *ip++ = gc->vertexArray.vertex.stride;
  2023. break;
  2024. case GL_NORMAL_ARRAY_TYPE:
  2025. *ip++ = gc->vertexArray.normal.type;
  2026. break;
  2027. case GL_NORMAL_ARRAY_STRIDE:
  2028. *ip++ = gc->vertexArray.normal.stride;
  2029. break;
  2030. case GL_COLOR_ARRAY_SIZE:
  2031. *ip++ = gc->vertexArray.color.size;
  2032. break;
  2033. case GL_COLOR_ARRAY_TYPE:
  2034. *ip++ = gc->vertexArray.color.type;
  2035. break;
  2036. case GL_COLOR_ARRAY_STRIDE:
  2037. *ip++ = gc->vertexArray.color.stride;
  2038. break;
  2039. case GL_INDEX_ARRAY_TYPE:
  2040. *ip++ = gc->vertexArray.index.type;
  2041. break;
  2042. case GL_INDEX_ARRAY_STRIDE:
  2043. *ip++ = gc->vertexArray.index.stride;
  2044. break;
  2045. case GL_TEXTURE_COORD_ARRAY_SIZE:
  2046. *ip++ = gc->vertexArray.texCoord.size;
  2047. break;
  2048. case GL_TEXTURE_COORD_ARRAY_TYPE:
  2049. *ip++ = gc->vertexArray.texCoord.type;
  2050. break;
  2051. case GL_TEXTURE_COORD_ARRAY_STRIDE:
  2052. *ip++ = gc->vertexArray.texCoord.stride;
  2053. break;
  2054. case GL_EDGE_FLAG_ARRAY_STRIDE:
  2055. *ip++ = gc->vertexArray.edgeFlag.stride;
  2056. break;
  2057. case GL_FEEDBACK_BUFFER_SIZE:
  2058. *ip++ = gc->feedback.resultLength;
  2059. break;
  2060. case GL_FEEDBACK_BUFFER_TYPE:
  2061. *ip++ = gc->feedback.type;
  2062. break;
  2063. case GL_SELECTION_BUFFER_SIZE:
  2064. *ip++ = gc->select.resultLength;
  2065. break;
  2066. case GL_MAX_ELEMENTS_INDICES_WIN:
  2067. *ip++ = VA_DRAWRANGEELEM_MAX_INDICES;
  2068. break;
  2069. case GL_MAX_ELEMENTS_VERTICES_WIN:
  2070. *ip++ = VA_DRAWRANGEELEM_MAX_VERTICES;
  2071. break;
  2072. default:
  2073. __glSetError(GL_INVALID_ENUM);
  2074. return;
  2075. }
  2076. /* Use the motion of the pointers to type convert the result */
  2077. if (ip != itemp) {
  2078. __glConvertResult(gc, __GL_INT32, itemp, type, result, (GLint)((ULONG_PTR)(ip - itemp)));
  2079. } else
  2080. if (fp != ftemp) {
  2081. __glConvertResult(gc, __GL_FLOAT, ftemp, type, result, (GLint)((ULONG_PTR)(fp - ftemp)));
  2082. } else
  2083. if (lp != ltemp) {
  2084. __glConvertResult(gc, __GL_BOOLEAN, ltemp, type, result, (GLint)((ULONG_PTR)(lp - ltemp)));
  2085. } else
  2086. if (cp != ctemp) {
  2087. __glConvertResult(gc, __GL_COLOR, ctemp, type, result, (GLint)((ULONG_PTR)(cp - ctemp)));
  2088. } else
  2089. if (scp != sctemp) {
  2090. __glConvertResult(gc, __GL_SCOLOR, sctemp, type, result, (GLint)((ULONG_PTR)(scp - sctemp)));
  2091. }
  2092. }
  2093. #ifdef NT
  2094. // __glGenDoGet implemented in ..\generic\gencx.c
  2095. extern void FASTCALL __glGenDoGet(GLenum, void *, GLint, const char *);
  2096. #endif
  2097. void APIPRIVATE __glim_GetDoublev(GLenum sq, GLdouble result[])
  2098. {
  2099. #ifdef NT
  2100. __glGenDoGet(sq, result, __GL_FLOAT64, "glGetDoublev");
  2101. #else
  2102. __glDoGet(sq, result, __GL_FLOAT64, "glGetDoublev");
  2103. #endif
  2104. }
  2105. void APIPRIVATE __glim_GetFloatv(GLenum sq, GLfloat result[])
  2106. {
  2107. #ifdef NT
  2108. __glGenDoGet(sq, result, __GL_FLOAT32, "glGetFloatv");
  2109. #else
  2110. __glDoGet(sq, result, __GL_FLOAT32, "glGetFloatv");
  2111. #endif
  2112. }
  2113. void APIPRIVATE __glim_GetIntegerv(GLenum sq, GLint result[])
  2114. {
  2115. #ifdef NT
  2116. __glGenDoGet(sq, result, __GL_INT32, "glGetIntegerv");
  2117. #else
  2118. __glDoGet(sq, result, __GL_INT32, "glGetIntegerv");
  2119. #endif
  2120. }
  2121. void APIPRIVATE __glim_GetBooleanv(GLenum sq, GLboolean result[])
  2122. {
  2123. #ifdef NT
  2124. __glGenDoGet(sq, result, __GL_BOOLEAN, "glGetBooleanv");
  2125. #else
  2126. __glDoGet(sq, result, __GL_BOOLEAN, "glGetBooleanv");
  2127. #endif
  2128. }
  2129. /*
  2130. ** Return the current error code.
  2131. */
  2132. GLenum APIPRIVATE __glim_GetError(void)
  2133. {
  2134. __GL_SETUP();
  2135. GLint error;
  2136. #ifdef NT
  2137. // glGetError is supposed to return GL_INVALID_OPERATION within
  2138. // a glBegin/glEnd pair but this can cause problems with apps
  2139. // which don't expect it. The suggested behavior is to return
  2140. // GL_NO_ERROR inside glBegin/glEnd but set the error code to
  2141. // GL_INVALID_OPERATION so a later glGetError outside of the
  2142. // glBegin/glEnd will return it
  2143. if (__GL_IN_BEGIN())
  2144. {
  2145. error = GL_NO_ERROR;
  2146. gc->error = GL_INVALID_OPERATION;
  2147. }
  2148. else
  2149. {
  2150. #endif
  2151. error = gc->error;
  2152. gc->error = 0;
  2153. #ifdef NT
  2154. }
  2155. #endif
  2156. return error;
  2157. }