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.

835 lines
26 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. #include <stdlib.h>
  19. /******************************************************************************
  20. __GLSwriteStream
  21. ******************************************************************************/
  22. __GLSwriteStream* __glsWriteStream_create(
  23. const GLubyte *inName, GLboolean inAppend
  24. ) {
  25. __GLScontext *const ctx = __GLS_CONTEXT;
  26. __GLSwriteStream *const outStream = __glsCalloc(
  27. 1, sizeof(__GLSwriteStream)
  28. );
  29. if (!outStream) return GLS_NONE;
  30. __glsString_init(&outStream->name);
  31. if (inName[0]) {
  32. const GLubyte *openName;
  33. if (
  34. !__glsListString_prefix(
  35. ctx->writePrefix, inName, &outStream->name
  36. ) ||
  37. !(openName = __glsUCS1String(outStream->name.head))
  38. ) {
  39. return __glsWriteStream_destroy(outStream);
  40. }
  41. if (outStream->channel = fopen((const char *)openName, "rb")) {
  42. fclose(outStream->channel);
  43. } else {
  44. outStream->created = GL_TRUE;
  45. }
  46. outStream->channel = fopen(
  47. (const char *)openName, inAppend ? "ab" : "wb"
  48. );
  49. if (openName != outStream->name.head) free((GLvoid *)openName);
  50. if (outStream->channel) {
  51. setbuf(outStream->channel, GLS_NONE);
  52. outStream->opened = GL_TRUE;
  53. return outStream;
  54. }
  55. __GLS_RAISE_ERROR(GLS_STREAM_OPEN_ERROR);
  56. return __glsWriteStream_destroy(outStream);
  57. } else {
  58. outStream->writeFunc = ctx->writeFunc;
  59. if (!outStream->writeFunc) {
  60. outStream->channel = ctx->defaultWriteChannel;
  61. }
  62. return outStream;
  63. }
  64. }
  65. __GLSwriteStream* __glsWriteStream_destroy(__GLSwriteStream *inStream) {
  66. if (!inStream) return GLS_NONE;
  67. if (inStream->opened && fclose(inStream->channel)) {
  68. __GLS_RAISE_ERROR(GLS_STREAM_CLOSE_ERROR);
  69. }
  70. __glsString_final(&inStream->name);
  71. free(inStream);
  72. return GLS_NONE;
  73. }
  74. size_t __glsWriteStream_getByteCount(const __GLSwriteStream *inStream) {
  75. fpos_t pos;
  76. if (!inStream->channel) return 0;
  77. if (
  78. !fgetpos(inStream->channel, &pos) &&
  79. !fseek(inStream->channel, 0, SEEK_END)
  80. ) {
  81. const long outVal = ftell(inStream->channel);
  82. fsetpos(inStream->channel, &pos);
  83. return outVal >= 0 ? (size_t)outVal : 0;
  84. } else {
  85. return 0;
  86. }
  87. }
  88. /******************************************************************************
  89. __GLSwriter
  90. ******************************************************************************/
  91. static const GLvoid* __glsPixelBase(
  92. GLenum inType,
  93. GLint inGroupElems,
  94. GLint inStrideElems,
  95. const __GLSpixelStoreConfig *inConfig,
  96. const GLvoid *inPixels
  97. ) {
  98. GLint skipRows = inConfig->skipRows;
  99. #if __GL_EXT_texture3D
  100. skipRows += inConfig->skipImages * inConfig->imageHeight;
  101. #endif /* __GL_EXT_texture3D */
  102. #if __GL_SGIS_texture4D
  103. skipRows += (
  104. inConfig->skipVolumes *
  105. inConfig->imageDepth *
  106. inConfig->imageHeight
  107. );
  108. #endif /* __GL_SGIS_texture4D */
  109. switch (inType) {
  110. case GL_BITMAP:
  111. return (
  112. (const GLubyte *)inPixels +
  113. skipRows * inStrideElems / 8 +
  114. inConfig->skipPixels * inGroupElems / 8
  115. );
  116. case GL_BYTE:
  117. case GL_UNSIGNED_BYTE:
  118. #if __GL_EXT_packed_pixels
  119. case GL_UNSIGNED_BYTE_3_3_2_EXT:
  120. #endif /* __GL_EXT_packed_pixels */
  121. return (
  122. (const GLbyte *)inPixels +
  123. skipRows * inStrideElems +
  124. inConfig->skipPixels * inGroupElems
  125. );
  126. case GL_SHORT:
  127. case GL_UNSIGNED_SHORT:
  128. #if __GL_EXT_packed_pixels
  129. case GL_UNSIGNED_SHORT_4_4_4_4_EXT:
  130. case GL_UNSIGNED_SHORT_5_5_5_1_EXT:
  131. #endif /* __GL_EXT_packed_pixels */
  132. return (
  133. (const GLshort *)inPixels +
  134. skipRows * inStrideElems +
  135. inConfig->skipPixels * inGroupElems
  136. );
  137. case GL_FLOAT:
  138. case GL_INT:
  139. case GL_UNSIGNED_INT:
  140. #if __GL_EXT_packed_pixels
  141. case GL_UNSIGNED_INT_8_8_8_8_EXT:
  142. case GL_UNSIGNED_INT_10_10_10_2_EXT:
  143. #endif /* __GL_EXT_packed_pixels */
  144. return (
  145. (const GLint *)inPixels +
  146. skipRows * inStrideElems +
  147. inConfig->skipPixels * inGroupElems
  148. );
  149. default:
  150. return inPixels;
  151. }
  152. }
  153. static GLint __glsPixelStrideElems(
  154. GLenum inType,
  155. GLint inGroupElems,
  156. GLint inWidth,
  157. const __GLSpixelStoreConfig *inConfig
  158. ) {
  159. const GLint align = inConfig->alignment;
  160. GLint elemLog, padBytes, strideBytes;
  161. const GLint strideElems = (
  162. inGroupElems * (inConfig->rowLength ? inConfig->rowLength : inWidth)
  163. );
  164. switch (inType) {
  165. case GL_BITMAP:
  166. strideBytes = (strideElems + 7) >> 3;
  167. if (padBytes = strideBytes & align - 1) {
  168. strideBytes += align - padBytes;
  169. }
  170. return strideBytes << 3;
  171. case GL_BYTE:
  172. case GL_UNSIGNED_BYTE:
  173. #if __GL_EXT_packed_pixels
  174. case GL_UNSIGNED_BYTE_3_3_2_EXT:
  175. #endif /* __GL_EXT_packed_pixels */
  176. elemLog = 0;
  177. break;
  178. case GL_SHORT:
  179. case GL_UNSIGNED_SHORT:
  180. #if __GL_EXT_packed_pixels
  181. case GL_UNSIGNED_SHORT_4_4_4_4_EXT:
  182. case GL_UNSIGNED_SHORT_5_5_5_1_EXT:
  183. #endif /* __GL_EXT_packed_pixels */
  184. elemLog = 1;
  185. break;
  186. case GL_FLOAT:
  187. case GL_INT:
  188. case GL_UNSIGNED_INT:
  189. #if __GL_EXT_packed_pixels
  190. case GL_UNSIGNED_INT_8_8_8_8_EXT:
  191. case GL_UNSIGNED_INT_10_10_10_2_EXT:
  192. #endif /* __GL_EXT_packed_pixels */
  193. elemLog = 2;
  194. break;
  195. default:
  196. return 0;
  197. }
  198. strideBytes = strideElems << elemLog;
  199. if (padBytes = strideBytes & align - 1) {
  200. return (strideBytes + align - padBytes) >> elemLog;
  201. } else {
  202. return strideElems;
  203. }
  204. }
  205. static __GLSwriter* __glsWriter_create_context(
  206. const GLubyte *inStreamName, GLbitfield inWriteFlags
  207. ) {
  208. __GLScontext *const ctx = __GLS_CONTEXT;
  209. __GLScontextStreamBlock *block;
  210. __GLSwriter *outWriter = GLS_NONE;
  211. __GLScontextStream *stream = GLS_NONE;
  212. if (stream = __glsStr2PtrDict_find(ctx->contextStreamDict, inStreamName)) {
  213. GLint i;
  214. for (i = 0 ; i < ctx->captureNesting ; ++i) {
  215. if (ctx->writers[i]->contextStream == stream) {
  216. __GLS_RAISE_ERROR(GLS_INVALID_OPERATION);
  217. return GLS_NONE;
  218. }
  219. }
  220. if (stream->callCount) {
  221. __GLS_RAISE_ERROR(GLS_INVALID_OPERATION);
  222. return GLS_NONE;
  223. }
  224. outWriter = __glsCalloc(1, sizeof(__GLSwriter));
  225. if (!outWriter) return GLS_NONE;
  226. if (!(inWriteFlags & GLS_WRITE_APPEND_BIT)) {
  227. __glsContextStream_truncate(
  228. stream, __glsContextStream_firstBlock(stream), 0
  229. );
  230. }
  231. } else {
  232. if (
  233. !(outWriter = __glsCalloc(1, sizeof(__GLSwriter))) ||
  234. !(stream = __glsContextStream_create(inStreamName)) ||
  235. !__glsStr2PtrDict_add(ctx->contextStreamDict, inStreamName, stream)
  236. ) {
  237. __glsContextStream_destroy(stream);
  238. return __glsWriter_destroy(outWriter);
  239. }
  240. __GLS_ITERLIST_APPEND(&ctx->contextStreamList, stream);
  241. outWriter->contextCreated = GL_TRUE;
  242. }
  243. block = __glsContextStream_lastBlock(stream);
  244. __glsContextStreamBlock_removeJump(block);
  245. outWriter->bufPtr = block->writeTail;
  246. outWriter->bufTail = block->bufTail - __GLS_JUMP_ALLOC;
  247. outWriter->startBlock = block;
  248. outWriter->startOffset = (size_t)((ULONG_PTR)(block->writeTail - block->buf));
  249. outWriter->contextStream = stream;
  250. __glsWriter_initDispatch_bin(outWriter, GLS_CONTEXT);
  251. outWriter->type = GLS_CONTEXT;
  252. return outWriter;
  253. }
  254. static __GLSwriter* __glsWriter_create_extern(
  255. const GLubyte *inStreamName, GLSenum inStreamType, GLbitfield inWriteFlags
  256. ) {
  257. __GLSwriter *outWriter;
  258. outWriter = __glsCalloc(1, sizeof(__GLSwriter));
  259. if (!outWriter) return GLS_NONE;
  260. outWriter->externStream = __glsWriteStream_create(
  261. inStreamName,
  262. (GLboolean)(inWriteFlags & GLS_WRITE_APPEND_BIT ? GL_TRUE : GL_FALSE)
  263. );
  264. if (!outWriter->externStream) return __glsWriter_destroy(outWriter);
  265. outWriter->startOffset = __glsWriteStream_getByteCount(
  266. outWriter->externStream
  267. );
  268. outWriter->externBuf = outWriter->externBufHead = __glsMalloc(
  269. __GLS_WRITER_EXTERN_BUF_BYTES
  270. );
  271. if (!outWriter->externBuf) return __glsWriter_destroy(outWriter);
  272. outWriter->bufPtr = outWriter->externBufHead;
  273. /*
  274. ** bufTail is moved back from actual buffer tail to streamline ALLOC
  275. ** check for GLS_TEXT parameter writing.
  276. */
  277. outWriter->bufTail = (
  278. outWriter->externBufHead +
  279. __GLS_WRITER_EXTERN_BUF_BYTES -
  280. __GLS_WRITER_EXTERN_BUF_SLOP
  281. );
  282. if (inStreamType == GLS_TEXT) {
  283. __glsWriter_initDispatch_text(outWriter);
  284. } else {
  285. __glsWriter_initDispatch_bin(outWriter, inStreamType);
  286. }
  287. outWriter->type = inStreamType;
  288. return outWriter;
  289. }
  290. __GLSwriter* __glsWriter_create(
  291. const GLubyte *inStreamName, GLSenum inStreamType, GLbitfield inWriteFlags
  292. ) {
  293. __GLSwriter *outWriter;
  294. if (inStreamType == GLS_CONTEXT) {
  295. outWriter = __glsWriter_create_context(inStreamName, inWriteFlags);
  296. } else {
  297. outWriter = __glsWriter_create_extern(
  298. inStreamName, inStreamType, inWriteFlags
  299. );
  300. }
  301. if (outWriter) {
  302. outWriter->beginCommand(outWriter, GLS_OP_glsBeginGLS, 8);
  303. outWriter->putGLint(outWriter, __GLS_VERSION_MAJOR);
  304. outWriter->putGLint(outWriter, __GLS_VERSION_MINOR);
  305. outWriter->endCommand(outWriter);
  306. __glsWriter_flush(outWriter);
  307. }
  308. return outWriter;
  309. }
  310. __GLSwriter* __glsWriter_destroy(__GLSwriter *inWriter) {
  311. if (!inWriter) return GLS_NONE;
  312. if (inWriter->type != GLS_NONE) {
  313. if (inWriter->beginCommand(inWriter, GLS_OP_glsEndGLS, 0)) {
  314. inWriter->endCommand(inWriter);
  315. }
  316. __glsWriter_flush(inWriter);
  317. if (inWriter->type == GLS_CONTEXT) {
  318. __GLScontextStreamBlock *endBlock;
  319. if (inWriter->error && inWriter->contextCreated) {
  320. __glsStrDict_remove(
  321. __GLS_CONTEXT->contextStreamDict,
  322. inWriter->contextStream->name.head
  323. );
  324. __GLS_ITERLIST_REMOVE_DESTROY(
  325. &__GLS_CONTEXT->contextStreamList,
  326. inWriter->contextStream,
  327. __glsContextStream_destroy
  328. );
  329. } else if (inWriter->error) {
  330. endBlock = inWriter->startBlock;
  331. endBlock->writeTail = endBlock->buf + inWriter->startOffset;
  332. __glsContextStream_truncate(
  333. inWriter->contextStream,
  334. endBlock,
  335. (size_t)((ULONG_PTR)(endBlock->writeTail - endBlock->buf))
  336. );
  337. } else {
  338. endBlock = __glsContextStream_lastBlock(
  339. inWriter->contextStream
  340. );
  341. endBlock->writeTail = inWriter->bufPtr;
  342. __glsContextStream_truncate(
  343. inWriter->contextStream,
  344. endBlock,
  345. (size_t)((ULONG_PTR)(endBlock->writeTail - endBlock->buf))
  346. );
  347. }
  348. } else {
  349. if (inWriter->error && inWriter->externStream->opened) {
  350. if (inWriter->externStream->created) {
  351. if (
  352. remove((const char *)inWriter->externStream->name.head)
  353. ) {
  354. __GLS_RAISE_ERROR(GLS_STREAM_DELETE_ERROR);
  355. }
  356. } else if (inWriter->externStream->channel) {
  357. __GLS_TRUNCATE_EXTERN(
  358. inWriter->externStream->channel, inWriter->startOffset
  359. );
  360. }
  361. }
  362. }
  363. }
  364. free(inWriter->externBuf);
  365. __glsWriteStream_destroy(inWriter->externStream);
  366. free(inWriter);
  367. return GLS_NONE;
  368. }
  369. GLboolean __glsWriter_flush(__GLSwriter *inoutWriter) {
  370. if (inoutWriter->error) return GL_FALSE;
  371. inoutWriter->prevCommand = GLS_NONE;
  372. if (inoutWriter->type == GLS_CONTEXT) {
  373. return GL_TRUE;
  374. } else {
  375. FILE *channel;
  376. const size_t n = (size_t)((ULONG_PTR)(inoutWriter->bufPtr - inoutWriter->externBufHead));
  377. if (!n) return GL_TRUE;
  378. if (channel = inoutWriter->externStream->channel) {
  379. if (
  380. fwrite(inoutWriter->externBufHead, 1, n, channel) == n &&
  381. !fflush(channel)
  382. ) {
  383. inoutWriter->externBufHead = (
  384. (inoutWriter->wordCount & 1) ?
  385. inoutWriter->externBuf + 4 :
  386. inoutWriter->externBuf
  387. );
  388. inoutWriter->bufPtr = inoutWriter->externBufHead;
  389. return GL_TRUE;
  390. } else {
  391. __GLS_RAISE_ERROR(GLS_STREAM_WRITE_ERROR);
  392. clearerr(channel);
  393. inoutWriter->error = GL_TRUE;
  394. return GL_FALSE;
  395. }
  396. } else {
  397. if (
  398. inoutWriter->externStream->writeFunc(
  399. n, inoutWriter->externBufHead
  400. )
  401. == n
  402. ) {
  403. inoutWriter->externBufHead = (
  404. (inoutWriter->wordCount & 1) ?
  405. inoutWriter->externBuf + 4 :
  406. inoutWriter->externBuf
  407. );
  408. inoutWriter->bufPtr = inoutWriter->externBufHead;
  409. return GL_TRUE;
  410. } else {
  411. __GLS_RAISE_ERROR(GLS_STREAM_WRITE_ERROR);
  412. inoutWriter->error = GL_TRUE;
  413. return GL_FALSE;
  414. }
  415. }
  416. }
  417. }
  418. void __glsWriter_putListv(
  419. __GLSwriter *inoutWriter,
  420. GLenum inType,
  421. GLint inCount,
  422. const GLvoid *inVec
  423. ) {
  424. switch (inType) {
  425. case GL_2_BYTES:
  426. inoutWriter->putGLubytev(
  427. inoutWriter, 2 * inCount, (const GLubyte *)inVec
  428. );
  429. break;
  430. case GL_3_BYTES:
  431. inoutWriter->putGLubytev(
  432. inoutWriter, 3 * inCount, (const GLubyte *)inVec
  433. );
  434. break;
  435. case GL_4_BYTES:
  436. inoutWriter->putGLubytev(
  437. inoutWriter, 4 * inCount, (const GLubyte *)inVec
  438. );
  439. break;
  440. case GL_BYTE:
  441. inoutWriter->putGLbytev(
  442. inoutWriter, inCount, (const GLbyte *)inVec
  443. );
  444. break;
  445. case GL_FLOAT:
  446. inoutWriter->putGLfloatv(
  447. inoutWriter, inCount, (const GLfloat *)inVec
  448. );
  449. break;
  450. case GL_INT:
  451. inoutWriter->putGLintv(
  452. inoutWriter, inCount, (const GLint *)inVec
  453. );
  454. break;
  455. case GL_SHORT:
  456. inoutWriter->putGLshortv(
  457. inoutWriter, inCount, (const GLshort *)inVec
  458. );
  459. break;
  460. case GL_UNSIGNED_BYTE:
  461. inoutWriter->putGLubytev(
  462. inoutWriter, inCount, (const GLubyte *)inVec
  463. );
  464. break;
  465. case GL_UNSIGNED_INT:
  466. inoutWriter->putGLuintv(
  467. inoutWriter, inCount, (const GLuint *)inVec
  468. );
  469. break;
  470. case GL_UNSIGNED_SHORT:
  471. inoutWriter->putGLushortv(
  472. inoutWriter, inCount, (const GLushort *)inVec
  473. );
  474. break;
  475. default:
  476. inoutWriter->putGLbytev(inoutWriter, 0, GLS_NONE);
  477. break;
  478. }
  479. }
  480. void __glsWriter_putPixelv(
  481. __GLSwriter *inoutWriter,
  482. GLenum inFormat,
  483. GLenum inType,
  484. GLint inWidth,
  485. GLint inHeight,
  486. const GLvoid *inVec
  487. ) {
  488. GLint groupElems;
  489. GLint rowElems;
  490. GLint strideElems;
  491. __GLSpixelStoreConfig pixelStore;
  492. if (!inVec) inType = GLS_NONE;
  493. __glsPixelStoreConfig_get_unpack(&pixelStore);
  494. switch (inFormat) {
  495. case GL_ALPHA:
  496. case GL_BLUE:
  497. case GL_COLOR_INDEX:
  498. case GL_DEPTH_COMPONENT:
  499. case GL_GREEN:
  500. case GL_LUMINANCE:
  501. case GL_RED:
  502. case GL_STENCIL_INDEX:
  503. groupElems = 1;
  504. break;
  505. case GL_LUMINANCE_ALPHA:
  506. groupElems = 2;
  507. break;
  508. case GL_RGB:
  509. #if __GL_EXT_bgra
  510. case GL_BGR_EXT:
  511. #endif
  512. groupElems = 3;
  513. break;
  514. case GL_RGBA:
  515. #if __GL_EXT_bgra
  516. case GL_BGRA_EXT:
  517. #endif
  518. groupElems = 4;
  519. break;
  520. #if __GL_EXT_abgr
  521. case GL_ABGR_EXT:
  522. groupElems = 4;
  523. break;
  524. #endif /* __GL_EXT_abgr */
  525. #if __GL_EXT_cmyka
  526. case GL_CMYK_EXT:
  527. groupElems = 4;
  528. break;
  529. case GL_CMYKA_EXT:
  530. groupElems = 5;
  531. break;
  532. #endif /* __GL_EXT_cmyka */
  533. default:
  534. groupElems = 0;
  535. inType = GLS_NONE;
  536. }
  537. #if __GL_EXT_packed_pixels
  538. switch (inType) {
  539. case GL_UNSIGNED_BYTE_3_3_2_EXT:
  540. if (groupElems != 3) inType = GLS_NONE;
  541. break;
  542. case GL_UNSIGNED_SHORT_4_4_4_4_EXT:
  543. case GL_UNSIGNED_SHORT_5_5_5_1_EXT:
  544. case GL_UNSIGNED_INT_8_8_8_8_EXT:
  545. case GL_UNSIGNED_INT_10_10_10_2_EXT:
  546. if (groupElems != 4) inType = GLS_NONE;
  547. break;
  548. }
  549. #endif /* __GL_EXT_packed_pixels */
  550. rowElems = groupElems * inWidth;
  551. strideElems = __glsPixelStrideElems(
  552. inType, groupElems, inWidth, &pixelStore
  553. );
  554. switch (inType) {
  555. case GL_BITMAP:
  556. inoutWriter->putGLbitvs(
  557. inoutWriter,
  558. (GLboolean)pixelStore.lsbFirst,
  559. pixelStore.skipPixels * groupElems & 7,
  560. rowElems,
  561. strideElems - rowElems,
  562. inHeight,
  563. (const GLubyte *)__glsPixelBase(
  564. inType, groupElems, strideElems, &pixelStore, inVec
  565. )
  566. );
  567. break;
  568. case GL_BYTE:
  569. inoutWriter->putGLbytevs(
  570. inoutWriter,
  571. GL_FALSE,
  572. rowElems,
  573. strideElems - rowElems,
  574. inHeight,
  575. 0,
  576. 1,
  577. (const GLbyte *)__glsPixelBase(
  578. inType, groupElems, strideElems, &pixelStore, inVec
  579. )
  580. );
  581. break;
  582. case GL_FLOAT:
  583. inoutWriter->putGLfloatvs(
  584. inoutWriter,
  585. (GLboolean)pixelStore.swapBytes,
  586. rowElems,
  587. (strideElems - rowElems) * 4,
  588. inHeight,
  589. 0,
  590. 1,
  591. (const GLfloat *)__glsPixelBase(
  592. inType, groupElems, strideElems, &pixelStore, inVec
  593. )
  594. );
  595. break;
  596. case GL_INT:
  597. inoutWriter->putGLintvs(
  598. inoutWriter,
  599. (GLboolean)pixelStore.swapBytes,
  600. rowElems,
  601. (strideElems - rowElems) * 4,
  602. inHeight,
  603. 0,
  604. 1,
  605. (const GLint *)__glsPixelBase(
  606. inType, groupElems, strideElems, &pixelStore, inVec
  607. )
  608. );
  609. break;
  610. case GL_SHORT:
  611. inoutWriter->putGLshortvs(
  612. inoutWriter,
  613. (GLboolean)pixelStore.swapBytes,
  614. rowElems,
  615. (strideElems - rowElems) * 2,
  616. inHeight,
  617. 0,
  618. 1,
  619. (const GLshort *)__glsPixelBase(
  620. inType, groupElems, strideElems, &pixelStore, inVec
  621. )
  622. );
  623. break;
  624. case GL_UNSIGNED_BYTE:
  625. #if __GL_EXT_packed_pixels
  626. case GL_UNSIGNED_BYTE_3_3_2_EXT:
  627. #endif /* __GL_EXT_packed_pixels */
  628. inoutWriter->putGLubytevs(
  629. inoutWriter,
  630. GL_FALSE,
  631. rowElems,
  632. strideElems - rowElems,
  633. inHeight,
  634. 0,
  635. 1,
  636. (const GLubyte *)__glsPixelBase(
  637. inType, groupElems, strideElems, &pixelStore, inVec
  638. )
  639. );
  640. break;
  641. case GL_UNSIGNED_INT:
  642. #if __GL_EXT_packed_pixels
  643. case GL_UNSIGNED_INT_8_8_8_8_EXT:
  644. case GL_UNSIGNED_INT_10_10_10_2_EXT:
  645. #endif /* __GL_EXT_packed_pixels */
  646. inoutWriter->putGLuintvs(
  647. inoutWriter,
  648. (GLboolean)pixelStore.swapBytes,
  649. rowElems,
  650. (strideElems - rowElems) * 4,
  651. inHeight,
  652. 0,
  653. 1,
  654. (const GLuint *)__glsPixelBase(
  655. inType, groupElems, strideElems, &pixelStore, inVec
  656. )
  657. );
  658. break;
  659. case GL_UNSIGNED_SHORT:
  660. #if __GL_EXT_packed_pixels
  661. case GL_UNSIGNED_SHORT_4_4_4_4_EXT:
  662. case GL_UNSIGNED_SHORT_5_5_5_1_EXT:
  663. #endif /* __GL_EXT_packed_pixels */
  664. inoutWriter->putGLushortvs(
  665. inoutWriter,
  666. (GLboolean)pixelStore.swapBytes,
  667. rowElems,
  668. (strideElems - rowElems) * 2,
  669. inHeight,
  670. 0,
  671. 1,
  672. (const GLushort *)__glsPixelBase(
  673. inType, groupElems, strideElems, &pixelStore, inVec
  674. )
  675. );
  676. break;
  677. default:
  678. inoutWriter->putGLbytev(inoutWriter, 0, GLS_NONE);
  679. break;
  680. }
  681. }
  682. // DrewB - Always enabled for 1.1 support
  683. void __glsWriter_putVertexv(
  684. __GLSwriter *inoutWriter,
  685. GLint inSize,
  686. GLenum inType,
  687. GLint inStride,
  688. GLint inCount,
  689. const GLvoid *inVec
  690. ) {
  691. if (!inVec) inType = GLS_NONE;
  692. switch (inType) {
  693. case __GLS_BOOLEAN:
  694. inoutWriter->putGLbooleanvs(
  695. inoutWriter,
  696. GL_FALSE,
  697. inSize,
  698. inStride ? inStride - inSize : 0,
  699. inCount,
  700. 0,
  701. 1,
  702. (const GLboolean *)inVec
  703. );
  704. break;
  705. case GL_BYTE:
  706. inoutWriter->putGLbytevs(
  707. inoutWriter,
  708. GL_FALSE,
  709. inSize,
  710. inStride ? inStride - inSize : 0,
  711. inCount,
  712. 0,
  713. 1,
  714. (const GLbyte *)inVec
  715. );
  716. break;
  717. case GL_DOUBLE_EXT:
  718. inoutWriter->putGLdoublevs(
  719. inoutWriter,
  720. GL_FALSE,
  721. inSize,
  722. inStride ? inStride - inSize * 8 : 0,
  723. inCount,
  724. 0,
  725. 1,
  726. (const GLdouble *)inVec
  727. );
  728. break;
  729. case GL_FLOAT:
  730. inoutWriter->putGLfloatvs(
  731. inoutWriter,
  732. GL_FALSE,
  733. inSize,
  734. inStride ? inStride - inSize * 4 : 0,
  735. inCount,
  736. 0,
  737. 1,
  738. (const GLfloat *)inVec
  739. );
  740. break;
  741. case GL_INT:
  742. inoutWriter->putGLintvs(
  743. inoutWriter,
  744. GL_FALSE,
  745. inSize,
  746. inStride ? inStride - inSize * 4 : 0,
  747. inCount,
  748. 0,
  749. 1,
  750. (const GLint *)inVec
  751. );
  752. break;
  753. case GL_SHORT:
  754. inoutWriter->putGLshortvs(
  755. inoutWriter,
  756. GL_FALSE,
  757. inSize,
  758. inStride ? inStride - inSize * 2 : 0,
  759. inCount,
  760. 0,
  761. 1,
  762. (const GLshort *)inVec
  763. );
  764. break;
  765. case GL_UNSIGNED_BYTE:
  766. inoutWriter->putGLubytevs(
  767. inoutWriter,
  768. GL_FALSE,
  769. inSize,
  770. inStride ? inStride - inSize : 0,
  771. inCount,
  772. 0,
  773. 1,
  774. (const GLubyte *)inVec
  775. );
  776. break;
  777. case GL_UNSIGNED_INT:
  778. inoutWriter->putGLuintvs(
  779. inoutWriter,
  780. GL_FALSE,
  781. inSize,
  782. inStride ? inStride - inSize * 4 : 0,
  783. inCount,
  784. 0,
  785. 1,
  786. (const GLuint *)inVec
  787. );
  788. break;
  789. case GL_UNSIGNED_SHORT:
  790. inoutWriter->putGLushortvs(
  791. inoutWriter,
  792. GL_FALSE,
  793. inSize,
  794. inStride ? inStride - inSize * 2 : 0,
  795. inCount,
  796. 0,
  797. 1,
  798. (const GLushort *)inVec
  799. );
  800. break;
  801. default:
  802. inoutWriter->putGLbytev(inoutWriter, 0, GLS_NONE);
  803. break;
  804. }
  805. }