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 / natFastLinesDBG.E < prev    next >
Encoding:
Text File  |  1999-09-04  |  5.1 KB  |  167 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 natGFlatRGBALineDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  31. {
  32.   GLubyte *db;
  33.   GLubyte pixel;
  34.  
  35.   db = dbPenGet(((amigaMesaContext) ctx->DriverCtx));
  36.   pixel = 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)    *dbPen(db, X, Y) = pixel
  41.  
  42. #include "../../linetemp.h"
  43. }
  44.  
  45. /* Draw a flat-shaded, Z-less, RGB line into an osmesa buffer. */
  46. void natGFlatRGBAZLineDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  47. {
  48.   GLubyte *db;
  49.   GLubyte pixel;
  50.  
  51.   db = dbPenGet(((amigaMesaContext) ctx->DriverCtx));
  52.   pixel = 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.     *dbPen(db, X, Y) = pixel;    \
  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 natGFlatBlendRGBALineDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  68. {
  69.   amigaMesaContext amesa;
  70.   GLubyte *db;
  71.   GLuint *PtoI;
  72.   struct vertex_buffer *VB;
  73.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  74.  
  75.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  76.   db = dbPenGet(amesa);
  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 *ptr4 = dbPen(db, X, Y);                    \
  89.     GLubyte *ptr3 = &PtoI[*ptr4];                    \
  90.     *ptr4 = PLG_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),    \
  91.                 ((ptr3[1] * msavalue + gvalue) >> 8),    \
  92.                 ((ptr3[2] * msavalue + bvalue) >> 8));    \
  93.   }
  94.  
  95. #include "../../linetemp.h"
  96. }
  97.  
  98. /* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. */
  99. void natGFlatBlendRGBAZLineDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  100. {
  101.   amigaMesaContext amesa;
  102.   GLubyte *db;
  103.   GLuint *PtoI;
  104.   struct vertex_buffer *VB;
  105.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  106.  
  107.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  108.   db = dbPenGet(amesa);
  109.   PtoI = amesa->PtoI;
  110.   VB = ctx->VB;
  111.   avalue = VB->ColorPtr->data[pvert][3];
  112.   msavalue = 255 - avalue;
  113.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  114.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  115.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  116.  
  117. #define INTERP_XY    1
  118. #define INTERP_Z    1
  119. #define CLIP_HACK    1
  120. #define PLOT(X,Y)                            \
  121.   if (Z < *zPtr) {                            \
  122.     GLubyte *ptr4 = dbPen(db, X, Y);                     \
  123.     GLubyte *ptr3 = &PtoI[*ptr4];                    \
  124.     *ptr4 = PLG_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),    \
  125.                 ((ptr3[1] * msavalue + gvalue) >> 8),    \
  126.                 ((ptr3[2] * msavalue + bvalue) >> 8));    \
  127.   }
  128.  
  129. #include "../../linetemp.h"
  130. }
  131.  
  132. /* Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. */
  133. void natGFlatBlendRGBAZLineWriteDB(GLcontext * ctx, GLuint vert0, GLuint vert1, GLuint pvert)
  134. {
  135.   amigaMesaContext amesa;
  136.   GLubyte *db;
  137.   GLuint *PtoI;
  138.   struct vertex_buffer *VB;
  139.   GLint avalue, msavalue, rvalue, gvalue, bvalue;
  140.  
  141.   amesa = ((amigaMesaContext) ctx->DriverCtx);
  142.   db = dbPenGet(amesa);
  143.   PtoI = amesa->PtoI;
  144.   VB = ctx->VB;
  145.   avalue = VB->ColorPtr->data[pvert][3];
  146.   msavalue = 255 - avalue;
  147.   rvalue = VB->ColorPtr->data[pvert][0] * avalue;
  148.   gvalue = VB->ColorPtr->data[pvert][1] * avalue;
  149.   bvalue = VB->ColorPtr->data[pvert][2] * avalue;
  150.  
  151. #define INTERP_XY    1
  152. #define INTERP_Z    1
  153. #define CLIP_HACK    1
  154. #define PLOT(X,Y)                            \
  155.   if (Z < *zPtr) {                            \
  156.     GLubyte *ptr4 = dbPen(db, X, Y);                     \
  157.     GLubyte *ptr3 = &PtoI[*ptr4];                    \
  158.     *ptr4 = PLG_RGBA(amesa, ((ptr3[0] * msavalue + rvalue) >> 8),    \
  159.                 ((ptr3[1] * msavalue + gvalue) >> 8),    \
  160.                 ((ptr3[2] * msavalue + bvalue) >> 8));    \
  161.     *zPtr = Z;                                \
  162.   }
  163.  
  164. #include "../../linetemp.h"
  165. }
  166.  
  167.