home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 2000 April & May / AMIGA_2000_04.iso / patches / mesa3.1 / mesa-3_1.lha / src / AOS / natDisplay / natFastLinesDBnD.E < prev    next >
Encoding:
Text File  |  1999-09-04  |  5.5 KB  |  178 lines

  1. /*
  2.  * $Id: $
  3.  */
  4.  
  5. /*
  6.  * Mesa 3-D graphics library
  7.  * Version:  3.1
  8.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  9.  *
  10.  * This library is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU Library General Public
  12.  * License as published by the Free Software Foundation; either
  13.  * version 2 of the License, or (at your option) any later version.
  14.  *
  15.  * This library is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18.  * Library General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU Library General Public
  21.  * License along with this library; if not, write to the Free
  22.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. /**********************************************************************/
  26. /*****                   Optimized line rendering                 *****/
  27. /**********************************************************************/
  28.  
  29. /* Draw a flat-shaded, RGB line into an osmesa buffer. */
  30. void natDFlatRGBALine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  31. {
  32.   struct RastPort *rp;
  33.  
  34.   rp = ((amigaMesaContext) ctx->DriverCtx)->rp;
  35.  
  36.  
  37. #define INTERP_XY    1
  38. #define CLIP_HACK    1
  39. #define PLOT(X,Y) {                                \
  40.     SetAPen(rp, PLD_RGBA(((amigaMesaContext) ctx->DriverCtx),            \
  41.                          ctx->VB->ColorPtr->data[pvert][0],        \
  42.                          ctx->VB->ColorPtr->data[pvert][1],        \
  43.                          ctx->VB->ColorPtr->data[pvert][2], X, Y));    \
  44.     WritePixel(rp, X, Y);                            \
  45.   }
  46.  
  47. #include "../../linetemp.h"
  48. }
  49.  
  50. /* Draw a flat-shaded, Z-less, RGB line into an osmesa buffer. */
  51. void natDFlatRGBAZLine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  52. {
  53.   struct RastPort *rp;
  54.  
  55.   rp = ((amigaMesaContext) ctx->DriverCtx)->rp;
  56.  
  57.   SetAPen(rp, PLD_RGBA(((amigaMesaContext) ctx->DriverCtx), ctx->VB->ColorPtr->data[pvert][0], ctx->VB->ColorPtr->data[pvert][1], ctx->VB->ColorPtr->data[pvert][2]));
  58.  
  59. #define INTERP_XY    1
  60. #define INTERP_Z    1
  61. #define CLIP_HACK    1
  62. #define PLOT(X,Y)                                \
  63.   if (Z < *zPtr) {                                \
  64.     SetAPen(rp, PLD_RGBA(((amigaMesaContext) ctx->DriverCtx),            \
  65.                          ctx->VB->ColorPtr->data[pvert][0],        \
  66.                          ctx->VB->ColorPtr->data[pvert][1],        \
  67.                          ctx->VB->ColorPtr->data[pvert][2], X, Y));    \
  68.     WritePixel(rp, X, Y);                            \
  69.     *zPtr = Z;                                    \
  70.   }
  71.  
  72. #include "../../linetemp.h"
  73. }
  74.  
  75. /* Draw a flat-shaded, alpha-blended, RGB line into an osmesa buffer. */
  76. void natDFlatBlendRGBALine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  77. {
  78.   amigaMesaContext amesa;
  79.   struct RastPort *rp;
  80.   GLuint *PtoI;
  81.   struct vertex_buffer *VB;
  82.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  83.  
  84.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  85.   rp = amesa->rp;
  86.   PtoI = amesa->PtoI;
  87.   VB = ctx->VB;
  88.   avalue = VB->ColorPtr->data[pvert][3];
  89.   msavalue = 255 - avalue;
  90.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  91.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  92.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  93.  
  94. #define INTERP_XY    1
  95. #define CLIP_HACK    1
  96. #define PLOT(X,Y) {                                \
  97.     GLubyte pel = ReadPixel(rp, X, Y);                        \
  98.     GLubyte *ptr3 = &PtoI[pel];                            \
  99.     SetAPen(rp, PLD_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),        \
  100.                 ((ptr3[1] * msavalue + gvalue) >> 8),        \
  101.                 ((ptr3[2] * msavalue + bvalue) >> 8), X, Y));    \
  102.     WritePixel(rp, X, Y);                            \
  103.   }
  104.  
  105. #include "../../linetemp.h"
  106. }
  107.  
  108. /* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. */
  109. void natDFlatBlendRGBAZLine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  110. {
  111.   amigaMesaContext amesa;
  112.   struct RastPort *rp;
  113.   GLuint *PtoI;
  114.   struct vertex_buffer *VB;
  115.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  116.  
  117.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  118.   rp = amesa->rp;
  119.   PtoI = amesa->PtoI;
  120.   VB = ctx->VB;
  121.   avalue = VB->ColorPtr->data[pvert][3];
  122.   msavalue = 255 - avalue;
  123.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  124.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  125.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  126.  
  127. #define INTERP_XY    1
  128. #define INTERP_Z    1
  129. #define CLIP_HACK    1
  130. #define PLOT(X,Y)                                \
  131.   if (Z < *zPtr) {                                \
  132.     GLubyte pel = ReadPixel(rp, X, Y);                        \
  133.     GLubyte *ptr3 = &PtoI[pel];                            \
  134.     SetAPen(rp, PLD_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),        \
  135.                 ((ptr3[1] * msavalue + gvalue) >> 8),        \
  136.                 ((ptr3[2] * msavalue + bvalue) >> 8), X, Y));    \
  137.     WritePixel(rp, X, Y);                            \
  138.   }
  139.  
  140. #include "../../linetemp.h"
  141. }
  142.  
  143. /* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. */
  144. void natDFlatBlendRGBAZLineWrite(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  145. {
  146.   amigaMesaContext amesa;
  147.   struct RastPort *rp;
  148.   GLuint *PtoI;
  149.   struct vertex_buffer *VB;
  150.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  151.  
  152.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  153.   rp = amesa->rp;
  154.   PtoI = amesa->PtoI;
  155.   VB = ctx->VB;
  156.   avalue = VB->ColorPtr->data[pvert][3];
  157.   msavalue = 255 - avalue;
  158.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  159.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  160.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  161.  
  162. #define INTERP_XY    1
  163. #define INTERP_Z    1
  164. #define CLIP_HACK    1
  165. #define PLOT(X,Y)                                \
  166.   if (Z < *zPtr) {                                \
  167.     GLubyte pel = ReadPixel(rp, X, Y);                        \
  168.     GLubyte *ptr3 = &PtoI[pel];                            \
  169.     SetAPen(rp, PLD_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),        \
  170.                 ((ptr3[1] * msavalue + gvalue) >> 8),        \
  171.                 ((ptr3[2] * msavalue + bvalue) >> 8), X, Y));    \
  172.     WritePixel(rp, X, Y);                            \
  173.     *zPtr = Z;                                    \
  174.   }
  175.  
  176. #include "../../linetemp.h"
  177. }
  178.