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