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 / wrpDisplay / wrpSetup.c < prev    next >
Encoding:
Text File  |  1999-09-23  |  12.5 KB  |  463 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. void wrpSetupFlat(GLcontext * ctx, GLuint start, GLuint end)
  26. {
  27.   struct TDdriver *TDdriver;
  28.   W3D_Float *win;
  29.   W3D_Float swap;
  30.   W3D_Vertex *vptr;
  31.   GLint i;
  32.  
  33.   /* raster setup function
  34.    * flat shading, no texture mapping, no fogging, no ZBuffering
  35.    */
  36.  
  37.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  38.   win = (W3D_Float *) ctx->VB->Win.data[start];
  39.   swap = TDdriver->height;
  40.   vptr = &TDdriver->vbuffer[start];
  41.  
  42.   for (i = start; i < end; i++, vptr++) {
  43.     vptr->x = (W3D_Float) (       *win++);
  44.     vptr->y = (W3D_Float) (swap - *win++);
  45.     win++;
  46.   }
  47. }
  48.  
  49. void wrpSetupFlatZ(GLcontext * ctx, GLuint start, GLuint end)
  50. {
  51.   struct TDdriver *TDdriver;
  52.   W3D_Vertex *vptr;
  53.   W3D_Float *win;
  54.   W3D_Float swap;
  55.   const W3D_Float invdepth = 1.0 / DEPTH_SCALE;
  56.   GLint i;
  57.  
  58.   /* raster setup function
  59.    * flat shading, no texture mapping, no fogging, ZBuffering
  60.    */
  61.  
  62.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  63.   win = (W3D_Float *) ctx->VB->Win.data[start];
  64.   swap = TDdriver->height;
  65.   vptr = &TDdriver->vbuffer[start];
  66.  
  67.   for (i = start; i < end; i++, vptr++) {
  68.     vptr->x = (W3D_Float) (           *win++);
  69.     vptr->y = (W3D_Float) (swap     - *win++);
  70.     vptr->z = (W3D_Float) (invdepth * *win++);
  71.   }
  72. }
  73.  
  74. void wrpSetupGouraud(GLcontext * ctx, GLuint start, GLuint end)
  75. {
  76.   struct TDdriver *TDdriver;
  77.   W3D_Vertex *vptr;
  78.   W3D_Float *win;
  79.   W3D_Float swap;
  80.   GLubyte *col;
  81.   GLint i;
  82.  
  83.   /* raster setup function
  84.    * gouraud shading, no texture mapping, no fogging, no ZBuffering
  85.    */
  86.  
  87.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  88.   win = (W3D_Float *) ctx->VB->Win.data[start];
  89.   swap = TDdriver->height;
  90.   vptr = &TDdriver->vbuffer[start];
  91.   col = ctx->VB->ColorPtr->data[start];
  92.  
  93.   for (i = start; i < end; i++, vptr++) {
  94.     vptr->x = (W3D_Float) (       *win++);
  95.     vptr->y = (W3D_Float) (swap - *win++);
  96.     TC_Color(vptr->color, *col++, *col++, *col++, *col++);
  97.     win++;
  98.   }
  99. }
  100.  
  101. void wrpSetupGouraudZ(GLcontext * ctx, GLuint start, GLuint end)
  102. {
  103.   struct TDdriver *TDdriver;
  104.   W3D_Vertex *vptr;
  105.   W3D_Float *win;
  106.   W3D_Float swap;
  107.   const W3D_Float invdepth = 1.0 / DEPTH_SCALE;
  108.   GLubyte *col;
  109.   GLint i;
  110.  
  111.   /* raster setup function
  112.    * gouraud shading, no texture mapping, no fogging, ZBuffering
  113.    */
  114.  
  115.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  116.   win = (W3D_Float *) ctx->VB->Win.data[start];
  117.   swap = TDdriver->height;
  118.   vptr = &TDdriver->vbuffer[start];
  119.   col = ctx->VB->ColorPtr->data[start];
  120.  
  121.   for (i = start; i < end; i++, vptr++) {
  122.     vptr->x = (W3D_Float) (           *win++);
  123.     vptr->y = (W3D_Float) (swap     - *win++);
  124.     vptr->z = (W3D_Float) (invdepth * *win++);
  125.     TC_Color(vptr->color, *col++, *col++, *col++, *col++);
  126.   }
  127. }
  128.  
  129. void wrpSetupFlatFog(GLcontext * ctx, GLuint start, GLuint end)
  130. {
  131.   struct TDdriver *TDdriver;
  132.   W3D_Vertex *vptr;
  133.   W3D_Float *win;
  134.   W3D_Float swap;
  135.   W3D_Float *clip;
  136.   W3D_Float wscale;
  137.   GLint i;
  138.  
  139.   /* raster setup function
  140.    * flat shading, no texture mapping, fogging, no ZBuffering
  141.    */
  142.  
  143.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  144.   win = (W3D_Float *) ctx->VB->Win.data[start];
  145.   swap = TDdriver->height;
  146.   vptr = &TDdriver->vbuffer[start];
  147.   clip = ctx->VB->ClipPtr->data[start];
  148.   wscale = TDdriver->wscale;
  149.  
  150.   for (i = start; i < end; i++, vptr++, clip += 4) {
  151.     vptr->x = (W3D_Float) (       *win++);
  152.     vptr->y = (W3D_Float) (swap - *win++);
  153.     vptr->w = (W3D_Float) (wscale / clip[3]);
  154.     win++;
  155.   }
  156. }
  157.  
  158. void wrpSetupFlatFogZ(GLcontext * ctx, GLuint start, GLuint end)
  159. {
  160.   struct TDdriver *TDdriver;
  161.   W3D_Vertex *vptr;
  162.   W3D_Float *win;
  163.   W3D_Float swap;
  164.   const W3D_Float invdepth = 1.0 / DEPTH_SCALE;
  165.   W3D_Float *clip;
  166.   W3D_Float wscale;
  167.   GLint i;
  168.  
  169.   /* raster setup function
  170.    * flat shading, no texture mapping, fogging, ZBuffering
  171.    */
  172.  
  173.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  174.   win = (W3D_Float *) ctx->VB->Win.data[start];
  175.   swap = TDdriver->height;
  176.   vptr = &TDdriver->vbuffer[start];
  177.   clip = ctx->VB->ClipPtr->data[start];
  178.   wscale = TDdriver->wscale;
  179.  
  180.   for (i = start; i < end; i++, vptr++, clip += 4) {
  181.     vptr->x = (W3D_Float) (           *win++);
  182.     vptr->y = (W3D_Float) (swap     - *win++);
  183.     vptr->z = (W3D_Float) (invdepth * *win++);
  184.     vptr->w = (W3D_Float) (wscale / clip[3]);
  185.   }
  186. }
  187.  
  188. void wrpSetupGouraudFog(GLcontext * ctx, GLuint start, GLuint end)
  189. {
  190.   struct TDdriver *TDdriver;
  191.   W3D_Vertex *vptr;
  192.   W3D_Float *win;
  193.   W3D_Float swap;
  194.   W3D_Float *clip;
  195.   W3D_Float wscale;
  196.   GLubyte *col;
  197.   GLint i;
  198.  
  199.   /* raster setup function
  200.    * gouraud shading, no texture mapping, fogging, no ZBuffering
  201.    */
  202.  
  203.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  204.   win = (W3D_Float *) ctx->VB->Win.data[start];
  205.   swap = TDdriver->height;
  206.   vptr = &TDdriver->vbuffer[start];
  207.   clip = ctx->VB->ClipPtr->data[start];
  208.   wscale = TDdriver->wscale;
  209.   col = ctx->VB->ColorPtr->data[start];
  210.  
  211.   for (i = start; i < end; i++, vptr++, clip += 4) {
  212.     vptr->x = (W3D_Float) *win++;
  213.     vptr->y = (W3D_Float) (swap - *win++);
  214.     vptr->w = (W3D_Float) (wscale / clip[3]);
  215.     TC_Color(vptr->color, *col++, *col++, *col++, *col++);
  216.     win++;
  217.   }
  218. }
  219.  
  220. void wrpSetupGouraudFogZ(GLcontext * ctx, GLuint start, GLuint end)
  221. {
  222.   struct TDdriver *TDdriver;
  223.   W3D_Vertex *vptr;
  224.   W3D_Float *win;
  225.   W3D_Float swap;
  226.   const W3D_Float invdepth = 1.0 / DEPTH_SCALE;
  227.   W3D_Float *clip;
  228.   W3D_Float wscale;
  229.   GLubyte *col;
  230.   GLint i;
  231.  
  232.   /* raster setup function
  233.    * gouraud shading, no texture mapping, fogging, ZBuffering
  234.    */
  235.  
  236.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  237.   win = (W3D_Float *) ctx->VB->Win.data[start];
  238.   swap = TDdriver->height;
  239.   vptr = &TDdriver->vbuffer[start];
  240.   clip = ctx->VB->ClipPtr->data[start];
  241.   wscale = TDdriver->wscale;
  242.   col = ctx->VB->ColorPtr->data[start];
  243.  
  244.   for (i = start; i < end; i++, vptr++, clip += 4) {
  245.     vptr->x = (W3D_Float) *win++;
  246.     vptr->y = (W3D_Float) (swap - *win++);
  247.     vptr->z = (W3D_Float) (*win++ * invdepth);
  248.     vptr->w = (W3D_Float) (wscale / clip[3]);
  249.     TC_Color(vptr->color, *col++, *col++, *col++, *col++);
  250.   }
  251. }
  252.  
  253. void wrpSetupFlatTex(GLcontext * ctx, GLuint start, GLuint end)
  254. {
  255.   struct TDdriver *TDdriver;
  256.   W3D_Vertex *vptr;
  257.   W3D_Float *win;
  258.   W3D_Float swap;
  259.   W3D_Float *texcoord;
  260.   W3D_Float *clip;
  261.   W3D_Float wscale;
  262.   const W3D_Float one = 1.0;
  263.   W3D_Float texwidth;
  264.   W3D_Float texheight;
  265.   GLint i;
  266.  
  267.   /* raster setup function
  268.    * flat shading, texture mapping, no ZBuffering
  269.    */
  270.  
  271.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  272.   win = (W3D_Float *) ctx->VB->Win.data[start];
  273.   swap = TDdriver->height;
  274.   vptr = &TDdriver->vbuffer[start];
  275.   clip = ctx->VB->ClipPtr->data[start];
  276.   wscale = TDdriver->wscale;
  277.   texwidth = TDdriver->texwidth;
  278.   texheight = TDdriver->texheight;
  279.   texcoord = ctx->VB->TexCoordPtr[0]->data[start];
  280.  
  281.   for (i = start; i < end; i++, vptr++, texcoord += 4, clip += 4) {
  282.     W3D_Float tc3, invq;
  283.  
  284.     vptr->x = (W3D_Float) *win++;
  285.     vptr->y = (W3D_Float) (swap - *win++);
  286.     tc3 = texcoord[3];
  287.  
  288.     if (tc3 == one) {
  289.       vptr->u = (W3D_Float) (texwidth * texcoord[0]);
  290.       vptr->v = (W3D_Float) (texheight * texcoord[1]);
  291.       vptr->w = (W3D_Float) (wscale / clip[3]);
  292.     }
  293.     else {
  294.       invq = one / tc3;
  295.       vptr->u = (W3D_Float) (texwidth * texcoord[0] * invq);
  296.       vptr->v = (W3D_Float) (texheight * texcoord[1] * invq);
  297.       vptr->w = (W3D_Float) (tc3 * wscale / clip[3]);
  298.     }
  299.  
  300.     win++;
  301.   }
  302. }
  303.  
  304. void wrpSetupFlatTexZ(GLcontext * ctx, GLuint start, GLuint end)
  305. {
  306.   struct TDdriver *TDdriver;
  307.   W3D_Vertex *vptr;
  308.   W3D_Float *win;
  309.   W3D_Float swap;
  310.   const W3D_Float invdepth = 1.0 / DEPTH_SCALE;
  311.   W3D_Float *texcoord;
  312.   W3D_Float *clip;
  313.   W3D_Float wscale;
  314.   const W3D_Float one = 1.0;
  315.   W3D_Float texwidth;
  316.   W3D_Float texheight;
  317.   GLint i;
  318.  
  319.   /* raster setup function
  320.    * flat shading, texture mapping, ZBuffering
  321.    */
  322.  
  323.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  324.   win = (W3D_Float *) ctx->VB->Win.data[start];
  325.   swap = TDdriver->height;
  326.   vptr = &TDdriver->vbuffer[start];
  327.   clip = ctx->VB->ClipPtr->data[start];
  328.   wscale = TDdriver->wscale;
  329.   texwidth = TDdriver->texwidth;
  330.   texheight = TDdriver->texheight;
  331.   texcoord = ctx->VB->TexCoordPtr[0]->data[start];
  332.  
  333.   for (i = start; i < end; i++, vptr++, texcoord += 4, clip += 4) {
  334.     W3D_Float tc3, invq;
  335.  
  336.     vptr->x = (W3D_Float) *win++;
  337.     vptr->y = (W3D_Float) (swap - *win++);
  338.     vptr->z = (W3D_Float) (*win++ * invdepth);
  339.     tc3 = texcoord[3];
  340.  
  341.     if (tc3 == one) {
  342.       vptr->u = (W3D_Float) (texwidth * texcoord[0]);
  343.       vptr->v = (W3D_Float) (texheight * texcoord[1]);
  344.       vptr->w = (W3D_Float) (wscale / clip[3]);
  345.     }
  346.     else {
  347.       invq = one / tc3;
  348.       vptr->u = (W3D_Float) (texwidth * texcoord[0] * invq);
  349.       vptr->v = (W3D_Float) (texheight * texcoord[1] * invq);
  350.       vptr->w = (W3D_Float) (tc3 * wscale / clip[3]);
  351.     }
  352.   }
  353. }
  354.  
  355. void wrpSetupGouraudTex(GLcontext * ctx, GLuint start, GLuint end)
  356. {
  357.   struct TDdriver *TDdriver;
  358.   W3D_Vertex *vptr;
  359.   W3D_Float *win;
  360.   W3D_Float swap;
  361.   W3D_Float *texcoord;
  362.   W3D_Float *clip;
  363.   W3D_Float wscale;
  364.   const W3D_Float one = 1.0;
  365.   W3D_Float texwidth;
  366.   W3D_Float texheight;
  367.   GLubyte *col;
  368.   GLint i;
  369.  
  370.   /* raster setup function
  371.    * gouraud shading, texture mapping, no ZBuffering
  372.    */
  373.  
  374.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  375.   win = (W3D_Float *) ctx->VB->Win.data[start];
  376.   swap = TDdriver->height;
  377.   vptr = &TDdriver->vbuffer[start];
  378.   clip = ctx->VB->ClipPtr->data[start];
  379.   wscale = TDdriver->wscale;
  380.   texwidth = TDdriver->texwidth;
  381.   texheight = TDdriver->texheight;
  382.   texcoord = ctx->VB->TexCoordPtr[0]->data[start];
  383.   col = ctx->VB->ColorPtr->data[start];
  384.  
  385.   for (i = start; i < end; i++, vptr++, texcoord += 4, clip += 4) {
  386.     W3D_Float tc3, invq;
  387.  
  388.     vptr->x = (W3D_Float) *win++;
  389.     vptr->y = (W3D_Float) (swap - *win++);
  390.     tc3 = texcoord[3];
  391.  
  392.     if (tc3 == one) {
  393.       vptr->u = (W3D_Float) (texwidth * texcoord[0]);
  394.       vptr->v = (W3D_Float) (texheight * texcoord[1]);
  395.       vptr->w = (W3D_Float) (wscale / clip[3]);
  396.     }
  397.     else {
  398.       invq = one / tc3;
  399.       vptr->u = (W3D_Float) (texwidth * texcoord[0] * invq);
  400.       vptr->v = (W3D_Float) (texheight * texcoord[1] * invq);
  401.       vptr->w = (W3D_Float) (tc3 * wscale / clip[3]);
  402.     }
  403.  
  404.     TC_Color(vptr->color, *col++, *col++, *col++, *col++);
  405.     win++;
  406.   }
  407. }
  408.  
  409. void wrpSetupGouraudTexZ(GLcontext * ctx, GLuint start, GLuint end)
  410. {
  411.   struct TDdriver *TDdriver;
  412.   W3D_Vertex *vptr;
  413.   W3D_Float *win;
  414.   W3D_Float swap;
  415.   const W3D_Float invdepth = 1.0 / DEPTH_SCALE;
  416.   W3D_Float *texcoord;
  417.   W3D_Float *clip;
  418.   W3D_Float wscale;
  419.   const W3D_Float one = 1.0;
  420.   W3D_Float texwidth;
  421.   W3D_Float texheight;
  422.   GLubyte *col;
  423.   GLint i;
  424.  
  425.   /* raster setup function
  426.    * gouraud shading, texture mapping, ZBuffering
  427.    */
  428.  
  429.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  430.   win = (W3D_Float *) ctx->VB->Win.data[start];
  431.   swap = TDdriver->height;
  432.   vptr = &TDdriver->vbuffer[start];
  433.   clip = ctx->VB->ClipPtr->data[start];
  434.   wscale = TDdriver->wscale;
  435.   texwidth = TDdriver->texwidth;
  436.   texheight = TDdriver->texheight;
  437.   texcoord = ctx->VB->TexCoordPtr[0]->data[start];
  438.   col = ctx->VB->ColorPtr->data[start];
  439.  
  440.   for (i = start; i < end; i++, vptr++, texcoord += 4, clip += 4) {
  441.     W3D_Float tc3, invq;
  442.  
  443.     vptr->x = (W3D_Float) *win++;
  444.     vptr->y = (W3D_Float) (swap - *win++);
  445.     vptr->z = (W3D_Float) (*win++ * invdepth);
  446.     tc3 = texcoord[3];
  447.  
  448.     if (tc3 == one) {
  449.       vptr->u = (W3D_Float) (texwidth * texcoord[0]);
  450.       vptr->v = (W3D_Float) (texheight * texcoord[1]);
  451.       vptr->w = (W3D_Float) (wscale / clip[3]);
  452.     }
  453.     else {
  454.       invq = one / tc3;
  455.       vptr->u = (W3D_Float) (texwidth * texcoord[0] * invq);
  456.       vptr->v = (W3D_Float) (texheight * texcoord[1] * invq);
  457.       vptr->w = (W3D_Float) (tc3 * wscale / clip[3]);
  458.     }
  459.  
  460.     TC_Color(vptr->color, *col++, *col++, *col++, *col++);
  461.   }
  462. }
  463.