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

942 lines
24 KiB

  1. /*
  2. ** Copyright 1991,1992, 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. ** $Revision: 1.15 $
  18. ** $Date: 1993/10/23 00:34:54 $
  19. */
  20. #include "precomp.h"
  21. #pragma hdrstop
  22. #include "listcomp.h"
  23. #include "g_listop.h"
  24. #include "lcfuncs.h"
  25. #include "dlist.h"
  26. #include "dlistopt.h"
  27. #ifndef NT
  28. // Move to dlist.
  29. /*
  30. ** The code in here makes a lot of assumptions about the size of the
  31. ** various user types (GLfloat, GLint, etcetra).
  32. */
  33. #define __GL_IMAGE_BITMAP 0
  34. #define __GL_IMAGE_INDICES 1
  35. #define __GL_IMAGE_RGBA 2
  36. void __gllc_Bitmap(GLsizei width, GLsizei height,
  37. GLfloat xorig, GLfloat yorig,
  38. GLfloat xmove, GLfloat ymove,
  39. const GLubyte *oldbits)
  40. {
  41. __GLbitmap *bitmap;
  42. GLubyte *newbits;
  43. GLint imageSize;
  44. __GL_SETUP();
  45. if ((width < 0) || (height < 0)) {
  46. __gllc_InvalidValue(gc);
  47. return;
  48. }
  49. imageSize = height * ((width + 7) >> 3);
  50. imageSize = __GL_PAD(imageSize);
  51. bitmap = (__GLbitmap *)
  52. __glDlistAddOpUnaligned(gc, DLIST_SIZE(imageSize + sizeof(__GLbitmap)),
  53. DLIST_GENERIC_OP(Bitmap));
  54. if (bitmap == NULL) return;
  55. bitmap->width = width;
  56. bitmap->height = height;
  57. bitmap->xorig = xorig;
  58. bitmap->yorig = yorig;
  59. bitmap->xmove = xmove;
  60. bitmap->ymove = ymove;
  61. bitmap->imageSize = imageSize;
  62. newbits = (GLubyte *)bitmap + sizeof(__GLbitmap);
  63. __glFillImage(gc, width, height, GL_COLOR_INDEX, GL_BITMAP,
  64. oldbits, newbits);
  65. __glDlistAppendOp(gc, bitmap, __glle_Bitmap);
  66. }
  67. const GLubyte *__glle_Bitmap(const GLubyte *PC)
  68. {
  69. const __GLbitmap *bitmap;
  70. __GL_SETUP();
  71. GLuint beginMode;
  72. bitmap = (const __GLbitmap *) PC;
  73. beginMode = gc->beginMode;
  74. if (beginMode != __GL_NOT_IN_BEGIN) {
  75. if (beginMode == __GL_NEED_VALIDATE) {
  76. (*gc->procs.validate)(gc);
  77. gc->beginMode = __GL_NOT_IN_BEGIN;
  78. } else {
  79. __glSetError(GL_INVALID_OPERATION);
  80. return PC + sizeof(__GLbitmap) + bitmap->imageSize;
  81. }
  82. }
  83. (*gc->procs.renderBitmap)(gc, bitmap, (const GLubyte *) (bitmap+1));
  84. return PC + sizeof(__GLbitmap) + bitmap->imageSize;
  85. }
  86. void FASTCALL __gllei_PolygonStipple(__GLcontext *gc, const GLubyte *bits)
  87. {
  88. if (__GL_IN_BEGIN()) {
  89. __glSetError(GL_INVALID_OPERATION);
  90. return;
  91. }
  92. /*
  93. ** Just copy bits into stipple, convertPolygonStipple() will do the rest.
  94. */
  95. __GL_MEMCOPY(&gc->state.polygonStipple.stipple[0], bits,
  96. sizeof(gc->state.polygonStipple.stipple));
  97. (*gc->procs.convertPolygonStipple)(gc);
  98. #ifdef _MCD_
  99. MCD_STATE_DIRTY(gc, POLYDRAW);
  100. #endif
  101. }
  102. void __gllc_PolygonStipple(const GLubyte *mask)
  103. {
  104. void *data;
  105. __GL_SETUP();
  106. GLubyte *newbits;
  107. newbits = (GLubyte *)
  108. __glDlistAddOpUnaligned(gc, DLIST_SIZE(__glImageSize(32, 32, GL_COLOR_INDEX, GL_BITMAP)),
  109. DLIST_GENERIC_OP(PolygonStipple));
  110. if (newbits == NULL) return;
  111. __glFillImage(gc, 32, 32, GL_COLOR_INDEX, GL_BITMAP, mask, newbits);
  112. __glDlistAppendOp(gc, newbits, __glle_PolygonStipple);
  113. }
  114. const GLubyte *__glle_PolygonStipple(const GLubyte *PC)
  115. {
  116. __GL_SETUP();
  117. __gllei_PolygonStipple(gc, (const GLubyte *) (PC));
  118. return PC + __glImageSize(32, 32, GL_COLOR_INDEX, GL_BITMAP);
  119. }
  120. typedef struct __GLmap1_Rec {
  121. GLenum target;
  122. __GLfloat u1;
  123. __GLfloat u2;
  124. GLint order;
  125. /* points */
  126. } __GLmap1;
  127. void __gllc_Map1f(GLenum target,
  128. GLfloat u1, GLfloat u2,
  129. GLint stride, GLint order,
  130. const GLfloat *points)
  131. {
  132. __GLmap1 *map1data;
  133. GLint k;
  134. GLint cmdsize;
  135. __GLfloat *data;
  136. __GL_SETUP();
  137. k=__glEvalComputeK(target);
  138. if (k < 0) {
  139. __gllc_InvalidEnum(gc);
  140. return;
  141. }
  142. if (order > gc->constants.maxEvalOrder || stride < k ||
  143. order < 1 || u1 == u2) {
  144. __gllc_InvalidValue(gc);
  145. return;
  146. }
  147. cmdsize = sizeof(__GLmap1) +
  148. __glMap1_size(k, order) * sizeof(__GLfloat);
  149. map1data = (__GLmap1 *)
  150. __glDlistAddOpUnaligned(gc, DLIST_SIZE(cmdsize), DLIST_GENERIC_OP(Map1));
  151. if (map1data == NULL) return;
  152. map1data->target = target;
  153. map1data->u1 = u1;
  154. map1data->u2 = u2;
  155. map1data->order = order;
  156. data = (__GLfloat *) ((GLubyte *)map1data + sizeof(__GLmap1));
  157. __glFillMap1f(k, order, stride, points, data);
  158. __glDlistAppendOp(gc, map1data, __glle_Map1);
  159. }
  160. const GLubyte *__glle_Map1(const GLubyte *PC)
  161. {
  162. __GL_SETUP();
  163. const __GLmap1 *map1data;
  164. GLint k;
  165. map1data = (const __GLmap1 *) PC;
  166. k = __glEvalComputeK(map1data->target);
  167. /* Stride of "k" matches internal stride */
  168. #ifdef __GL_DOUBLE
  169. (*gc->dispatchState->dispatch->Map1d)
  170. #else /* __GL_DOUBLE */
  171. (*gc->dispatchState->dispatch->Map1f)
  172. #endif /* __GL_DOUBLE */
  173. (map1data->target, map1data->u1, map1data->u2,
  174. k, map1data->order, (const __GLfloat *)(PC + sizeof(__GLmap1)));
  175. return PC + sizeof(__GLmap1) +
  176. __glMap1_size(k, map1data->order) * sizeof(__GLfloat);
  177. }
  178. void __gllc_Map1d(GLenum target,
  179. GLdouble u1, GLdouble u2,
  180. GLint stride, GLint order,
  181. const GLdouble *points)
  182. {
  183. __GLmap1 *map1data;
  184. GLint k;
  185. GLint cmdsize;
  186. __GLfloat *data;
  187. __GL_SETUP();
  188. k=__glEvalComputeK(target);
  189. if (k < 0) {
  190. __gllc_InvalidEnum(gc);
  191. return;
  192. }
  193. if (order > gc->constants.maxEvalOrder || stride < k ||
  194. order < 1 || u1 == u2) {
  195. __gllc_InvalidValue(gc);
  196. return;
  197. }
  198. cmdsize = sizeof(__GLmap1) +
  199. __glMap1_size(k, order) * sizeof(__GLfloat);
  200. map1data = (__GLmap1 *)
  201. __glDlistAddOpUnaligned(gc, DLIST_SIZE(cmdsize), DLIST_GENERIC_OP(Map1));
  202. if (map1data == NULL) return;
  203. map1data->target = target;
  204. map1data->u1 = u1;
  205. map1data->u2 = u2;
  206. map1data->order = order;
  207. data = (__GLfloat *) ((GLubyte *)map1data + sizeof(__GLmap1));
  208. __glFillMap1d(k, order, stride, points, data);
  209. __glDlistAppendOp(gc, map1data, __glle_Map1);
  210. }
  211. typedef struct __GLmap2_Rec {
  212. GLenum target;
  213. __GLfloat u1;
  214. __GLfloat u2;
  215. GLint uorder;
  216. __GLfloat v1;
  217. __GLfloat v2;
  218. GLint vorder;
  219. /* points */
  220. } __GLmap2;
  221. void __gllc_Map2f(GLenum target,
  222. GLfloat u1, GLfloat u2,
  223. GLint ustride, GLint uorder,
  224. GLfloat v1, GLfloat v2,
  225. GLint vstride, GLint vorder,
  226. const GLfloat *points)
  227. {
  228. __GLmap2 *map2data;
  229. GLint k;
  230. GLint cmdsize;
  231. __GLfloat *data;
  232. __GL_SETUP();
  233. k=__glEvalComputeK(target);
  234. if (k < 0) {
  235. __gllc_InvalidEnum(gc);
  236. return;
  237. }
  238. if (vorder > gc->constants.maxEvalOrder || vstride < k ||
  239. vorder < 1 || u1 == u2 || ustride < k ||
  240. uorder > gc->constants.maxEvalOrder || uorder < 1 ||
  241. v1 == v2) {
  242. __gllc_InvalidValue(gc);
  243. return;
  244. }
  245. cmdsize = sizeof(__GLmap2) +
  246. __glMap2_size(k, uorder, vorder) * sizeof(__GLfloat);
  247. map2data = (__GLmap2 *)
  248. __glDlistAddOpUnaligned(gc, DLIST_SIZE(cmdsize), DLIST_GENERIC_OP(Map2));
  249. if (map2data == NULL) return;
  250. map2data->target = target;
  251. map2data->u1 = u1;
  252. map2data->u2 = u2;
  253. map2data->uorder = uorder;
  254. map2data->v1 = v1;
  255. map2data->v2 = v2;
  256. map2data->vorder = vorder;
  257. data = (__GLfloat *) ((GLubyte *)map2data + sizeof(__GLmap2));
  258. __glFillMap2f(k, uorder, vorder, ustride, vstride, points, data);
  259. __glDlistAppendOp(gc, map2data, __glle_Map2);
  260. }
  261. const GLubyte *__glle_Map2(const GLubyte *PC)
  262. {
  263. __GL_SETUP();
  264. const __GLmap2 *map2data;
  265. GLint k;
  266. map2data = (const __GLmap2 *) PC;
  267. k = __glEvalComputeK(map2data->target);
  268. /* Stride of "k" and "k * vorder" matches internal strides */
  269. #ifdef __GL_DOUBLE
  270. (*gc->dispatchState->dispatch->Map2d)
  271. #else /* __GL_DOUBLE */
  272. (*gc->dispatchState->dispatch->Map2f)
  273. #endif /* __GL_DOUBLE */
  274. (map2data->target,
  275. map2data->u1, map2data->u2, k * map2data->vorder, map2data->uorder,
  276. map2data->v1, map2data->v2, k, map2data->vorder,
  277. (const __GLfloat *)(PC + sizeof(__GLmap2)));
  278. return PC + sizeof(__GLmap2) +
  279. __glMap2_size(k, map2data->uorder, map2data->vorder) *
  280. sizeof(__GLfloat);
  281. }
  282. void __gllc_Map2d(GLenum target,
  283. GLdouble u1, GLdouble u2,
  284. GLint ustride, GLint uorder,
  285. GLdouble v1, GLdouble v2,
  286. GLint vstride, GLint vorder,
  287. const GLdouble *points)
  288. {
  289. __GLmap2 *map2data;
  290. GLint k;
  291. GLint cmdsize;
  292. __GLfloat *data;
  293. __GL_SETUP();
  294. k=__glEvalComputeK(target);
  295. if (k < 0) {
  296. __gllc_InvalidEnum(gc);
  297. return;
  298. }
  299. if (vorder > gc->constants.maxEvalOrder || vstride < k ||
  300. vorder < 1 || u1 == u2 || ustride < k ||
  301. uorder > gc->constants.maxEvalOrder || uorder < 1 ||
  302. v1 == v2) {
  303. __gllc_InvalidValue(gc);
  304. return;
  305. }
  306. cmdsize = sizeof(__GLmap2) +
  307. __glMap2_size(k, uorder, vorder) * sizeof(__GLfloat);
  308. map2data = (__GLmap2 *)
  309. __glDlistAddOpUnaligned(gc, DLIST_SIZE(cmdsize), DLIST_GENERIC_OP(Map2));
  310. if (map2data == NULL) return;
  311. map2data->target = target;
  312. map2data->u1 = u1;
  313. map2data->u2 = u2;
  314. map2data->uorder = uorder;
  315. map2data->v1 = v1;
  316. map2data->v2 = v2;
  317. map2data->vorder = vorder;
  318. data = (__GLfloat *) ((GLubyte *)map2data + sizeof(__GLmap2));
  319. __glFillMap2d(k, uorder, vorder, ustride, vstride, points, data);
  320. __glDlistAppendOp(gc, map2data, __glle_Map2);
  321. }
  322. typedef struct __GLdrawPixels_Rec {
  323. GLsizei width;
  324. GLsizei height;
  325. GLenum format;
  326. GLenum type;
  327. /* pixels */
  328. } __GLdrawPixels;
  329. const GLubyte *__glle_DrawPixels(const GLubyte *PC)
  330. {
  331. const __GLdrawPixels *pixdata;
  332. GLint imageSize;
  333. __GL_SETUP();
  334. GLuint beginMode;
  335. pixdata = (const __GLdrawPixels *) PC;
  336. imageSize = __glImageSize(pixdata->width, pixdata->height,
  337. pixdata->format, pixdata->type);
  338. beginMode = gc->beginMode;
  339. if (beginMode != __GL_NOT_IN_BEGIN) {
  340. if (beginMode == __GL_NEED_VALIDATE) {
  341. (*gc->procs.validate)(gc);
  342. gc->beginMode = __GL_NOT_IN_BEGIN;
  343. } else {
  344. __glSetError(GL_INVALID_OPERATION);
  345. return PC + sizeof(__GLdrawPixels) + __GL_PAD(imageSize);
  346. }
  347. }
  348. (*gc->procs.drawPixels)(gc, pixdata->width, pixdata->height,
  349. pixdata->format, pixdata->type,
  350. (const GLubyte *)(PC + sizeof(__GLdrawPixels)),
  351. GL_TRUE);
  352. return PC + sizeof(__GLdrawPixels) + __GL_PAD(imageSize);
  353. }
  354. void __gllc_DrawPixels(GLint width, GLint height, GLenum format,
  355. GLenum type, const GLvoid *pixels)
  356. {
  357. __GLdrawPixels *pixdata;
  358. GLint imageSize;
  359. GLboolean index;
  360. __GL_SETUP();
  361. if ((width < 0) || (height < 0)) {
  362. __gllc_InvalidValue(gc);
  363. return;
  364. }
  365. switch (format) {
  366. case GL_STENCIL_INDEX:
  367. case GL_COLOR_INDEX:
  368. index = GL_TRUE;
  369. break;
  370. case GL_RED:
  371. case GL_GREEN:
  372. case GL_BLUE:
  373. case GL_ALPHA:
  374. case GL_RGB:
  375. case GL_RGBA:
  376. #ifdef GL_EXT_bgra
  377. case GL_BGR_EXT:
  378. case GL_BGRA_EXT:
  379. #endif
  380. case GL_LUMINANCE:
  381. case GL_LUMINANCE_ALPHA:
  382. case GL_DEPTH_COMPONENT:
  383. index = GL_FALSE;
  384. break;
  385. default:
  386. __gllc_InvalidEnum(gc);
  387. return;
  388. }
  389. switch (type) {
  390. case GL_BITMAP:
  391. if (!index) {
  392. __gllc_InvalidEnum(gc);
  393. return;
  394. }
  395. break;
  396. case GL_BYTE:
  397. case GL_UNSIGNED_BYTE:
  398. case GL_SHORT:
  399. case GL_UNSIGNED_SHORT:
  400. case GL_INT:
  401. case GL_UNSIGNED_INT:
  402. case GL_FLOAT:
  403. break;
  404. default:
  405. __gllc_InvalidEnum(gc);
  406. return;
  407. }
  408. imageSize = __glImageSize(width, height, format, type);
  409. imageSize = __GL_PAD(imageSize);
  410. pixdata = (__GLdrawPixels *)
  411. __glDlistAddOpUnaligned(gc, DLIST_SIZE(sizeof(__GLdrawPixels) + imageSize),
  412. DLIST_GENERIC_OP(DrawPixels));
  413. if (pixdata == NULL) return;
  414. pixdata->width = width;
  415. pixdata->height = height;
  416. pixdata->format = format;
  417. pixdata->type = type;
  418. __glFillImage(gc, width, height, format, type, pixels,
  419. (GLubyte *)pixdata + sizeof(__GLdrawPixels));
  420. __glDlistAppendOp(gc, pixdata, __glle_DrawPixels);
  421. }
  422. typedef struct __GLtexImage1D_Rec {
  423. GLenum target;
  424. GLint level;
  425. GLint components;
  426. GLsizei width;
  427. GLint border;
  428. GLenum format;
  429. GLenum type;
  430. GLint imageSize;
  431. /* pixels */
  432. } __GLtexImage1D;
  433. const GLubyte *__glle_TexImage1D(const GLubyte *PC)
  434. {
  435. __GL_SETUP();
  436. const __GLtexImage1D *data;
  437. data = (const __GLtexImage1D *) PC;
  438. __gllei_TexImage1D(gc, data->target, data->level, data->components,
  439. data->width, data->border, data->format, data->type,
  440. (const GLubyte *)(PC + sizeof(__GLtexImage1D)));
  441. return PC + sizeof(__GLtexImage1D) + __GL_PAD(data->imageSize);
  442. }
  443. typedef struct __GLtexImage2D_Rec {
  444. GLenum target;
  445. GLint level;
  446. GLint components;
  447. GLsizei width;
  448. GLsizei height;
  449. GLint border;
  450. GLenum format;
  451. GLenum type;
  452. GLint imageSize;
  453. /* pixels */
  454. } __GLtexImage2D;
  455. const GLubyte *__glle_TexImage2D(const GLubyte *PC)
  456. {
  457. __GL_SETUP();
  458. const __GLtexImage2D *data;
  459. data = (const __GLtexImage2D *) PC;
  460. __gllei_TexImage2D(gc, data->target, data->level, data->components,
  461. data->width, data->height, data->border, data->format,
  462. data->type,
  463. (const GLubyte *)(PC + sizeof(__GLtexImage2D)));
  464. return PC + sizeof(__GLtexImage2D) + __GL_PAD(data->imageSize);
  465. }
  466. void __gllc_TexImage1D(GLenum target, GLint level,
  467. GLint components,
  468. GLint width, GLint border, GLenum format,
  469. GLenum type, const GLvoid *pixels)
  470. {
  471. __GLtexImage1D *texdata;
  472. GLint imageSize;
  473. GLboolean index;
  474. __GL_SETUP();
  475. if (border < 0 || border > 1) {
  476. __gllc_InvalidValue(gc);
  477. return;
  478. }
  479. if (width < 0) {
  480. __gllc_InvalidValue(gc);
  481. return;
  482. }
  483. switch (format) {
  484. case GL_COLOR_INDEX:
  485. index = GL_TRUE;
  486. break;
  487. case GL_RED:
  488. case GL_GREEN:
  489. case GL_BLUE:
  490. case GL_ALPHA:
  491. case GL_RGB:
  492. case GL_RGBA:
  493. #ifdef GL_EXT_bgra
  494. case GL_BGR_EXT:
  495. case GL_BGRA_EXT:
  496. #endif
  497. case GL_LUMINANCE:
  498. case GL_LUMINANCE_ALPHA:
  499. index = GL_FALSE;
  500. break;
  501. default:
  502. __gllc_InvalidEnum(gc);
  503. return;
  504. }
  505. switch (type) {
  506. case GL_BITMAP:
  507. if (!index) {
  508. __gllc_InvalidEnum(gc);
  509. return;
  510. }
  511. break;
  512. case GL_BYTE:
  513. case GL_UNSIGNED_BYTE:
  514. case GL_SHORT:
  515. case GL_UNSIGNED_SHORT:
  516. case GL_INT:
  517. case GL_UNSIGNED_INT:
  518. case GL_FLOAT:
  519. break;
  520. default:
  521. __gllc_InvalidEnum(gc);
  522. return;
  523. }
  524. if (target == GL_PROXY_TEXTURE_1D_EXT) {
  525. imageSize = 0;
  526. } else {
  527. imageSize = __glImageSize(width, 1, format, type);
  528. }
  529. imageSize = __GL_PAD(imageSize);
  530. texdata = (__GLtexImage1D *)
  531. __glDlistAddOpUnaligned(gc, DLIST_SIZE(sizeof(__GLtexImage1D)+imageSize),
  532. DLIST_GENERIC_OP(TexImage1D));
  533. if (texdata == NULL) return;
  534. texdata->target = target;
  535. texdata->level = level;
  536. texdata->components = components;
  537. texdata->width = width;
  538. texdata->border = border;
  539. texdata->format = format;
  540. texdata->type = type;
  541. texdata->imageSize = imageSize;
  542. if (imageSize > 0 && pixels != NULL) {
  543. __glFillImage(gc, width, 1, format, type, pixels,
  544. (GLubyte *)texdata + sizeof(__GLtexImage1D));
  545. }
  546. __glDlistAppendOp(gc, texdata, __glle_TexImage1D);
  547. }
  548. void __gllc_TexImage2D(GLenum target, GLint level,
  549. GLint components,
  550. GLint width, GLint height, GLint border,
  551. GLenum format, GLenum type,
  552. const GLvoid *pixels)
  553. {
  554. __GLtexImage2D *texdata;
  555. GLint imageSize;
  556. GLboolean index;
  557. __GL_SETUP();
  558. if (border < 0 || border > 1) {
  559. __gllc_InvalidValue(gc);
  560. return;
  561. }
  562. if ((width < 0) || (height < 0)) {
  563. __gllc_InvalidValue(gc);
  564. return;
  565. }
  566. switch (format) {
  567. case GL_COLOR_INDEX:
  568. index = GL_TRUE;
  569. break;
  570. case GL_RED:
  571. case GL_GREEN:
  572. case GL_BLUE:
  573. case GL_ALPHA:
  574. case GL_RGB:
  575. case GL_RGBA:
  576. #ifdef GL_EXT_bgra
  577. case GL_BGR_EXT:
  578. case GL_BGRA_EXT:
  579. #endif
  580. case GL_LUMINANCE:
  581. case GL_LUMINANCE_ALPHA:
  582. index = GL_FALSE;
  583. break;
  584. default:
  585. __gllc_InvalidEnum(gc);
  586. return;
  587. }
  588. switch (type) {
  589. case GL_BITMAP:
  590. if (!index) {
  591. __gllc_InvalidEnum(gc);
  592. return;
  593. }
  594. break;
  595. case GL_BYTE:
  596. case GL_UNSIGNED_BYTE:
  597. case GL_SHORT:
  598. case GL_UNSIGNED_SHORT:
  599. case GL_INT:
  600. case GL_UNSIGNED_INT:
  601. case GL_FLOAT:
  602. break;
  603. default:
  604. __gllc_InvalidEnum(gc);
  605. return;
  606. }
  607. if (target == GL_PROXY_TEXTURE_2D_EXT) {
  608. imageSize = 0;
  609. } else {
  610. imageSize = __glImageSize(width, height, format, type);
  611. }
  612. imageSize = __GL_PAD(imageSize);
  613. texdata = (__GLtexImage2D *)
  614. __glDlistAddOpUnaligned(gc, DLIST_SIZE(sizeof(__GLtexImage2D) + imageSize),
  615. DLIST_GENERIC_OP(TexImage2D));
  616. if (texdata == NULL) return;
  617. texdata->target = target;
  618. texdata->level = level;
  619. texdata->components = components;
  620. texdata->width = width;
  621. texdata->height = height;
  622. texdata->border = border;
  623. texdata->format = format;
  624. texdata->type = type;
  625. texdata->imageSize = imageSize;
  626. if (imageSize > 0 && pixels != NULL) {
  627. __glFillImage(gc, width, height, format, type, pixels,
  628. (GLubyte *) (GLubyte *)texdata + sizeof(__GLtexImage2D));
  629. }
  630. __glDlistAppendOp(gc, texdata, __glle_TexImage2D);
  631. }
  632. typedef struct __GLtexSubImage1D_Rec {
  633. GLenum target;
  634. GLint level;
  635. GLint xoffset;
  636. GLsizei width;
  637. GLenum format;
  638. GLenum type;
  639. GLint imageSize;
  640. /* pixels */
  641. } __GLtexSubImage1D;
  642. const GLubyte *__glle_TexSubImage1D(const GLubyte *PC)
  643. {
  644. __GL_SETUP();
  645. const __GLtexSubImage1D *data;
  646. data = (const __GLtexSubImage1D *) PC;
  647. __gllei_TexSubImage1D(gc, data->target, data->level,
  648. data->xoffset, data->width,
  649. data->format, data->type,
  650. (const GLubyte *)(PC + sizeof(__GLtexSubImage1D)));
  651. return PC + sizeof(__GLtexSubImage1D) + __GL_PAD(data->imageSize);
  652. }
  653. void __gllc_TexSubImage1D(GLenum target, GLint level,
  654. GLint xoffset, GLsizei width,
  655. GLenum format, GLenum type, const GLvoid *pixels)
  656. {
  657. __GLtexSubImage1D *texdata;
  658. GLint imageSize;
  659. GLboolean index;
  660. __GL_SETUP();
  661. if (width < 0) {
  662. __gllc_InvalidValue(gc);
  663. return;
  664. }
  665. switch (format) {
  666. case GL_COLOR_INDEX:
  667. index = GL_TRUE;
  668. break;
  669. case GL_RED:
  670. case GL_GREEN:
  671. case GL_BLUE:
  672. case GL_ALPHA:
  673. case GL_RGB:
  674. case GL_RGBA:
  675. #ifdef GL_EXT_bgra
  676. case GL_BGR_EXT:
  677. case GL_BGRA_EXT:
  678. #endif
  679. case GL_LUMINANCE:
  680. case GL_LUMINANCE_ALPHA:
  681. index = GL_FALSE;
  682. break;
  683. default:
  684. __gllc_InvalidEnum(gc);
  685. return;
  686. }
  687. switch (type) {
  688. case GL_BITMAP:
  689. if (!index) {
  690. __gllc_InvalidEnum(gc);
  691. return;
  692. }
  693. break;
  694. case GL_BYTE:
  695. case GL_UNSIGNED_BYTE:
  696. case GL_SHORT:
  697. case GL_UNSIGNED_SHORT:
  698. case GL_INT:
  699. case GL_UNSIGNED_INT:
  700. case GL_FLOAT:
  701. break;
  702. default:
  703. __gllc_InvalidEnum(gc);
  704. return;
  705. }
  706. imageSize = __glImageSize(width, 1, format, type);
  707. imageSize = __GL_PAD(imageSize);
  708. texdata = (__GLtexSubImage1D *)
  709. __glDlistAddOpUnaligned(gc, DLIST_SIZE(sizeof(__GLtexSubImage1D) + imageSize),
  710. DLIST_GENERIC_OP(TexSubImage1D));
  711. if (texdata == NULL) return;
  712. texdata->target = target;
  713. texdata->level = level;
  714. texdata->xoffset = xoffset;
  715. texdata->width = width;
  716. texdata->format = format;
  717. texdata->type = type;
  718. texdata->imageSize = imageSize;
  719. if (imageSize > 0) {
  720. __glFillImage(gc, width, 1, format, type, pixels,
  721. (GLubyte *)texdata + sizeof(__GLtexSubImage1D));
  722. }
  723. __glDlistAppendOp(gc, texdata, __glle_TexSubImage1D);
  724. }
  725. typedef struct __GLtexSubImage2D_Rec {
  726. GLenum target;
  727. GLint level;
  728. GLint xoffset;
  729. GLint yoffset;
  730. GLsizei width;
  731. GLsizei height;
  732. GLenum format;
  733. GLenum type;
  734. GLint imageSize;
  735. /* pixels */
  736. } __GLtexSubImage2D;
  737. const GLubyte *__glle_TexSubImage2D(const GLubyte *PC)
  738. {
  739. __GL_SETUP();
  740. const __GLtexSubImage2D *data;
  741. data = (const __GLtexSubImage2D *) PC;
  742. __gllei_TexSubImage2D(gc, data->target, data->level,
  743. data->xoffset, data->yoffset,
  744. data->width, data->height,
  745. data->format, data->type,
  746. (const GLubyte *)(PC + sizeof(__GLtexSubImage2D)));
  747. return PC + sizeof(__GLtexSubImage2D) + __GL_PAD(data->imageSize);
  748. }
  749. void __gllc_TexSubImage2D(GLenum target, GLint level,
  750. GLint xoffset, GLint yoffset,
  751. GLsizei width, GLsizei height,
  752. GLenum format, GLenum type, const GLvoid *pixels)
  753. {
  754. __GLtexSubImage2D *texdata;
  755. GLint imageSize;
  756. GLboolean index;
  757. __GL_SETUP();
  758. if ((width < 0) || (height < 0)) {
  759. __gllc_InvalidValue(gc);
  760. return;
  761. }
  762. switch (format) {
  763. case GL_COLOR_INDEX:
  764. index = GL_TRUE;
  765. break;
  766. case GL_RED:
  767. case GL_GREEN:
  768. case GL_BLUE:
  769. case GL_ALPHA:
  770. case GL_RGB:
  771. case GL_RGBA:
  772. #ifdef GL_EXT_bgra
  773. case GL_BGR_EXT:
  774. case GL_BGRA_EXT:
  775. #endif
  776. case GL_LUMINANCE:
  777. case GL_LUMINANCE_ALPHA:
  778. index = GL_FALSE;
  779. break;
  780. default:
  781. __gllc_InvalidEnum(gc);
  782. return;
  783. }
  784. switch (type) {
  785. case GL_BITMAP:
  786. if (!index) {
  787. __gllc_InvalidEnum(gc);
  788. return;
  789. }
  790. break;
  791. case GL_BYTE:
  792. case GL_UNSIGNED_BYTE:
  793. case GL_SHORT:
  794. case GL_UNSIGNED_SHORT:
  795. case GL_INT:
  796. case GL_UNSIGNED_INT:
  797. case GL_FLOAT:
  798. break;
  799. default:
  800. __gllc_InvalidEnum(gc);
  801. return;
  802. }
  803. imageSize = __glImageSize(width, height, format, type);
  804. imageSize = __GL_PAD(imageSize);
  805. texdata = (__GLtexSubImage2D *)
  806. __glDlistAddOpUnaligned(gc, DLIST_SIZE(sizeof(__GLtexSubImage2D) + imageSize),
  807. DLIST_GENERIC_OP(TexSubImage2D));
  808. if (texdata == NULL) return;
  809. texdata->target = target;
  810. texdata->level = level;
  811. texdata->xoffset = xoffset;
  812. texdata->yoffset = yoffset;
  813. texdata->width = width;
  814. texdata->height = height;
  815. texdata->format = format;
  816. texdata->type = type;
  817. texdata->imageSize = imageSize;
  818. if (imageSize > 0) {
  819. __glFillImage(gc, width, height, format, type, pixels,
  820. (GLubyte *) texdata + sizeof(__GLtexSubImage2D));
  821. }
  822. __glDlistAppendOp(gc, texdata, __glle_TexSubImage2D);
  823. }
  824. #endif // !NT