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.

726 lines
22 KiB

  1. /*
  2. ** Copyright 1991,1992, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. **
  17. */
  18. #include "precomp.h"
  19. #pragma hdrstop
  20. /* 1 Component modulate */
  21. void FASTCALL __glTextureModulateL(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  22. {
  23. #ifdef __GL_LINT
  24. gc = gc;
  25. #endif
  26. color->r = texel->luminance * color->r;
  27. color->g = texel->luminance * color->g;
  28. color->b = texel->luminance * color->b;
  29. }
  30. /* 2 Component modulate */
  31. void FASTCALL __glTextureModulateLA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  32. {
  33. #ifdef __GL_LINT
  34. gc = gc;
  35. #endif
  36. color->r = texel->luminance * color->r;
  37. color->g = texel->luminance * color->g;
  38. color->b = texel->luminance * color->b;
  39. color->a = texel->alpha * color->a;
  40. }
  41. /* 3 Component modulate */
  42. void FASTCALL __glTextureModulateRGB(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  43. {
  44. #ifdef __GL_LINT
  45. gc = gc;
  46. #endif
  47. color->r = texel->r * color->r;
  48. color->g = texel->g * color->g;
  49. color->b = texel->b * color->b;
  50. }
  51. /* 4 Component modulate */
  52. void FASTCALL __glTextureModulateRGBA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  53. {
  54. #ifdef __GL_LINT
  55. gc = gc;
  56. #endif
  57. color->r = texel->r * color->r;
  58. color->g = texel->g * color->g;
  59. color->b = texel->b * color->b;
  60. color->a = texel->alpha * color->a;
  61. }
  62. /* Alpha modulate */
  63. void FASTCALL __glTextureModulateA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  64. {
  65. #ifdef __GL_LINT
  66. gc = gc;
  67. #endif
  68. color->a = texel->alpha * color->a;
  69. }
  70. /* Intensity modulate */
  71. void FASTCALL __glTextureModulateI(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  72. {
  73. #ifdef __GL_LINT
  74. gc = gc;
  75. #endif
  76. color->r = texel->intensity * color->r;
  77. color->g = texel->intensity * color->g;
  78. color->b = texel->intensity * color->b;
  79. color->a = texel->intensity * color->a;
  80. }
  81. /***********************************************************************/
  82. /* 3 Component decal */
  83. void FASTCALL __glTextureDecalRGB(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  84. {
  85. color->r = texel->r * gc->frontBuffer.redScale;
  86. color->g = texel->g * gc->frontBuffer.greenScale;
  87. color->b = texel->b * gc->frontBuffer.blueScale;
  88. }
  89. /* 4 Component decal */
  90. void FASTCALL __glTextureDecalRGBA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  91. {
  92. __GLfloat a = texel->alpha;
  93. __GLfloat oma = __glOne - a;
  94. color->r = oma * color->r
  95. + a * texel->r * gc->frontBuffer.redScale;
  96. color->g = oma * color->g
  97. + a * texel->g * gc->frontBuffer.greenScale;
  98. color->b = oma * color->b
  99. + a * texel->b * gc->frontBuffer.blueScale;
  100. }
  101. /***********************************************************************/
  102. /* 1 Component blend */
  103. void FASTCALL __glTextureBlendL(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  104. {
  105. __GLfloat l = texel->luminance;
  106. __GLfloat oml = __glOne - l;
  107. __GLcolor *cc = &gc->state.texture.env[0].color;
  108. color->r = oml * color->r + l * cc->r;
  109. color->g = oml * color->g + l * cc->g;
  110. color->b = oml * color->b + l * cc->b;
  111. }
  112. /* 2 Component blend */
  113. void FASTCALL __glTextureBlendLA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  114. {
  115. __GLfloat l = texel->luminance;
  116. __GLfloat oml = __glOne - l;
  117. __GLcolor *cc = &gc->state.texture.env[0].color;
  118. color->r = oml * color->r + l * cc->r;
  119. color->g = oml * color->g + l * cc->g;
  120. color->b = oml * color->b + l * cc->b;
  121. color->a = texel->alpha * color->a;
  122. }
  123. /* 3 Component blend */
  124. void FASTCALL __glTextureBlendRGB(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  125. {
  126. __GLfloat r = texel->r;
  127. __GLfloat g = texel->g;
  128. __GLfloat b = texel->b;
  129. __GLcolor *cc = &gc->state.texture.env[0].color;
  130. color->r = (__glOne - r) * color->r + r * cc->r;
  131. color->g = (__glOne - g) * color->g + g * cc->g;
  132. color->b = (__glOne - b) * color->b + b * cc->b;
  133. }
  134. /* 4 Component blend */
  135. void FASTCALL __glTextureBlendRGBA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  136. {
  137. __GLfloat r = texel->r;
  138. __GLfloat g = texel->g;
  139. __GLfloat b = texel->b;
  140. __GLcolor *cc = &gc->state.texture.env[0].color;
  141. color->r = (__glOne - r) * color->r + r * cc->r;
  142. color->g = (__glOne - g) * color->g + g * cc->g;
  143. color->b = (__glOne - b) * color->b + b * cc->b;
  144. color->a = texel->alpha * color->a;
  145. }
  146. /* Alpha blend */
  147. void FASTCALL __glTextureBlendA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  148. {
  149. #ifdef __GL_LINT
  150. gc = gc;
  151. #endif
  152. color->a = texel->alpha * color->a;
  153. }
  154. /* Intensity blend */
  155. void FASTCALL __glTextureBlendI(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  156. {
  157. __GLfloat i = texel->intensity;
  158. __GLfloat omi = __glOne - i;
  159. __GLcolor *cc = &gc->state.texture.env[0].color;
  160. color->r = omi * color->r + i * cc->r;
  161. color->g = omi * color->g + i * cc->g;
  162. color->b = omi * color->b + i * cc->b;
  163. color->a = omi * color->a + i * cc->a;
  164. }
  165. /***********************************************************************/
  166. /* 1 Component replace */
  167. void FASTCALL __glTextureReplaceL(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  168. {
  169. color->r = texel->luminance * gc->frontBuffer.redScale;
  170. color->g = texel->luminance * gc->frontBuffer.greenScale;
  171. color->b = texel->luminance * gc->frontBuffer.blueScale;
  172. }
  173. /* 2 Component replace */
  174. void FASTCALL __glTextureReplaceLA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  175. {
  176. color->r = texel->luminance * gc->frontBuffer.redScale;
  177. color->g = texel->luminance * gc->frontBuffer.greenScale;
  178. color->b = texel->luminance * gc->frontBuffer.blueScale;
  179. color->a = texel->alpha * gc->frontBuffer.alphaScale;
  180. }
  181. /* 3 Component replace */
  182. void FASTCALL __glTextureReplaceRGB(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  183. {
  184. color->r = texel->r * gc->frontBuffer.redScale;
  185. color->g = texel->g * gc->frontBuffer.greenScale;
  186. color->b = texel->b * gc->frontBuffer.blueScale;
  187. }
  188. /* 4 Component replace */
  189. void FASTCALL __glTextureReplaceRGBA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  190. {
  191. color->r = texel->r * gc->frontBuffer.redScale;
  192. color->g = texel->g * gc->frontBuffer.greenScale;
  193. color->b = texel->b * gc->frontBuffer.blueScale;
  194. color->a = texel->alpha * gc->frontBuffer.alphaScale;
  195. }
  196. /* Alpha replace */
  197. void FASTCALL __glTextureReplaceA(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  198. {
  199. color->a = texel->alpha * gc->frontBuffer.alphaScale;
  200. }
  201. /* Intensity replace */
  202. void FASTCALL __glTextureReplaceI(__GLcontext *gc, __GLcolor *color, __GLtexel *texel)
  203. {
  204. color->r = texel->intensity * gc->frontBuffer.redScale;
  205. color->g = texel->intensity * gc->frontBuffer.greenScale;
  206. color->b = texel->intensity * gc->frontBuffer.blueScale;
  207. color->a = texel->intensity * gc->frontBuffer.alphaScale;
  208. }
  209. /************************************************************************/
  210. /*
  211. ** Get a texture element out of the one component texture buffer
  212. ** with no border.
  213. */
  214. void FASTCALL __glExtractTexelL(__GLmipMapLevel *level, __GLtexture *tex,
  215. GLint row, GLint col, __GLtexel *result)
  216. {
  217. __GLtextureBuffer *image;
  218. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  219. (col >= level->width2)) {
  220. /*
  221. ** Use border color when the texture supplies no border.
  222. */
  223. result->luminance = tex->params.borderColor.r;
  224. } else {
  225. image = level->buffer + ((row << level->widthLog2) + col);
  226. result->luminance = image[0];
  227. }
  228. }
  229. /*
  230. ** Get a texture element out of the two component texture buffer
  231. ** with no border.
  232. */
  233. void FASTCALL __glExtractTexelLA(__GLmipMapLevel *level, __GLtexture *tex,
  234. GLint row, GLint col, __GLtexel *result)
  235. {
  236. __GLtextureBuffer *image;
  237. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  238. (col >= level->width2)) {
  239. /*
  240. ** Use border color when the texture supplies no border.
  241. */
  242. result->luminance = tex->params.borderColor.r;
  243. result->alpha = tex->params.borderColor.a;
  244. } else {
  245. image = level->buffer + ((row << level->widthLog2) + col) * 2;
  246. result->luminance = image[0];
  247. result->alpha = image[1];
  248. }
  249. }
  250. /*
  251. ** Get a texture element out of the three component texture buffer
  252. ** with no border.
  253. */
  254. void FASTCALL __glExtractTexelRGB(__GLmipMapLevel *level, __GLtexture *tex,
  255. GLint row, GLint col, __GLtexel *result)
  256. {
  257. __GLtextureBuffer *image;
  258. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  259. (col >= level->width2)) {
  260. /*
  261. ** Use border color when the texture supplies no border.
  262. */
  263. result->r = tex->params.borderColor.r;
  264. result->g = tex->params.borderColor.g;
  265. result->b = tex->params.borderColor.b;
  266. } else {
  267. image = level->buffer + ((row << level->widthLog2) + col) * 3;
  268. result->r = image[0];
  269. result->g = image[1];
  270. result->b = image[2];
  271. }
  272. }
  273. /*
  274. ** Get a texture element out of the four component texture buffer
  275. ** with no border.
  276. */
  277. void FASTCALL __glExtractTexelRGBA(__GLmipMapLevel *level, __GLtexture *tex,
  278. GLint row, GLint col, __GLtexel *result)
  279. {
  280. __GLtextureBuffer *image;
  281. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  282. (col >= level->width2)) {
  283. /*
  284. ** Use border color when the texture supplies no border.
  285. */
  286. result->r = tex->params.borderColor.r;
  287. result->g = tex->params.borderColor.g;
  288. result->b = tex->params.borderColor.b;
  289. result->alpha = tex->params.borderColor.a;
  290. } else {
  291. image = level->buffer + ((row << level->widthLog2) + col) * 4;
  292. result->r = image[0];
  293. result->g = image[1];
  294. result->b = image[2];
  295. result->alpha = image[3];
  296. }
  297. }
  298. void FASTCALL __glExtractTexelA(__GLmipMapLevel *level, __GLtexture *tex,
  299. GLint row, GLint col, __GLtexel *result)
  300. {
  301. __GLtextureBuffer *image;
  302. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  303. (col >= level->width2)) {
  304. /*
  305. ** Use border color when the texture supplies no border.
  306. */
  307. result->alpha = tex->params.borderColor.a;
  308. } else {
  309. image = level->buffer + ((row << level->widthLog2) + col);
  310. result->alpha = image[0];
  311. }
  312. }
  313. void FASTCALL __glExtractTexelI(__GLmipMapLevel *level, __GLtexture *tex,
  314. GLint row, GLint col, __GLtexel *result)
  315. {
  316. __GLtextureBuffer *image;
  317. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  318. (col >= level->width2)) {
  319. /*
  320. ** Use border color when the texture supplies no border.
  321. */
  322. result->intensity = tex->params.borderColor.r;
  323. } else {
  324. image = level->buffer + ((row << level->widthLog2) + col);
  325. result->intensity = image[0];
  326. }
  327. }
  328. void FASTCALL __glExtractTexelBGR8(__GLmipMapLevel *level, __GLtexture *tex,
  329. GLint row, GLint col, __GLtexel *result)
  330. {
  331. __GLcontext *gc = tex->gc;
  332. GLubyte *image;
  333. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  334. (col >= level->width2)) {
  335. /*
  336. ** Use border color when the texture supplies no border.
  337. */
  338. result->r = tex->params.borderColor.r;
  339. result->g = tex->params.borderColor.g;
  340. result->b = tex->params.borderColor.b;
  341. } else {
  342. image = (GLubyte *)level->buffer + ((row << level->widthLog2) + col) * 4;
  343. result->r = __GL_UB_TO_FLOAT(image[2]);
  344. result->g = __GL_UB_TO_FLOAT(image[1]);
  345. result->b = __GL_UB_TO_FLOAT(image[0]);
  346. }
  347. }
  348. void FASTCALL __glExtractTexelBGRA8(__GLmipMapLevel *level, __GLtexture *tex,
  349. GLint row, GLint col, __GLtexel *result)
  350. {
  351. __GLcontext *gc = tex->gc;
  352. GLubyte *image;
  353. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  354. (col >= level->width2)) {
  355. /*
  356. ** Use border color when the texture supplies no border.
  357. */
  358. result->r = tex->params.borderColor.r;
  359. result->g = tex->params.borderColor.g;
  360. result->b = tex->params.borderColor.b;
  361. result->alpha = tex->params.borderColor.a;
  362. } else {
  363. image = (GLubyte *)level->buffer + ((row << level->widthLog2) + col) * 4;
  364. result->r = __GL_UB_TO_FLOAT(image[2]);
  365. result->g = __GL_UB_TO_FLOAT(image[1]);
  366. result->b = __GL_UB_TO_FLOAT(image[0]);
  367. result->alpha = __GL_UB_TO_FLOAT(image[3]);
  368. }
  369. }
  370. #ifdef GL_EXT_paletted_texture
  371. void FASTCALL __glExtractTexelPI8BGRA(__GLmipMapLevel *level, __GLtexture *tex,
  372. GLint row, GLint col, __GLtexel *result)
  373. {
  374. __GLcontext *gc = tex->gc;
  375. GLubyte *image;
  376. RGBQUAD *rgb;
  377. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  378. (col >= level->width2)) {
  379. /*
  380. ** Use border color when the texture supplies no border.
  381. */
  382. result->r = tex->params.borderColor.r;
  383. result->g = tex->params.borderColor.g;
  384. result->b = tex->params.borderColor.b;
  385. result->alpha = tex->params.borderColor.a;
  386. } else {
  387. image = (GLubyte *)level->buffer + ((row << level->widthLog2) + col);
  388. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  389. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  390. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  391. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  392. result->alpha = __GL_UB_TO_FLOAT(rgb->rgbReserved);
  393. }
  394. }
  395. void FASTCALL __glExtractTexelPI8BGR(__GLmipMapLevel *level, __GLtexture *tex,
  396. GLint row, GLint col, __GLtexel *result)
  397. {
  398. __GLcontext *gc = tex->gc;
  399. GLubyte *image;
  400. RGBQUAD *rgb;
  401. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  402. (col >= level->width2)) {
  403. /*
  404. ** Use border color when the texture supplies no border.
  405. */
  406. result->r = tex->params.borderColor.r;
  407. result->g = tex->params.borderColor.g;
  408. result->b = tex->params.borderColor.b;
  409. } else {
  410. image = (GLubyte *)level->buffer + ((row << level->widthLog2) + col);
  411. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  412. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  413. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  414. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  415. }
  416. }
  417. void FASTCALL __glExtractTexelPI16BGRA(__GLmipMapLevel *level, __GLtexture *tex,
  418. GLint row, GLint col, __GLtexel *result)
  419. {
  420. __GLcontext *gc = tex->gc;
  421. GLushort *image;
  422. RGBQUAD *rgb;
  423. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  424. (col >= level->width2)) {
  425. /*
  426. ** Use border color when the texture supplies no border.
  427. */
  428. result->r = tex->params.borderColor.r;
  429. result->g = tex->params.borderColor.g;
  430. result->b = tex->params.borderColor.b;
  431. result->alpha = tex->params.borderColor.a;
  432. } else {
  433. image = (GLushort *)level->buffer + ((row << level->widthLog2) + col);
  434. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  435. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  436. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  437. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  438. result->alpha = __GL_UB_TO_FLOAT(rgb->rgbReserved);
  439. }
  440. }
  441. void FASTCALL __glExtractTexelPI16BGR(__GLmipMapLevel *level, __GLtexture *tex,
  442. GLint row, GLint col, __GLtexel *result)
  443. {
  444. __GLcontext *gc = tex->gc;
  445. GLushort *image;
  446. RGBQUAD *rgb;
  447. if ((row < 0) || (col < 0) || (row >= level->height2) ||
  448. (col >= level->width2)) {
  449. /*
  450. ** Use border color when the texture supplies no border.
  451. */
  452. result->r = tex->params.borderColor.r;
  453. result->g = tex->params.borderColor.g;
  454. result->b = tex->params.borderColor.b;
  455. } else {
  456. image = (GLushort *)level->buffer + ((row << level->widthLog2) + col);
  457. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  458. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  459. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  460. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  461. }
  462. }
  463. #endif // GL_EXT_paletted_texture
  464. /*
  465. ** Get a texture element out of the one component texture buffer
  466. ** with a border.
  467. */
  468. void FASTCALL __glExtractTexelL_B(__GLmipMapLevel *level, __GLtexture *tex,
  469. GLint row, GLint col, __GLtexel *result)
  470. {
  471. __GLtextureBuffer *image;
  472. #ifdef __GL_LINT
  473. tex = tex;
  474. #endif
  475. row++;
  476. col++;
  477. image = level->buffer + (row * level->width + col);
  478. result->luminance = image[0];
  479. }
  480. /*
  481. ** Get a texture element out of the two component texture buffer
  482. ** with a border.
  483. */
  484. void FASTCALL __glExtractTexelLA_B(__GLmipMapLevel *level, __GLtexture *tex,
  485. GLint row, GLint col, __GLtexel *result)
  486. {
  487. __GLtextureBuffer *image;
  488. #ifdef __GL_LINT
  489. tex = tex;
  490. #endif
  491. row++;
  492. col++;
  493. image = level->buffer + (row * level->width + col) * 2;
  494. result->luminance = image[0];
  495. result->alpha = image[1];
  496. }
  497. /*
  498. ** Get a texture element out of the three component texture buffer
  499. ** with a border.
  500. */
  501. void FASTCALL __glExtractTexelRGB_B(__GLmipMapLevel *level, __GLtexture *tex,
  502. GLint row, GLint col, __GLtexel *result)
  503. {
  504. __GLtextureBuffer *image;
  505. #ifdef __GL_LINT
  506. tex = tex;
  507. #endif
  508. row++;
  509. col++;
  510. image = level->buffer + (row * level->width + col) * 3;
  511. result->r = image[0];
  512. result->g = image[1];
  513. result->b = image[2];
  514. }
  515. /*
  516. ** Get a texture element out of the four component texture buffer
  517. ** with a border.
  518. */
  519. void FASTCALL __glExtractTexelRGBA_B(__GLmipMapLevel *level, __GLtexture *tex,
  520. GLint row, GLint col, __GLtexel *result)
  521. {
  522. __GLtextureBuffer *image;
  523. #ifdef __GL_LINT
  524. tex = tex;
  525. #endif
  526. row++;
  527. col++;
  528. image = level->buffer + (row * level->width + col) * 4;
  529. result->r = image[0];
  530. result->g = image[1];
  531. result->b = image[2];
  532. result->alpha = image[3];
  533. }
  534. void FASTCALL __glExtractTexelA_B(__GLmipMapLevel *level, __GLtexture *tex,
  535. GLint row, GLint col, __GLtexel *result)
  536. {
  537. __GLtextureBuffer *image;
  538. #ifdef __GL_LINT
  539. tex = tex;
  540. #endif
  541. row++;
  542. col++;
  543. image = level->buffer + (row * level->width + col);
  544. result->alpha = image[0];
  545. }
  546. void FASTCALL __glExtractTexelI_B(__GLmipMapLevel *level, __GLtexture *tex,
  547. GLint row, GLint col, __GLtexel *result)
  548. {
  549. __GLtextureBuffer *image;
  550. #ifdef __GL_LINT
  551. tex = tex;
  552. #endif
  553. row++;
  554. col++;
  555. image = level->buffer + (row * level->width + col);
  556. result->intensity = image[0];
  557. }
  558. void FASTCALL __glExtractTexelBGR8_B(__GLmipMapLevel *level, __GLtexture *tex,
  559. GLint row, GLint col, __GLtexel *result)
  560. {
  561. __GLcontext *gc = tex->gc;
  562. GLubyte *image;
  563. #ifdef __GL_LINT
  564. tex = tex;
  565. #endif
  566. row++;
  567. col++;
  568. image = (GLubyte *)level->buffer + (row * level->width + col) * 4;
  569. result->r = __GL_UB_TO_FLOAT(image[2]);
  570. result->g = __GL_UB_TO_FLOAT(image[1]);
  571. result->b = __GL_UB_TO_FLOAT(image[0]);
  572. }
  573. void FASTCALL __glExtractTexelBGRA8_B(__GLmipMapLevel *level, __GLtexture *tex,
  574. GLint row, GLint col, __GLtexel *result)
  575. {
  576. __GLcontext *gc = tex->gc;
  577. GLubyte *image;
  578. #ifdef __GL_LINT
  579. tex = tex;
  580. #endif
  581. row++;
  582. col++;
  583. image = (GLubyte *)level->buffer + (row * level->width + col) * 4;
  584. result->r = __GL_UB_TO_FLOAT(image[2]);
  585. result->g = __GL_UB_TO_FLOAT(image[1]);
  586. result->b = __GL_UB_TO_FLOAT(image[0]);
  587. result->alpha = __GL_UB_TO_FLOAT(image[3]);
  588. }
  589. #ifdef GL_EXT_paletted_texture
  590. void FASTCALL __glExtractTexelPI8BGRA_B(__GLmipMapLevel *level, __GLtexture *tex,
  591. GLint row, GLint col, __GLtexel *result)
  592. {
  593. __GLcontext *gc = tex->gc;
  594. GLubyte *image;
  595. RGBQUAD *rgb;
  596. row++;
  597. col++;
  598. image = (GLubyte *)level->buffer + (row * level->width + col);
  599. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  600. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  601. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  602. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  603. result->alpha = __GL_UB_TO_FLOAT(rgb->rgbReserved);
  604. }
  605. void FASTCALL __glExtractTexelPI8BGR_B(__GLmipMapLevel *level, __GLtexture *tex,
  606. GLint row, GLint col, __GLtexel *result)
  607. {
  608. __GLcontext *gc = tex->gc;
  609. GLubyte *image;
  610. RGBQUAD *rgb;
  611. row++;
  612. col++;
  613. image = (GLubyte *)level->buffer + (row * level->width + col);
  614. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  615. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  616. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  617. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  618. }
  619. void FASTCALL __glExtractTexelPI16BGRA_B(__GLmipMapLevel *level, __GLtexture *tex,
  620. GLint row, GLint col, __GLtexel *result)
  621. {
  622. __GLcontext *gc = tex->gc;
  623. GLushort *image;
  624. RGBQUAD *rgb;
  625. row++;
  626. col++;
  627. image = (GLushort *)level->buffer + (row * level->width + col);
  628. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  629. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  630. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  631. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  632. result->alpha = __GL_UB_TO_FLOAT(rgb->rgbReserved);
  633. }
  634. void FASTCALL __glExtractTexelPI16BGR_B(__GLmipMapLevel *level, __GLtexture *tex,
  635. GLint row, GLint col, __GLtexel *result)
  636. {
  637. __GLcontext *gc = tex->gc;
  638. GLushort *image;
  639. RGBQUAD *rgb;
  640. row++;
  641. col++;
  642. image = (GLushort *)level->buffer + (row * level->width + col);
  643. rgb = &tex->paletteData[image[0] & (tex->paletteSize-1)];
  644. result->r = __GL_UB_TO_FLOAT(rgb->rgbRed);
  645. result->g = __GL_UB_TO_FLOAT(rgb->rgbGreen);
  646. result->b = __GL_UB_TO_FLOAT(rgb->rgbBlue);
  647. }
  648. #endif // GL_EXT_paletted_texture