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.

5164 lines
148 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: glcltgs.c
  3. *
  4. * Routines to batch function calls and primitives
  5. *
  6. * Copyright (c) 1993-1996 Microsoft Corporation
  7. \**************************************************************************/
  8. /*
  9. ** Copyright 1991-1993, Silicon Graphics, Inc.
  10. ** All Rights Reserved.
  11. **
  12. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  13. ** the contents of this file may not be disclosed to third parties, copied or
  14. ** duplicated in any form, in whole or in part, without the prior written
  15. ** permission of Silicon Graphics, Inc.
  16. **
  17. ** RESTRICTED RIGHTS LEGEND:
  18. ** Use, duplication or disclosure by the Government is subject to restrictions
  19. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  20. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  21. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  22. ** rights reserved under the Copyright Laws of the United States.
  23. */
  24. /*
  25. * AUTOMATICALLY UPDATED OR GENERATED BY SGI: DO NOT EDIT
  26. * IF YOU MUST MODIFY THIS FILE, PLEASE CONTACT ptar@sgi.com 415-390-1483
  27. */
  28. #include "precomp.h"
  29. #pragma hdrstop
  30. /* Generic OpenGL Client using subbatching. */
  31. #include <string.h>
  32. #include "imports.h"
  33. #include "types.h"
  34. #include "glsbmsg.h"
  35. #include "glsbmsgh.h"
  36. #include "glsrvspt.h"
  37. #include "subbatch.h"
  38. #include "batchinf.h"
  39. #include "glteb.h"
  40. #include "glsbcltu.h"
  41. #include "glclt.h"
  42. #include "compsize.h"
  43. #include "context.h"
  44. #include "global.h"
  45. #include "parray.h"
  46. #include "glarray.h"
  47. #include "lighting.h"
  48. #include "imfuncs.h"
  49. #include "..\dlist\dlistopt.h"
  50. #ifdef NEW_PARTIAL_PRIM
  51. // Vertex flags that should be propagated to polyarray flags
  52. //
  53. #define VERTEX_FLAGS_FOR_POLYARRAY (POLYDATA_VERTEX2 | POLYDATA_VERTEX3 | \
  54. POLYDATA_VERTEX4)
  55. #define VERTEX_MATERIAL(pm, pa, pd) (pm->pdMaterial0[pd - pa->pdBuffer0])
  56. PDMATERIAL* FASTCALL GetVertexMaterial(POLYARRAY *pa, POLYDATA *pd)
  57. {
  58. POLYMATERIAL *pm = GLTEB_CLTPOLYMATERIAL();
  59. if (!pm)
  60. {
  61. PAMatAlloc();
  62. pm = GLTEB_CLTPOLYMATERIAL();
  63. if (!pm)
  64. return NULL;
  65. }
  66. return &VERTEX_MATERIAL(pm, pa, pd);
  67. }
  68. //------------------------------------------------------------------------
  69. // Assumes that POLYMATERIAL structure is valid
  70. //
  71. PDMATERIAL* FASTCALL GetVertexMaterialSafe(POLYARRAY *pa, POLYDATA *pd)
  72. {
  73. POLYMATERIAL *pm = GLTEB_CLTPOLYMATERIAL();
  74. return &VERTEX_MATERIAL(pm, pa, pd);
  75. }
  76. //------------------------------------------------------------------------
  77. // Copy material changes from src to pd material
  78. //
  79. void FASTCALL SetVertexMaterial(POLYARRAY *pa,
  80. POLYDATA *pd,
  81. __GLmatChange *src,
  82. GLint faceOrientation)
  83. {
  84. __GLmatChange *pdMat;
  85. PDMATERIAL *mat;
  86. // Get POLYMATERIAL pointer after PAMatAlloc!
  87. mat = GetVertexMaterial(pa, pd);
  88. if (!mat)
  89. return;
  90. if (faceOrientation == __GL_FRONTFACE)
  91. {
  92. mat->front = PAMatAlloc();
  93. if (!mat->front)
  94. return;
  95. pdMat = mat->front;
  96. }
  97. else
  98. {
  99. mat->back = PAMatAlloc();
  100. pdMat = mat->back;
  101. }
  102. if (pdMat)
  103. *pdMat = *src;
  104. }
  105. //-----------------------------------------------------------------------------
  106. // Save shared vertex for a partial primitive
  107. //
  108. // We have to save all data applicapable for vertex (all data that can be inside
  109. // BEGIN END brackets): flags, color, texture, normal, coordinate, material, edge flag.
  110. // We do not save evaluator data, because it was processed earlier.
  111. //
  112. void SaveSharedVertex(SAVEREGION *dst, POLYDATA *src, POLYARRAY *pa)
  113. {
  114. dst->pd.flags = src->flags;
  115. dst->pd.obj = src->obj;
  116. if (src->flags & POLYDATA_TEXTURE_VALID)
  117. dst->pd.texture = src->texture;
  118. if (src->flags & POLYDATA_NORMAL_VALID)
  119. dst->pd.normal = src->normal;
  120. if (src->flags & POLYDATA_COLOR_VALID)
  121. dst->pd.colors[0] = src->colors[0];
  122. if (src->flags & POLYDATA_MATERIAL_FRONT)
  123. dst->front = *(GetVertexMaterial(pa, src)->front);
  124. if (src->flags & POLYDATA_MATERIAL_BACK)
  125. dst->back = *(GetVertexMaterial(pa, src)->back);
  126. }
  127. //
  128. // dst - POLYDATA
  129. // src - SAVEREGION
  130. // pa - POLYARRAY
  131. //
  132. #define RESTOREMATERIAL(dst, src, pa) \
  133. if (dst->flags & POLYDATA_MATERIAL_FRONT) \
  134. { \
  135. SetVertexMaterial(pa, dst, &src->front, __GL_FRONTFACE); \
  136. } \
  137. if (dst->flags & POLYDATA_MATERIAL_BACK) \
  138. { \
  139. SetVertexMaterial(pa, dst, &src->back, __GL_BACKFACE); \
  140. }
  141. // Restore shared vertex for a partial primitive
  142. //
  143. // We have to restore all data applicapable for vertex (all data that can be inside
  144. // BEGIN END brackets): flags, color, texture, normal, coordinate, material, edge flag.
  145. // We do not restore evaluator data, because it was processed earlier.
  146. // We must update POLYARRAY flags and current color, normal, edge flag, texture pointers.
  147. // We also must intitialize flags for a next vertex.
  148. //
  149. void RestoreSharedVertex(POLYDATA *dst, SAVEREGION *src, POLYARRAY *pa)
  150. {
  151. dst->flags = src->pd.flags;
  152. dst->obj = src->pd.obj;
  153. if (dst->flags & POLYDATA_TEXTURE_VALID)
  154. {
  155. dst->texture = src->pd.texture;
  156. if (src->pd.flags & POLYDATA_EVAL_TEXCOORD)
  157. pa->pdLastEvalTexture = dst;
  158. else
  159. pa->pdCurTexture = dst;
  160. }
  161. if (dst->flags & POLYDATA_NORMAL_VALID)
  162. {
  163. dst->normal = src->pd.normal;
  164. if (src->pd.flags & POLYDATA_EVAL_NORMAL)
  165. pa->pdLastEvalNormal = dst;
  166. else
  167. pa->pdCurNormal = dst;
  168. }
  169. if (dst->flags & POLYDATA_COLOR_VALID)
  170. {
  171. dst->colors[0] = src->pd.colors[0];
  172. if (src->pd.flags & POLYDATA_EVAL_COLOR)
  173. pa->pdLastEvalColor = dst;
  174. else
  175. pa->pdCurColor = dst;
  176. }
  177. if (dst->flags & POLYDATA_EDGEFLAG_VALID)
  178. pa->pdCurEdgeFlag = dst;
  179. RESTOREMATERIAL(dst, src, pa);
  180. pa->flags |= (dst->flags & VERTEX_FLAGS_FOR_POLYARRAY);
  181. (dst+1)->flags = 0; // Initialize flag for a next vertex
  182. }
  183. //------------------------------------------------------------------------------
  184. // Copy data from Graphics Context
  185. //
  186. void FASTCALL CopyColorFromGC(__GLcontext *gc, POLYARRAY *pa, POLYDATA *pd)
  187. {
  188. __GLcolor scaledUserColor;
  189. pd->flags |= POLYDATA_COLOR_VALID;
  190. if (!gc->modes.colorIndexMode)
  191. {
  192. __GL_SCALE_AND_CHECK_CLAMP_RGBA(scaledUserColor.r,
  193. scaledUserColor.g,
  194. scaledUserColor.b,
  195. scaledUserColor.a,
  196. gc, pa->flags,
  197. gc->state.current.userColor.r,
  198. gc->state.current.userColor.g,
  199. gc->state.current.userColor.b,
  200. gc->state.current.userColor.a);
  201. }
  202. else
  203. {
  204. __GL_CHECK_CLAMP_CI(scaledUserColor.r, gc, pa->flags,
  205. gc->state.current.userColorIndex);
  206. }
  207. pd->colors[0] = scaledUserColor;
  208. }
  209. void FASTCALL CopyTextureFromGC(__GLcontext *gc, POLYARRAY *pa, POLYDATA *pd)
  210. {
  211. pd->flags |= POLYDATA_TEXTURE_VALID;
  212. pd->texture = gc->state.current.texture;
  213. if (__GL_FLOAT_COMPARE_PONE(pd->texture.w, !=))
  214. pa->flags |= POLYARRAY_TEXTURE4;
  215. else if (__GL_FLOAT_NEZ(pd->texture.z))
  216. pa->flags |= POLYARRAY_TEXTURE3;
  217. else if (__GL_FLOAT_NEZ(pd->texture.y))
  218. pa->flags |= POLYARRAY_TEXTURE2;
  219. else
  220. pa->flags |= POLYARRAY_TEXTURE1;
  221. }
  222. void FASTCALL CopyEdgeFlagFromGC(__GLcontext *gc, POLYDATA *pd)
  223. {
  224. pd->flags |= POLYDATA_EDGEFLAG_VALID;
  225. if (gc->state.current.edgeTag)
  226. pd->flags |= POLYDATA_EDGEFLAG_BOUNDARY;
  227. }
  228. void FASTCALL CopyNormalFromGC(__GLcontext *gc, POLYDATA *pd)
  229. {
  230. pd->flags |= POLYDATA_NORMAL_VALID;
  231. pd->normal = gc->state.current.normal;
  232. }
  233. //-------------------------------------------------------------------------------
  234. // Copy material state corresponding to changeBits from GC to mat.
  235. // face defines front or back material to use.
  236. //
  237. void FASTCALL CopyMaterialFromGC(__GLcontext *gc, __GLmatChange *mat,
  238. GLuint changeBits, GLint face)
  239. {
  240. __GLmaterialState *ms;
  241. ms = &gc->state.light.front;
  242. if (face != __GL_FRONTFACE)
  243. ms = &gc->state.light.back;
  244. // Take data from graphics context
  245. if (changeBits & __GL_MATERIAL_AMBIENT)
  246. mat->ambient = ms->ambient;
  247. if (changeBits & __GL_MATERIAL_DIFFUSE)
  248. mat->diffuse = ms->diffuse;
  249. if (changeBits & __GL_MATERIAL_SPECULAR)
  250. mat->specular = ms->specular;
  251. if (changeBits & __GL_MATERIAL_EMISSIVE)
  252. {
  253. mat->emissive.r = ms->emissive.r * gc->oneOverRedVertexScale;
  254. mat->emissive.g = ms->emissive.g * gc->oneOverGreenVertexScale;
  255. mat->emissive.b = ms->emissive.b * gc->oneOverBlueVertexScale;
  256. mat->emissive.a = ms->emissive.a * gc->oneOverAlphaVertexScale;
  257. }
  258. if (changeBits & __GL_MATERIAL_SHININESS)
  259. mat->shininess = ms->specularExponent;
  260. if (changeBits & __GL_MATERIAL_COLORINDEXES)
  261. {
  262. mat->cmapa = ms->cmapa;
  263. mat->cmapd = ms->cmapd;
  264. mat->cmaps = ms->cmaps;
  265. }
  266. }
  267. //-------------------------------------------------------------------------------
  268. // Compute complete vertex state to restore state modified by pdLast vertex.
  269. //
  270. // We have to preserve the following state for a vertex:
  271. // - normal
  272. // - texture
  273. // - color
  274. // - edge flag
  275. // - material
  276. //
  277. // Input:
  278. // dst - where to copy vertex state
  279. // pdStart - we go from this vertex to the beginning of a polyarray to find
  280. // material changes
  281. // pdLast - we have to update vertex state only if the state is changed by
  282. // this vertex
  283. //
  284. void FASTCALL UpdateVertexState(__GLcontext *gc,
  285. POLYARRAY *pa,
  286. SAVEREGION *dst,
  287. POLYDATA *pdStart,
  288. POLYDATA *pdLast)
  289. {
  290. GLuint flags = dst->pd.flags;
  291. GLuint flagsLast = pdLast ? pdLast->flags : 0xFFFFFFFF;
  292. POLYDATA *pd0 = pa->pd0;
  293. ASSERTOPENGL(pdStart >= pd0, "Infinite loop possible!");
  294. // If last vertex changes normal we have to find nearest previous normal
  295. // and propagate it to the dst
  296. if (flagsLast & POLYDATA_NORMAL_VALID && !(flags & POLYDATA_NORMAL_VALID))
  297. {
  298. POLYDATA *pd;
  299. // Find nearest normal
  300. for (pd = pdStart; pd >= pd0; pd--)
  301. {
  302. if (pd->flags & POLYDATA_NORMAL_VALID &&
  303. !(pd->flags & POLYDATA_EVAL_NORMAL))
  304. break;
  305. }
  306. flags |= POLYDATA_NORMAL_VALID;
  307. if (pd < pd0)
  308. // We have not found any normal, so take value from graphics state
  309. CopyNormalFromGC(gc, &dst->pd);
  310. else
  311. dst->pd.normal = pd->normal;
  312. }
  313. // If last vertex changes texture we have to find nearest previous texture
  314. // and propagate it to the dst
  315. if (flagsLast & POLYDATA_TEXTURE_VALID && !(flags & POLYDATA_TEXTURE_VALID))
  316. {
  317. POLYDATA *pd;
  318. // Find latest texture
  319. for (pd = pdStart; pd >= pd0; pd--)
  320. {
  321. if (pd->flags & POLYDATA_TEXTURE_VALID &&
  322. !(pd->flags & POLYDATA_EVAL_TEXCOORD))
  323. break;
  324. }
  325. flags |= POLYDATA_TEXTURE_VALID;
  326. if (pd < pd0)
  327. // We have not found any vertex, so take value from graphics state
  328. CopyTextureFromGC(gc, pa, &dst->pd);
  329. else
  330. dst->pd.texture = pd->texture;
  331. }
  332. // If last vertex changes color we have to find nearest previous color
  333. // and propagate it to the dst
  334. if (flagsLast & POLYDATA_COLOR_VALID && !(flags & POLYDATA_COLOR_VALID))
  335. {
  336. POLYDATA *pd;
  337. // Find latest color
  338. for (pd = pdStart; pd >= pd0; pd--)
  339. {
  340. if (pd->flags & POLYDATA_COLOR_VALID &&
  341. !(pd->flags & POLYDATA_EVAL_COLOR))
  342. break;
  343. }
  344. flags |= POLYDATA_COLOR_VALID;
  345. if (pd < pd0)
  346. // We have not found any vertex, so take value from graphics state
  347. CopyColorFromGC(gc, pa, &dst->pd);
  348. else
  349. dst->pd.colors[0] = pd->colors[0];
  350. }
  351. if (flagsLast & POLYDATA_EDGEFLAG_VALID && !(flags & POLYDATA_EDGEFLAG_VALID))
  352. {
  353. POLYDATA *pd;
  354. // Find latest edge flag
  355. for (pd = pdStart; pd >= pd0; pd--)
  356. {
  357. if (pd->flags & POLYDATA_EDGEFLAG_VALID)
  358. break;
  359. }
  360. flags |= POLYDATA_EDGEFLAG_VALID;
  361. if (pd < pd0)
  362. {
  363. // We have not found any vertex, so take value from graphics state
  364. if (gc->state.current.edgeTag)
  365. flags |= POLYDATA_EDGEFLAG_BOUNDARY;
  366. }
  367. else
  368. flags |= (pd->flags & POLYDATA_EDGEFLAG_BOUNDARY);
  369. }
  370. dst->pd.flags |= flags;
  371. // Now we have to update material state
  372. if (pdLast->flags & (POLYARRAY_MATERIAL_FRONT | POLYARRAY_MATERIAL_BACK))
  373. {
  374. // We have to compute material state for pdLast1, because after the primitive is
  375. // processed, current material state will have changes from pdLast2 vertex.
  376. __GLmatChange *mat;
  377. __GLmatChange *pdMatLast;
  378. POLYDATA *pd;
  379. GLint face;
  380. GLuint matMask;
  381. GLuint changeBits;
  382. for (face = __GL_BACKFACE, matMask = POLYARRAY_MATERIAL_BACK;
  383. face >= 0;
  384. face--, matMask = POLYARRAY_MATERIAL_FRONT
  385. )
  386. {
  387. if (!(pa->flags & matMask))
  388. continue;
  389. // Only reset material data changed by pdLast
  390. if (face == __GL_FRONTFACE)
  391. {
  392. pdMatLast = GetVertexMaterial(pa, pdLast)->front;
  393. changeBits = pdMatLast->dirtyBits;
  394. mat = &dst->front;
  395. // Don't modify color materials if they are in effect!
  396. changeBits &= ~gc->light.front.colorMaterialChange;
  397. }
  398. else
  399. {
  400. pdMatLast = GetVertexMaterial(pa, pdLast)->back;
  401. changeBits = pdMatLast->dirtyBits;
  402. mat = &dst->back;
  403. // Don't modify color materials if they are in effect!
  404. changeBits &= ~gc->light.back.colorMaterialChange;
  405. }
  406. // Don't modify material settings used by this vertex
  407. changeBits &= ~mat->dirtyBits;
  408. if (!changeBits)
  409. continue;
  410. mat->dirtyBits |= changeBits;
  411. // Apply changes from vertices
  412. // We go backwards and apply the latest change
  413. for (pd = pdStart; pd >= pd0; pd--)
  414. {
  415. __GLmatChange *pdMat;
  416. GLuint dirtyBits;
  417. if (pd->flags & matMask)
  418. {
  419. GLuint dirtyBits;
  420. pdMat = GetVertexMaterial(pa, pd)->front + face;
  421. dirtyBits = pdMat->dirtyBits & changeBits;
  422. if (!dirtyBits)
  423. continue;
  424. if (dirtyBits & __GL_MATERIAL_AMBIENT)
  425. {
  426. mat->ambient = pdMat->ambient;
  427. }
  428. if (dirtyBits & __GL_MATERIAL_DIFFUSE)
  429. {
  430. mat->diffuse = pdMat->diffuse;
  431. }
  432. if (dirtyBits & __GL_MATERIAL_SPECULAR)
  433. {
  434. mat->specular = pdMat->specular;
  435. }
  436. if (dirtyBits & __GL_MATERIAL_EMISSIVE)
  437. {
  438. mat->emissive = pdMat->emissive;
  439. }
  440. if (dirtyBits & __GL_MATERIAL_SHININESS)
  441. {
  442. mat->shininess = pdMat->shininess;
  443. }
  444. if (dirtyBits & __GL_MATERIAL_COLORINDEXES)
  445. {
  446. mat->cmapa = pdMat->cmapa;
  447. mat->cmapd = pdMat->cmapd;
  448. mat->cmaps = pdMat->cmaps;
  449. }
  450. // Clear processed bits
  451. changeBits &= ~dirtyBits;
  452. if (!changeBits)
  453. break;
  454. }
  455. }
  456. if (changeBits)
  457. CopyMaterialFromGC (gc, mat, changeBits, face);
  458. dst->pd.flags |= matMask;
  459. }
  460. }
  461. }
  462. //-------------------------------------------------------------------------------------
  463. // Propagate vertex state from GC to the vertex.
  464. //
  465. // Already set vertex data should be preserved.
  466. //
  467. void FASTCALL UpdateVertexStateUsingGC(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *dst)
  468. {
  469. POLYDATA * const pd = &dst->pd;
  470. if (!(pd->flags & POLYDATA_NORMAL_VALID))
  471. CopyNormalFromGC(gc, pd);
  472. if (!(pd->flags & POLYDATA_TEXTURE_VALID))
  473. CopyTextureFromGC(gc, pa, pd);
  474. if (!(pd->flags & POLYDATA_COLOR_VALID))
  475. CopyColorFromGC(gc, pa, pd);
  476. if (!(pd->flags & POLYDATA_EDGEFLAG_VALID))
  477. CopyEdgeFlagFromGC(gc, pd);
  478. if (pa->flags & (POLYARRAY_MATERIAL_FRONT | POLYARRAY_MATERIAL_BACK))
  479. {
  480. // Compute material state for the vertex, using GC
  481. // Do not override material changes in the vertex
  482. __GLmatChange *mat;
  483. GLint face;
  484. GLuint matMask;
  485. GLuint changeBits;
  486. for (face = __GL_BACKFACE, matMask = POLYARRAY_MATERIAL_BACK;
  487. face >= 0;
  488. face--, matMask = POLYARRAY_MATERIAL_FRONT
  489. )
  490. {
  491. GLuint dirtyBits;
  492. if (!(pa->flags & matMask))
  493. continue;
  494. // Don't modify color materials if they are in effect or if they are set
  495. // by pdFirst!
  496. changeBits = 0xFFFFFFFF;
  497. if (face == __GL_FRONTFACE)
  498. {
  499. if (pd->flags & matMask)
  500. changeBits &= ~dst->front.dirtyBits;
  501. changeBits &= ~gc->light.front.colorMaterialChange;
  502. mat = &dst->front;
  503. }
  504. else
  505. {
  506. if (pd->flags & matMask)
  507. changeBits &= ~dst->back.dirtyBits;
  508. changeBits = ~gc->light.back.colorMaterialChange;
  509. mat = &dst->back;
  510. }
  511. // Apply changes from vertices
  512. // We go backwards and remember the latest change
  513. if (changeBits)
  514. {
  515. CopyMaterialFromGC (gc, mat, changeBits, face);
  516. // Update changes for the vertex
  517. pd->flags |= matMask;
  518. mat->dirtyBits |= changeBits;
  519. }
  520. }
  521. }
  522. }
  523. #endif // NEW_PARTIAL_PRIM
  524. //
  525. // extension apis these are not exported
  526. //
  527. void APIENTRY
  528. glAddSwapHintRectWIN(IN GLint x, IN GLint y, IN GLint width, IN GLint height)
  529. {
  530. PLRC plrc = GLTEB_CLTCURRENTRC();
  531. if (plrc == NULL || plrc->dhrc != 0) {
  532. // this api should only be called if there is a generic rc
  533. // currently selected.
  534. return;
  535. }
  536. GLCLIENT_BEGIN( AddSwapHintRectWIN, ADDSWAPHINTRECTWIN )
  537. pMsg->xs = x;
  538. pMsg->ys = y;
  539. pMsg->xe = x + width;
  540. pMsg->ye = y + height;
  541. return;
  542. GLCLIENT_END
  543. }
  544. #ifdef PRIMITIVE_TRACK
  545. static ULONG prim_entries;
  546. static ULONG prim_total = 0;
  547. static ULONG prim_count = 0;
  548. #endif
  549. // Polyarray begin flags. Reset line stipple for new line loop,
  550. // line strip, and polygon.
  551. // Assume that all vertices have the same color.
  552. GLuint aPolyArrayBeginFlags[] =
  553. {
  554. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_POINTS
  555. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_LINES
  556. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA | POLYARRAY_RESET_STIPPLE, // GL_LINE_LOOP
  557. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA | POLYARRAY_RESET_STIPPLE, // GL_LINE_STRIP
  558. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_TRIANGLES
  559. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_TRIANGLE_STRIP
  560. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_TRIANGLE_FAN
  561. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_QUADS
  562. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA, // GL_QUAD_STRIP
  563. POLYARRAY_IN_BEGIN | POLYARRAY_SAME_COLOR_DATA | POLYARRAY_RESET_STIPPLE // GL_POLYGON
  564. };
  565. // If you modify this function, you need to also modify VA_DrawElementsBegin.
  566. void APIENTRY
  567. glcltBegin ( IN GLenum mode )
  568. {
  569. POLYARRAY *pa;
  570. POLYDATA *pd0, *pdFlush;
  571. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  572. __GL_SETUP();
  573. DWORD flags = GET_EVALSTATE (gc);
  574. // The invalid functions within begin/end are detected in glsbAttention.
  575. pa = GLTEB_CLTPOLYARRAY();
  576. // The vertex buffer is used as follows. The first entry contains the
  577. // POLYARRAY structure. The incoming vertices will be saved beginning
  578. // at a following entry. As an optimization, the POLYARRAY structure is
  579. // kept in the TEB. When glEnd is called, it will be copied to the
  580. // vertex buffer.
  581. #ifndef _WIN95_
  582. ASSERTOPENGL(sizeof(POLYARRAY) <= sizeof(NtCurrentTeb()->glReserved1),
  583. "POLYARRAY and TEB sizes mismatch!");
  584. #endif
  585. ASSERTOPENGL(sizeof(POLYDATA) == sizeof(__GLvertex),
  586. "POLYDATA and __GLvertex sizes mismatch!");
  587. ASSERTOPENGL(sizeof(POLYARRAY) <= sizeof(POLYDATA),
  588. "POLYARRAY and POLYDATA sizes mismatch!");
  589. // Keep vertex structure a multiple of 4 bytes (or 8 bytes).
  590. // The vertex buffer must be 4-byte aligned.
  591. ASSERTOPENGL(!(sizeof(POLYDATA) & 0x3), "bad POLYDATA size!");
  592. ASSERTOPENGL(!((ULONG_PTR)pa->pdBuffer0 & 0x3), "POLYDATA should be aligned!\n");
  593. // If we are already in the begin/end bracket, return an error.
  594. if (pa->flags & POLYARRAY_IN_BEGIN)
  595. {
  596. GLSETERROR(GL_INVALID_OPERATION);
  597. return;
  598. }
  599. if ((GLuint) mode > GL_POLYGON)
  600. {
  601. GLSETERROR(GL_INVALID_ENUM);
  602. return;
  603. }
  604. // if there are any pending API calls that affect the Evaluator state
  605. // then flush the message buffer
  606. if (flags & (__EVALS_AFFECTS_ALL_EVAL|
  607. __EVALS_AFFECTS_1D_EVAL|
  608. __EVALS_AFFECTS_2D_EVAL))
  609. glsbAttention ();
  610. // Flush the command buffer if the vertex buffer is nearly full.
  611. // Otherwise, just continue with the next available vertex buffer entry.
  612. if (pa->pdBufferNext > pa->pdBufferMax - MIN_POLYDATA_BATCH_SIZE)
  613. {
  614. #ifdef PRIMITIVE_TRACK
  615. DbgPrint("* Min-not-present flush\n");
  616. #endif
  617. glsbAttention(); // it resets pdBufferNext pointer too
  618. ASSERTOPENGL(pa->nextMsgOffset == PA_nextMsgOffset_RESET_VALUE,
  619. "bad nextMsgOffset\n");
  620. }
  621. // Batch POLYARRAY command in the command buffer.
  622. // We want to leave enough room to accomodate at least one invalid command
  623. // that may be batched in the begin/end bracket. When glsbAttention,
  624. // glsbAttentionAlt, or glcltEnd is called, we will remove these invalid
  625. // commands.
  626. //
  627. // Combine adjacent DrawPolyArray commands into one command.
  628. // request DRAWPOLYARRAY_LARGE structure to make room for invalid commands
  629. GLCLIENT_BEGIN(DrawPolyArray, DRAWPOLYARRAY_LARGE)
  630. // need msg pointer to update pa later
  631. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *) pMsg;
  632. if (pa->nextMsgOffset == CurrentOffset)
  633. {
  634. // rewind command buffer pointer
  635. pMsgBatchInfo->NextOffset = CurrentOffset;
  636. ((BYTE *) pMsgDrawPolyArray) -=
  637. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY));
  638. // chain adjacent DrawPolyArray commands
  639. ((POLYARRAY *) pMsgDrawPolyArray->paLast)->paNext
  640. = (POLYARRAY *) pa->pdBufferNext;
  641. ((POLYARRAY *) pMsgDrawPolyArray->paLast)
  642. = (POLYARRAY *) pa->pdBufferNext;
  643. }
  644. else
  645. {
  646. // resize the msg to the real size
  647. pMsgBatchInfo->NextOffset = CurrentOffset
  648. + GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY));
  649. // remember the end of the primitive command
  650. pa->nextMsgOffset = pMsgBatchInfo->NextOffset;
  651. // start of a new chain
  652. pMsgDrawPolyArray->pa0 =
  653. pMsgDrawPolyArray->paLast = (PVOID) pa->pdBufferNext;
  654. }
  655. GLCLIENT_END
  656. // Compute the start of the primitive. A new primitive always begins with a
  657. // POLYARRAY entry immediately followed by vertex entries.
  658. pd0 = pa->pdBufferNext + 1;
  659. // Initialize first polydata.
  660. pd0->flags = 0;
  661. ASSERTOPENGL(pd0->color == &pd0->colors[__GL_FRONTFACE],
  662. "bad color pointer!\n");
  663. // Initialize the polyarray structure in the TEB.
  664. pa->flags = aPolyArrayBeginFlags[mode];
  665. pa->pdNextVertex =
  666. pa->pd0 = pd0;
  667. pa->primType = mode;
  668. pa->pdCurColor =
  669. pa->pdCurNormal =
  670. pa->pdCurTexture =
  671. pa->pdCurEdgeFlag = NULL;
  672. pa->paNext = NULL;
  673. pa->nIndices = 0;
  674. pa->aIndices = NULL; // identity mapping
  675. pa->pdLastEvalColor =
  676. pa->pdLastEvalNormal =
  677. pa->pdLastEvalTexture = NULL;
  678. // Compute the flush vertex for this primitive. When the flush vertex is
  679. // reached, we will have accumulated enough vertices to render a partially
  680. // composed primitive.
  681. pdFlush = pa->pdBufferMax;
  682. switch (mode)
  683. {
  684. case GL_POINTS:
  685. case GL_LINE_STRIP:
  686. case GL_TRIANGLE_FAN:
  687. break;
  688. case GL_LINE_LOOP:
  689. // Line loop reserves an additional end vertex to close the loop.
  690. pdFlush--;
  691. break;
  692. case GL_POLYGON:
  693. // The polygon decomposer can only handle up to
  694. // __GL_MAX_POLYGON_CLIP_SIZE vertices.
  695. if (pdFlush > pd0 + __GL_MAX_POLYGON_CLIP_SIZE - 1)
  696. pdFlush = pd0 + __GL_MAX_POLYGON_CLIP_SIZE - 1;
  697. break;
  698. case GL_LINES:
  699. case GL_TRIANGLE_STRIP:
  700. case GL_QUAD_STRIP:
  701. // number of vertices must be a multiple of 2
  702. if ((pdFlush - pd0 + 1) % 2)
  703. pdFlush--;
  704. break;
  705. case GL_TRIANGLES:
  706. // number of vertices must be a multiple of 3
  707. switch ((pdFlush - pd0 + 1) % 3)
  708. {
  709. case 2: pdFlush--; // fall through
  710. case 1: pdFlush--;
  711. }
  712. break;
  713. case GL_QUADS:
  714. // number of vertices must be a multiple of 4
  715. switch ((pdFlush - pd0 + 1) % 4)
  716. {
  717. case 3: pdFlush--; // fall through
  718. case 2: pdFlush--; // fall through
  719. case 1: pdFlush--;
  720. }
  721. break;
  722. }
  723. pa->pdFlush = pdFlush;
  724. #ifdef PRIMITIVE_TRACK
  725. DbgPrint("glcltBegin with %3d space left\n", pdFlush-pd0+1);
  726. prim_entries = 0;
  727. #endif
  728. }
  729. // Special version of Begin for DrawElements.
  730. // If you modify this function, you need to also modify glcltBegin.
  731. void FASTCALL VA_DrawElementsBegin(POLYARRAY *pa, GLenum mode, GLsizei count)
  732. {
  733. POLYDATA *pd0;
  734. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  735. GLint maxVertexCount;
  736. // The vertex buffer is used as follows. The first entry contains the
  737. // POLYARRAY structure. The incoming vertices will be saved beginning
  738. // at a following entry. As an optimization, the POLYARRAY structure is
  739. // kept in the TEB. When VA_DrawElementsEnd is called, it will be copied
  740. // to the vertex buffer.
  741. // We don't handle Points, Line Loop, and Polygon here. They should
  742. // have been sent to Begin/End.
  743. ASSERTOPENGL(mode != GL_POINTS && mode != GL_LINE_LOOP && mode != GL_POLYGON,
  744. "Primitive type not handled\n");
  745. // Flush the command buffer if the vertex buffer will overflow.
  746. // Otherwise, just continue with the next available vertex buffer entry.
  747. // Maximum number of vertex entries that we will handle in next batch
  748. maxVertexCount = min(count,VA_DRAWELEM_MAP_SIZE)
  749. // Add maximum number of entries used for index map
  750. + (VA_DRAWELEM_INDEX_SIZE + sizeof(POLYDATA) - 1) / sizeof(POLYDATA)
  751. // Reserve an extra vertex entry to prevent calling
  752. // PolyArrayFlushPartialPrimitive in the Vertex routines.
  753. // It should call VA_DrawElementsFlushPartialPrimitive instead.
  754. + 1
  755. // Add an entry for POLYARRAY
  756. + 1
  757. // Add a few more entries to be safe
  758. + 4;
  759. if (pa->pdBufferNext > pa->pdBufferMax - maxVertexCount + 1)
  760. {
  761. #ifdef PRIMITIVE_TRACK
  762. DbgPrint("* Min-not-present flush\n");
  763. #endif
  764. glsbAttention(); // it resets pdBufferNext pointer too
  765. ASSERTOPENGL(pa->nextMsgOffset == PA_nextMsgOffset_RESET_VALUE,
  766. "bad nextMsgOffset\n");
  767. }
  768. // The vertex buffer must have at least maxVertexCount (currently <= 277)
  769. // entries.
  770. ASSERTOPENGL(maxVertexCount <= pa->pdBufferMax - pa->pdBuffer0 + 1,
  771. "vertex buffer is too small!\n");
  772. // Batch POLYARRAY command in the command buffer.
  773. // Combine adjacent DrawPolyArray commands into one command.
  774. GLCLIENT_BEGIN(DrawPolyArray, DRAWPOLYARRAY)
  775. // need msg pointer to update pa later
  776. pMsgDrawPolyArray = pMsg;
  777. if (pa->nextMsgOffset == CurrentOffset)
  778. {
  779. // rewind command buffer pointer
  780. pMsgBatchInfo->NextOffset = CurrentOffset;
  781. ((BYTE *) pMsgDrawPolyArray) -=
  782. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY));
  783. // chain adjacent DrawPolyArray commands
  784. ((POLYARRAY *) pMsgDrawPolyArray->paLast)->paNext
  785. = (POLYARRAY *) pa->pdBufferNext;
  786. ((POLYARRAY *) pMsgDrawPolyArray->paLast)
  787. = (POLYARRAY *) pa->pdBufferNext;
  788. }
  789. else
  790. {
  791. // remember the end of the primitive command
  792. pa->nextMsgOffset = pMsgBatchInfo->NextOffset;
  793. // start of a new chain
  794. pMsgDrawPolyArray->pa0 =
  795. pMsgDrawPolyArray->paLast = (PVOID) pa->pdBufferNext;
  796. }
  797. GLCLIENT_END
  798. // Compute the start of the primitive. A new primitive always begins with a
  799. // POLYARRAY entry immediately followed by vertex entries.
  800. pd0 = pa->pdBufferNext + 1;
  801. // Initialize first polydata.
  802. pd0->flags = 0;
  803. ASSERTOPENGL(pd0->color == &pd0->colors[__GL_FRONTFACE],
  804. "bad color pointer!\n");
  805. // Initialize the polyarray structure in the TEB.
  806. pa->flags = aPolyArrayBeginFlags[mode] | POLYARRAY_SAME_POLYDATA_TYPE;
  807. pa->pdNextVertex =
  808. pa->pd0 = pd0;
  809. pa->primType = mode;
  810. pa->pdCurColor =
  811. pa->pdCurNormal =
  812. pa->pdCurTexture =
  813. pa->pdCurEdgeFlag = NULL;
  814. pa->paNext = NULL;
  815. pa->nIndices = 0;
  816. pa->aIndices = PA_aIndices_INITIAL_VALUE; // this is updated in End
  817. // For consistency
  818. pa->pdLastEvalColor =
  819. pa->pdLastEvalNormal =
  820. pa->pdLastEvalTexture = NULL;
  821. // The flush vertex for this primitive should never be reached. We have
  822. // reserved enough room for a vertex batch. Set it to maximum and assert
  823. // that we never reach the vertex in PolyArrayFlushPartialPrimitive!
  824. pa->pdFlush = pa->pdBufferMax;
  825. #ifdef PRIMITIVE_TRACK
  826. DbgPrint("VA_DrawElementsBegin with %3d space left\n", pa->pdBufferMax-pd0+1);
  827. #endif
  828. return;
  829. }
  830. void APIENTRY
  831. glcltEnd ( void )
  832. {
  833. POLYARRAY *pa;
  834. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  835. #ifdef NEW_PARTIAL_PRIM
  836. __GL_SETUP();
  837. pa = gc->paTeb;
  838. #else
  839. pa = GLTEB_CLTPOLYARRAY();
  840. #endif
  841. // Flush invalid commands accumulated in the command buffer if there is any.
  842. glsbAttention();
  843. // If we are not in the begin/end bracket, return an error.
  844. if (!(pa->flags & POLYARRAY_IN_BEGIN))
  845. {
  846. GLSETERROR(GL_INVALID_OPERATION);
  847. return;
  848. }
  849. // Clear the POLYARRAY_IN_BEGIN flag in the TEB. We are now out of
  850. // the begin/end bracket.
  851. pa->flags &= ~POLYARRAY_IN_BEGIN;
  852. // Clear POLYARRAY_SAME_COLOR_DATA flag if the primitive uses more than
  853. // one color. Also clear the flag if an evaluator is used. We cannot
  854. // tell if an evaluator modifies the color on the client side.
  855. // If there are evaluator calls in this polyarray that also generate
  856. // color, then too, remove the POLYARRAY_SAME_COLOR_DATA flag
  857. if ((pa->pdCurColor != pa->pd0) ||
  858. ((pa->pd0->flags & POLYDATA_COLOR_VALID) &&
  859. (pa->flags & POLYARRAY_PARTIAL_BEGIN)) ||
  860. (pa->pdLastEvalColor != NULL))
  861. pa->flags &= ~POLYARRAY_SAME_COLOR_DATA;
  862. // Compute nIndices. It is the final number of vertices passed to the low
  863. // level render routines and is different from the number of polydata's
  864. // accumulated. The final number includes the reserved vertices and the
  865. // accumulated vertices.
  866. pa->nIndices += (GLint)((ULONG_PTR)(pa->pdNextVertex - pa->pd0));
  867. /*
  868. // If there are no vertices and no attributes to propagate to a next
  869. // primitive, we can remove this polyarray from the batch
  870. if (pa->nIndices == 0 && pa->pdNextVertex->flags == 0)
  871. return;
  872. */
  873. #ifdef NEW_PARTIAL_PRIM
  874. if (pa->primType == GL_LINE_LOOP)
  875. {
  876. if (pa->nIndices > 1)
  877. {
  878. // We have to add an additional vertex at the end. It could be
  879. // - saved vertex if primitive is partial begin OR
  880. // - first vertex
  881. // We will change primitive type to GL_LINE_STRIP after we update
  882. // current color, normal, texture, edge flag in __glim_DrawPolyArray
  883. //
  884. POLYDATA *pd = pa->pdNextVertex++;
  885. SAVEREGION firstVertex;
  886. SAVEREGION lastVertex;
  887. SAVEREGION *reg;
  888. // We have to propagate vertex state for next primitive before we
  889. // insert the vertex.
  890. pa->nIndices++;
  891. if (pa->flags & POLYARRAY_PARTIAL_BEGIN)
  892. { // This is partial primitive
  893. reg = &gc->vertex.regSaved;
  894. }
  895. else
  896. { // This is non partial primitive
  897. SaveSharedVertex(&firstVertex, pa->pd0, pa);
  898. reg = &firstVertex;
  899. }
  900. // Save pdNextVertex before we override it
  901. SaveSharedVertex(&lastVertex, pd, pa);
  902. // Insert first vertex at the end
  903. RestoreSharedVertex(pd, reg, pa);
  904. // Compute state for last vertex, because we have to override
  905. // changes made by first vertex.
  906. UpdateVertexState(gc, pa, &lastVertex, pd-1, pd);
  907. // pdNextVertex will have state for a next primitive
  908. RestoreSharedVertex(pa->pdNextVertex, &lastVertex, pa);
  909. }
  910. pa->primType = GL_LINE_STRIP;
  911. }
  912. #else // NEW_PARTIAL_PRIM
  913. if (pa->primType == GL_LINE_LOOP)
  914. pa->nIndices++; // add one extra vertex when a line loop is closed.
  915. // It's okay not to advance pdBufferNext since we
  916. // don't need attributes after they've been
  917. // processed.
  918. #endif // NEWFLUSH
  919. // Save the POLYARRAY structure in the batch.
  920. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  921. ((BYTE *) pa->pMsgBatchInfo + pa->nextMsgOffset -
  922. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  923. *(POLYARRAY *) pMsgDrawPolyArray->paLast = *pa;
  924. #ifdef PRIMITIVE_TRACK
  925. prim_entries += pa->pdNextVertex-pa->pd0;
  926. prim_total += prim_entries;
  927. prim_count++;
  928. DbgPrint("glcltEnd with %3d polydata entries, %3d now, avg %d\n",
  929. prim_entries, pa->pdNextVertex-pa->pd0, prim_total/prim_count);
  930. #endif
  931. // Advance polyarray batch pointer.
  932. // Skip a vertex because it may contain attributes for the current batch.
  933. pa->pdBufferNext = pa->pdNextVertex + 1;
  934. }
  935. void FASTCALL VA_DrawElementsEnd(POLYARRAY *pa)
  936. {
  937. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  938. ASSERTOPENGL(pa->flags & POLYARRAY_IN_BEGIN, "not in begin\n");
  939. ASSERTOPENGL(pa->aIndices && (pa->aIndices != PA_aIndices_INITIAL_VALUE),
  940. "no output index array!\n");
  941. // Clear the POLYARRAY_IN_BEGIN flag in the TEB. We are now out of
  942. // the begin/end bracket.
  943. pa->flags &= ~POLYARRAY_IN_BEGIN;
  944. // Clear POLYARRAY_SAME_COLOR_DATA flag if the primitive uses more than
  945. // one color.
  946. if (pa->pdCurColor != pa->pd0)
  947. pa->flags &= ~POLYARRAY_SAME_COLOR_DATA;
  948. // Save the POLYARRAY structure in the batch.
  949. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  950. ((BYTE *) pa->pMsgBatchInfo + pa->nextMsgOffset -
  951. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  952. *(POLYARRAY *) pMsgDrawPolyArray->paLast = *pa;
  953. #ifdef PRIMITIVE_TRACK
  954. prim_count++;
  955. DbgPrint("VA_DrawElementsEnd called\n");
  956. #endif
  957. // Advance polyarray batch pointer.
  958. pa->pdBufferNext = (POLYDATA *) (pa->aIndices +
  959. (pa->nIndices + sizeof(POLYDATA) - 1) / sizeof(POLYDATA) * sizeof(POLYDATA));
  960. }
  961. #ifdef NEW_PARTIAL_PRIM
  962. typedef void (*PFNSAVERESTORE)(__GLcontext*, POLYARRAY*, SAVEREGION*);
  963. void FASTCALL SaveFirstVertex(__GLcontext* gc, POLYARRAY* pa)
  964. {
  965. if (!(pa->flags & POLYARRAY_PARTIAL_BEGIN))
  966. {
  967. GLuint flags = pa->flags & (POLYARRAY_MATERIAL_FRONT | POLYARRAY_MATERIAL_BACK);
  968. SaveSharedVertex(&gc->vertex.regSaved, pa->pd0, pa);
  969. // Save vertex state to restore it later
  970. pa->flags |= (POLYARRAY_MATERIAL_FRONT | POLYARRAY_MATERIAL_BACK);
  971. UpdateVertexStateUsingGC(gc, pa, &gc->vertex.regSaved);
  972. // Restore pa flags
  973. pa->flags &= ~(POLYARRAY_MATERIAL_FRONT | POLYARRAY_MATERIAL_BACK);
  974. pa->flags |= flags;
  975. }
  976. }
  977. // This function is used by GL_POINTS, GL_LINES, GL_TRIANGLES, GL_QUADS,
  978. // because for these cases parts of broken primitive are not connected.
  979. // We also clear POLYARRAY_PARTIAL_END flag, because in DrawPolyArray we
  980. // can remove this partial primitive if it is clipped out (we do not have
  981. // to preserve line stipple for these primitives).
  982. //
  983. void SaveEmpty(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  984. {
  985. pa->flags &= ~POLYARRAY_PARTIAL_END;
  986. }
  987. // A line loop is the same as a line strip except that a final segment is
  988. // added from the final specified vertex to the first vertex. We convert
  989. // the line loop into a strip here. We have to save first vertex of line
  990. // loop only if the primitive is not partial begin (i.e. it is not a middle
  991. // part of a line loop broken into more than two polyarrays).
  992. // We do not clear POLYARRAY_PARTIAL_END flag, because in DrawPolyArray we
  993. // can not remove this partial primitive if it is clipped out to preserve
  994. // line stipple.
  995. // Index mapping is always indentity for GL_LINE_LOOP.
  996. // We save first vertex in graphics state, because it will be restored in glcltEnd.
  997. // We change line loop to line strip here.
  998. //
  999. // When the first vertex is saved we have preserve its state to restore it in the next part
  1000. // of partial primitive.
  1001. //
  1002. void SaveLineLoop(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1003. {
  1004. POLYDATA* pd;
  1005. SaveFirstVertex(gc, pa);
  1006. pd = pa->pdNextVertex-1;
  1007. SaveSharedVertex(r, pd, pa);
  1008. pa->primType = GL_LINE_STRIP;
  1009. }
  1010. // For GL_LINE_STRIP we save last vertex. We do not clear POLYARRAY_PARTIAL_END flag,
  1011. // because in DrawPolyArray we can not remove this partial primitive if it is clipped
  1012. // out to preserve line stipple.
  1013. // We do not preserve index because it is assumed to be 0 for the next part
  1014. // of the primitive.
  1015. //
  1016. void SaveLineStrip(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1017. {
  1018. POLYDATA *pd;
  1019. if (pa->aIndices)
  1020. pd = &pa->pd0[pa->aIndices[pa->nIndices-1]];
  1021. else
  1022. pd = pa->pdNextVertex-1;
  1023. SaveSharedVertex(r, pd, pa);
  1024. }
  1025. // For GL_TRIANLE_FAN we save first and last vertices. Line stipple is reset for every
  1026. // triangle in a fan, so we can clear POLYARRAY_PARTIAL_END flag
  1027. // We do not preserve indices because they are assumed to be 0 and 1 for the next part
  1028. // of the primitive.
  1029. //
  1030. // When we restore first vertex it must have the same state as when we saved it.
  1031. // But this state should no affect vertex last vertex.
  1032. // So we have to compute vertex state for the first when we save it and compute
  1033. // vertex state for the lase vertex when we restore it.
  1034. // First vertex and its state should be computed only once, even if a primitive is broken
  1035. // several times.
  1036. //
  1037. void SaveTFan(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1038. {
  1039. if (pa->aIndices)
  1040. {
  1041. POLYDATA *pd;
  1042. GLubyte *aIndices = pa->aIndices;
  1043. pd = &pa->pd0[aIndices[0]];
  1044. SaveSharedVertex(&gc->vertex.regSaved, pd, pa);
  1045. pd = &pa->pd0[aIndices[pa->nIndices-1]];
  1046. SaveSharedVertex(r, pd, pa);
  1047. }
  1048. else
  1049. {
  1050. POLYDATA *pd;
  1051. // Compute state for the first vertex only for the very first part
  1052. // of partial primitive
  1053. SaveFirstVertex(gc, pa);
  1054. pd = pa->pdNextVertex-1;
  1055. SaveSharedVertex(r, pd, pa);
  1056. }
  1057. pa->flags &= ~POLYARRAY_PARTIAL_END;
  1058. }
  1059. // This function handles GL_TRIANGLE_STRIP and GL_QUAD_STRIP.
  1060. // We save two last vertices.
  1061. // Line stipple is reset for every triangle (quad) in a strip, so we can clear
  1062. // POLYARRAY_PARTIAL_END flag.
  1063. // We do not preserve indices because they are assumed to be 0 and 1 for the
  1064. // next part of the primitive.
  1065. //
  1066. // We have to save 2 last vertices: v1 and v2 (last vertex).
  1067. // Next part of partial primitive will start with vertex v1.
  1068. // v2 could change vertex state, so we have to compute vertex state for v1 and
  1069. // restore it. This should be done only for non indexed case.
  1070. //
  1071. void SaveTStrip(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1072. {
  1073. if (pa->aIndices)
  1074. {
  1075. POLYDATA *pd;
  1076. GLint nIndices = pa->nIndices;
  1077. GLubyte *aIndices = pa->aIndices;
  1078. pd = &pa->pd0[aIndices[nIndices-2]];
  1079. SaveSharedVertex(r, pd, pa);
  1080. pd = &pa->pd0[aIndices[nIndices-1]];
  1081. SaveSharedVertex(r+1, pd, pa);
  1082. }
  1083. else
  1084. {
  1085. POLYDATA *pd = pa->pdNextVertex-2;
  1086. SaveSharedVertex(r, pd, pa);
  1087. // Compute vertex state, changed by vertex pd+1
  1088. UpdateVertexState(gc, pa, r, pd-1, pd+1);
  1089. pd++;
  1090. SaveSharedVertex(r+1, pd, pa);
  1091. }
  1092. pa->flags &= ~POLYARRAY_PARTIAL_END;
  1093. }
  1094. // For GL_POLYGON we first and last two vertices, because we do not know
  1095. // if the last vertex of this part is the last vertex for the primitive. We need this
  1096. // information to compute edge flag for the last vertex.
  1097. // We remove last vertex from the primitive. It will be processed in the next part of
  1098. // the primitive.
  1099. // We need POLYARRAY_PARTIAL_END flag when we compute edge flag in DrawPolyArray.
  1100. //
  1101. void SavePolygon(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1102. {
  1103. POLYDATA *pd;
  1104. // Compute state for the first vertex only for the very first part
  1105. // of partial primitive
  1106. SaveFirstVertex(gc, pa);
  1107. pd = pa->pdNextVertex-2;
  1108. SaveSharedVertex(r, pd, pa);
  1109. r++;
  1110. pd = pa->pdNextVertex-1;
  1111. SaveSharedVertex(r, pd, pa);
  1112. // Remove last vertex from the primitive
  1113. pa->nIndices--;
  1114. pa->pdNextVertex--;
  1115. }
  1116. PFNSAVERESTORE pfnSaveFunc[] =
  1117. {
  1118. SaveEmpty, // GL_POINTS
  1119. SaveEmpty, // GL_LINES
  1120. SaveLineLoop, // GL_LINE_LOOP
  1121. SaveLineStrip, // GL_LINE_STRIP
  1122. SaveEmpty, // GL_TRIANGLES
  1123. SaveTStrip, // GL_TRIANGLE_STRIP
  1124. SaveTFan, // GL_TRIANGLE_FAN
  1125. SaveEmpty, // GL_QUADS
  1126. SaveTStrip, // GL_QUAD_STRIP
  1127. SavePolygon // GL_POLYGON
  1128. };
  1129. // This function is used by GL_POINTS, GL_LINES, GL_TRIANGLES, GL_QUADS,
  1130. // because for these cases parts of broken primitive are not connected. We
  1131. // also clear POLYARRAY_PARTIAL_BEGIN flag, because in DrawPolyArray we can
  1132. // remove this partial primitive if it is clipped out (we do not have to
  1133. // preserve line stipple for these primitives).
  1134. //
  1135. void RestoreEmpty(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1136. {
  1137. pa->flags &= ~POLYARRAY_PARTIAL_BEGIN;
  1138. }
  1139. // For GL_LINE_LOOP and GL_LINE_STRIP last vertex from previous part will be the first.
  1140. // We will convert line loop into line strip in glcltEnd or PolyArrayFlushPartialPrimitive
  1141. // To preserve line stipple we need POLYARRAY_PARTIAL_BEGIN flag.
  1142. //
  1143. void RestoreLineStrip(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1144. {
  1145. POLYDATA *pd = pa->pdNextVertex++;
  1146. RestoreSharedVertex(pd, r, pa);
  1147. }
  1148. // For GL_TRIANGLE_STRIP and GL_QUAD_STRIP we have to add two saved
  1149. // vertices at the beginning of primitive.
  1150. // We do not to preserve line stipple, so we clear POLYARRAY_PARTIAL_BEGIN flag.
  1151. //
  1152. void RestoreTStrip(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1153. {
  1154. POLYDATA *pd = pa->pdNextVertex++;
  1155. RestoreSharedVertex(pd, r, pa);
  1156. r++;
  1157. pd = pa->pdNextVertex++;
  1158. RestoreSharedVertex(pd, r, pa);
  1159. pa->flags &= ~POLYARRAY_PARTIAL_BEGIN;
  1160. }
  1161. // For GL_TRIANGLE_FAN we have to add two saved vertices at the beginning
  1162. // of primitive. Last vertex should have a state, not modified by previous vertex.
  1163. // We do not to preserve line stipple, so we clear POLYARRAY_PARTIAL_BEGIN flag.
  1164. //
  1165. void RestoreTFan(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1166. {
  1167. POLYDATA *pd = pa->pdNextVertex++;
  1168. RestoreSharedVertex(pd, &gc->vertex.regSaved, pa);
  1169. pd = pa->pdNextVertex++;
  1170. if (!pa->aIndices)
  1171. // Compute state for last vertex, because it could be modified
  1172. // by first vertex
  1173. UpdateVertexStateUsingGC(gc, pa, r);
  1174. RestoreSharedVertex(pd, r, pa);
  1175. }
  1176. // For GL_POLYGON we have to add three saved vertices at the beginning of primitive.
  1177. // We need POLYARRAY_PARTIAL_BEGIN flag to compute edge flag in DrawPolyArray.
  1178. //
  1179. void RestorePolygon(__GLcontext *gc, POLYARRAY *pa, SAVEREGION *r)
  1180. {
  1181. POLYDATA *pd = pa->pdNextVertex++;
  1182. RestoreSharedVertex(pd, &gc->vertex.regSaved, pa);
  1183. // Compute state for this vertex, because it could be modified
  1184. // by first vertex
  1185. UpdateVertexStateUsingGC(gc, pa, r);
  1186. pd = pa->pdNextVertex++;
  1187. RestoreSharedVertex(pd, r, pa);
  1188. r++;
  1189. pd = pa->pdNextVertex++;
  1190. RestoreSharedVertex(pd, r, pa);
  1191. }
  1192. PFNSAVERESTORE pfnRestoreFunc[] =
  1193. {
  1194. RestoreEmpty, // GL_POINTS
  1195. RestoreEmpty, // GL_LINES
  1196. RestoreLineStrip, // GL_LINE_LOOP
  1197. RestoreLineStrip, // GL_LINE_STRIP
  1198. RestoreEmpty, // GL_TRIANGLES
  1199. RestoreTStrip, // GL_TRIANGLE_STRIP
  1200. RestoreTFan, // GL_TRIANGLE_FAN
  1201. RestoreEmpty, // GL_QUADS
  1202. RestoreTStrip, // GL_QUAD_STRIP
  1203. RestorePolygon // GL_POLYGON
  1204. };
  1205. #endif // NEW_PARTIAL_PRIM
  1206. // Number of reserved vertices for partial Begin.
  1207. GLint nReservedIndicesPartialBegin[] =
  1208. {
  1209. 0, // GL_POINTS
  1210. 0, // GL_LINES
  1211. 1, // GL_LINE_LOOP
  1212. 1, // GL_LINE_STRIP
  1213. 0, // GL_TRIANGLES
  1214. 2, // GL_TRIANGLE_STRIP
  1215. 2, // GL_TRIANGLE_FAN
  1216. 0, // GL_QUADS
  1217. 2, // GL_QUAD_STRIP
  1218. 3 // GL_POLYGON
  1219. };
  1220. // If you modify this function, you need to also modify
  1221. // VA_DrawElementsFlushPartialPrimitive.
  1222. void FASTCALL PolyArrayFlushPartialPrimitive()
  1223. {
  1224. POLYARRAY *pa;
  1225. POLYDATA *pd0, *pdFlush;
  1226. GLenum mode;
  1227. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  1228. GLuint paFlags;
  1229. #ifdef NEW_PARTIAL_PRIM
  1230. SAVEREGION savereg[3]; // Temporary storage for vertices, shared between
  1231. #endif // NEW_PARTIAL_PRIM // parts of decomposed primitive
  1232. __GL_SETUP();
  1233. pa = gc->paTeb;
  1234. #ifdef PRIMITIVE_TRACK
  1235. prim_entries += pa->pdNextVertex-pa->pd0;
  1236. DbgPrint("* Flush partial primitive with %d polydata entries\n",
  1237. pa->pdNextVertex-pa->pd0);
  1238. #endif
  1239. ASSERTOPENGL(pa->flags & POLYARRAY_IN_BEGIN, "not in begin\n");
  1240. ASSERTOPENGL(!pa->aIndices || (pa->aIndices == PA_aIndices_INITIAL_VALUE),
  1241. "Flushing DrawElements unexpected!\n");
  1242. // Flush invalid commands accumulated in the command buffer if there is any.
  1243. glsbAttention();
  1244. // Clear the POLYARRAY_IN_BEGIN flag in the TEB. We are now out of
  1245. // the begin/end bracket temporarily. glsbAttention does not flush
  1246. // unless the flag is clear.
  1247. pa->flags &= ~POLYARRAY_IN_BEGIN;
  1248. // Mark it as a partially completed primitive batch.
  1249. pa->flags |= POLYARRAY_PARTIAL_END;
  1250. // Clear POLYARRAY_SAME_COLOR_DATA flag if the primitive uses more than
  1251. // one color. Also clear the flag if an evaluator is used. We cannot
  1252. // tell if an evaluator modifies the color on the client side.
  1253. if ((pa->pdCurColor != pa->pd0) ||
  1254. ((pa->pd0->flags & POLYDATA_COLOR_VALID) &&
  1255. (pa->flags & POLYARRAY_PARTIAL_BEGIN)) ||
  1256. (pa->pdLastEvalColor != pa->pd0))
  1257. pa->flags &= ~POLYARRAY_SAME_COLOR_DATA;
  1258. // Save some pa flags for next partial primitive.
  1259. // Need to preserve POLYARRAY_CLAMP_COLOR flag in dlist playback.
  1260. #ifdef NEW_PARTIAL_PRIM
  1261. // We have to preserve material flags to handle first vertex
  1262. //
  1263. paFlags = pa->flags & (POLYARRAY_SAME_POLYDATA_TYPE |
  1264. POLYARRAY_SAME_COLOR_DATA |
  1265. POLYARRAY_TEXTURE1 |
  1266. POLYARRAY_TEXTURE2 |
  1267. POLYARRAY_TEXTURE3 |
  1268. POLYARRAY_TEXTURE4 |
  1269. POLYARRAY_VERTEX2 |
  1270. POLYARRAY_VERTEX3 |
  1271. POLYARRAY_VERTEX4 |
  1272. POLYDATA_MATERIAL_FRONT |
  1273. POLYDATA_MATERIAL_BACK |
  1274. POLYARRAY_CLAMP_COLOR);
  1275. #else
  1276. paFlags = pa->flags & (POLYARRAY_SAME_POLYDATA_TYPE |
  1277. POLYARRAY_SAME_COLOR_DATA |
  1278. POLYARRAY_CLAMP_COLOR);
  1279. #endif
  1280. // Compute nIndices. It is the final number of vertices passed to the low
  1281. // level render routines and is different from the number of polydata's
  1282. // accumulated. The final number includes the reserved vertices and the
  1283. // accumulated vertices.
  1284. pa->nIndices += (GLint)((ULONG_PTR)(pa->pdNextVertex - pa->pd0));
  1285. // Save states before flushing the batch.
  1286. mode = pa->primType;
  1287. #ifdef NEW_PARTIAL_PRIM
  1288. // Save shared vertices for the next part of the partial primitive
  1289. pfnSaveFunc[mode](gc, pa, savereg);
  1290. #endif // NEW_PARTIAL_PRIM
  1291. // Save the POLYARRAY structure in the batch.
  1292. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  1293. ((BYTE *) pa->pMsgBatchInfo + pa->nextMsgOffset -
  1294. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  1295. *(POLYARRAY *) pMsgDrawPolyArray->paLast = *pa;
  1296. // Flush the command buffer and reset pointer for the next batch.
  1297. // If we are compiling poly array primitive in dlist, record the last poly
  1298. // data record.
  1299. if (gc->dlist.beginRec)
  1300. {
  1301. // Record the poly data.
  1302. __glDlistCompilePolyData(gc, GL_FALSE);
  1303. // We just recorded this vertex, don't record it in the compile
  1304. // code again!
  1305. gc->dlist.skipPolyData = GL_TRUE;
  1306. if (gc->dlist.mode == GL_COMPILE_AND_EXECUTE)
  1307. glsbAttention(); // reset pdBufferNext pointer too!
  1308. else
  1309. glsbResetBuffers(TRUE); // reset pointers but no execution
  1310. }
  1311. else
  1312. {
  1313. glsbAttention(); // reset pdBufferNext pointer too!
  1314. }
  1315. ASSERTOPENGL(pa->nextMsgOffset == PA_nextMsgOffset_RESET_VALUE,
  1316. "bad nextMsgOffset\n");
  1317. // Batch new POLYARRAY command in the command buffer.
  1318. GLCLIENT_BEGIN(DrawPolyArray, DRAWPOLYARRAY)
  1319. // need msg pointer to update pa later
  1320. pMsgDrawPolyArray = pMsg;
  1321. // start of a new chain
  1322. pMsgDrawPolyArray->pa0 =
  1323. pMsgDrawPolyArray->paLast = (PVOID) pa->pdBufferNext;
  1324. // remember the end of the primitive command
  1325. pa->nextMsgOffset = pMsgBatchInfo->NextOffset;
  1326. GLCLIENT_END
  1327. #ifdef NEW_PARTIAL_PRIM
  1328. // Compute the start of the PARTIAL primitive. A partial primitive begins
  1329. // with a POLYARRAY entry followed by vertex entries. We DO NOT not need to
  1330. // reserve additional vertex entries at the beginning for connectivity
  1331. // between decomposed primitives. Because we just add them at the beginning
  1332. pd0 = pa->pdBufferNext + 1;
  1333. #else
  1334. // Compute the start of the PARTIAL primitive. A partial primitive begins
  1335. // with a POLYARRAY entry followed by vertex entries. We need to
  1336. // reserve additional vertex entries at the beginning for connectivity
  1337. // between decomposed primitives.
  1338. pd0 = pa->pdBufferNext + 1 + nReservedIndicesPartialBegin[mode];
  1339. #endif // NEW_PARTIAL_PRIM
  1340. // Initialize first polydata.
  1341. pd0->flags = 0;
  1342. ASSERTOPENGL(pd0->color == &pd0->colors[__GL_FRONTFACE],
  1343. "bad color pointer!\n");
  1344. // Initialize the polyarray structure in the TEB.
  1345. pa->flags = POLYARRAY_IN_BEGIN | POLYARRAY_PARTIAL_BEGIN | paFlags;
  1346. pa->pdNextVertex =
  1347. pa->pd0 = pd0;
  1348. pa->primType = mode;
  1349. pa->paNext = NULL;
  1350. #ifdef NEW_PARTIAL_PRIM
  1351. pa->nIndices = 0; // WE do not reserve any vertices
  1352. #else
  1353. pa->nIndices = nReservedIndicesPartialBegin[mode];
  1354. #endif // NEW_PARTIAL_PRIM
  1355. pa->aIndices = NULL; // identity mapping
  1356. pa->pdCurColor =
  1357. pa->pdCurNormal =
  1358. pa->pdCurTexture =
  1359. pa->pdCurEdgeFlag =
  1360. pa->pdLastEvalColor =
  1361. pa->pdLastEvalNormal =
  1362. pa->pdLastEvalTexture = NULL;
  1363. // Compute the flush vertex for this primitive. When the flush vertex is
  1364. // reached, we will have accumulated enough vertices to render a partially
  1365. // composed primitive.
  1366. pdFlush = pa->pdBufferMax;
  1367. switch (mode)
  1368. {
  1369. case GL_POINTS:
  1370. case GL_LINE_STRIP:
  1371. case GL_TRIANGLE_FAN:
  1372. break;
  1373. case GL_LINE_LOOP:
  1374. // Line loop reserves an additional end vertex to close the loop.
  1375. pdFlush--;
  1376. break;
  1377. case GL_POLYGON:
  1378. // The polygon decomposer can only handle up to
  1379. // __GL_MAX_POLYGON_CLIP_SIZE vertices. We also need to give
  1380. // allowance for 3 vertices in the decomposed polygons.
  1381. if (pdFlush > (pd0 - 3) + __GL_MAX_POLYGON_CLIP_SIZE - 1)
  1382. pdFlush = (pd0 - 3) + __GL_MAX_POLYGON_CLIP_SIZE - 1;
  1383. ASSERTOPENGL(nReservedIndicesPartialBegin[GL_POLYGON] == 3,
  1384. "bad reserved size!\n");
  1385. break;
  1386. case GL_LINES:
  1387. case GL_TRIANGLE_STRIP:
  1388. case GL_QUAD_STRIP:
  1389. // number of vertices must be a multiple of 2
  1390. if ((pdFlush - pd0 + 1) % 2)
  1391. pdFlush--;
  1392. break;
  1393. case GL_TRIANGLES:
  1394. // number of vertices must be a multiple of 3
  1395. switch ((pdFlush - pd0 + 1) % 3)
  1396. {
  1397. case 2: pdFlush--; // fall through
  1398. case 1: pdFlush--;
  1399. }
  1400. break;
  1401. case GL_QUADS:
  1402. // number of vertices must be a multiple of 4
  1403. switch ((pdFlush - pd0 + 1) % 4)
  1404. {
  1405. case 3: pdFlush--; // fall through
  1406. case 2: pdFlush--; // fall through
  1407. case 1: pdFlush--;
  1408. }
  1409. break;
  1410. }
  1411. pa->pdFlush = pdFlush;
  1412. #ifdef NEW_PARTIAL_PRIM
  1413. // Add saved vertices into the new part of the primitive
  1414. pfnRestoreFunc[mode](gc, pa, savereg);
  1415. #endif // NEW_PARTIAL_PRIM
  1416. }
  1417. // Special version of Flush for DrawElements.
  1418. // If you modify this function, you need to also modify
  1419. // PolyArrayFlushPartialPrimitive.
  1420. void FASTCALL VA_DrawElementsFlushPartialPrimitive(POLYARRAY *pa, GLenum mode)
  1421. {
  1422. POLYDATA *pd0;
  1423. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  1424. GLuint paFlags;
  1425. #ifdef NEW_PARTIAL_PRIM
  1426. SAVEREGION savereg[3]; // Temporary storage for vertices, shared between
  1427. #endif // NEW_PARTIAL_PRIM // parts of decomposed primitive
  1428. __GL_SETUP();
  1429. #ifdef PRIMITIVE_TRACK
  1430. DbgPrint("VA_DrawElementsFlushPartialPrimitive called\n");
  1431. #endif
  1432. // We don't handle Points, Line Loop, and Polygon here. They should
  1433. // have been sent to Begin/End.
  1434. ASSERTOPENGL(mode != GL_POINTS && mode != GL_LINE_LOOP && mode != GL_POLYGON,
  1435. "Primitive type not handled\n");
  1436. ASSERTOPENGL(pa->flags & POLYARRAY_IN_BEGIN, "not in begin\n");
  1437. ASSERTOPENGL(pa->aIndices && (pa->aIndices != PA_aIndices_INITIAL_VALUE),
  1438. "no output index array!\n");
  1439. // Clear the POLYARRAY_IN_BEGIN flag in the TEB. We are now out of
  1440. // the begin/end bracket temporarily. glsbAttention does not flush
  1441. // unless the flag is clear.
  1442. pa->flags &= ~POLYARRAY_IN_BEGIN;
  1443. // Mark it as a partially completed primitive batch.
  1444. pa->flags |= POLYARRAY_PARTIAL_END;
  1445. // Clear POLYARRAY_SAME_COLOR_DATA flag if the primitive uses more than
  1446. // one color.
  1447. if (pa->pdCurColor != pa->pd0)
  1448. pa->flags &= ~POLYARRAY_SAME_COLOR_DATA;
  1449. // Save some pa flags for next partial primitive.
  1450. paFlags = pa->flags & (POLYARRAY_SAME_COLOR_DATA |
  1451. POLYARRAY_TEXTURE1 |
  1452. POLYARRAY_TEXTURE2 |
  1453. POLYARRAY_TEXTURE3 |
  1454. POLYARRAY_TEXTURE4 |
  1455. POLYARRAY_VERTEX2 |
  1456. POLYARRAY_VERTEX3 |
  1457. POLYARRAY_VERTEX4 |
  1458. POLYARRAY_CLAMP_COLOR);
  1459. #ifdef NEW_PARTIAL_PRIM
  1460. // Save shared vertices for the next part of partial primitive
  1461. pfnSaveFunc[mode](gc, pa, savereg);
  1462. #endif // NEW_PARTIAL_PRIM
  1463. // Save the POLYARRAY structure in the batch.
  1464. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  1465. ((BYTE *) pa->pMsgBatchInfo + pa->nextMsgOffset -
  1466. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  1467. *(POLYARRAY *) pMsgDrawPolyArray->paLast = *pa;
  1468. // Flush the command buffer and reset pointer for the next batch.
  1469. ASSERTOPENGL(!gc->dlist.beginRec
  1470. || gc->dlist.mode == GL_COMPILE_AND_EXECUTE,
  1471. "dlist complilation unexpected!\n");
  1472. glsbAttention(); // reset pdBufferNext pointer too!
  1473. ASSERTOPENGL(pa->nextMsgOffset == PA_nextMsgOffset_RESET_VALUE,
  1474. "bad nextMsgOffset\n");
  1475. // Batch new POLYARRAY command in the command buffer.
  1476. GLCLIENT_BEGIN(DrawPolyArray, DRAWPOLYARRAY)
  1477. // need msg pointer to update pa later
  1478. pMsgDrawPolyArray = pMsg;
  1479. // start of a new chain
  1480. pMsgDrawPolyArray->pa0 =
  1481. pMsgDrawPolyArray->paLast = (PVOID) pa->pdBufferNext;
  1482. // remember the end of the primitive command
  1483. pa->nextMsgOffset = pMsgBatchInfo->NextOffset;
  1484. GLCLIENT_END
  1485. #ifdef NEW_PARTIAL_PRIM
  1486. // Compute the start of the PARTIAL primitive. A partial primitive begins
  1487. // with a POLYARRAY entry followed by vertex entries. We DO NOT need to
  1488. // reserve additional vertex entries at the beginning for connectivity
  1489. // between decomposed primitives.
  1490. pd0 = pa->pdBufferNext + 1;
  1491. #else
  1492. // Compute the start of the PARTIAL primitive. A partial primitive begins
  1493. // with a POLYARRAY entry followed by vertex entries. We need to
  1494. // reserve additional vertex entries at the beginning for connectivity
  1495. // between decomposed primitives.
  1496. pd0 = pa->pdBufferNext + 1 + nReservedIndicesPartialBegin[mode];
  1497. #endif
  1498. // Initialize first polydata.
  1499. pd0->flags = 0;
  1500. ASSERTOPENGL(pd0->color == &pd0->colors[__GL_FRONTFACE],
  1501. "bad color pointer!\n");
  1502. // Initialize the polyarray structure in the TEB.
  1503. pa->flags = POLYARRAY_IN_BEGIN | POLYARRAY_PARTIAL_BEGIN |
  1504. POLYARRAY_SAME_POLYDATA_TYPE | paFlags;
  1505. pa->pdNextVertex =
  1506. pa->pd0 = pd0;
  1507. pa->primType = mode;
  1508. pa->pdCurColor =
  1509. pa->pdCurNormal =
  1510. pa->pdCurTexture =
  1511. pa->pdCurEdgeFlag = NULL;
  1512. pa->paNext = NULL;
  1513. #ifdef NEW_PARTIAL_PRIM
  1514. pa->nIndices = 0;
  1515. #else
  1516. pa->nIndices = nReservedIndicesPartialBegin[mode];
  1517. #endif // NEW_PARTIAL_PRIM
  1518. pa->aIndices = PA_aIndices_INITIAL_VALUE; // this is updated in End
  1519. // The flush vertex for this primitive should never be reached. The call
  1520. // to glsbAttention in this function has left enough room for a vertex batch.
  1521. // Set it to maximum and assert that we never reach the vertex in
  1522. // PolyArrayFlushPartialPrimitive!
  1523. pa->pdFlush = pa->pdBufferMax;
  1524. #ifdef NEW_PARTIAL_PRIM
  1525. // Add saved vertices into the new part of the primitive
  1526. pfnRestoreFunc[mode](gc, pa, savereg);
  1527. #endif // NEW_PARTIAL_PRIM
  1528. }
  1529. // The vertex functions are called in begin/end only.
  1530. #define PA_VERTEX2(x1,y1) \
  1531. \
  1532. POLYARRAY *pa; \
  1533. POLYDATA *pd; \
  1534. \
  1535. pa = GLTEB_CLTPOLYARRAY(); \
  1536. \
  1537. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1538. { \
  1539. pa->flags |= POLYARRAY_VERTEX2; \
  1540. \
  1541. pd = pa->pdNextVertex++; \
  1542. pd->flags |= POLYDATA_VERTEX2; \
  1543. pd->obj.x = x1; \
  1544. pd->obj.y = y1; \
  1545. pd->obj.z = __glZero; \
  1546. pd->obj.w = __glOne; \
  1547. \
  1548. pd[1].flags = 0; \
  1549. \
  1550. if (pd >= pa->pdFlush) \
  1551. PolyArrayFlushPartialPrimitive(); \
  1552. }
  1553. #define PA_VERTEX3(x1,y1,z1) \
  1554. { \
  1555. GLfloat t1; \
  1556. POLYARRAY *pa; \
  1557. POLYDATA *pd, *pd1; \
  1558. ULONG flag1, flag2, flag3; \
  1559. register GLfloat tone; \
  1560. \
  1561. pa = GLTEB_CLTPOLYARRAY(); \
  1562. tone = 1.0; \
  1563. \
  1564. pd1 = pa->pdFlush; \
  1565. flag1 = pa->flags; \
  1566. pd = pa->pdNextVertex; \
  1567. \
  1568. if (flag1 & POLYARRAY_IN_BEGIN) \
  1569. { \
  1570. flag3 = pd->flags; \
  1571. pa->pdNextVertex++; \
  1572. flag2 = flag1 | POLYARRAY_VERTEX3; \
  1573. flag3 = flag3 | POLYDATA_VERTEX3; \
  1574. \
  1575. pd->obj.x = x1; \
  1576. pd->obj.y = y1; \
  1577. pd->obj.z = z1; \
  1578. pd->obj.w = tone; \
  1579. pa->flags = flag2; \
  1580. pd->flags = flag3; \
  1581. \
  1582. pd[1].flags = 0; \
  1583. \
  1584. if (pd >= pd1) \
  1585. PolyArrayFlushPartialPrimitive(); \
  1586. } \
  1587. }
  1588. #define PA_VERTEX4(x1,y1,z1,w1) \
  1589. \
  1590. POLYARRAY *pa; \
  1591. POLYDATA *pd; \
  1592. \
  1593. pa = GLTEB_CLTPOLYARRAY(); \
  1594. \
  1595. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1596. { \
  1597. pa->flags |= POLYARRAY_VERTEX4; \
  1598. \
  1599. pd = pa->pdNextVertex++; \
  1600. pd->flags |= POLYDATA_VERTEX4; \
  1601. pd->obj.x = x1; \
  1602. pd->obj.y = y1; \
  1603. pd->obj.z = z1; \
  1604. pd->obj.w = w1; \
  1605. \
  1606. pd[1].flags = 0; \
  1607. \
  1608. if (pd >= pa->pdFlush) \
  1609. PolyArrayFlushPartialPrimitive(); \
  1610. }
  1611. #define PA_COLOR_IN_RGBA_NO_CLAMP1(red,green,blue) \
  1612. POLYARRAY *pa; \
  1613. POLYDATA *pd; \
  1614. __GL_SETUP(); \
  1615. \
  1616. pa = gc->paTeb; \
  1617. \
  1618. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1619. { \
  1620. pd = pa->pdNextVertex; \
  1621. pa->pdCurColor = pd; \
  1622. \
  1623. __GL_SCALE_RGB(pd->colors[0].r, pd->colors[0].g, pd->colors[0].b, \
  1624. gc, red, green, blue); \
  1625. pd->colors[0].a = gc->alphaVertexScale; \
  1626. \
  1627. pd->flags |= POLYDATA_COLOR_VALID; \
  1628. } \
  1629. else \
  1630. { \
  1631. glcltColor4f_InRGBA_NotInBegin(gc, pa, \
  1632. POLYDATA_COLOR_VALID, red, green, blue, __glOne); \
  1633. }
  1634. #define PA_COLOR_IN_RGBA_NO_CLAMP(red,green,blue,alpha) \
  1635. POLYARRAY *pa; \
  1636. POLYDATA *pd; \
  1637. __GL_SETUP(); \
  1638. \
  1639. pa = gc->paTeb; \
  1640. \
  1641. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1642. { \
  1643. pd = pa->pdNextVertex; \
  1644. pa->pdCurColor = pd; \
  1645. \
  1646. __GL_SCALE_RGBA(pd->colors[0].r, \
  1647. pd->colors[0].g, \
  1648. pd->colors[0].b, \
  1649. pd->colors[0].a, \
  1650. gc, red, green, blue, alpha); \
  1651. \
  1652. pd->flags |= POLYDATA_COLOR_VALID | POLYDATA_DLIST_COLOR_4; \
  1653. } \
  1654. else \
  1655. { \
  1656. glcltColor4f_InRGBA_NotInBegin(gc, pa, \
  1657. POLYDATA_COLOR_VALID | POLYDATA_DLIST_COLOR_4, red, green, blue, alpha);\
  1658. }
  1659. #define PA_COLOR_IN_RGB1(red,green,blue) \
  1660. POLYARRAY *pa; \
  1661. POLYDATA *pd; \
  1662. __GL_SETUP(); \
  1663. \
  1664. pa = gc->paTeb; \
  1665. \
  1666. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1667. { \
  1668. pd = pa->pdNextVertex; \
  1669. pa->pdCurColor = pd; \
  1670. \
  1671. __GL_SCALE_AND_CHECK_CLAMP_RGB(pd->colors[0].r, \
  1672. pd->colors[0].g, \
  1673. pd->colors[0].b, \
  1674. gc, pa->flags, \
  1675. red, green, blue); \
  1676. pd->colors[0].a = gc->alphaVertexScale; \
  1677. \
  1678. pd->flags |= POLYDATA_COLOR_VALID; \
  1679. } \
  1680. else \
  1681. { \
  1682. glcltColor4f_InRGBA_NotInBegin(gc, pa, \
  1683. POLYDATA_COLOR_VALID, red, green, blue, __glOne); \
  1684. }
  1685. #define PA_COLOR_IN_RGB2(red, green, blue) \
  1686. { \
  1687. POLYARRAY *pa; \
  1688. POLYDATA *pd; \
  1689. GLfloat sr, sg, sb; \
  1690. ULONG f1, f2, f3, f4, f5, f6; \
  1691. LONG t1, t2, t3; \
  1692. \
  1693. __GL_SETUP(); \
  1694. \
  1695. pa = gc->paTeb; \
  1696. \
  1697. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1698. { \
  1699. \
  1700. t1 = (LONG) (CASTINT(gc->redVertexScale)); \
  1701. t2 = (LONG) (CASTINT(gc->greenVertexScale)); \
  1702. t3 = (LONG) (CASTINT(gc->blueVertexScale)); \
  1703. \
  1704. pd = pa->pdNextVertex; \
  1705. pa->pdCurColor = pd; \
  1706. \
  1707. sr = red * gc->redVertexScale; \
  1708. sg = green * gc->greenVertexScale; \
  1709. sb = blue * gc->blueVertexScale; \
  1710. \
  1711. f1 = (ULONG) (CASTINT(sr)); \
  1712. f2 = (ULONG) (CASTINT(sg)); \
  1713. f3 = (ULONG) (CASTINT(sb)); \
  1714. \
  1715. f4 = (ULONG) (t1 - CASTINT(sr)); \
  1716. f5 = (ULONG) (t2 - CASTINT(sg)); \
  1717. f6 = (ULONG) (t3 - CASTINT(sb)); \
  1718. \
  1719. f1 = f1 | f2; \
  1720. f3 = f3 | f4; \
  1721. f5 = f5 | f6; \
  1722. \
  1723. pd->colors[0].r = sr; \
  1724. pd->colors[0].g = sg; \
  1725. pd->colors[0].b = sb; \
  1726. \
  1727. f1 = f1 | f3 | f5; \
  1728. \
  1729. pa->flags |= (f1 & 0x80000000); \
  1730. \
  1731. pd->colors[0].a = gc->alphaVertexScale; \
  1732. \
  1733. pd->flags |= POLYDATA_COLOR_VALID; \
  1734. } \
  1735. else \
  1736. { \
  1737. glcltColor4f_InRGBA_NotInBegin(gc, pa, \
  1738. POLYDATA_COLOR_VALID, red, green, blue, __glOne); \
  1739. } \
  1740. }
  1741. #define PA_COLOR_IN_RGBA(red,green,blue,alpha) \
  1742. POLYARRAY *pa; \
  1743. POLYDATA *pd; \
  1744. __GL_SETUP(); \
  1745. \
  1746. pa = gc->paTeb; \
  1747. \
  1748. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1749. { \
  1750. pd = pa->pdNextVertex; \
  1751. pa->pdCurColor = pd; \
  1752. \
  1753. __GL_SCALE_AND_CHECK_CLAMP_RGBA(pd->colors[0].r, \
  1754. pd->colors[0].g, \
  1755. pd->colors[0].b, \
  1756. pd->colors[0].a, \
  1757. gc, pa->flags, \
  1758. red, green, blue, alpha); \
  1759. \
  1760. pd->flags |= POLYDATA_COLOR_VALID | POLYDATA_DLIST_COLOR_4; \
  1761. } \
  1762. else \
  1763. { \
  1764. glcltColor4f_InRGBA_NotInBegin(gc, pa, \
  1765. POLYDATA_COLOR_VALID | POLYDATA_DLIST_COLOR_4, red, green, blue, alpha);\
  1766. }
  1767. #define PA_COLOR_IN_CI(red,green,blue,alpha) \
  1768. \
  1769. POLYARRAY *pa; \
  1770. \
  1771. pa = GLTEB_CLTPOLYARRAY(); \
  1772. \
  1773. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1774. { \
  1775. pa->flags |= POLYARRAY_OTHER_COLOR; \
  1776. /* need only record the latest values */ \
  1777. /* otherColor in the TEB may not be aligned at 16-byte boundary */ \
  1778. pa->otherColor.r = red; \
  1779. pa->otherColor.g = green; \
  1780. pa->otherColor.b = blue; \
  1781. pa->otherColor.a = alpha; \
  1782. } \
  1783. else \
  1784. { \
  1785. glcltColor4f_NotInBegin(red, green, blue, alpha); \
  1786. }
  1787. void FASTCALL glcltColor4f_NotInBegin(GLfloat red, GLfloat green,
  1788. GLfloat blue, GLfloat alpha)
  1789. {
  1790. GLCLIENT_BEGIN( Color4fv, COLOR4FV )
  1791. pMsg->v[0] = red;
  1792. pMsg->v[1] = green;
  1793. pMsg->v[2] = blue;
  1794. pMsg->v[3] = alpha;
  1795. GLCLIENT_END
  1796. }
  1797. void FASTCALL glcltColor4f_InRGBA_NotInBegin(__GLcontext *gc, POLYARRAY *pa,
  1798. GLuint pdFlags, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
  1799. {
  1800. POLYDATA *pd;
  1801. GLMSGBATCHINFO *pMsgBatchInfo;
  1802. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  1803. pMsgBatchInfo = (GLMSGBATCHINFO *) pa->pMsgBatchInfo;
  1804. // If the last command is DrawPolyArray, add it to the command.
  1805. // This allows us to chain primitives separated by the attribute.
  1806. if (pMsgBatchInfo->NextOffset == pa->nextMsgOffset)
  1807. {
  1808. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  1809. ((BYTE *) pMsgBatchInfo + pMsgBatchInfo->NextOffset -
  1810. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  1811. pa = (POLYARRAY *) pMsgDrawPolyArray->paLast;
  1812. pd = pa->pdNextVertex;
  1813. pa->pdCurColor = pd;
  1814. __GL_SCALE_AND_CHECK_CLAMP_RGBA(pd->colors[0].r,
  1815. pd->colors[0].g,
  1816. pd->colors[0].b,
  1817. pd->colors[0].a,
  1818. gc, pa->flags,
  1819. red, green, blue, alpha);
  1820. pd->flags |= pdFlags;
  1821. }
  1822. else
  1823. {
  1824. glcltColor4f_NotInBegin(red, green, blue, alpha);
  1825. }
  1826. }
  1827. #define PA_INDEX_IN_RGBA(i) \
  1828. \
  1829. POLYARRAY *pa; \
  1830. \
  1831. pa = GLTEB_CLTPOLYARRAY(); \
  1832. \
  1833. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1834. { \
  1835. pa->flags |= POLYARRAY_OTHER_COLOR; \
  1836. /* need only record the latest value */ \
  1837. pa->otherColor.r = i; \
  1838. } \
  1839. else \
  1840. { \
  1841. glcltIndexf_NotInBegin(i); \
  1842. }
  1843. #define PA_INDEX_IN_CI(i) \
  1844. \
  1845. POLYARRAY *pa; \
  1846. POLYDATA *pd; \
  1847. __GL_SETUP(); \
  1848. \
  1849. pa = gc->paTeb; \
  1850. \
  1851. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1852. { \
  1853. pd = pa->pdNextVertex; \
  1854. pa->pdCurColor = pd; \
  1855. __GL_CHECK_CLAMP_CI(pd->colors[0].r, gc, pa->flags, i); \
  1856. pd->flags |= POLYDATA_COLOR_VALID; \
  1857. } \
  1858. else \
  1859. { \
  1860. glcltIndexf_InCI_NotInBegin(gc, pa, i); \
  1861. }
  1862. void FASTCALL glcltIndexf_NotInBegin(GLfloat c)
  1863. {
  1864. GLCLIENT_BEGIN( Indexf, INDEXF )
  1865. pMsg->c = c;
  1866. GLCLIENT_END
  1867. }
  1868. void FASTCALL glcltIndexf_InCI_NotInBegin(__GLcontext *gc, POLYARRAY *pa, GLfloat c)
  1869. {
  1870. POLYDATA *pd;
  1871. GLMSGBATCHINFO *pMsgBatchInfo;
  1872. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  1873. pMsgBatchInfo = (GLMSGBATCHINFO *) pa->pMsgBatchInfo;
  1874. // If the last command is DrawPolyArray, add it to the command.
  1875. // This allows us to chain primitives separated by the attribute.
  1876. if (pMsgBatchInfo->NextOffset == pa->nextMsgOffset)
  1877. {
  1878. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  1879. ((BYTE *) pMsgBatchInfo + pMsgBatchInfo->NextOffset -
  1880. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  1881. pa = (POLYARRAY *) pMsgDrawPolyArray->paLast;
  1882. pd = pa->pdNextVertex;
  1883. pa->pdCurColor = pd;
  1884. __GL_CHECK_CLAMP_CI(pd->colors[0].r, gc, pa->flags, c);
  1885. pd->flags |= POLYDATA_COLOR_VALID;
  1886. }
  1887. else
  1888. {
  1889. glcltIndexf_NotInBegin(c);
  1890. }
  1891. }
  1892. #define PA_TEXTURE1(s1) \
  1893. \
  1894. POLYARRAY *pa; \
  1895. POLYDATA *pd; \
  1896. \
  1897. pa = GLTEB_CLTPOLYARRAY(); \
  1898. \
  1899. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1900. { \
  1901. pa->flags |= POLYARRAY_TEXTURE1; \
  1902. \
  1903. pd = pa->pdNextVertex; \
  1904. pa->pdCurTexture = pd; \
  1905. pd->flags |= POLYDATA_TEXTURE_VALID | POLYDATA_DLIST_TEXTURE1; \
  1906. pd->texture.x = s1; \
  1907. pd->texture.y = __glZero; \
  1908. pd->texture.z = __glZero; \
  1909. pd->texture.w = __glOne; \
  1910. } \
  1911. else \
  1912. { \
  1913. glcltTexCoord4f_NotInBegin(pa, POLYARRAY_TEXTURE1, \
  1914. s1, __glZero, __glZero, __glOne); \
  1915. }
  1916. #define PA_TEXTURE2(s1,t1) \
  1917. \
  1918. POLYARRAY *pa; \
  1919. POLYDATA *pd; \
  1920. \
  1921. pa = GLTEB_CLTPOLYARRAY(); \
  1922. \
  1923. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1924. { \
  1925. pa->flags |= POLYARRAY_TEXTURE2; \
  1926. \
  1927. pd = pa->pdNextVertex; \
  1928. pa->pdCurTexture = pd; \
  1929. pd->flags |= POLYDATA_TEXTURE_VALID | POLYDATA_DLIST_TEXTURE2; \
  1930. pd->texture.x = s1; \
  1931. pd->texture.y = t1; \
  1932. pd->texture.z = __glZero; \
  1933. pd->texture.w = __glOne; \
  1934. } \
  1935. else \
  1936. { \
  1937. glcltTexCoord4f_NotInBegin(pa, POLYARRAY_TEXTURE2, \
  1938. s1, t1, __glZero, __glOne); \
  1939. }
  1940. #define PA_TEXTURE3(s1,t1,r1) \
  1941. \
  1942. POLYARRAY *pa; \
  1943. POLYDATA *pd; \
  1944. \
  1945. pa = GLTEB_CLTPOLYARRAY(); \
  1946. \
  1947. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1948. { \
  1949. pa->flags |= POLYARRAY_TEXTURE3; \
  1950. \
  1951. pd = pa->pdNextVertex; \
  1952. pa->pdCurTexture = pd; \
  1953. pd->flags |= POLYDATA_TEXTURE_VALID | POLYDATA_DLIST_TEXTURE3; \
  1954. pd->texture.x = s1; \
  1955. pd->texture.y = t1; \
  1956. pd->texture.z = r1; \
  1957. pd->texture.w = __glOne; \
  1958. } \
  1959. else \
  1960. { \
  1961. glcltTexCoord4f_NotInBegin(pa, POLYARRAY_TEXTURE3, \
  1962. s1, t1, r1, __glOne); \
  1963. }
  1964. #define PA_TEXTURE4(s1,t1,r1,q1) \
  1965. \
  1966. POLYARRAY *pa; \
  1967. POLYDATA *pd; \
  1968. \
  1969. pa = GLTEB_CLTPOLYARRAY(); \
  1970. \
  1971. if (pa->flags & POLYARRAY_IN_BEGIN) \
  1972. { \
  1973. pa->flags |= POLYARRAY_TEXTURE4; \
  1974. \
  1975. pd = pa->pdNextVertex; \
  1976. pa->pdCurTexture = pd; \
  1977. pd->flags |= POLYDATA_TEXTURE_VALID | POLYDATA_DLIST_TEXTURE4; \
  1978. pd->texture.x = s1; \
  1979. pd->texture.y = t1; \
  1980. pd->texture.z = r1; \
  1981. pd->texture.w = q1; \
  1982. } \
  1983. else \
  1984. { \
  1985. glcltTexCoord4f_NotInBegin(pa, POLYARRAY_TEXTURE4, \
  1986. s1, t1, r1, q1); \
  1987. }
  1988. void FASTCALL glcltTexCoord4f_NotInBegin(POLYARRAY *pa, GLuint paFlags,
  1989. GLfloat s, GLfloat t, GLfloat r, GLfloat q)
  1990. {
  1991. POLYDATA *pd;
  1992. GLMSGBATCHINFO *pMsgBatchInfo;
  1993. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  1994. pMsgBatchInfo = (GLMSGBATCHINFO *) pa->pMsgBatchInfo;
  1995. // If the last command is DrawPolyArray, add it to the command.
  1996. // This allows us to chain primitives separated by the attribute.
  1997. if (pMsgBatchInfo->NextOffset == pa->nextMsgOffset)
  1998. {
  1999. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  2000. ((BYTE *) pMsgBatchInfo + pMsgBatchInfo->NextOffset -
  2001. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  2002. pa = (POLYARRAY *) pMsgDrawPolyArray->paLast;
  2003. pa->flags |= paFlags;
  2004. pd = pa->pdNextVertex;
  2005. pa->pdCurTexture = pd;
  2006. pd->flags |= POLYDATA_TEXTURE_VALID | paFlags;
  2007. pd->texture.x = s;
  2008. pd->texture.y = t;
  2009. pd->texture.z = r;
  2010. pd->texture.w = q;
  2011. }
  2012. else
  2013. {
  2014. GLCLIENT_BEGIN( TexCoord4fv, TEXCOORD4FV )
  2015. pMsg->v[0] = s;
  2016. pMsg->v[1] = t;
  2017. pMsg->v[2] = r;
  2018. pMsg->v[3] = q;
  2019. GLCLIENT_END
  2020. }
  2021. }
  2022. #define PA_NORMAL(x1, y1, z1) \
  2023. { \
  2024. POLYARRAY *pa; \
  2025. POLYDATA *pd; \
  2026. ULONG flag1, flag2; \
  2027. \
  2028. pa = GLTEB_CLTPOLYARRAY(); \
  2029. \
  2030. pd = pa->pdNextVertex; \
  2031. flag1 = pa->flags; \
  2032. \
  2033. if (flag1 & POLYARRAY_IN_BEGIN) \
  2034. { \
  2035. flag2 = pd->flags; \
  2036. flag2 |= POLYDATA_NORMAL_VALID; \
  2037. pa->pdCurNormal = pd; \
  2038. pd->normal.x = x1; \
  2039. pd->normal.y = y1; \
  2040. pd->normal.z = z1; \
  2041. pd->flags = flag2; \
  2042. } \
  2043. else \
  2044. { \
  2045. glcltNormal3f_NotInBegin(pa, x1, y1, z1); \
  2046. } \
  2047. \
  2048. }
  2049. void FASTCALL glcltNormal3f_NotInBegin(POLYARRAY *pa, GLfloat nx, GLfloat ny, GLfloat nz)
  2050. {
  2051. POLYDATA *pd;
  2052. GLMSGBATCHINFO *pMsgBatchInfo;
  2053. GLMSG_DRAWPOLYARRAY *pMsgDrawPolyArray;
  2054. pMsgBatchInfo = (GLMSGBATCHINFO *) pa->pMsgBatchInfo;
  2055. // If the last command is DrawPolyArray, add it to the command.
  2056. // This allows us to chain primitives separated by the attribute.
  2057. if (pMsgBatchInfo->NextOffset == pa->nextMsgOffset)
  2058. {
  2059. pMsgDrawPolyArray = (GLMSG_DRAWPOLYARRAY *)
  2060. ((BYTE *) pMsgBatchInfo + pMsgBatchInfo->NextOffset -
  2061. GLMSG_ALIGN(sizeof(GLMSG_DRAWPOLYARRAY)));
  2062. pa = (POLYARRAY *) pMsgDrawPolyArray->paLast;
  2063. pd = pa->pdNextVertex;
  2064. pa->pdCurNormal = pd;
  2065. pd->flags |= POLYDATA_NORMAL_VALID;
  2066. pd->normal.x = nx;
  2067. pd->normal.y = ny;
  2068. pd->normal.z = nz;
  2069. }
  2070. else
  2071. {
  2072. GLCLIENT_BEGIN( Normal3fv, NORMAL3FV )
  2073. pMsg->v[ 0] = nx;
  2074. pMsg->v[ 1] = ny;
  2075. pMsg->v[ 2] = nz;
  2076. GLCLIENT_END
  2077. }
  2078. }
  2079. #define PA_EDGEFLAG(edgeflag) \
  2080. \
  2081. POLYARRAY *pa; \
  2082. POLYDATA *pd; \
  2083. \
  2084. pa = GLTEB_CLTPOLYARRAY(); \
  2085. \
  2086. if (pa->flags & POLYARRAY_IN_BEGIN) \
  2087. { \
  2088. pd = pa->pdNextVertex; \
  2089. pa->pdCurEdgeFlag = pd; \
  2090. if (edgeflag) \
  2091. pd->flags |= POLYDATA_EDGEFLAG_VALID|POLYDATA_EDGEFLAG_BOUNDARY;\
  2092. else \
  2093. { \
  2094. /* must clear POLYDATA_EDGEFLAG_BOUNDARY flag here since */ \
  2095. /* there may have been a previous edge flag for this same */ \
  2096. /* vertex! */ \
  2097. pd->flags &= ~POLYDATA_EDGEFLAG_BOUNDARY; \
  2098. pd->flags |= POLYDATA_EDGEFLAG_VALID; \
  2099. } \
  2100. } \
  2101. else \
  2102. { \
  2103. glcltEdgeFlag_NotInBegin(edgeflag); \
  2104. }
  2105. void FASTCALL glcltEdgeFlag_NotInBegin(GLboolean flag)
  2106. {
  2107. GLCLIENT_BEGIN( EdgeFlag, EDGEFLAG )
  2108. pMsg->flag = flag;
  2109. GLCLIENT_END
  2110. }
  2111. void APIENTRY
  2112. glcltColor3b_InRGBA ( IN GLbyte red, IN GLbyte green, IN GLbyte blue )
  2113. {
  2114. PA_COLOR_IN_RGB1(__GL_B_TO_FLOAT(red), __GL_B_TO_FLOAT(green),
  2115. __GL_B_TO_FLOAT(blue));
  2116. }
  2117. void APIENTRY
  2118. glcltColor3bv_InRGBA ( IN const GLbyte v[3] )
  2119. {
  2120. PA_COLOR_IN_RGB1(__GL_B_TO_FLOAT(v[0]), __GL_B_TO_FLOAT(v[1]),
  2121. __GL_B_TO_FLOAT(v[2]));
  2122. }
  2123. void APIENTRY
  2124. glcltColor3d_InRGBA ( IN GLdouble red, IN GLdouble green, IN GLdouble blue )
  2125. {
  2126. PA_COLOR_IN_RGB1((GLfloat) red, (GLfloat) green,
  2127. (GLfloat) blue);
  2128. }
  2129. void APIENTRY
  2130. glcltColor3dv_InRGBA ( IN const GLdouble v[3] )
  2131. {
  2132. PA_COLOR_IN_RGB1((GLfloat) v[0], (GLfloat) v[1],
  2133. (GLfloat) v[2]);
  2134. }
  2135. #ifndef __GL_ASM_GLCLTCOLOR3F_INRGBA
  2136. void APIENTRY
  2137. glcltColor3f_InRGBA ( IN GLfloat red, IN GLfloat green, IN GLfloat blue )
  2138. {
  2139. PA_COLOR_IN_RGB2(red, green, blue);
  2140. }
  2141. #endif // __GL_ASM_GLCLTCOLOR3F_INRGBA
  2142. #ifndef __GL_ASM_GLCLTCOLOR3FV_INRGBA
  2143. void APIENTRY
  2144. glcltColor3fv_InRGBA ( IN const GLfloat v[3] )
  2145. {
  2146. GLfloat red, green, blue;
  2147. red = (GLfloat) v[0];
  2148. green = (GLfloat) v[1];
  2149. blue = (GLfloat) v[2];
  2150. PA_COLOR_IN_RGB2(red, green, blue);
  2151. }
  2152. #endif // __GL_ASM_GLCLTCOLOR3FV_INRGBA
  2153. void APIENTRY
  2154. glcltColor3i_InRGBA ( IN GLint red, IN GLint green, IN GLint blue )
  2155. {
  2156. PA_COLOR_IN_RGB1(__GL_I_TO_FLOAT(red), __GL_I_TO_FLOAT(green),
  2157. __GL_I_TO_FLOAT(blue));
  2158. }
  2159. void APIENTRY
  2160. glcltColor3iv_InRGBA ( IN const GLint v[3] )
  2161. {
  2162. PA_COLOR_IN_RGB1(__GL_I_TO_FLOAT(v[0]), __GL_I_TO_FLOAT(v[1]),
  2163. __GL_I_TO_FLOAT(v[2]));
  2164. }
  2165. void APIENTRY
  2166. glcltColor3s_InRGBA ( IN GLshort red, IN GLshort green, IN GLshort blue )
  2167. {
  2168. PA_COLOR_IN_RGB1(__GL_S_TO_FLOAT(red), __GL_S_TO_FLOAT(green),
  2169. __GL_S_TO_FLOAT(blue));
  2170. }
  2171. void APIENTRY
  2172. glcltColor3sv_InRGBA ( IN const GLshort v[3] )
  2173. {
  2174. PA_COLOR_IN_RGB1(__GL_S_TO_FLOAT(v[0]), __GL_S_TO_FLOAT(v[1]),
  2175. __GL_S_TO_FLOAT(v[2]));
  2176. }
  2177. void APIENTRY
  2178. glcltColor3ub_InRGBA ( IN GLubyte red, IN GLubyte green, IN GLubyte blue )
  2179. {
  2180. PA_COLOR_IN_RGBA_NO_CLAMP1(__GL_UB_TO_FLOAT(red), __GL_UB_TO_FLOAT(green),
  2181. __GL_UB_TO_FLOAT(blue));
  2182. }
  2183. void APIENTRY
  2184. glcltColor3ubv_InRGBA ( IN const GLubyte v[3] )
  2185. {
  2186. PA_COLOR_IN_RGBA_NO_CLAMP1(__GL_UB_TO_FLOAT(v[0]), __GL_UB_TO_FLOAT(v[1]),
  2187. __GL_UB_TO_FLOAT(v[2]));
  2188. }
  2189. void APIENTRY
  2190. glcltColor3ui_InRGBA ( IN GLuint red, IN GLuint green, IN GLuint blue )
  2191. {
  2192. PA_COLOR_IN_RGB1(__GL_UI_TO_FLOAT(red), __GL_UI_TO_FLOAT(green),
  2193. __GL_UI_TO_FLOAT(blue));
  2194. }
  2195. void APIENTRY
  2196. glcltColor3uiv_InRGBA ( IN const GLuint v[3] )
  2197. {
  2198. PA_COLOR_IN_RGB1(__GL_UI_TO_FLOAT(v[0]), __GL_UI_TO_FLOAT(v[1]),
  2199. __GL_UI_TO_FLOAT(v[2]));
  2200. }
  2201. void APIENTRY
  2202. glcltColor3us_InRGBA ( IN GLushort red, IN GLushort green, IN GLushort blue )
  2203. {
  2204. PA_COLOR_IN_RGBA_NO_CLAMP1(__GL_US_TO_FLOAT(red), __GL_US_TO_FLOAT(green),
  2205. __GL_US_TO_FLOAT(blue));
  2206. }
  2207. void APIENTRY
  2208. glcltColor3usv_InRGBA ( IN const GLushort v[3] )
  2209. {
  2210. PA_COLOR_IN_RGBA_NO_CLAMP1(__GL_US_TO_FLOAT(v[0]), __GL_US_TO_FLOAT(v[1]),
  2211. __GL_US_TO_FLOAT(v[2]));
  2212. }
  2213. void APIENTRY
  2214. glcltColor4b_InRGBA ( IN GLbyte red, IN GLbyte green, IN GLbyte blue, IN GLbyte alpha )
  2215. {
  2216. PA_COLOR_IN_RGBA(__GL_B_TO_FLOAT(red), __GL_B_TO_FLOAT(green),
  2217. __GL_B_TO_FLOAT(blue), __GL_B_TO_FLOAT(alpha));
  2218. }
  2219. void APIENTRY
  2220. glcltColor4bv_InRGBA ( IN const GLbyte v[4] )
  2221. {
  2222. PA_COLOR_IN_RGBA(__GL_B_TO_FLOAT(v[0]), __GL_B_TO_FLOAT(v[1]),
  2223. __GL_B_TO_FLOAT(v[2]), __GL_B_TO_FLOAT(v[3]));
  2224. }
  2225. void APIENTRY
  2226. glcltColor4d_InRGBA ( IN GLdouble red, IN GLdouble green, IN GLdouble blue, IN GLdouble alpha )
  2227. {
  2228. PA_COLOR_IN_RGBA((GLfloat) red, (GLfloat) green,
  2229. (GLfloat) blue, (GLfloat) alpha);
  2230. }
  2231. void APIENTRY
  2232. glcltColor4dv_InRGBA ( IN const GLdouble v[4] )
  2233. {
  2234. PA_COLOR_IN_RGBA((GLfloat) v[0], (GLfloat) v[1],
  2235. (GLfloat) v[2], (GLfloat) v[3]);
  2236. }
  2237. #ifndef __GL_ASM_GLCLTCOLOR4F_INRGBA
  2238. void APIENTRY
  2239. glcltColor4f_InRGBA ( IN GLfloat red, IN GLfloat green, IN GLfloat blue, IN GLfloat alpha )
  2240. {
  2241. PA_COLOR_IN_RGBA(red, green, blue, alpha);
  2242. }
  2243. #endif // __GL_ASM_GLCLTCOLOR4F_INRGBA
  2244. #ifndef __GL_ASM_GLCLTCOLOR4FV_INRGBA
  2245. void APIENTRY
  2246. glcltColor4fv_InRGBA ( IN const GLfloat v[4] )
  2247. {
  2248. PA_COLOR_IN_RGBA(v[0], v[1], v[2], v[3]);
  2249. }
  2250. #endif // __GL_ASM_GLCLTCOLOR4FV_INRGBA
  2251. void APIENTRY
  2252. glcltColor4i_InRGBA ( IN GLint red, IN GLint green, IN GLint blue, IN GLint alpha )
  2253. {
  2254. PA_COLOR_IN_RGBA(__GL_I_TO_FLOAT(red), __GL_I_TO_FLOAT(green),
  2255. __GL_I_TO_FLOAT(blue), __GL_I_TO_FLOAT(alpha));
  2256. }
  2257. void APIENTRY
  2258. glcltColor4iv_InRGBA ( IN const GLint v[4] )
  2259. {
  2260. PA_COLOR_IN_RGBA(__GL_I_TO_FLOAT(v[0]), __GL_I_TO_FLOAT(v[1]),
  2261. __GL_I_TO_FLOAT(v[2]), __GL_I_TO_FLOAT(v[3]));
  2262. }
  2263. void APIENTRY
  2264. glcltColor4s_InRGBA ( IN GLshort red, IN GLshort green, IN GLshort blue, IN GLshort alpha )
  2265. {
  2266. PA_COLOR_IN_RGBA(__GL_S_TO_FLOAT(red), __GL_S_TO_FLOAT(green),
  2267. __GL_S_TO_FLOAT(blue), __GL_S_TO_FLOAT(alpha));
  2268. }
  2269. void APIENTRY
  2270. glcltColor4sv_InRGBA ( IN const GLshort v[4] )
  2271. {
  2272. PA_COLOR_IN_RGBA(__GL_S_TO_FLOAT(v[0]), __GL_S_TO_FLOAT(v[1]),
  2273. __GL_S_TO_FLOAT(v[2]), __GL_S_TO_FLOAT(v[3]));
  2274. }
  2275. void APIENTRY
  2276. glcltColor4ub_InRGBA ( IN GLubyte red, IN GLubyte green, IN GLubyte blue, IN GLubyte alpha )
  2277. {
  2278. PA_COLOR_IN_RGBA_NO_CLAMP(__GL_UB_TO_FLOAT(red), __GL_UB_TO_FLOAT(green),
  2279. __GL_UB_TO_FLOAT(blue), __GL_UB_TO_FLOAT(alpha));
  2280. }
  2281. void APIENTRY
  2282. glcltColor4ubv_InRGBA ( IN const GLubyte v[4] )
  2283. {
  2284. PA_COLOR_IN_RGBA_NO_CLAMP(__GL_UB_TO_FLOAT(v[0]), __GL_UB_TO_FLOAT(v[1]),
  2285. __GL_UB_TO_FLOAT(v[2]), __GL_UB_TO_FLOAT(v[3]));
  2286. }
  2287. void APIENTRY
  2288. glcltColor4ui_InRGBA ( IN GLuint red, IN GLuint green, IN GLuint blue, IN GLuint alpha )
  2289. {
  2290. PA_COLOR_IN_RGBA(__GL_UI_TO_FLOAT(red), __GL_UI_TO_FLOAT(green),
  2291. __GL_UI_TO_FLOAT(blue), __GL_UI_TO_FLOAT(alpha));
  2292. }
  2293. void APIENTRY
  2294. glcltColor4uiv_InRGBA ( IN const GLuint v[4] )
  2295. {
  2296. PA_COLOR_IN_RGBA(__GL_UI_TO_FLOAT(v[0]), __GL_UI_TO_FLOAT(v[1]),
  2297. __GL_UI_TO_FLOAT(v[2]), __GL_UI_TO_FLOAT(v[3]));
  2298. }
  2299. void APIENTRY
  2300. glcltColor4us_InRGBA ( IN GLushort red, IN GLushort green, IN GLushort blue, IN GLushort alpha )
  2301. {
  2302. PA_COLOR_IN_RGBA_NO_CLAMP(__GL_US_TO_FLOAT(red), __GL_US_TO_FLOAT(green),
  2303. __GL_US_TO_FLOAT(blue), __GL_US_TO_FLOAT(alpha));
  2304. }
  2305. void APIENTRY
  2306. glcltColor4usv_InRGBA ( IN const GLushort v[4] )
  2307. {
  2308. PA_COLOR_IN_RGBA_NO_CLAMP(__GL_US_TO_FLOAT(v[0]), __GL_US_TO_FLOAT(v[1]),
  2309. __GL_US_TO_FLOAT(v[2]), __GL_US_TO_FLOAT(v[3]));
  2310. }
  2311. void APIENTRY
  2312. glcltColor3b_InCI ( IN GLbyte red, IN GLbyte green, IN GLbyte blue )
  2313. {
  2314. PA_COLOR_IN_CI(__GL_B_TO_FLOAT(red), __GL_B_TO_FLOAT(green),
  2315. __GL_B_TO_FLOAT(blue), __glOne);
  2316. }
  2317. void APIENTRY
  2318. glcltColor3bv_InCI ( IN const GLbyte v[3] )
  2319. {
  2320. PA_COLOR_IN_CI(__GL_B_TO_FLOAT(v[0]), __GL_B_TO_FLOAT(v[1]),
  2321. __GL_B_TO_FLOAT(v[2]), __glOne);
  2322. }
  2323. void APIENTRY
  2324. glcltColor3d_InCI ( IN GLdouble red, IN GLdouble green, IN GLdouble blue )
  2325. {
  2326. PA_COLOR_IN_CI((GLfloat) red, (GLfloat) green,
  2327. (GLfloat) blue, __glOne);
  2328. }
  2329. void APIENTRY
  2330. glcltColor3dv_InCI ( IN const GLdouble v[3] )
  2331. {
  2332. PA_COLOR_IN_CI((GLfloat) v[0], (GLfloat) v[1],
  2333. (GLfloat) v[2], __glOne);
  2334. }
  2335. void APIENTRY
  2336. glcltColor3f_InCI ( IN GLfloat red, IN GLfloat green, IN GLfloat blue )
  2337. {
  2338. PA_COLOR_IN_CI(red, green, blue, __glOne);
  2339. }
  2340. void APIENTRY
  2341. glcltColor3fv_InCI ( IN const GLfloat v[3] )
  2342. {
  2343. PA_COLOR_IN_CI(v[0], v[1], v[2], __glOne);
  2344. }
  2345. void APIENTRY
  2346. glcltColor3i_InCI ( IN GLint red, IN GLint green, IN GLint blue )
  2347. {
  2348. PA_COLOR_IN_CI(__GL_I_TO_FLOAT(red), __GL_I_TO_FLOAT(green),
  2349. __GL_I_TO_FLOAT(blue), __glOne);
  2350. }
  2351. void APIENTRY
  2352. glcltColor3iv_InCI ( IN const GLint v[3] )
  2353. {
  2354. PA_COLOR_IN_CI(__GL_I_TO_FLOAT(v[0]), __GL_I_TO_FLOAT(v[1]),
  2355. __GL_I_TO_FLOAT(v[2]), __glOne);
  2356. }
  2357. void APIENTRY
  2358. glcltColor3s_InCI ( IN GLshort red, IN GLshort green, IN GLshort blue )
  2359. {
  2360. PA_COLOR_IN_CI(__GL_S_TO_FLOAT(red), __GL_S_TO_FLOAT(green),
  2361. __GL_S_TO_FLOAT(blue), __glOne);
  2362. }
  2363. void APIENTRY
  2364. glcltColor3sv_InCI ( IN const GLshort v[3] )
  2365. {
  2366. PA_COLOR_IN_CI(__GL_S_TO_FLOAT(v[0]), __GL_S_TO_FLOAT(v[1]),
  2367. __GL_S_TO_FLOAT(v[2]), __glOne);
  2368. }
  2369. void APIENTRY
  2370. glcltColor3ub_InCI ( IN GLubyte red, IN GLubyte green, IN GLubyte blue )
  2371. {
  2372. PA_COLOR_IN_CI(__GL_UB_TO_FLOAT(red), __GL_UB_TO_FLOAT(green),
  2373. __GL_UB_TO_FLOAT(blue), __glOne);
  2374. }
  2375. void APIENTRY
  2376. glcltColor3ubv_InCI ( IN const GLubyte v[3] )
  2377. {
  2378. PA_COLOR_IN_CI(__GL_UB_TO_FLOAT(v[0]), __GL_UB_TO_FLOAT(v[1]),
  2379. __GL_UB_TO_FLOAT(v[2]), __glOne);
  2380. }
  2381. void APIENTRY
  2382. glcltColor3ui_InCI ( IN GLuint red, IN GLuint green, IN GLuint blue )
  2383. {
  2384. PA_COLOR_IN_CI(__GL_UI_TO_FLOAT(red), __GL_UI_TO_FLOAT(green),
  2385. __GL_UI_TO_FLOAT(blue), __glOne);
  2386. }
  2387. void APIENTRY
  2388. glcltColor3uiv_InCI ( IN const GLuint v[3] )
  2389. {
  2390. PA_COLOR_IN_CI(__GL_UI_TO_FLOAT(v[0]), __GL_UI_TO_FLOAT(v[1]),
  2391. __GL_UI_TO_FLOAT(v[2]), __glOne);
  2392. }
  2393. void APIENTRY
  2394. glcltColor3us_InCI ( IN GLushort red, IN GLushort green, IN GLushort blue )
  2395. {
  2396. PA_COLOR_IN_CI(__GL_US_TO_FLOAT(red), __GL_US_TO_FLOAT(green),
  2397. __GL_US_TO_FLOAT(blue), __glOne);
  2398. }
  2399. void APIENTRY
  2400. glcltColor3usv_InCI ( IN const GLushort v[3] )
  2401. {
  2402. PA_COLOR_IN_CI(__GL_US_TO_FLOAT(v[0]), __GL_US_TO_FLOAT(v[1]),
  2403. __GL_US_TO_FLOAT(v[2]), __glOne);
  2404. }
  2405. void APIENTRY
  2406. glcltColor4b_InCI ( IN GLbyte red, IN GLbyte green, IN GLbyte blue, IN GLbyte alpha )
  2407. {
  2408. PA_COLOR_IN_CI(__GL_B_TO_FLOAT(red), __GL_B_TO_FLOAT(green),
  2409. __GL_B_TO_FLOAT(blue), __GL_B_TO_FLOAT(alpha));
  2410. }
  2411. void APIENTRY
  2412. glcltColor4bv_InCI ( IN const GLbyte v[4] )
  2413. {
  2414. PA_COLOR_IN_CI(__GL_B_TO_FLOAT(v[0]), __GL_B_TO_FLOAT(v[1]),
  2415. __GL_B_TO_FLOAT(v[2]), __GL_B_TO_FLOAT(v[3]));
  2416. }
  2417. void APIENTRY
  2418. glcltColor4d_InCI ( IN GLdouble red, IN GLdouble green, IN GLdouble blue, IN GLdouble alpha )
  2419. {
  2420. PA_COLOR_IN_CI((GLfloat) red, (GLfloat) green,
  2421. (GLfloat) blue, (GLfloat) alpha);
  2422. }
  2423. void APIENTRY
  2424. glcltColor4dv_InCI ( IN const GLdouble v[4] )
  2425. {
  2426. PA_COLOR_IN_CI((GLfloat) v[0], (GLfloat) v[1],
  2427. (GLfloat) v[2], (GLfloat) v[3]);
  2428. }
  2429. void APIENTRY
  2430. glcltColor4f_InCI ( IN GLfloat red, IN GLfloat green, IN GLfloat blue, IN GLfloat alpha )
  2431. {
  2432. PA_COLOR_IN_CI(red, green, blue, alpha);
  2433. }
  2434. void APIENTRY
  2435. glcltColor4fv_InCI ( IN const GLfloat v[4] )
  2436. {
  2437. PA_COLOR_IN_CI(v[0], v[1], v[2], v[3]);
  2438. }
  2439. void APIENTRY
  2440. glcltColor4i_InCI ( IN GLint red, IN GLint green, IN GLint blue, IN GLint alpha )
  2441. {
  2442. PA_COLOR_IN_CI(__GL_I_TO_FLOAT(red), __GL_I_TO_FLOAT(green),
  2443. __GL_I_TO_FLOAT(blue), __GL_I_TO_FLOAT(alpha));
  2444. }
  2445. void APIENTRY
  2446. glcltColor4iv_InCI ( IN const GLint v[4] )
  2447. {
  2448. PA_COLOR_IN_CI(__GL_I_TO_FLOAT(v[0]), __GL_I_TO_FLOAT(v[1]),
  2449. __GL_I_TO_FLOAT(v[2]), __GL_I_TO_FLOAT(v[3]));
  2450. }
  2451. void APIENTRY
  2452. glcltColor4s_InCI ( IN GLshort red, IN GLshort green, IN GLshort blue, IN GLshort alpha )
  2453. {
  2454. PA_COLOR_IN_CI(__GL_S_TO_FLOAT(red), __GL_S_TO_FLOAT(green),
  2455. __GL_S_TO_FLOAT(blue), __GL_S_TO_FLOAT(alpha));
  2456. }
  2457. void APIENTRY
  2458. glcltColor4sv_InCI ( IN const GLshort v[4] )
  2459. {
  2460. PA_COLOR_IN_CI(__GL_S_TO_FLOAT(v[0]), __GL_S_TO_FLOAT(v[1]),
  2461. __GL_S_TO_FLOAT(v[2]), __GL_S_TO_FLOAT(v[3]));
  2462. }
  2463. void APIENTRY
  2464. glcltColor4ub_InCI ( IN GLubyte red, IN GLubyte green, IN GLubyte blue, IN GLubyte alpha )
  2465. {
  2466. PA_COLOR_IN_CI(__GL_UB_TO_FLOAT(red), __GL_UB_TO_FLOAT(green),
  2467. __GL_UB_TO_FLOAT(blue), __GL_UB_TO_FLOAT(alpha));
  2468. }
  2469. void APIENTRY
  2470. glcltColor4ubv_InCI ( IN const GLubyte v[4] )
  2471. {
  2472. PA_COLOR_IN_CI(__GL_UB_TO_FLOAT(v[0]), __GL_UB_TO_FLOAT(v[1]),
  2473. __GL_UB_TO_FLOAT(v[2]), __GL_UB_TO_FLOAT(v[3]));
  2474. }
  2475. void APIENTRY
  2476. glcltColor4ui_InCI ( IN GLuint red, IN GLuint green, IN GLuint blue, IN GLuint alpha )
  2477. {
  2478. PA_COLOR_IN_CI(__GL_UI_TO_FLOAT(red), __GL_UI_TO_FLOAT(green),
  2479. __GL_UI_TO_FLOAT(blue), __GL_UI_TO_FLOAT(alpha));
  2480. }
  2481. void APIENTRY
  2482. glcltColor4uiv_InCI ( IN const GLuint v[4] )
  2483. {
  2484. PA_COLOR_IN_CI(__GL_UI_TO_FLOAT(v[0]), __GL_UI_TO_FLOAT(v[1]),
  2485. __GL_UI_TO_FLOAT(v[2]), __GL_UI_TO_FLOAT(v[3]));
  2486. }
  2487. void APIENTRY
  2488. glcltColor4us_InCI ( IN GLushort red, IN GLushort green, IN GLushort blue, IN GLushort alpha )
  2489. {
  2490. PA_COLOR_IN_CI(__GL_US_TO_FLOAT(red), __GL_US_TO_FLOAT(green),
  2491. __GL_US_TO_FLOAT(blue), __GL_US_TO_FLOAT(alpha));
  2492. }
  2493. void APIENTRY
  2494. glcltColor4usv_InCI ( IN const GLushort v[4] )
  2495. {
  2496. PA_COLOR_IN_CI(__GL_US_TO_FLOAT(v[0]), __GL_US_TO_FLOAT(v[1]),
  2497. __GL_US_TO_FLOAT(v[2]), __GL_US_TO_FLOAT(v[3]));
  2498. }
  2499. // Allocate a __GLmatChange structure.
  2500. //
  2501. // The POLYMATERIAL structure contains pointers to __GLmatChange arrays.
  2502. // These __GLmatChange structures are used to record material changes to
  2503. // vertices in the vertex buffer.
  2504. //
  2505. // To reduce memory requirement, the POLYMATERIAL structure keeps an array
  2506. // of pointers to __GLmatChange arrays. Each __GLmatChange array is
  2507. // allocated as needed.
  2508. //
  2509. // An iMat index is used to keep track of the next free __GLmatChange
  2510. // entry. When the poly array buffer is flushed in glsbAttention, iMat
  2511. // is reset to 0.
  2512. //
  2513. // The POLYMATERIAL structure and its __GLmatChange arrays are part of
  2514. // a thread local storage and are freed when the thread exits.
  2515. __GLmatChange * FASTCALL PAMatAlloc()
  2516. {
  2517. POLYMATERIAL *pm;
  2518. GLuint iArray, iMat;
  2519. #if DBG
  2520. __GL_SETUP();
  2521. #endif
  2522. pm = GLTEB_CLTPOLYMATERIAL();
  2523. // Allocate a POLYMATERIAL structure for this thread if one does not exist.
  2524. if (!pm)
  2525. {
  2526. GLuint nv, aMatSize;
  2527. __GL_SETUP();
  2528. nv = gc->vertex.pdBufSize;
  2529. aMatSize = nv * 2 / POLYMATERIAL_ARRAY_SIZE + 1;
  2530. if (!(pm = (POLYMATERIAL *) ALLOCZ(
  2531. // Base size
  2532. sizeof(POLYMATERIAL) - sizeof(__GLmatChange *) +
  2533. // array of pointers to __GLmatChange arrays
  2534. aMatSize * sizeof(__GLmatChange *) +
  2535. // the PDMATERIAL array
  2536. nv * sizeof(PDMATERIAL))))
  2537. {
  2538. GLSETERROR(GL_OUT_OF_MEMORY);
  2539. return NULL;
  2540. }
  2541. pm->aMatSize = aMatSize;
  2542. // Initialize pointer to the PDMATERIAL array
  2543. pm->pdMaterial0 = (PDMATERIAL *) &pm->aMat[aMatSize];
  2544. GLTEB_SET_CLTPOLYMATERIAL(pm);
  2545. }
  2546. // Sanity check that pdBufSize has not changed.
  2547. ASSERTOPENGL
  2548. (
  2549. pm->aMatSize == gc->vertex.pdBufSize * 2 / POLYMATERIAL_ARRAY_SIZE + 1,
  2550. "vertex buffer size has changed!\n"
  2551. );
  2552. // Find the material array from which to allocate the material change structure.
  2553. iMat = pm->iMat;
  2554. iArray = iMat / POLYMATERIAL_ARRAY_SIZE;
  2555. iMat = iMat % POLYMATERIAL_ARRAY_SIZE;
  2556. ASSERTOPENGL(iArray < pm->aMatSize, "iArray exceeds range!\n");
  2557. // Allocate the material array if it has not been allocated.
  2558. if (!(pm->aMat[iArray]))
  2559. {
  2560. if (!(pm->aMat[iArray] = (__GLmatChange *) ALLOC(
  2561. sizeof(__GLmatChange) * POLYMATERIAL_ARRAY_SIZE)))
  2562. {
  2563. GLSETERROR(GL_OUT_OF_MEMORY);
  2564. return NULL;
  2565. }
  2566. }
  2567. // Advance next available material pointer.
  2568. pm->iMat++;
  2569. ASSERTOPENGL(pm->iMat <= gc->vertex.pdBufSize * 2,
  2570. "too many material changes!\n");
  2571. // Return the material change.
  2572. return (&pm->aMat[iArray][iMat]);
  2573. }
  2574. // Free polymaterial for current thread.
  2575. void FASTCALL FreePolyMaterial(void)
  2576. {
  2577. POLYMATERIAL *pm = GLTEB_CLTPOLYMATERIAL();
  2578. GLuint i;
  2579. if (pm)
  2580. {
  2581. for (i = 0; i < pm->aMatSize && pm->aMat[i]; i++)
  2582. {
  2583. FREE(pm->aMat[i]);
  2584. }
  2585. FREE(pm);
  2586. GLTEB_SET_CLTPOLYMATERIAL(NULL);
  2587. }
  2588. }
  2589. #if !((POLYARRAY_MATERIAL_FRONT == POLYDATA_MATERIAL_FRONT) \
  2590. && (POLYARRAY_MATERIAL_BACK == POLYDATA_MATERIAL_BACK))
  2591. #error "bad material mask\n"
  2592. #endif
  2593. void APIENTRY
  2594. glcltMaterialfv ( IN GLenum face, IN GLenum pname, IN const GLfloat params[] )
  2595. {
  2596. POLYARRAY *pa;
  2597. POLYDATA *pd;
  2598. GLuint i, pdFlags, dirtyBits, matMask;
  2599. POLYMATERIAL *pm;
  2600. pa = GLTEB_CLTPOLYARRAY();
  2601. if (pa->flags & POLYARRAY_IN_BEGIN)
  2602. {
  2603. switch (pname)
  2604. {
  2605. case GL_SHININESS:
  2606. if (params[0] < (GLfloat) 0 || params[0] > (GLfloat) 128)
  2607. {
  2608. GLSETERROR(GL_INVALID_VALUE);
  2609. return;
  2610. }
  2611. dirtyBits = __GL_MATERIAL_SHININESS;
  2612. break;
  2613. case GL_EMISSION:
  2614. dirtyBits = __GL_MATERIAL_EMISSIVE;
  2615. break;
  2616. case GL_AMBIENT:
  2617. dirtyBits = __GL_MATERIAL_AMBIENT;
  2618. break;
  2619. case GL_DIFFUSE:
  2620. dirtyBits = __GL_MATERIAL_DIFFUSE;
  2621. break;
  2622. case GL_SPECULAR:
  2623. dirtyBits = __GL_MATERIAL_SPECULAR;
  2624. break;
  2625. case GL_AMBIENT_AND_DIFFUSE:
  2626. dirtyBits = __GL_MATERIAL_AMBIENT | __GL_MATERIAL_DIFFUSE;
  2627. break;
  2628. case GL_COLOR_INDEXES:
  2629. dirtyBits = __GL_MATERIAL_COLORINDEXES;
  2630. break;
  2631. default:
  2632. GLSETERROR(GL_INVALID_ENUM);
  2633. return;
  2634. }
  2635. switch (face)
  2636. {
  2637. case GL_FRONT:
  2638. pdFlags = POLYDATA_MATERIAL_FRONT;
  2639. break;
  2640. case GL_BACK:
  2641. pdFlags = POLYDATA_MATERIAL_BACK;
  2642. break;
  2643. case GL_FRONT_AND_BACK:
  2644. pdFlags = POLYDATA_MATERIAL_FRONT | POLYDATA_MATERIAL_BACK;
  2645. break;
  2646. default:
  2647. GLSETERROR(GL_INVALID_ENUM);
  2648. return;
  2649. }
  2650. // Update pa flags POLYARRAY_MATERIAL_FRONT and POLYARRAY_MATERIAL_BACK.
  2651. pa->flags |= pdFlags;
  2652. // Do front and back material for this vertex
  2653. // Overwrite the previous material changes for this vertex if they exist since
  2654. // only the last material changes matter.
  2655. pd = pa->pdNextVertex;
  2656. for (i = 0, matMask = POLYDATA_MATERIAL_FRONT;
  2657. i < 2;
  2658. i++, matMask = POLYDATA_MATERIAL_BACK)
  2659. {
  2660. __GLmatChange *pdMat;
  2661. if (!(pdFlags & matMask))
  2662. continue;
  2663. // allocate __GLmatChange structure if this vertex hasn't got one
  2664. if (!(pd->flags & matMask))
  2665. {
  2666. if (!(pdMat = PAMatAlloc()))
  2667. return;
  2668. // Get POLYMATERIAL pointer after PAMatAlloc!
  2669. pm = GLTEB_CLTPOLYMATERIAL();
  2670. if (matMask == POLYDATA_MATERIAL_FRONT)
  2671. pm->pdMaterial0[pd - pa->pdBuffer0].front = pdMat;
  2672. else
  2673. pm->pdMaterial0[pd - pa->pdBuffer0].back = pdMat;
  2674. pdMat->dirtyBits = dirtyBits;
  2675. }
  2676. else
  2677. {
  2678. pm = GLTEB_CLTPOLYMATERIAL();
  2679. if (matMask == POLYDATA_MATERIAL_FRONT)
  2680. pdMat = pm->pdMaterial0[pd - pa->pdBuffer0].front;
  2681. else
  2682. pdMat = pm->pdMaterial0[pd - pa->pdBuffer0].back;
  2683. pdMat->dirtyBits |= dirtyBits;
  2684. }
  2685. if (dirtyBits & __GL_MATERIAL_SHININESS)
  2686. {
  2687. pdMat->shininess = params[0];
  2688. }
  2689. else if (dirtyBits & __GL_MATERIAL_COLORINDEXES)
  2690. {
  2691. pdMat->cmapa = params[0];
  2692. pdMat->cmapd = params[1];
  2693. pdMat->cmaps = params[2];
  2694. }
  2695. else if (dirtyBits & __GL_MATERIAL_EMISSIVE)
  2696. {
  2697. pdMat->emissive.r = params[0];
  2698. pdMat->emissive.g = params[1];
  2699. pdMat->emissive.b = params[2];
  2700. pdMat->emissive.a = params[3];
  2701. }
  2702. else if (dirtyBits & __GL_MATERIAL_SPECULAR)
  2703. {
  2704. pdMat->specular.r = params[0];
  2705. pdMat->specular.g = params[1];
  2706. pdMat->specular.b = params[2];
  2707. pdMat->specular.a = params[3];
  2708. }
  2709. else
  2710. {
  2711. // ambient and/or diffuse
  2712. if (dirtyBits & __GL_MATERIAL_AMBIENT)
  2713. {
  2714. pdMat->ambient.r = params[0];
  2715. pdMat->ambient.g = params[1];
  2716. pdMat->ambient.b = params[2];
  2717. pdMat->ambient.a = params[3];
  2718. }
  2719. if (dirtyBits & __GL_MATERIAL_DIFFUSE)
  2720. {
  2721. pdMat->diffuse.r = params[0];
  2722. pdMat->diffuse.g = params[1];
  2723. pdMat->diffuse.b = params[2];
  2724. pdMat->diffuse.a = params[3];
  2725. }
  2726. }
  2727. }
  2728. // Finally, update pd flags
  2729. pd->flags |= pdFlags;
  2730. }
  2731. else
  2732. {
  2733. int cArgs;
  2734. switch (pname)
  2735. {
  2736. case GL_SHININESS:
  2737. if (params[0] < (GLfloat) 0 || params[0] > (GLfloat) 128)
  2738. {
  2739. GLSETERROR(GL_INVALID_VALUE);
  2740. return;
  2741. }
  2742. cArgs = 1;
  2743. break;
  2744. case GL_EMISSION:
  2745. case GL_AMBIENT:
  2746. case GL_DIFFUSE:
  2747. case GL_SPECULAR:
  2748. case GL_AMBIENT_AND_DIFFUSE:
  2749. cArgs = 4;
  2750. break;
  2751. case GL_COLOR_INDEXES:
  2752. cArgs = 3;
  2753. break;
  2754. default:
  2755. GLSETERROR(GL_INVALID_ENUM);
  2756. return;
  2757. }
  2758. switch (face)
  2759. {
  2760. case GL_FRONT:
  2761. case GL_BACK:
  2762. case GL_FRONT_AND_BACK:
  2763. break;
  2764. default:
  2765. GLSETERROR(GL_INVALID_ENUM);
  2766. return;
  2767. }
  2768. GLCLIENT_BEGIN( Materialfv, MATERIALFV )
  2769. pMsg->face = face;
  2770. pMsg->pname = pname;
  2771. while (--cArgs >= 0)
  2772. pMsg->params[cArgs] = params[cArgs];
  2773. GLCLIENT_END
  2774. }
  2775. }
  2776. void APIENTRY
  2777. glcltMaterialf ( IN GLenum face, IN GLenum pname, IN GLfloat param )
  2778. {
  2779. if (pname != GL_SHININESS)
  2780. {
  2781. GLSETERROR(GL_INVALID_ENUM);
  2782. return;
  2783. }
  2784. glcltMaterialfv(face, pname, &param);
  2785. }
  2786. void APIENTRY
  2787. glcltMateriali ( IN GLenum face, IN GLenum pname, IN GLint param )
  2788. {
  2789. GLfloat fParams[1];
  2790. if (pname != GL_SHININESS)
  2791. {
  2792. GLSETERROR(GL_INVALID_ENUM);
  2793. return;
  2794. }
  2795. fParams[0] = (GLfloat) param;
  2796. glcltMaterialfv(face, pname, fParams);
  2797. }
  2798. void APIENTRY
  2799. glcltMaterialiv ( IN GLenum face, IN GLenum pname, IN const GLint params[] )
  2800. {
  2801. GLfloat fParams[4];
  2802. switch (pname)
  2803. {
  2804. case GL_EMISSION:
  2805. case GL_AMBIENT:
  2806. case GL_DIFFUSE:
  2807. case GL_SPECULAR:
  2808. case GL_AMBIENT_AND_DIFFUSE:
  2809. fParams[0] = __GL_I_TO_FLOAT(params[0]);
  2810. fParams[1] = __GL_I_TO_FLOAT(params[1]);
  2811. fParams[2] = __GL_I_TO_FLOAT(params[2]);
  2812. fParams[3] = __GL_I_TO_FLOAT(params[3]);
  2813. break;
  2814. case GL_COLOR_INDEXES:
  2815. fParams[2] = (GLfloat) params[2];
  2816. fParams[1] = (GLfloat) params[1];
  2817. case GL_SHININESS:
  2818. fParams[0] = (GLfloat) params[0];
  2819. break;
  2820. }
  2821. glcltMaterialfv(face, pname, fParams);
  2822. }
  2823. void APIENTRY
  2824. glcltEdgeFlag ( IN GLboolean flag )
  2825. {
  2826. PA_EDGEFLAG(flag);
  2827. }
  2828. void APIENTRY
  2829. glcltEdgeFlagv ( IN const GLboolean flag[1] )
  2830. {
  2831. PA_EDGEFLAG(flag[0]);
  2832. }
  2833. void APIENTRY
  2834. glcltIndexd_InCI ( IN GLdouble c )
  2835. {
  2836. PA_INDEX_IN_CI((GLfloat) c);
  2837. }
  2838. void APIENTRY
  2839. glcltIndexdv_InCI ( IN const GLdouble c[1] )
  2840. {
  2841. PA_INDEX_IN_CI((GLfloat) c[0]);
  2842. }
  2843. void APIENTRY
  2844. glcltIndexf_InCI ( IN GLfloat c )
  2845. {
  2846. PA_INDEX_IN_CI((GLfloat) c);
  2847. }
  2848. void APIENTRY
  2849. glcltIndexfv_InCI ( IN const GLfloat c[1] )
  2850. {
  2851. PA_INDEX_IN_CI((GLfloat) c[0]);
  2852. }
  2853. void APIENTRY
  2854. glcltIndexi_InCI ( IN GLint c )
  2855. {
  2856. PA_INDEX_IN_CI((GLfloat) c);
  2857. }
  2858. void APIENTRY
  2859. glcltIndexiv_InCI ( IN const GLint c[1] )
  2860. {
  2861. PA_INDEX_IN_CI((GLfloat) c[0]);
  2862. }
  2863. void APIENTRY
  2864. glcltIndexs_InCI ( IN GLshort c )
  2865. {
  2866. PA_INDEX_IN_CI((GLfloat) c);
  2867. }
  2868. void APIENTRY
  2869. glcltIndexsv_InCI ( IN const GLshort c[1] )
  2870. {
  2871. PA_INDEX_IN_CI((GLfloat) c[0]);
  2872. }
  2873. void APIENTRY
  2874. glcltIndexub_InCI ( IN GLubyte c )
  2875. {
  2876. PA_INDEX_IN_CI((GLfloat) c);
  2877. }
  2878. void APIENTRY
  2879. glcltIndexubv_InCI ( IN const GLubyte c[1] )
  2880. {
  2881. PA_INDEX_IN_CI((GLfloat) c[0]);
  2882. }
  2883. void APIENTRY
  2884. glcltIndexd_InRGBA ( IN GLdouble c )
  2885. {
  2886. PA_INDEX_IN_RGBA((GLfloat) c);
  2887. }
  2888. void APIENTRY
  2889. glcltIndexdv_InRGBA ( IN const GLdouble c[1] )
  2890. {
  2891. PA_INDEX_IN_RGBA((GLfloat) c[0]);
  2892. }
  2893. void APIENTRY
  2894. glcltIndexf_InRGBA ( IN GLfloat c )
  2895. {
  2896. PA_INDEX_IN_RGBA((GLfloat) c);
  2897. }
  2898. void APIENTRY
  2899. glcltIndexfv_InRGBA ( IN const GLfloat c[1] )
  2900. {
  2901. PA_INDEX_IN_RGBA((GLfloat) c[0]);
  2902. }
  2903. void APIENTRY
  2904. glcltIndexi_InRGBA ( IN GLint c )
  2905. {
  2906. PA_INDEX_IN_RGBA((GLfloat) c);
  2907. }
  2908. void APIENTRY
  2909. glcltIndexiv_InRGBA ( IN const GLint c[1] )
  2910. {
  2911. PA_INDEX_IN_RGBA((GLfloat) c[0]);
  2912. }
  2913. void APIENTRY
  2914. glcltIndexs_InRGBA ( IN GLshort c )
  2915. {
  2916. PA_INDEX_IN_RGBA((GLfloat) c);
  2917. }
  2918. void APIENTRY
  2919. glcltIndexsv_InRGBA ( IN const GLshort c[1] )
  2920. {
  2921. PA_INDEX_IN_RGBA((GLfloat) c[0]);
  2922. }
  2923. void APIENTRY
  2924. glcltIndexub_InRGBA ( IN GLubyte c )
  2925. {
  2926. PA_INDEX_IN_RGBA((GLfloat) c);
  2927. }
  2928. void APIENTRY
  2929. glcltIndexubv_InRGBA ( IN const GLubyte c[1] )
  2930. {
  2931. PA_INDEX_IN_RGBA((GLfloat) c[0]);
  2932. }
  2933. /******************************************************************/
  2934. void APIENTRY
  2935. glcltNormal3b ( IN GLbyte nx, IN GLbyte ny, IN GLbyte nz )
  2936. {
  2937. PA_NORMAL(__GL_B_TO_FLOAT(nx), __GL_B_TO_FLOAT(ny), __GL_B_TO_FLOAT(nz));
  2938. }
  2939. void APIENTRY
  2940. glcltNormal3bv ( IN const GLbyte v[3] )
  2941. {
  2942. PA_NORMAL(__GL_B_TO_FLOAT(v[0]), __GL_B_TO_FLOAT(v[1]), __GL_B_TO_FLOAT(v[2]));
  2943. }
  2944. void APIENTRY
  2945. glcltNormal3d ( IN GLdouble nx, IN GLdouble ny, IN GLdouble nz )
  2946. {
  2947. PA_NORMAL((GLfloat) nx, (GLfloat) ny, (GLfloat) nz);
  2948. }
  2949. void APIENTRY
  2950. glcltNormal3dv ( IN const GLdouble v[3] )
  2951. {
  2952. PA_NORMAL((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  2953. }
  2954. #ifndef __GL_ASM_GLCLTNORMAL3F
  2955. void APIENTRY
  2956. glcltNormal3f ( IN GLfloat x, IN GLfloat y, IN GLfloat z )
  2957. {
  2958. PA_NORMAL(x, y, z);
  2959. }
  2960. #endif //__GL_ASM_GLCLTNORMAL3F
  2961. #ifndef __GL_ASM_GLCLTNORMAL3FV
  2962. void APIENTRY
  2963. glcltNormal3fv ( IN const GLfloat v[3] )
  2964. {
  2965. GLfloat x, y, z;
  2966. x = v[0];
  2967. y = v[1];
  2968. z = v[2];
  2969. PA_NORMAL(x, y, z);
  2970. }
  2971. #endif //__GL_ASM_GLCLTNORMAL3FV
  2972. void APIENTRY
  2973. glcltNormal3i ( IN GLint nx, IN GLint ny, IN GLint nz )
  2974. {
  2975. PA_NORMAL(__GL_I_TO_FLOAT(nx), __GL_I_TO_FLOAT(ny), __GL_I_TO_FLOAT(nz));
  2976. }
  2977. void APIENTRY
  2978. glcltNormal3iv ( IN const GLint v[3] )
  2979. {
  2980. PA_NORMAL(__GL_I_TO_FLOAT(v[0]), __GL_I_TO_FLOAT(v[1]), __GL_I_TO_FLOAT(v[2]));
  2981. }
  2982. void APIENTRY
  2983. glcltNormal3s ( IN GLshort nx, IN GLshort ny, IN GLshort nz )
  2984. {
  2985. PA_NORMAL(__GL_S_TO_FLOAT(nx), __GL_S_TO_FLOAT(ny), __GL_S_TO_FLOAT(nz));
  2986. }
  2987. void APIENTRY
  2988. glcltNormal3sv ( IN const GLshort v[3] )
  2989. {
  2990. PA_NORMAL(__GL_S_TO_FLOAT(v[0]), __GL_S_TO_FLOAT(v[1]), __GL_S_TO_FLOAT(v[2]));
  2991. }
  2992. void APIENTRY
  2993. glcltRasterPos2d ( IN GLdouble x, IN GLdouble y )
  2994. {
  2995. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) 0.0, (GLfloat) 1.0);
  2996. }
  2997. void APIENTRY
  2998. glcltRasterPos2dv ( IN const GLdouble v[2] )
  2999. {
  3000. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) 0.0, (GLfloat) 1.0);
  3001. }
  3002. void APIENTRY
  3003. glcltRasterPos2f ( IN GLfloat x, IN GLfloat y )
  3004. {
  3005. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) 0.0, (GLfloat) 1.0);
  3006. }
  3007. void APIENTRY
  3008. glcltRasterPos2fv ( IN const GLfloat v[2] )
  3009. {
  3010. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) 0.0, (GLfloat) 1.0);
  3011. }
  3012. void APIENTRY
  3013. glcltRasterPos2i ( IN GLint x, IN GLint y )
  3014. {
  3015. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) 0.0, (GLfloat) 1.0);
  3016. }
  3017. void APIENTRY
  3018. glcltRasterPos2iv ( IN const GLint v[2] )
  3019. {
  3020. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) 0.0, (GLfloat) 1.0);
  3021. }
  3022. void APIENTRY
  3023. glcltRasterPos2s ( IN GLshort x, IN GLshort y )
  3024. {
  3025. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) 0.0, (GLfloat) 1.0);
  3026. }
  3027. void APIENTRY
  3028. glcltRasterPos2sv ( IN const GLshort v[2] )
  3029. {
  3030. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) 0.0, (GLfloat) 1.0);
  3031. }
  3032. void APIENTRY
  3033. glcltRasterPos3d ( IN GLdouble x, IN GLdouble y, IN GLdouble z )
  3034. {
  3035. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) 1.0);
  3036. }
  3037. void APIENTRY
  3038. glcltRasterPos3dv ( IN const GLdouble v[3] )
  3039. {
  3040. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) 1.0);
  3041. }
  3042. void APIENTRY
  3043. glcltRasterPos3f ( IN GLfloat x, IN GLfloat y, IN GLfloat z )
  3044. {
  3045. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) 1.0);
  3046. }
  3047. void APIENTRY
  3048. glcltRasterPos3fv ( IN const GLfloat v[3] )
  3049. {
  3050. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) 1.0);
  3051. }
  3052. void APIENTRY
  3053. glcltRasterPos3i ( IN GLint x, IN GLint y, IN GLint z )
  3054. {
  3055. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) 1.0);
  3056. }
  3057. void APIENTRY
  3058. glcltRasterPos3iv ( IN const GLint v[3] )
  3059. {
  3060. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) 1.0);
  3061. }
  3062. void APIENTRY
  3063. glcltRasterPos3s ( IN GLshort x, IN GLshort y, IN GLshort z )
  3064. {
  3065. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) 1.0);
  3066. }
  3067. void APIENTRY
  3068. glcltRasterPos3sv ( IN const GLshort v[3] )
  3069. {
  3070. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) 1.0);
  3071. }
  3072. void APIENTRY
  3073. glcltRasterPos4d ( IN GLdouble x, IN GLdouble y, IN GLdouble z, IN GLdouble w )
  3074. {
  3075. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3076. }
  3077. void APIENTRY
  3078. glcltRasterPos4dv ( IN const GLdouble v[4] )
  3079. {
  3080. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3081. }
  3082. void APIENTRY
  3083. glcltRasterPos4f ( IN GLfloat x, IN GLfloat y, IN GLfloat z, IN GLfloat w )
  3084. {
  3085. GLCLIENT_BEGIN( RasterPos4fv, RASTERPOS4FV )
  3086. pMsg->v[0] = x;
  3087. pMsg->v[1] = y;
  3088. pMsg->v[2] = z;
  3089. pMsg->v[3] = w;
  3090. return;
  3091. GLCLIENT_END
  3092. }
  3093. void APIENTRY
  3094. glcltRasterPos4fv ( IN const GLfloat v[4] )
  3095. {
  3096. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3097. }
  3098. void APIENTRY
  3099. glcltRasterPos4i ( IN GLint x, IN GLint y, IN GLint z, IN GLint w )
  3100. {
  3101. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3102. }
  3103. void APIENTRY
  3104. glcltRasterPos4iv ( IN const GLint v[4] )
  3105. {
  3106. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3107. }
  3108. void APIENTRY
  3109. glcltRasterPos4s ( IN GLshort x, IN GLshort y, IN GLshort z, IN GLshort w )
  3110. {
  3111. glcltRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3112. }
  3113. void APIENTRY
  3114. glcltRasterPos4sv ( IN const GLshort v[4] )
  3115. {
  3116. glcltRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3117. }
  3118. void APIENTRY
  3119. glcltRectd ( IN GLdouble x1, IN GLdouble y1, IN GLdouble x2, IN GLdouble y2 )
  3120. {
  3121. glcltRectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
  3122. }
  3123. void APIENTRY
  3124. glcltRectdv ( IN const GLdouble v1[2], IN const GLdouble v2[2] )
  3125. {
  3126. glcltRectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
  3127. }
  3128. void APIENTRY
  3129. glcltRectf ( IN GLfloat x1, IN GLfloat y1, IN GLfloat x2, IN GLfloat y2 )
  3130. {
  3131. POLYARRAY *pa;
  3132. // Not allowed in begin/end.
  3133. pa = GLTEB_CLTPOLYARRAY();
  3134. if (pa->flags & POLYARRAY_IN_BEGIN)
  3135. {
  3136. GLSETERROR(GL_INVALID_OPERATION);
  3137. return;
  3138. }
  3139. // Call Begin/End to do polyarray correctly. Note that by calling these
  3140. // functions, we allow poly array to be batched correctly.
  3141. // Note also that we use quad strip instead of quad to force edge flag to be on.
  3142. //!!! Conformance fails if we use QUAD_STRIP!
  3143. //glcltBegin(GL_QUAD_STRIP);
  3144. glcltBegin(GL_QUADS);
  3145. pa->flags |= POLYARRAY_SAME_POLYDATA_TYPE;
  3146. glcltVertex2f(x1, y1);
  3147. glcltVertex2f(x2, y1);
  3148. glcltVertex2f(x2, y2);
  3149. glcltVertex2f(x1, y2);
  3150. glcltEnd();
  3151. }
  3152. void APIENTRY
  3153. glcltRectfv ( IN const GLfloat v1[2], IN const GLfloat v2[2] )
  3154. {
  3155. glcltRectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
  3156. }
  3157. void APIENTRY
  3158. glcltRecti ( IN GLint x1, IN GLint y1, IN GLint x2, IN GLint y2 )
  3159. {
  3160. glcltRectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
  3161. }
  3162. void APIENTRY
  3163. glcltRectiv ( IN const GLint v1[2], IN const GLint v2[2] )
  3164. {
  3165. glcltRectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
  3166. }
  3167. void APIENTRY
  3168. glcltRects ( IN GLshort x1, IN GLshort y1, IN GLshort x2, IN GLshort y2 )
  3169. {
  3170. glcltRectf((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
  3171. }
  3172. void APIENTRY
  3173. glcltRectsv ( IN const GLshort v1[2], IN const GLshort v2[2] )
  3174. {
  3175. glcltRectf((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
  3176. }
  3177. void APIENTRY
  3178. glcltTexCoord1d ( IN GLdouble s )
  3179. {
  3180. PA_TEXTURE1((GLfloat) s);
  3181. }
  3182. void APIENTRY
  3183. glcltTexCoord1dv ( IN const GLdouble v[1] )
  3184. {
  3185. PA_TEXTURE1((GLfloat) v[0]);
  3186. }
  3187. void APIENTRY
  3188. glcltTexCoord1f ( IN GLfloat s )
  3189. {
  3190. PA_TEXTURE1((GLfloat) s);
  3191. }
  3192. void APIENTRY
  3193. glcltTexCoord1fv ( IN const GLfloat v[1] )
  3194. {
  3195. PA_TEXTURE1((GLfloat) v[0]);
  3196. }
  3197. void APIENTRY
  3198. glcltTexCoord1i ( IN GLint s )
  3199. {
  3200. PA_TEXTURE1((GLfloat) s);
  3201. }
  3202. void APIENTRY
  3203. glcltTexCoord1iv ( IN const GLint v[1] )
  3204. {
  3205. PA_TEXTURE1((GLfloat) v[0]);
  3206. }
  3207. void APIENTRY
  3208. glcltTexCoord1s ( IN GLshort s )
  3209. {
  3210. PA_TEXTURE1((GLfloat) s);
  3211. }
  3212. void APIENTRY
  3213. glcltTexCoord1sv ( IN const GLshort v[1] )
  3214. {
  3215. PA_TEXTURE1((GLfloat) v[0]);
  3216. }
  3217. void APIENTRY
  3218. glcltTexCoord2d ( IN GLdouble s, IN GLdouble t )
  3219. {
  3220. PA_TEXTURE2((GLfloat) s, (GLfloat) t);
  3221. }
  3222. void APIENTRY
  3223. glcltTexCoord2dv ( IN const GLdouble v[2] )
  3224. {
  3225. PA_TEXTURE2((GLfloat) v[0], (GLfloat) v[1]);
  3226. }
  3227. #ifndef __GL_ASM_GLCLTTEXCOORD2F
  3228. void APIENTRY
  3229. glcltTexCoord2f ( IN GLfloat s, IN GLfloat t )
  3230. {
  3231. PA_TEXTURE2((GLfloat) s, (GLfloat) t);
  3232. }
  3233. #endif //__GL_ASM_GLCLTTEXCOORD2F
  3234. #ifndef __GL_ASM_GLCLTTEXCOORD2FV
  3235. void APIENTRY
  3236. glcltTexCoord2fv ( IN const GLfloat v[2] )
  3237. {
  3238. PA_TEXTURE2((GLfloat) v[0], (GLfloat) v[1]);
  3239. }
  3240. #endif //__GL_ASM_GLCLTTEXCOORD2FV
  3241. void APIENTRY
  3242. glcltTexCoord2i ( IN GLint s, IN GLint t )
  3243. {
  3244. PA_TEXTURE2((GLfloat) s, (GLfloat) t);
  3245. }
  3246. void APIENTRY
  3247. glcltTexCoord2iv ( IN const GLint v[2] )
  3248. {
  3249. PA_TEXTURE2((GLfloat) v[0], (GLfloat) v[1]);
  3250. }
  3251. void APIENTRY
  3252. glcltTexCoord2s ( IN GLshort s, IN GLshort t )
  3253. {
  3254. PA_TEXTURE2((GLfloat) s, (GLfloat) t);
  3255. }
  3256. void APIENTRY
  3257. glcltTexCoord2sv ( IN const GLshort v[2] )
  3258. {
  3259. PA_TEXTURE2((GLfloat) v[0], (GLfloat) v[1]);
  3260. }
  3261. void APIENTRY
  3262. glcltTexCoord3d ( IN GLdouble s, IN GLdouble t, IN GLdouble r )
  3263. {
  3264. PA_TEXTURE3((GLfloat) s, (GLfloat) t, (GLfloat) r);
  3265. }
  3266. void APIENTRY
  3267. glcltTexCoord3dv ( IN const GLdouble v[3] )
  3268. {
  3269. PA_TEXTURE3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3270. }
  3271. #ifndef __GL_ASM_GLCLTTEXCOORD3F
  3272. void APIENTRY
  3273. glcltTexCoord3f ( IN GLfloat s, IN GLfloat t, IN GLfloat r )
  3274. {
  3275. PA_TEXTURE3((GLfloat) s, (GLfloat) t, (GLfloat) r);
  3276. }
  3277. #endif //__GL_ASM_GLCLTTEXCOORD3F
  3278. #ifndef __GL_ASM_GLCLTTEXCOORD3FV
  3279. void APIENTRY
  3280. glcltTexCoord3fv ( IN const GLfloat v[3] )
  3281. {
  3282. PA_TEXTURE3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3283. }
  3284. #endif //__GL_ASM_GLCLTTEXCOORD3FV
  3285. void APIENTRY
  3286. glcltTexCoord3i ( IN GLint s, IN GLint t, IN GLint r )
  3287. {
  3288. PA_TEXTURE3((GLfloat) s, (GLfloat) t, (GLfloat) r);
  3289. }
  3290. void APIENTRY
  3291. glcltTexCoord3iv ( IN const GLint v[3] )
  3292. {
  3293. PA_TEXTURE3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3294. }
  3295. void APIENTRY
  3296. glcltTexCoord3s ( IN GLshort s, IN GLshort t, IN GLshort r )
  3297. {
  3298. PA_TEXTURE3((GLfloat) s, (GLfloat) t, (GLfloat) r);
  3299. }
  3300. void APIENTRY
  3301. glcltTexCoord3sv ( IN const GLshort v[3] )
  3302. {
  3303. PA_TEXTURE3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3304. }
  3305. void APIENTRY
  3306. glcltTexCoord4d ( IN GLdouble s, IN GLdouble t, IN GLdouble r, IN GLdouble q )
  3307. {
  3308. PA_TEXTURE4((GLfloat) s, (GLfloat) t, (GLfloat) r, (GLfloat) q);
  3309. }
  3310. void APIENTRY
  3311. glcltTexCoord4dv ( IN const GLdouble v[4] )
  3312. {
  3313. PA_TEXTURE4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3314. }
  3315. void APIENTRY
  3316. glcltTexCoord4f ( IN GLfloat s, IN GLfloat t, IN GLfloat r, IN GLfloat q )
  3317. {
  3318. PA_TEXTURE4((GLfloat) s, (GLfloat) t, (GLfloat) r, (GLfloat) q);
  3319. }
  3320. void APIENTRY
  3321. glcltTexCoord4fv ( IN const GLfloat v[4] )
  3322. {
  3323. PA_TEXTURE4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3324. }
  3325. void APIENTRY
  3326. glcltTexCoord4i ( IN GLint s, IN GLint t, IN GLint r, IN GLint q )
  3327. {
  3328. PA_TEXTURE4((GLfloat) s, (GLfloat) t, (GLfloat) r, (GLfloat) q);
  3329. }
  3330. void APIENTRY
  3331. glcltTexCoord4iv ( IN const GLint v[4] )
  3332. {
  3333. PA_TEXTURE4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3334. }
  3335. void APIENTRY
  3336. glcltTexCoord4s ( IN GLshort s, IN GLshort t, IN GLshort r, IN GLshort q )
  3337. {
  3338. PA_TEXTURE4((GLfloat) s, (GLfloat) t, (GLfloat) r, (GLfloat) q);
  3339. }
  3340. void APIENTRY
  3341. glcltTexCoord4sv ( IN const GLshort v[4] )
  3342. {
  3343. PA_TEXTURE4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3344. }
  3345. #ifdef GL_WIN_multiple_textures
  3346. void APIENTRY glcltMultiTexCoord1dWIN
  3347. (GLbitfield mask, GLdouble s)
  3348. {
  3349. // ATTENTION
  3350. }
  3351. void APIENTRY glcltMultiTexCoord1dvWIN
  3352. (GLbitfield mask, const GLdouble *v)
  3353. {
  3354. // ATTENTION
  3355. }
  3356. void APIENTRY glcltMultiTexCoord1fWIN
  3357. (GLbitfield mask, GLfloat s)
  3358. {
  3359. // ATTENTION
  3360. }
  3361. void APIENTRY glcltMultiTexCoord1fvWIN
  3362. (GLbitfield mask, const GLfloat *v)
  3363. {
  3364. // ATTENTION
  3365. }
  3366. void APIENTRY glcltMultiTexCoord1iWIN
  3367. (GLbitfield mask, GLint s)
  3368. {
  3369. // ATTENTION
  3370. }
  3371. void APIENTRY glcltMultiTexCoord1ivWIN
  3372. (GLbitfield mask, const GLint *v)
  3373. {
  3374. // ATTENTION
  3375. }
  3376. void APIENTRY glcltMultiTexCoord1sWIN
  3377. (GLbitfield mask, GLshort s)
  3378. {
  3379. // ATTENTION
  3380. }
  3381. void APIENTRY glcltMultiTexCoord1svWIN
  3382. (GLbitfield mask, const GLshort *v)
  3383. {
  3384. // ATTENTION
  3385. }
  3386. void APIENTRY glcltMultiTexCoord2dWIN
  3387. (GLbitfield mask, GLdouble s, GLdouble t)
  3388. {
  3389. // ATTENTION
  3390. }
  3391. void APIENTRY glcltMultiTexCoord2dvWIN
  3392. (GLbitfield mask, const GLdouble *v)
  3393. {
  3394. // ATTENTION
  3395. }
  3396. void APIENTRY glcltMultiTexCoord2fWIN
  3397. (GLbitfield mask, GLfloat s, GLfloat t)
  3398. {
  3399. // ATTENTION
  3400. }
  3401. void APIENTRY glcltMultiTexCoord2fvWIN
  3402. (GLbitfield mask, const GLfloat *v)
  3403. {
  3404. // ATTENTION
  3405. }
  3406. void APIENTRY glcltMultiTexCoord2iWIN
  3407. (GLbitfield mask, GLint s, GLint t)
  3408. {
  3409. // ATTENTION
  3410. }
  3411. void APIENTRY glcltMultiTexCoord2ivWIN
  3412. (GLbitfield mask, const GLint *v)
  3413. {
  3414. // ATTENTION
  3415. }
  3416. void APIENTRY glcltMultiTexCoord2sWIN
  3417. (GLbitfield mask, GLshort s, GLshort t)
  3418. {
  3419. // ATTENTION
  3420. }
  3421. void APIENTRY glcltMultiTexCoord2svWIN
  3422. (GLbitfield mask, const GLshort *v)
  3423. {
  3424. // ATTENTION
  3425. }
  3426. void APIENTRY glcltMultiTexCoord3dWIN
  3427. (GLbitfield mask, GLdouble s, GLdouble t, GLdouble r)
  3428. {
  3429. // ATTENTION
  3430. }
  3431. void APIENTRY glcltMultiTexCoord3dvWIN
  3432. (GLbitfield mask, const GLdouble *v)
  3433. {
  3434. // ATTENTION
  3435. }
  3436. void APIENTRY glcltMultiTexCoord3fWIN
  3437. (GLbitfield mask, GLfloat s, GLfloat t, GLfloat r)
  3438. {
  3439. // ATTENTION
  3440. }
  3441. void APIENTRY glcltMultiTexCoord3fvWIN
  3442. (GLbitfield mask, const GLfloat *v)
  3443. {
  3444. // ATTENTION
  3445. }
  3446. void APIENTRY glcltMultiTexCoord3iWIN
  3447. (GLbitfield mask, GLint s, GLint t, GLint r)
  3448. {
  3449. // ATTENTION
  3450. }
  3451. void APIENTRY glcltMultiTexCoord3ivWIN
  3452. (GLbitfield mask, const GLint *v)
  3453. {
  3454. // ATTENTION
  3455. }
  3456. void APIENTRY glcltMultiTexCoord3sWIN
  3457. (GLbitfield mask, GLshort s, GLshort t, GLshort r)
  3458. {
  3459. // ATTENTION
  3460. }
  3461. void APIENTRY glcltMultiTexCoord3svWIN
  3462. (GLbitfield mask, const GLshort *v)
  3463. {
  3464. // ATTENTION
  3465. }
  3466. void APIENTRY glcltMultiTexCoord4dWIN
  3467. (GLbitfield mask, GLdouble s, GLdouble t, GLdouble r, GLdouble q)
  3468. {
  3469. // ATTENTION
  3470. }
  3471. void APIENTRY glcltMultiTexCoord4dvWIN
  3472. (GLbitfield mask, const GLdouble *v)
  3473. {
  3474. // ATTENTION
  3475. }
  3476. void APIENTRY glcltMultiTexCoord4fWIN
  3477. (GLbitfield mask, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
  3478. {
  3479. // ATTENTION
  3480. }
  3481. void APIENTRY glcltMultiTexCoord4fvWIN
  3482. (GLbitfield mask, const GLfloat *v)
  3483. {
  3484. // ATTENTION
  3485. }
  3486. void APIENTRY glcltMultiTexCoord4iWIN
  3487. (GLbitfield mask, GLint s, GLint t, GLint r, GLint q)
  3488. {
  3489. // ATTENTION
  3490. }
  3491. void APIENTRY glcltMultiTexCoord4ivWIN
  3492. (GLbitfield mask, const GLint *v)
  3493. {
  3494. // ATTENTION
  3495. }
  3496. void APIENTRY glcltMultiTexCoord4sWIN
  3497. (GLbitfield mask, GLshort s, GLshort t, GLshort r, GLshort q)
  3498. {
  3499. // ATTENTION
  3500. }
  3501. void APIENTRY glcltMultiTexCoord4svWIN
  3502. (GLbitfield mask, const GLshort *v)
  3503. {
  3504. // ATTENTION
  3505. }
  3506. #endif // GL_WIN_multiple_textures
  3507. void APIENTRY
  3508. glcltVertex2d ( IN GLdouble x, IN GLdouble y )
  3509. {
  3510. PA_VERTEX2((GLfloat) x, (GLfloat) y);
  3511. }
  3512. void APIENTRY
  3513. glcltVertex2dv ( IN const GLdouble v[2] )
  3514. {
  3515. PA_VERTEX2((GLfloat) v[0], (GLfloat) v[1]);
  3516. }
  3517. #ifndef __GL_ASM_GLCLTVERTEX2F
  3518. void APIENTRY
  3519. glcltVertex2f ( IN GLfloat x, IN GLfloat y )
  3520. {
  3521. PA_VERTEX2((GLfloat) x, (GLfloat) y);
  3522. }
  3523. #endif //__GL_ASM_GLCLTVERTEX2F
  3524. #ifndef __GL_ASM_GLCLTVERTEX2FV
  3525. void APIENTRY
  3526. glcltVertex2fv ( IN const GLfloat v[2] )
  3527. {
  3528. PA_VERTEX2((GLfloat) v[0], (GLfloat) v[1]);
  3529. }
  3530. #endif //__GL_ASM_GLCLTVERTEX2FV
  3531. void APIENTRY
  3532. glcltVertex2i ( IN GLint x, IN GLint y )
  3533. {
  3534. PA_VERTEX2((GLfloat) x, (GLfloat) y);
  3535. }
  3536. void APIENTRY
  3537. glcltVertex2iv ( IN const GLint v[2] )
  3538. {
  3539. PA_VERTEX2((GLfloat) v[0], (GLfloat) v[1]);
  3540. }
  3541. void APIENTRY
  3542. glcltVertex2s ( IN GLshort x, IN GLshort y )
  3543. {
  3544. PA_VERTEX2((GLfloat) x, (GLfloat) y);
  3545. }
  3546. void APIENTRY
  3547. glcltVertex2sv ( IN const GLshort v[2] )
  3548. {
  3549. PA_VERTEX2((GLfloat) v[0], (GLfloat) v[1]);
  3550. }
  3551. void APIENTRY
  3552. glcltVertex3d ( IN GLdouble x, IN GLdouble y, IN GLdouble z )
  3553. {
  3554. PA_VERTEX3((GLfloat) x, (GLfloat) y, (GLfloat) z);
  3555. }
  3556. void APIENTRY
  3557. glcltVertex3dv ( IN const GLdouble v[3] )
  3558. {
  3559. PA_VERTEX3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3560. }
  3561. #ifndef __GL_ASM_GLCLTVERTEX3F
  3562. void APIENTRY
  3563. glcltVertex3f ( IN GLfloat x, IN GLfloat y, IN GLfloat z )
  3564. {
  3565. PA_VERTEX3((GLfloat) x, (GLfloat) y, (GLfloat) z);
  3566. }
  3567. #endif //__GL_ASM_GLCLTVERTEX3F
  3568. #ifndef __GL_ASM_GLCLTVERTEX3FV
  3569. void APIENTRY
  3570. glcltVertex3fv ( IN const GLfloat v[3] )
  3571. {
  3572. GLfloat x1, y1, z1;
  3573. x1 = (GLfloat) v[0];
  3574. y1 = (GLfloat) v[1];
  3575. z1 = (GLfloat) v[2];
  3576. PA_VERTEX3(x1, y1, z1);
  3577. }
  3578. #endif //__GL_ASM_GLCLTVERTEX3FV
  3579. void APIENTRY
  3580. glcltVertex3i ( IN GLint x, IN GLint y, IN GLint z )
  3581. {
  3582. PA_VERTEX3((GLfloat) x, (GLfloat) y, (GLfloat) z);
  3583. }
  3584. void APIENTRY
  3585. glcltVertex3iv ( IN const GLint v[3] )
  3586. {
  3587. PA_VERTEX3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3588. }
  3589. void APIENTRY
  3590. glcltVertex3s ( IN GLshort x, IN GLshort y, IN GLshort z )
  3591. {
  3592. PA_VERTEX3((GLfloat) x, (GLfloat) y, (GLfloat) z);
  3593. }
  3594. void APIENTRY
  3595. glcltVertex3sv ( IN const GLshort v[3] )
  3596. {
  3597. PA_VERTEX3((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
  3598. }
  3599. void APIENTRY
  3600. glcltVertex4d ( IN GLdouble x, IN GLdouble y, IN GLdouble z, IN GLdouble w )
  3601. {
  3602. PA_VERTEX4((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3603. }
  3604. void APIENTRY
  3605. glcltVertex4dv ( IN const GLdouble v[4] )
  3606. {
  3607. PA_VERTEX4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3608. }
  3609. void APIENTRY
  3610. glcltVertex4f ( IN GLfloat x, IN GLfloat y, IN GLfloat z, IN GLfloat w )
  3611. {
  3612. PA_VERTEX4((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3613. }
  3614. void APIENTRY
  3615. glcltVertex4fv ( IN const GLfloat v[4] )
  3616. {
  3617. PA_VERTEX4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3618. }
  3619. void APIENTRY
  3620. glcltVertex4i ( IN GLint x, IN GLint y, IN GLint z, IN GLint w )
  3621. {
  3622. PA_VERTEX4((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3623. }
  3624. void APIENTRY
  3625. glcltVertex4iv ( IN const GLint v[4] )
  3626. {
  3627. PA_VERTEX4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3628. }
  3629. void APIENTRY
  3630. glcltVertex4s ( IN GLshort x, IN GLshort y, IN GLshort z, IN GLshort w )
  3631. {
  3632. PA_VERTEX4((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
  3633. }
  3634. void APIENTRY
  3635. glcltVertex4sv ( IN const GLshort v[4] )
  3636. {
  3637. PA_VERTEX4((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
  3638. }
  3639. void APIENTRY
  3640. glcltClipPlane ( IN GLenum plane, IN const GLdouble equation[4] )
  3641. {
  3642. GLCLIENT_BEGIN( ClipPlane, CLIPPLANE )
  3643. pMsg->plane = plane ;
  3644. pMsg->equation[ 0] = equation[ 0];
  3645. pMsg->equation[ 1] = equation[ 1];
  3646. pMsg->equation[ 2] = equation[ 2];
  3647. pMsg->equation[ 3] = equation[ 3];
  3648. return;
  3649. GLCLIENT_END
  3650. }
  3651. void APIENTRY
  3652. glcltColorMaterial ( IN GLenum face, IN GLenum mode )
  3653. {
  3654. GLCLIENT_BEGIN( ColorMaterial, COLORMATERIAL )
  3655. pMsg->face = face ;
  3656. pMsg->mode = mode ;
  3657. return;
  3658. GLCLIENT_END
  3659. }
  3660. void APIENTRY
  3661. glcltCullFace ( IN GLenum mode )
  3662. {
  3663. GLCLIENT_BEGIN( CullFace, CULLFACE )
  3664. pMsg->mode = mode ;
  3665. return;
  3666. GLCLIENT_END
  3667. }
  3668. void APIENTRY
  3669. glcltFrontFace ( IN GLenum mode )
  3670. {
  3671. GLCLIENT_BEGIN( FrontFace, FRONTFACE )
  3672. pMsg->mode = mode ;
  3673. return;
  3674. GLCLIENT_END
  3675. }
  3676. void APIENTRY
  3677. glcltHint ( IN GLenum target, IN GLenum mode )
  3678. {
  3679. GLCLIENT_BEGIN( Hint, HINT )
  3680. pMsg->target = target ;
  3681. pMsg->mode = mode ;
  3682. return;
  3683. GLCLIENT_END
  3684. }
  3685. void APIENTRY
  3686. glcltLineStipple ( IN GLint factor, IN GLushort pattern )
  3687. {
  3688. GLCLIENT_BEGIN( LineStipple, LINESTIPPLE )
  3689. pMsg->factor = factor ;
  3690. pMsg->pattern = pattern ;
  3691. return;
  3692. GLCLIENT_END
  3693. }
  3694. void APIENTRY
  3695. glcltLineWidth ( IN GLfloat width )
  3696. {
  3697. GLCLIENT_BEGIN( LineWidth, LINEWIDTH )
  3698. pMsg->width = width ;
  3699. return;
  3700. GLCLIENT_END
  3701. }
  3702. void APIENTRY
  3703. glcltPointSize ( IN GLfloat size )
  3704. {
  3705. GLCLIENT_BEGIN( PointSize, POINTSIZE )
  3706. pMsg->size = size ;
  3707. return;
  3708. GLCLIENT_END
  3709. }
  3710. void APIENTRY
  3711. glcltPolygonMode ( IN GLenum face, IN GLenum mode )
  3712. {
  3713. GLCLIENT_BEGIN( PolygonMode, POLYGONMODE )
  3714. pMsg->face = face ;
  3715. pMsg->mode = mode ;
  3716. return;
  3717. GLCLIENT_END
  3718. }
  3719. void APIENTRY
  3720. glcltScissor ( IN GLint x, IN GLint y, IN GLsizei width, IN GLsizei height )
  3721. {
  3722. GLCLIENT_BEGIN( Scissor, SCISSOR )
  3723. pMsg->x = x ;
  3724. pMsg->y = y ;
  3725. pMsg->width = width ;
  3726. pMsg->height = height ;
  3727. return;
  3728. GLCLIENT_END
  3729. }
  3730. void APIENTRY
  3731. glcltShadeModel ( IN GLenum mode )
  3732. {
  3733. GLCLIENT_BEGIN( ShadeModel, SHADEMODEL )
  3734. pMsg->mode = mode ;
  3735. return;
  3736. GLCLIENT_END
  3737. }
  3738. void APIENTRY
  3739. glcltInitNames ( void )
  3740. {
  3741. GLCLIENT_BEGIN( InitNames, INITNAMES )
  3742. return;
  3743. GLCLIENT_END
  3744. }
  3745. void APIENTRY
  3746. glcltLoadName ( IN GLuint name )
  3747. {
  3748. GLCLIENT_BEGIN( LoadName, LOADNAME )
  3749. pMsg->name = name ;
  3750. return;
  3751. GLCLIENT_END
  3752. }
  3753. void APIENTRY
  3754. glcltPassThrough ( IN GLfloat token )
  3755. {
  3756. GLCLIENT_BEGIN( PassThrough, PASSTHROUGH )
  3757. pMsg->token = token ;
  3758. return;
  3759. GLCLIENT_END
  3760. }
  3761. void APIENTRY
  3762. glcltPopName ( void )
  3763. {
  3764. GLCLIENT_BEGIN( PopName, POPNAME )
  3765. return;
  3766. GLCLIENT_END
  3767. }
  3768. void APIENTRY
  3769. glcltPushName ( IN GLuint name )
  3770. {
  3771. GLCLIENT_BEGIN( PushName, PUSHNAME )
  3772. pMsg->name = name ;
  3773. return;
  3774. GLCLIENT_END
  3775. }
  3776. void APIENTRY
  3777. glcltDrawBuffer ( IN GLenum mode )
  3778. {
  3779. // We're doing something special here. By doing a glsbAttention after
  3780. // putting a glDrawBuffer in the batch, we are guaranteeing that all
  3781. // drawing done in the batch is in the same drawing mode and that the
  3782. // drawing mode cannot change until the end of the batch. This allows
  3783. // the server to sample the current drawing mode at the beginning of
  3784. // batch and to assume that it is constant for the entire batch.
  3785. //
  3786. // The server might be able to take advantage of the fact, for example,
  3787. // that all drawing in a batch is only to the back buffer.
  3788. GLCLIENT_BEGIN( DrawBuffer, DRAWBUFFER )
  3789. pMsg->mode = mode ;
  3790. glsbAttention();
  3791. return;
  3792. GLCLIENT_END
  3793. }
  3794. void APIENTRY
  3795. glcltClear ( IN GLbitfield mask )
  3796. {
  3797. GLCLIENT_BEGIN( Clear, CLEAR )
  3798. pMsg->mask = mask ;
  3799. return;
  3800. GLCLIENT_END
  3801. }
  3802. void APIENTRY
  3803. glcltClearAccum ( IN GLfloat red, IN GLfloat green, IN GLfloat blue, IN GLfloat alpha )
  3804. {
  3805. GLCLIENT_BEGIN( ClearAccum, CLEARACCUM )
  3806. pMsg->red = red ;
  3807. pMsg->green = green ;
  3808. pMsg->blue = blue ;
  3809. pMsg->alpha = alpha ;
  3810. return;
  3811. GLCLIENT_END
  3812. }
  3813. void APIENTRY
  3814. glcltClearIndex ( IN GLfloat c )
  3815. {
  3816. GLCLIENT_BEGIN( ClearIndex, CLEARINDEX )
  3817. pMsg->c = c ;
  3818. return;
  3819. GLCLIENT_END
  3820. }
  3821. void APIENTRY
  3822. glcltClearColor ( IN GLclampf red, IN GLclampf green, IN GLclampf blue, IN GLclampf alpha )
  3823. {
  3824. GLCLIENT_BEGIN( ClearColor, CLEARCOLOR )
  3825. pMsg->red = red ;
  3826. pMsg->green = green ;
  3827. pMsg->blue = blue ;
  3828. pMsg->alpha = alpha ;
  3829. return;
  3830. GLCLIENT_END
  3831. }
  3832. void APIENTRY
  3833. glcltClearStencil ( IN GLint s )
  3834. {
  3835. GLCLIENT_BEGIN( ClearStencil, CLEARSTENCIL )
  3836. pMsg->s = s ;
  3837. return;
  3838. GLCLIENT_END
  3839. }
  3840. void APIENTRY
  3841. glcltClearDepth ( IN GLclampd depth )
  3842. {
  3843. GLCLIENT_BEGIN( ClearDepth, CLEARDEPTH )
  3844. pMsg->depth = depth ;
  3845. return;
  3846. GLCLIENT_END
  3847. }
  3848. void APIENTRY
  3849. glcltStencilMask ( IN GLuint mask )
  3850. {
  3851. GLCLIENT_BEGIN( StencilMask, STENCILMASK )
  3852. pMsg->mask = mask ;
  3853. return;
  3854. GLCLIENT_END
  3855. }
  3856. void APIENTRY
  3857. glcltColorMask ( IN GLboolean red, IN GLboolean green, IN GLboolean blue, IN GLboolean alpha )
  3858. {
  3859. GLCLIENT_BEGIN( ColorMask, COLORMASK )
  3860. pMsg->red = red ;
  3861. pMsg->green = green ;
  3862. pMsg->blue = blue ;
  3863. pMsg->alpha = alpha ;
  3864. return;
  3865. GLCLIENT_END
  3866. }
  3867. void APIENTRY
  3868. glcltDepthMask ( IN GLboolean flag )
  3869. {
  3870. GLCLIENT_BEGIN( DepthMask, DEPTHMASK )
  3871. pMsg->flag = flag ;
  3872. return;
  3873. GLCLIENT_END
  3874. }
  3875. void APIENTRY
  3876. glcltIndexMask ( IN GLuint mask )
  3877. {
  3878. GLCLIENT_BEGIN( IndexMask, INDEXMASK )
  3879. pMsg->mask = mask ;
  3880. return;
  3881. GLCLIENT_END
  3882. }
  3883. void APIENTRY
  3884. glcltAccum ( IN GLenum op, IN GLfloat value )
  3885. {
  3886. GLCLIENT_BEGIN( Accum, ACCUM )
  3887. pMsg->op = op ;
  3888. pMsg->value = value ;
  3889. return;
  3890. GLCLIENT_END
  3891. }
  3892. void APIENTRY
  3893. glcltDisable ( IN GLenum cap )
  3894. {
  3895. __GL_SETUP();
  3896. GLCLIENT_BEGIN( Disable, DISABLE )
  3897. pMsg->cap = cap ;
  3898. // Set the enable flags for the evaluators
  3899. switch (cap)
  3900. {
  3901. case GL_MAP1_COLOR_4:
  3902. case GL_MAP1_INDEX:
  3903. case GL_MAP1_NORMAL:
  3904. case GL_MAP1_TEXTURE_COORD_1:
  3905. case GL_MAP1_TEXTURE_COORD_2:
  3906. case GL_MAP1_TEXTURE_COORD_3:
  3907. case GL_MAP1_TEXTURE_COORD_4:
  3908. case GL_MAP1_VERTEX_3:
  3909. case GL_MAP1_VERTEX_4:
  3910. gc->eval.evalStateFlags |= __EVALS_AFFECTS_1D_EVAL;
  3911. break;
  3912. case GL_MAP2_COLOR_4:
  3913. case GL_MAP2_INDEX:
  3914. case GL_MAP2_NORMAL:
  3915. case GL_MAP2_TEXTURE_COORD_1:
  3916. case GL_MAP2_TEXTURE_COORD_2:
  3917. case GL_MAP2_TEXTURE_COORD_3:
  3918. case GL_MAP2_TEXTURE_COORD_4:
  3919. case GL_MAP2_VERTEX_3:
  3920. case GL_MAP2_VERTEX_4:
  3921. case GL_NORMALIZE:
  3922. case GL_AUTO_NORMAL:
  3923. gc->eval.evalStateFlags |= __EVALS_AFFECTS_2D_EVAL;
  3924. break;
  3925. case GL_LIGHTING:
  3926. gc->eval.evalStateFlags |= __EVALS_AFFECTS_ALL_EVAL;
  3927. break;
  3928. }
  3929. return;
  3930. GLCLIENT_END
  3931. }
  3932. void APIENTRY
  3933. glcltEnable ( IN GLenum cap )
  3934. {
  3935. __GL_SETUP();
  3936. GLCLIENT_BEGIN( Enable, ENABLE )
  3937. pMsg->cap = cap ;
  3938. // Set the enable flags for the evaluators
  3939. switch (cap)
  3940. {
  3941. case GL_MAP1_COLOR_4:
  3942. case GL_MAP1_INDEX:
  3943. case GL_MAP1_NORMAL:
  3944. case GL_MAP1_TEXTURE_COORD_1:
  3945. case GL_MAP1_TEXTURE_COORD_2:
  3946. case GL_MAP1_TEXTURE_COORD_3:
  3947. case GL_MAP1_TEXTURE_COORD_4:
  3948. case GL_MAP1_VERTEX_3:
  3949. case GL_MAP1_VERTEX_4:
  3950. gc->eval.evalStateFlags |= __EVALS_AFFECTS_1D_EVAL;
  3951. break;
  3952. case GL_MAP2_COLOR_4:
  3953. case GL_MAP2_INDEX:
  3954. case GL_MAP2_NORMAL:
  3955. case GL_MAP2_TEXTURE_COORD_1:
  3956. case GL_MAP2_TEXTURE_COORD_2:
  3957. case GL_MAP2_TEXTURE_COORD_3:
  3958. case GL_MAP2_TEXTURE_COORD_4:
  3959. case GL_MAP2_VERTEX_3:
  3960. case GL_MAP2_VERTEX_4:
  3961. case GL_NORMALIZE:
  3962. case GL_AUTO_NORMAL:
  3963. gc->eval.evalStateFlags |= __EVALS_AFFECTS_2D_EVAL;
  3964. break;
  3965. case GL_LIGHTING:
  3966. gc->eval.evalStateFlags |= __EVALS_AFFECTS_ALL_EVAL;
  3967. break;
  3968. }
  3969. return;
  3970. GLCLIENT_END
  3971. }
  3972. void APIENTRY
  3973. glcltFinish ( void )
  3974. {
  3975. // This function is invalid between glBegin and glEnd.
  3976. // This is detected in glsbAttention.
  3977. glsbAttention();
  3978. }
  3979. void APIENTRY
  3980. glcltFlush ( void )
  3981. {
  3982. // This function is invalid between glBegin and glEnd.
  3983. // This is detected in glsbAttention.
  3984. glsbAttention();
  3985. }
  3986. void APIENTRY
  3987. glcltPopAttrib ( void )
  3988. {
  3989. __GL_SETUP();
  3990. GLCLIENT_BEGIN( PopAttrib, POPATTRIB )
  3991. if (gc->eval.evalStackState & 0x1)
  3992. {
  3993. gc->eval.evalStateFlags = gc->eval.evalStateFlags |
  3994. __EVALS_AFFECTS_ALL_EVAL |
  3995. __EVALS_POP_EVAL_ATTRIB;
  3996. }
  3997. gc->eval.evalStackState = (gc->eval.evalStackState) >> 1;
  3998. return;
  3999. GLCLIENT_END
  4000. }
  4001. void APIENTRY
  4002. glcltPushAttrib ( IN GLbitfield mask )
  4003. {
  4004. __GL_SETUP ();
  4005. // Assert that the stack size is always less than 31 since the
  4006. // bitfield is a DWORD.
  4007. ASSERTOPENGL (gc->constants.maxAttribStackDepth < 31, "Attrib state stack is greater than the size of the bitfield used to track it\n");
  4008. GLCLIENT_BEGIN( PushAttrib, PUSHATTRIB )
  4009. pMsg->mask = mask ;
  4010. gc->eval.evalStackState = (gc->eval.evalStackState) << 1;
  4011. if (mask & GL_EVAL_BIT)
  4012. {
  4013. gc->eval.evalStateFlags = gc->eval.evalStateFlags |
  4014. __EVALS_AFFECTS_ALL_EVAL |
  4015. __EVALS_PUSH_EVAL_ATTRIB;
  4016. gc->eval.evalStackState = (gc->eval.evalStackState) | 0x1;
  4017. }
  4018. return;
  4019. GLCLIENT_END
  4020. }
  4021. void APIENTRY
  4022. glcltAlphaFunc ( IN GLenum func, IN GLclampf ref )
  4023. {
  4024. GLCLIENT_BEGIN( AlphaFunc, ALPHAFUNC )
  4025. pMsg->func = func ;
  4026. pMsg->ref = ref ;
  4027. return;
  4028. GLCLIENT_END
  4029. }
  4030. void APIENTRY
  4031. glcltBlendFunc ( IN GLenum sfactor, IN GLenum dfactor )
  4032. {
  4033. GLCLIENT_BEGIN( BlendFunc, BLENDFUNC )
  4034. pMsg->sfactor = sfactor ;
  4035. pMsg->dfactor = dfactor ;
  4036. return;
  4037. GLCLIENT_END
  4038. }
  4039. void APIENTRY
  4040. glcltLogicOp ( IN GLenum opcode )
  4041. {
  4042. GLCLIENT_BEGIN( LogicOp, LOGICOP )
  4043. pMsg->opcode = opcode ;
  4044. return;
  4045. GLCLIENT_END
  4046. }
  4047. void APIENTRY
  4048. glcltStencilFunc ( IN GLenum func, IN GLint ref, IN GLuint mask )
  4049. {
  4050. GLCLIENT_BEGIN( StencilFunc, STENCILFUNC )
  4051. pMsg->func = func ;
  4052. pMsg->ref = ref ;
  4053. pMsg->mask = mask ;
  4054. return;
  4055. GLCLIENT_END
  4056. }
  4057. void APIENTRY
  4058. glcltStencilOp ( IN GLenum fail, IN GLenum zfail, IN GLenum zpass )
  4059. {
  4060. GLCLIENT_BEGIN( StencilOp, STENCILOP )
  4061. pMsg->fail = fail ;
  4062. pMsg->zfail = zfail ;
  4063. pMsg->zpass = zpass ;
  4064. return;
  4065. GLCLIENT_END
  4066. }
  4067. void APIENTRY
  4068. glcltDepthFunc ( IN GLenum func )
  4069. {
  4070. GLCLIENT_BEGIN( DepthFunc, DEPTHFUNC )
  4071. pMsg->func = func ;
  4072. return;
  4073. GLCLIENT_END
  4074. }
  4075. void APIENTRY
  4076. glcltPixelZoom ( IN GLfloat xfactor, IN GLfloat yfactor )
  4077. {
  4078. GLCLIENT_BEGIN( PixelZoom, PIXELZOOM )
  4079. pMsg->xfactor = xfactor ;
  4080. pMsg->yfactor = yfactor ;
  4081. return;
  4082. GLCLIENT_END
  4083. }
  4084. void APIENTRY
  4085. glcltPixelTransferf ( IN GLenum pname, IN GLfloat param )
  4086. {
  4087. GLCLIENT_BEGIN( PixelTransferf, PIXELTRANSFERF )
  4088. pMsg->pname = pname ;
  4089. pMsg->param = param ;
  4090. return;
  4091. GLCLIENT_END
  4092. }
  4093. void APIENTRY
  4094. glcltPixelTransferi ( IN GLenum pname, IN GLint param )
  4095. {
  4096. GLCLIENT_BEGIN( PixelTransferi, PIXELTRANSFERI )
  4097. pMsg->pname = pname ;
  4098. pMsg->param = param ;
  4099. return;
  4100. GLCLIENT_END
  4101. }
  4102. void APIENTRY
  4103. glcltPixelStoref ( IN GLenum pname, IN GLfloat param )
  4104. {
  4105. GLCLIENT_BEGIN( PixelStoref, PIXELSTOREF )
  4106. pMsg->pname = pname ;
  4107. pMsg->param = param ;
  4108. return;
  4109. GLCLIENT_END
  4110. }
  4111. void APIENTRY
  4112. glcltPixelStorei ( IN GLenum pname, IN GLint param )
  4113. {
  4114. GLCLIENT_BEGIN( PixelStorei, PIXELSTOREI )
  4115. pMsg->pname = pname ;
  4116. pMsg->param = param ;
  4117. return;
  4118. GLCLIENT_END
  4119. }
  4120. void APIENTRY
  4121. glcltPixelMapfv ( IN GLenum map, IN GLint mapsize, IN const GLfloat values[] )
  4122. {
  4123. GLCLIENT_BEGIN_LARGE_SET( PixelMapfv, PIXELMAPFV, values, ulSize, valuesOff )
  4124. pMsg->map = map ;
  4125. pMsg->mapsize = mapsize ;
  4126. GLCLIENT_END_LARGE_SET
  4127. return;
  4128. }
  4129. void APIENTRY
  4130. glcltPixelMapuiv ( IN GLenum map, IN GLint mapsize, IN const GLuint values[] )
  4131. {
  4132. GLCLIENT_BEGIN_LARGE_SET( PixelMapuiv, PIXELMAPUIV, values, ulSize, valuesOff )
  4133. pMsg->map = map ;
  4134. pMsg->mapsize = mapsize ;
  4135. GLCLIENT_END_LARGE_SET
  4136. return;
  4137. }
  4138. void APIENTRY
  4139. glcltPixelMapusv ( IN GLenum map, IN GLint mapsize, IN const GLushort values[] )
  4140. {
  4141. GLCLIENT_BEGIN_LARGE_SET( PixelMapusv, PIXELMAPUSV, values, ulSize, valuesOff )
  4142. pMsg->map = map ;
  4143. pMsg->mapsize = mapsize ;
  4144. GLCLIENT_END_LARGE_SET
  4145. return;
  4146. }
  4147. void APIENTRY
  4148. glcltReadBuffer ( IN GLenum mode )
  4149. {
  4150. GLCLIENT_BEGIN( ReadBuffer, READBUFFER )
  4151. pMsg->mode = mode ;
  4152. glsbAttention();
  4153. return;
  4154. GLCLIENT_END
  4155. }
  4156. void APIENTRY
  4157. glcltCopyPixels ( IN GLint x, IN GLint y, IN GLsizei width, IN GLsizei height, IN GLenum type )
  4158. {
  4159. GLCLIENT_BEGIN( CopyPixels, COPYPIXELS )
  4160. pMsg->x = x ;
  4161. pMsg->y = y ;
  4162. pMsg->width = width ;
  4163. pMsg->height = height ;
  4164. pMsg->type = type ;
  4165. return;
  4166. GLCLIENT_END
  4167. }
  4168. void APIENTRY
  4169. glcltGetClipPlane ( IN GLenum plane, OUT GLdouble equation[4] )
  4170. {
  4171. GLCLIENT_BEGIN( GetClipPlane, GETCLIPPLANE )
  4172. pMsg->plane = plane ;
  4173. pMsg->equation = equation;
  4174. glsbAttention();
  4175. return;
  4176. GLCLIENT_END
  4177. }
  4178. GLenum APIENTRY
  4179. glcltGetError ( void )
  4180. {
  4181. GLCLIENT_BEGIN( GetError, GETERROR )
  4182. GLTEB_RETURNVALUE() = GL_INVALID_OPERATION; // assume error
  4183. glsbAttention();
  4184. return((GLenum)GLTEB_RETURNVALUE());
  4185. GLCLIENT_END
  4186. }
  4187. void APIENTRY
  4188. glcltGetMapdv ( IN GLenum target, IN GLenum query, OUT GLdouble v[] )
  4189. {
  4190. GLCLIENT_BEGIN_LARGE_GET( GetMapdv, GETMAPDV, v, ulSize, vOff )
  4191. pMsg->target = target ;
  4192. pMsg->query = query ;
  4193. GLCLIENT_END_LARGE_GET
  4194. return;
  4195. }
  4196. void APIENTRY
  4197. glcltGetMapfv ( IN GLenum target, IN GLenum query, OUT GLfloat v[] )
  4198. {
  4199. GLCLIENT_BEGIN_LARGE_GET( GetMapfv, GETMAPFV, v, ulSize, vOff )
  4200. pMsg->target = target ;
  4201. pMsg->query = query ;
  4202. GLCLIENT_END_LARGE_GET
  4203. return;
  4204. }
  4205. void APIENTRY
  4206. glcltGetMapiv ( IN GLenum target, IN GLenum query, OUT GLint v[] )
  4207. {
  4208. GLCLIENT_BEGIN_LARGE_GET( GetMapiv, GETMAPIV, v, ulSize, vOff )
  4209. pMsg->target = target ;
  4210. pMsg->query = query ;
  4211. GLCLIENT_END_LARGE_GET
  4212. return;
  4213. }
  4214. void APIENTRY
  4215. glcltGetPixelMapfv ( IN GLenum map, OUT GLfloat values[] )
  4216. {
  4217. GLCLIENT_BEGIN_LARGE_GET( GetPixelMapfv, GETPIXELMAPFV, values, ulSize, valuesOff )
  4218. pMsg->map = map ;
  4219. GLCLIENT_END_LARGE_GET
  4220. return;
  4221. }
  4222. void APIENTRY
  4223. glcltGetPixelMapuiv ( IN GLenum map, OUT GLuint values[] )
  4224. {
  4225. GLCLIENT_BEGIN_LARGE_GET( GetPixelMapuiv, GETPIXELMAPUIV, values, ulSize, valuesOff )
  4226. pMsg->map = map ;
  4227. GLCLIENT_END_LARGE_GET
  4228. return;
  4229. }
  4230. void APIENTRY
  4231. glcltGetPixelMapusv ( IN GLenum map, OUT GLushort values[] )
  4232. {
  4233. GLCLIENT_BEGIN_LARGE_GET( GetPixelMapusv, GETPIXELMAPUSV, values, ulSize, valuesOff )
  4234. pMsg->map = map ;
  4235. GLCLIENT_END_LARGE_GET
  4236. return;
  4237. }
  4238. GLboolean APIENTRY
  4239. glcltIsEnabled ( IN GLenum cap )
  4240. {
  4241. GLCLIENT_BEGIN( IsEnabled, ISENABLED )
  4242. pMsg->cap = cap ;
  4243. GLTEB_RETURNVALUE() = 0; // assume error
  4244. glsbAttention();
  4245. return((GLboolean)GLTEB_RETURNVALUE());
  4246. GLCLIENT_END
  4247. }
  4248. void APIENTRY
  4249. glcltDepthRange ( IN GLclampd zNear, IN GLclampd zFar )
  4250. {
  4251. GLCLIENT_BEGIN( DepthRange, DEPTHRANGE )
  4252. pMsg->zNear = zNear ;
  4253. pMsg->zFar = zFar ;
  4254. return;
  4255. GLCLIENT_END
  4256. }
  4257. void APIENTRY
  4258. glcltFrustum ( IN GLdouble left, IN GLdouble right, IN GLdouble bottom, IN GLdouble top, IN GLdouble zNear, IN GLdouble zFar )
  4259. {
  4260. GLCLIENT_BEGIN( Frustum, FRUSTUM )
  4261. pMsg->left = left ;
  4262. pMsg->right = right ;
  4263. pMsg->bottom = bottom ;
  4264. pMsg->top = top ;
  4265. pMsg->zNear = zNear ;
  4266. pMsg->zFar = zFar ;
  4267. return;
  4268. GLCLIENT_END
  4269. }
  4270. void APIENTRY
  4271. glcltLoadIdentity ( void )
  4272. {
  4273. GLCLIENT_BEGIN( LoadIdentity, LOADIDENTITY )
  4274. return;
  4275. GLCLIENT_END
  4276. }
  4277. void APIENTRY
  4278. glcltLoadMatrixf ( IN const GLfloat m[16] )
  4279. {
  4280. GLCLIENT_BEGIN( LoadMatrixf, LOADMATRIXF )
  4281. pMsg->m[ 0] = m[ 0];
  4282. pMsg->m[ 1] = m[ 1];
  4283. pMsg->m[ 2] = m[ 2];
  4284. pMsg->m[ 3] = m[ 3];
  4285. pMsg->m[ 4] = m[ 4];
  4286. pMsg->m[ 5] = m[ 5];
  4287. pMsg->m[ 6] = m[ 6];
  4288. pMsg->m[ 7] = m[ 7];
  4289. pMsg->m[ 8] = m[ 8];
  4290. pMsg->m[ 9] = m[ 9];
  4291. pMsg->m[10] = m[10];
  4292. pMsg->m[11] = m[11];
  4293. pMsg->m[12] = m[12];
  4294. pMsg->m[13] = m[13];
  4295. pMsg->m[14] = m[14];
  4296. pMsg->m[15] = m[15];
  4297. return;
  4298. GLCLIENT_END
  4299. }
  4300. void APIENTRY
  4301. glcltLoadMatrixd ( IN const GLdouble m[16] )
  4302. {
  4303. // Call LoadMatrixf instead
  4304. GLCLIENT_BEGIN( LoadMatrixf, LOADMATRIXF )
  4305. pMsg->m[ 0] = (GLfloat) m[ 0];
  4306. pMsg->m[ 1] = (GLfloat) m[ 1];
  4307. pMsg->m[ 2] = (GLfloat) m[ 2];
  4308. pMsg->m[ 3] = (GLfloat) m[ 3];
  4309. pMsg->m[ 4] = (GLfloat) m[ 4];
  4310. pMsg->m[ 5] = (GLfloat) m[ 5];
  4311. pMsg->m[ 6] = (GLfloat) m[ 6];
  4312. pMsg->m[ 7] = (GLfloat) m[ 7];
  4313. pMsg->m[ 8] = (GLfloat) m[ 8];
  4314. pMsg->m[ 9] = (GLfloat) m[ 9];
  4315. pMsg->m[10] = (GLfloat) m[10];
  4316. pMsg->m[11] = (GLfloat) m[11];
  4317. pMsg->m[12] = (GLfloat) m[12];
  4318. pMsg->m[13] = (GLfloat) m[13];
  4319. pMsg->m[14] = (GLfloat) m[14];
  4320. pMsg->m[15] = (GLfloat) m[15];
  4321. return;
  4322. GLCLIENT_END
  4323. }
  4324. void APIENTRY
  4325. glcltMatrixMode ( IN GLenum mode )
  4326. {
  4327. GLCLIENT_BEGIN( MatrixMode, MATRIXMODE )
  4328. pMsg->mode = mode ;
  4329. return;
  4330. GLCLIENT_END
  4331. }
  4332. void APIENTRY
  4333. glcltMultMatrixf ( IN const GLfloat m[16] )
  4334. {
  4335. GLCLIENT_BEGIN( MultMatrixf, MULTMATRIXF )
  4336. pMsg->m[ 0] = m[ 0];
  4337. pMsg->m[ 1] = m[ 1];
  4338. pMsg->m[ 2] = m[ 2];
  4339. pMsg->m[ 3] = m[ 3];
  4340. pMsg->m[ 4] = m[ 4];
  4341. pMsg->m[ 5] = m[ 5];
  4342. pMsg->m[ 6] = m[ 6];
  4343. pMsg->m[ 7] = m[ 7];
  4344. pMsg->m[ 8] = m[ 8];
  4345. pMsg->m[ 9] = m[ 9];
  4346. pMsg->m[10] = m[10];
  4347. pMsg->m[11] = m[11];
  4348. pMsg->m[12] = m[12];
  4349. pMsg->m[13] = m[13];
  4350. pMsg->m[14] = m[14];
  4351. pMsg->m[15] = m[15];
  4352. return;
  4353. GLCLIENT_END
  4354. }
  4355. void APIENTRY
  4356. glcltMultMatrixd ( IN const GLdouble m[16] )
  4357. {
  4358. // Call MultMatrixf instead
  4359. GLCLIENT_BEGIN( MultMatrixf, MULTMATRIXF )
  4360. pMsg->m[ 0] = (GLfloat) m[ 0];
  4361. pMsg->m[ 1] = (GLfloat) m[ 1];
  4362. pMsg->m[ 2] = (GLfloat) m[ 2];
  4363. pMsg->m[ 3] = (GLfloat) m[ 3];
  4364. pMsg->m[ 4] = (GLfloat) m[ 4];
  4365. pMsg->m[ 5] = (GLfloat) m[ 5];
  4366. pMsg->m[ 6] = (GLfloat) m[ 6];
  4367. pMsg->m[ 7] = (GLfloat) m[ 7];
  4368. pMsg->m[ 8] = (GLfloat) m[ 8];
  4369. pMsg->m[ 9] = (GLfloat) m[ 9];
  4370. pMsg->m[10] = (GLfloat) m[10];
  4371. pMsg->m[11] = (GLfloat) m[11];
  4372. pMsg->m[12] = (GLfloat) m[12];
  4373. pMsg->m[13] = (GLfloat) m[13];
  4374. pMsg->m[14] = (GLfloat) m[14];
  4375. pMsg->m[15] = (GLfloat) m[15];
  4376. return;
  4377. GLCLIENT_END
  4378. }
  4379. void APIENTRY
  4380. glcltOrtho ( IN GLdouble left, IN GLdouble right, IN GLdouble bottom, IN GLdouble top, IN GLdouble zNear, IN GLdouble zFar )
  4381. {
  4382. GLCLIENT_BEGIN( Ortho, ORTHO )
  4383. pMsg->left = left ;
  4384. pMsg->right = right ;
  4385. pMsg->bottom = bottom ;
  4386. pMsg->top = top ;
  4387. pMsg->zNear = zNear ;
  4388. pMsg->zFar = zFar ;
  4389. return;
  4390. GLCLIENT_END
  4391. }
  4392. void APIENTRY
  4393. glcltPopMatrix ( void )
  4394. {
  4395. GLCLIENT_BEGIN( PopMatrix, POPMATRIX )
  4396. return;
  4397. GLCLIENT_END
  4398. }
  4399. void APIENTRY
  4400. glcltPushMatrix ( void )
  4401. {
  4402. GLCLIENT_BEGIN( PushMatrix, PUSHMATRIX )
  4403. return;
  4404. GLCLIENT_END
  4405. }
  4406. void APIENTRY
  4407. glcltRotated ( IN GLdouble angle, IN GLdouble x, IN GLdouble y, IN GLdouble z )
  4408. {
  4409. // Call Rotatef instead
  4410. glcltRotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
  4411. }
  4412. void APIENTRY
  4413. glcltRotatef ( IN GLfloat angle, IN GLfloat x, IN GLfloat y, IN GLfloat z )
  4414. {
  4415. GLCLIENT_BEGIN( Rotatef, ROTATEF )
  4416. pMsg->angle = angle ;
  4417. pMsg->x = x ;
  4418. pMsg->y = y ;
  4419. pMsg->z = z ;
  4420. return;
  4421. GLCLIENT_END
  4422. }
  4423. void APIENTRY
  4424. glcltScaled ( IN GLdouble x, IN GLdouble y, IN GLdouble z )
  4425. {
  4426. // Call Scalef instead
  4427. glcltScalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
  4428. }
  4429. void APIENTRY
  4430. glcltScalef ( IN GLfloat x, IN GLfloat y, IN GLfloat z )
  4431. {
  4432. GLCLIENT_BEGIN( Scalef, SCALEF )
  4433. pMsg->x = x ;
  4434. pMsg->y = y ;
  4435. pMsg->z = z ;
  4436. return;
  4437. GLCLIENT_END
  4438. }
  4439. void APIENTRY
  4440. glcltTranslated ( IN GLdouble x, IN GLdouble y, IN GLdouble z )
  4441. {
  4442. // Call Translatef instead
  4443. glcltTranslatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
  4444. }
  4445. void APIENTRY
  4446. glcltTranslatef ( IN GLfloat x, IN GLfloat y, IN GLfloat z )
  4447. {
  4448. GLCLIENT_BEGIN( Translatef, TRANSLATEF )
  4449. pMsg->x = x ;
  4450. pMsg->y = y ;
  4451. pMsg->z = z ;
  4452. return;
  4453. GLCLIENT_END
  4454. }
  4455. void APIENTRY
  4456. glcltViewport ( IN GLint x, IN GLint y, IN GLsizei width, IN GLsizei height )
  4457. {
  4458. GLCLIENT_BEGIN( Viewport, VIEWPORT )
  4459. pMsg->x = x ;
  4460. pMsg->y = y ;
  4461. pMsg->width = width ;
  4462. pMsg->height = height ;
  4463. return;
  4464. GLCLIENT_END
  4465. }