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 / natFastLinesDBnG.E < prev    next >
Encoding:
Text File  |  1999-09-04  |  5.2 KB  |  169 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 natGFlatRGBALine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  31. {
  32.   struct RastPort *rp;
  33.  
  34.   rp = ((amigaMesaContext) ctx->DriverCtx)->rp;
  35.  
  36.   SetAPen(rp, PLG_RGBA(((amigaMesaContext) ctx->DriverCtx), ctx->VB->ColorPtr->data[pvert][0], ctx->VB->ColorPtr->data[pvert][1], ctx->VB->ColorPtr->data[pvert][2]));
  37.  
  38. #define INTERP_XY    1
  39. #define CLIP_HACK    1
  40. #define PLOT(X,Y)    WritePixel(rp, X, Y)
  41.  
  42. #include "../../linetemp.h"
  43. }
  44.  
  45. /* Draw a flat-shaded, Z-less, RGB line into an osmesa buffer. */
  46. void natGFlatRGBAZLine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  47. {
  48.   struct RastPort *rp;
  49.  
  50.   rp = ((amigaMesaContext) ctx->DriverCtx)->rp;
  51.  
  52.   SetAPen(rp, PLG_RGBA(((amigaMesaContext) ctx->DriverCtx), ctx->VB->ColorPtr->data[pvert][0], ctx->VB->ColorPtr->data[pvert][1], ctx->VB->ColorPtr->data[pvert][2]));
  53.  
  54. #define INTERP_XY    1
  55. #define INTERP_Z    1
  56. #define CLIP_HACK    1
  57. #define PLOT(X,Y)        \
  58.   if (Z < *zPtr) {        \
  59.     WritePixel(rp, X, Y);    \
  60.     *zPtr = Z;            \
  61.   }
  62.  
  63. #include "../../linetemp.h"
  64. }
  65.  
  66. /* Draw a flat-shaded, alpha-blended, RGB line into an osmesa buffer. */
  67. void natGFlatBlendRGBALine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  68. {
  69.   amigaMesaContext amesa;
  70.   struct RastPort *rp;
  71.   GLuint *PtoI;
  72.   struct vertex_buffer *VB;
  73.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  74.  
  75.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  76.   rp = amesa->rp;
  77.   PtoI = amesa->PtoI;
  78.   VB = ctx->VB;
  79.   avalue = VB->ColorPtr->data[pvert][3];
  80.   msavalue = 255 - avalue;
  81.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  82.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  83.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  84.  
  85. #define INTERP_XY    1
  86. #define CLIP_HACK    1
  87. #define PLOT(X,Y) {                            \
  88.     GLubyte pel = ReadPixel(rp, X, Y);                    \
  89.     GLubyte *ptr3 = &PtoI[pel];                        \
  90.     SetAPen(rp, PLG_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),    \
  91.                 ((ptr3[1] * msavalue + gvalue) >> 8),    \
  92.                 ((ptr3[2] * msavalue + bvalue) >> 8)));    \
  93.     WritePixel(rp, X, Y);                        \
  94.   }
  95.  
  96. #include "../../linetemp.h"
  97. }
  98.  
  99. /* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. */
  100. void natGFlatBlendRGBAZLine(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  101. {
  102.   amigaMesaContext amesa;
  103.   struct RastPort *rp;
  104.   GLuint *PtoI;
  105.   struct vertex_buffer *VB;
  106.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  107.  
  108.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  109.   rp = amesa->rp;
  110.   PtoI = amesa->PtoI;
  111.   VB = ctx->VB;
  112.   avalue = VB->ColorPtr->data[pvert][3];
  113.   msavalue = 255 - avalue;
  114.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  115.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  116.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  117.  
  118. #define INTERP_XY    1
  119. #define INTERP_Z    1
  120. #define CLIP_HACK    1
  121. #define PLOT(X,Y)                            \
  122.   if (Z < *zPtr) {                            \
  123.     GLubyte pel = ReadPixel(rp, X, Y);                    \
  124.     GLubyte *ptr3 = &PtoI[pel];                        \
  125.     SetAPen(rp, PLG_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),    \
  126.                 ((ptr3[1] * msavalue + gvalue) >> 8),    \
  127.                 ((ptr3[2] * msavalue + bvalue) >> 8)));    \
  128.     WritePixel(rp, X, Y);                        \
  129.   }
  130.  
  131. #include "../../linetemp.h"
  132. }
  133.  
  134. /* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. */
  135. void natGFlatBlendRGBAZLineWrite(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  136. {
  137.   amigaMesaContext amesa;
  138.   struct RastPort *rp;
  139.   GLuint *PtoI;
  140.   struct vertex_buffer *VB;
  141.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  142.  
  143.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  144.   rp = amesa->rp;
  145.   PtoI = amesa->PtoI;
  146.   VB = ctx->VB;
  147.   avalue = VB->ColorPtr->data[pvert][3];
  148.   msavalue = 255 - avalue;
  149.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  150.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  151.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  152.  
  153. #define INTERP_XY    1
  154. #define INTERP_Z    1
  155. #define CLIP_HACK    1
  156. #define PLOT(X,Y)                            \
  157.   if (Z < *zPtr) {                            \
  158.     GLubyte pel = ReadPixel(rp, X, Y);                    \
  159.     GLubyte *ptr3 = &PtoI[pel];                        \
  160.     SetAPen(rp, PLG_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),    \
  161.                 ((ptr3[1] * msavalue + gvalue) >> 8),    \
  162.                 ((ptr3[2] * msavalue + bvalue) >> 8)));    \
  163.     WritePixel(rp, X, Y);                        \
  164.     *zPtr = Z;                                \
  165.   }
  166.  
  167. #include "../../linetemp.h"
  168. }
  169.