Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.6 KiB

  1. /*
  2. ** Copyright 1991,1992, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. **
  17. ** $Revision: 1.8 $
  18. ** $Date: 1993/04/10 04:07:00 $
  19. */
  20. #include "precomp.h"
  21. #pragma hdrstop
  22. #define __GL_BITS_PER_UINT32 (sizeof(GLuint) * __GL_BITS_PER_BYTE)
  23. void __glDrawBitmap(__GLcontext *gc, GLsizei width, GLsizei height,
  24. GLfloat xOrig, GLfloat yOrig,
  25. GLfloat xMove, GLfloat yMove,
  26. const GLubyte oldbits[])
  27. {
  28. __GLbitmap bitmap;
  29. GLubyte *newbits;
  30. size_t size;
  31. bitmap.width = width;
  32. bitmap.height = height;
  33. bitmap.xorig = xOrig;
  34. bitmap.yorig = yOrig;
  35. bitmap.xmove = xMove;
  36. bitmap.ymove = yMove;
  37. /*
  38. ** Could check the pixel transfer modes and see if we can maybe just
  39. ** render oldbits directly rather than converting it first.
  40. */
  41. size = (size_t) __glImageSize(width, height, GL_COLOR_INDEX, GL_BITMAP);
  42. newbits = (GLubyte *) gcTempAlloc(gc, size);
  43. __glFillImage(gc, width, height, GL_COLOR_INDEX, GL_BITMAP,
  44. oldbits, newbits);
  45. (*gc->procs.renderBitmap)(gc, &bitmap, newbits);
  46. gcTempFree(gc, newbits);
  47. }
  48. void FASTCALL __glRenderBitmap(__GLcontext *gc, const __GLbitmap *bitmap,
  49. const GLubyte *data)
  50. {
  51. __GLfragment frag;
  52. __GLvertex *rp;
  53. __GLfloat fx;
  54. GLint x, y, bit;
  55. GLint ySign;
  56. GLuint modeFlags = gc->polygon.shader.modeFlags;
  57. // Crank down the fpu precision to 24-bit mantissa to gain front-end speed.
  58. // This will only affect code which relies on double arithmetic. Also,
  59. // mask off FP exceptions. Finally, to draw primitives, we can let the
  60. // FPU run in chop (truncation) mode since we have enough precision left
  61. // to convert to pixel units:
  62. FPU_SAVE_MODE();
  63. FPU_PREC_LOW_MASK_EXCEPTIONS();
  64. FPU_CHOP_ON_PREC_LOW();
  65. ySign = gc->constants.ySign;
  66. /*
  67. ** Check if current raster position is valid. Do not render if invalid.
  68. ** Also, if selection is in progress skip the rendering of the
  69. ** bitmap. Bitmaps are invisible to selection and do not generate
  70. ** selection hits.
  71. */
  72. rp = &gc->state.current.rasterPos;
  73. if (!gc->state.current.validRasterPos) {
  74. goto glBitmap_exit;
  75. }
  76. if (gc->renderMode == GL_SELECT) {
  77. rp->window.x += bitmap->xmove;
  78. rp->window.y += ySign * bitmap->ymove;
  79. goto glBitmap_exit;
  80. }
  81. if (gc->renderMode == GL_FEEDBACK) {
  82. __glFeedbackBitmap(gc, rp);
  83. /*
  84. ** Advance the raster position as if the bitmap had been rendered.
  85. */
  86. rp->window.x += bitmap->xmove;
  87. rp->window.y += ySign * bitmap->ymove;
  88. goto glBitmap_exit;
  89. }
  90. frag.color = *rp->color;
  91. if (modeFlags & __GL_SHADE_TEXTURE) {
  92. __GLfloat qInv;
  93. if (__GL_FLOAT_EQZ(rp->texture.w))
  94. {
  95. qInv = __glZero;
  96. }
  97. else
  98. {
  99. qInv = __glOne / rp->texture.w;
  100. }
  101. (*gc->procs.texture)(gc, &frag.color, rp->texture.x * qInv,
  102. rp->texture.y * qInv, __glOne);
  103. }
  104. /* XXX - is this the correct test */
  105. if (gc->state.enables.general & __GL_FOG_ENABLE) {
  106. (*gc->procs.fogPoint)(gc, &frag, rp->eyeZ);
  107. }
  108. frag.z = rp->window.z;
  109. fx = (GLint) (rp->window.x - bitmap->xorig);
  110. frag.y = (GLint) (rp->window.y - ySign * bitmap->yorig);
  111. bit = 7;
  112. for (y = 0; y < bitmap->height; y++) {
  113. frag.x = fx;
  114. for (x = 0; x < bitmap->width; x++) {
  115. if (*data & (1<<bit)) {
  116. (*gc->procs.store)(gc->drawBuffer, &frag);
  117. }
  118. frag.x++;
  119. bit--;
  120. if (bit < 0) {
  121. bit = 7;
  122. data++;
  123. }
  124. }
  125. frag.y += ySign;
  126. if (bit != 7) {
  127. bit = 7;
  128. data++;
  129. }
  130. }
  131. /*
  132. ** Advance current raster position.
  133. */
  134. rp->window.x += bitmap->xmove;
  135. rp->window.y += ySign * bitmap->ymove;
  136. glBitmap_exit:
  137. FPU_RESTORE_MODE_NO_EXCEPTIONS();
  138. }