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 / wrpFastTriangles.c < prev    next >
Encoding:
Text File  |  1999-09-24  |  20.2 KB  |  647 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. /*****            Accelerated point, line, polygon rendering      *****/
  27. /**********************************************************************/
  28.  
  29. void wrpDrawTriangleFlat(GLcontext * ctx, GLuint v1, GLuint v2,
  30.               GLuint v3, GLuint pv)
  31. {
  32.   struct TDdriver *TDdriver;
  33.   struct vertex_buffer *VB;
  34.   W3D_Context *TDcontext;
  35.   W3D_Triangle tri;
  36.   W3D_Color TDcol;
  37.  
  38.   DEBUGOUT(1, "wrpDrawTriangleFlat()\n");
  39.  
  40.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  41.   TDcontext = TDdriver->td_ctx;
  42.   VB = ctx->VB;
  43.  
  44.   LockHardware(TDdriver, TDcontext);
  45.  
  46.   TC_Color(TDcol, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2], VB->ColorPtr->data[pv][3]);
  47.   W3D_SetCurrentColor(TDcontext, &TDcol);
  48.  
  49.   if (((v2 - 1 == v1) && (v3 - 2 == v1)) || ((v2 - 1 == v3) && (v1 - 2 == v3))) {
  50.     /* optimization, very ugly style */
  51.     W3D_Triangle *triptr = (W3D_Triangle *) (&TDdriver->vbuffer[v2 - 1]);
  52.     W3D_Texture *texsave = triptr->tex;
  53.     unsigned char *patternsave = triptr->st_pattern;
  54.  
  55.     triptr->tex = TDdriver->TDtex;
  56.  
  57.     if (!ctx->Polygon.StippleFlag)
  58.       triptr->st_pattern = (unsigned char *)ctx->PolygonStipple;
  59.     else
  60.       triptr->st_pattern = NULL;
  61.  
  62.     if (W3D_DrawTriangle(TDcontext, triptr) != W3D_SUCCESS)
  63.       ClrF(TDdriver->flags, TD_ACTIVE);
  64.     SetF(TDdriver->flags, TD_DIRTY);
  65.  
  66.     triptr->tex = texsave;
  67.     triptr->st_pattern = patternsave;
  68.   }
  69.   else {
  70.     tri.tex = TDdriver->TDtex;
  71.  
  72.     if (!ctx->Polygon.StippleFlag)
  73.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  74.     else
  75.       tri.st_pattern = NULL;
  76.  
  77.     TDdriver->CopyVertex(&tri.v1, &TDdriver->vbuffer[v1]);
  78.     TDdriver->CopyVertex(&tri.v2, &TDdriver->vbuffer[v2]);
  79.     TDdriver->CopyVertex(&tri.v3, &TDdriver->vbuffer[v3]);
  80.  
  81.     if (W3D_DrawTriangle(TDcontext, &tri) != W3D_SUCCESS)
  82.       ClrF(TDdriver->flags, TD_ACTIVE);
  83.     SetF(TDdriver->flags, TD_DIRTY);
  84.   }
  85. }
  86.  
  87. void wrpDrawTriangleSmooth(GLcontext * ctx, GLuint v1, GLuint v2,
  88.                GLuint v3, GLuint pv)
  89. {
  90.   struct TDdriver *TDdriver;
  91.   W3D_Context *TDcontext;
  92.   W3D_Triangle tri;
  93.  
  94.   DEBUGOUT(1, "wrpDrawTriangleFlat()\n");
  95.  
  96.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  97.   TDcontext = TDdriver->td_ctx;
  98.  
  99.   LockHardware(TDdriver, TDcontext);
  100.  
  101.   if (((v2 - 1 == v1) && (v3 - 2 == v1)) || ((v2 - 1 == v3) && (v1 - 2 == v3))) {
  102.     /* optimization, very ugly style */
  103.     W3D_Triangle *triptr = (W3D_Triangle *) (&TDdriver->vbuffer[v2 - 1]);
  104.     W3D_Texture *texsave = triptr->tex;
  105.     unsigned char *patternsave = triptr->st_pattern;
  106.  
  107.     triptr->tex = TDdriver->TDtex;
  108.  
  109.     if (!ctx->Polygon.StippleFlag)
  110.       triptr->st_pattern = (unsigned char *)ctx->PolygonStipple;
  111.     else
  112.       triptr->st_pattern = NULL;
  113.  
  114.     if (W3D_DrawTriangle(TDcontext, triptr) != W3D_SUCCESS)
  115.       ClrF(TDdriver->flags, TD_ACTIVE);
  116.     SetF(TDdriver->flags, TD_DIRTY);
  117.  
  118.     triptr->tex = texsave;
  119.     triptr->st_pattern = patternsave;
  120.   }
  121.   else {
  122.     tri.tex = TDdriver->TDtex;
  123.  
  124.     if (!ctx->Polygon.StippleFlag)
  125.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  126.     else
  127.       tri.st_pattern = NULL;
  128.  
  129.     TDdriver->CopyVertex(&tri.v1, &TDdriver->vbuffer[v1]);
  130.     TDdriver->CopyVertex(&tri.v2, &TDdriver->vbuffer[v2]);
  131.     TDdriver->CopyVertex(&tri.v3, &TDdriver->vbuffer[v3]);
  132.  
  133.     if (W3D_DrawTriangle(TDcontext, &tri) != W3D_SUCCESS)
  134.       ClrF(TDdriver->flags, TD_ACTIVE);
  135.     SetF(TDdriver->flags, TD_DIRTY);
  136.   }
  137. }
  138.  
  139. void wrpDrawTriangleSmoothTwo(GLcontext * ctx, GLuint v1, GLuint v2,
  140.                   GLuint v3, GLuint pv)
  141. {
  142.   struct TDdriver *TDdriver;
  143.   struct vertex_buffer *VB = ctx->VB;
  144.   W3D_Context *TDcontext;
  145.   W3D_Triangle tri;
  146.  
  147.   DEBUGOUT(1, "wrpDrawTriangleFlat()\n");
  148.  
  149.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  150.   TDcontext = TDdriver->td_ctx;
  151.  
  152.   LockHardware(TDdriver, TDcontext);
  153.  
  154.   if (((v2 - 1 == v1) && (v3 - 2 == v1)) || ((v2 - 1 == v3) && (v1 - 2 == v3))) {
  155.     /* optimization, very ugly style */
  156.     W3D_Triangle *triptr = (W3D_Triangle *) (&TDdriver->vbuffer[v2 - 1]);
  157.     W3D_Texture *texsave = triptr->tex;
  158.     unsigned char *patternsave = triptr->st_pattern;
  159.  
  160.     triptr->tex = TDdriver->TDtex;
  161.  
  162.     if (!ctx->Polygon.StippleFlag)
  163.       triptr->st_pattern = (unsigned char *)ctx->PolygonStipple;
  164.     else
  165.       triptr->st_pattern = NULL;
  166.  
  167.     TC_Color(TDdriver->vbuffer[v1].color, VB->ColorPtr->data[v1][0], VB->ColorPtr->data[v1][1], VB->ColorPtr->data[v1][2], VB->ColorPtr->data[v1][3]);
  168.     TC_Color(TDdriver->vbuffer[v2].color, VB->ColorPtr->data[v2][0], VB->ColorPtr->data[v2][1], VB->ColorPtr->data[v2][2], VB->ColorPtr->data[v2][3]);
  169.     TC_Color(TDdriver->vbuffer[v3].color, VB->ColorPtr->data[v3][0], VB->ColorPtr->data[v3][1], VB->ColorPtr->data[v3][2], VB->ColorPtr->data[v3][3]);
  170.  
  171.     if (W3D_DrawTriangle(TDcontext, triptr) != W3D_SUCCESS)
  172.       ClrF(TDdriver->flags, TD_ACTIVE);
  173.     SetF(TDdriver->flags, TD_DIRTY);
  174.  
  175.     triptr->tex = texsave;
  176.     triptr->st_pattern = patternsave;
  177.   }
  178.   else {
  179.     tri.tex = TDdriver->TDtex;
  180.  
  181.     if (!ctx->Polygon.StippleFlag)
  182.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  183.     else
  184.       tri.st_pattern = NULL;
  185.  
  186.     TDdriver->CopyVertex(&tri.v1, &TDdriver->vbuffer[v1]);
  187.     TDdriver->CopyVertex(&tri.v2, &TDdriver->vbuffer[v2]);
  188.     TDdriver->CopyVertex(&tri.v3, &TDdriver->vbuffer[v3]);
  189.  
  190.     TC_Color(tri.v1.color, VB->ColorPtr->data[v1][0], VB->ColorPtr->data[v1][1], VB->ColorPtr->data[v1][2], VB->ColorPtr->data[v1][3]);
  191.     TC_Color(tri.v2.color, VB->ColorPtr->data[v2][0], VB->ColorPtr->data[v2][1], VB->ColorPtr->data[v2][2], VB->ColorPtr->data[v2][3]);
  192.     TC_Color(tri.v3.color, VB->ColorPtr->data[v3][0], VB->ColorPtr->data[v3][1], VB->ColorPtr->data[v3][2], VB->ColorPtr->data[v3][3]);
  193.  
  194.     if (W3D_DrawTriangle(TDcontext, &tri) != W3D_SUCCESS)
  195.       ClrF(TDdriver->flags, TD_ACTIVE);
  196.     SetF(TDdriver->flags, TD_DIRTY);
  197.   }
  198. }
  199.  
  200. triangle_func wrpChooseTriangleFunction(GLcontext * ctx)
  201. {
  202.   struct TDdriver *TDdriver;
  203.   W3D_Context *TDcontext;
  204.  
  205.   DEBUGOUT(1, "wrpChooseTriangle()\n");
  206.  
  207.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  208.   TDcontext = TDdriver->td_ctx;
  209.  
  210.   if (W3D_Query(TDcontext, W3D_Q_DRAW_TRIANGLE, NULL) != W3D_FULLY_SUPPORTED)
  211.     return NULL;
  212.  
  213. #if 0
  214.   if ((ctx->Polygon.OffsetAny) || (ctx->RasterMask & FRONT_AND_BACK_BIT))
  215.     return NULL;
  216. #endif
  217.  
  218.   if (ctx->Polygon.SmoothFlag)
  219.     if (W3D_Query(TDcontext,W3D_Q_ANTI_POLYGON,NULL) != W3D_FULLY_SUPPORTED)
  220.       return NULL;
  221.  
  222.   if (ctx->Polygon.StippleFlag)
  223.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POLY_ST, NULL) != W3D_FULLY_SUPPORTED)
  224.       return NULL;
  225.  
  226.   if (ctx->Light.ShadeModel == GL_SMOOTH) {
  227.     if (ctx->Light.Model.TwoSide)
  228.       return wrpDrawTriangleSmoothTwo;
  229.  
  230.     return wrpDrawTriangleSmooth;
  231.   }
  232.  
  233.   return wrpDrawTriangleFlat;
  234. }
  235.  
  236. /**********************************************************************/
  237. /*****            Accelerated point, line, polygon rendering      *****/
  238. /**********************************************************************/
  239.  
  240. void wrpDrawQuadFlat(GLcontext * ctx, GLuint v1, GLuint v2,
  241.               GLuint v3, GLuint v4, GLuint pv)
  242. {
  243.   struct TDdriver *TDdriver;
  244.   struct vertex_buffer *VB = ctx->VB;
  245.   W3D_Context *TDcontext;
  246.   W3D_Triangles tri;
  247.   W3D_Vertex w3dv[4];
  248.   W3D_Color TDcol;
  249.  
  250.   DEBUGOUT(1, "wrpDrawQuadFlat()\n");
  251.  
  252.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  253.   TDcontext = TDdriver->td_ctx;
  254.  
  255.   LockHardware(TDdriver, TDcontext);
  256.  
  257.   TC_Color(TDcol, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2], VB->ColorPtr->data[pv][3]);
  258.   W3D_SetCurrentColor(TDcontext, &TDcol);
  259.  
  260.   if ((v2 - 1 == v1) && (v3 - 3 == v1) && (v4 - 2 == v1)) {
  261.     tri.vertexcount = 4;
  262.     tri.v = (&TDdriver->vbuffer[v1]);
  263.     tri.tex = TDdriver->TDtex;
  264.  
  265.     if (!ctx->Polygon.StippleFlag)
  266.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  267.     else
  268.       tri.st_pattern = NULL;
  269.  
  270.     if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  271.       ClrF(TDdriver->flags, TD_ACTIVE);
  272.     SetF(TDdriver->flags, TD_DIRTY);
  273.   }
  274.   else if ((v2 - 1 == v1) && (v3 - 2 == v1) && (v4 - 3 == v1)) {
  275.     tri.vertexcount = 4;
  276.     tri.v = (&TDdriver->vbuffer[v1]);
  277.     tri.tex = TDdriver->TDtex;
  278.  
  279.     if (!ctx->Polygon.StippleFlag)
  280.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  281.     else
  282.       tri.st_pattern = NULL;
  283.  
  284.     if (W3D_DrawTriFan(TDcontext, &tri) != W3D_SUCCESS)
  285.       ClrF(TDdriver->flags, TD_ACTIVE);
  286.     SetF(TDdriver->flags, TD_DIRTY);
  287.   }
  288.   else {
  289.     tri.vertexcount = 4;
  290.     tri.v = w3dv;
  291.     tri.tex = TDdriver->TDtex;
  292.  
  293.     if (!ctx->Polygon.StippleFlag)
  294.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  295.     else
  296.       tri.st_pattern = NULL;
  297.  
  298.     TDdriver->CopyVertex(&w3dv[0], &TDdriver->vbuffer[v1]);
  299.     TDdriver->CopyVertex(&w3dv[1], &TDdriver->vbuffer[v2]);
  300.     TDdriver->CopyVertex(&w3dv[2], &TDdriver->vbuffer[v4]);
  301.     TDdriver->CopyVertex(&w3dv[3], &TDdriver->vbuffer[v3]);
  302.  
  303.     if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  304.       ClrF(TDdriver->flags, TD_ACTIVE);
  305.     SetF(TDdriver->flags, TD_DIRTY);
  306.   }
  307. }
  308.  
  309. void wrpDrawQuadSmooth(GLcontext * ctx, GLuint v1, GLuint v2,
  310.             GLuint v3, GLuint v4, GLuint pv)
  311. {
  312.   struct TDdriver *TDdriver;
  313.   W3D_Context *TDcontext;
  314.   W3D_Triangles tri;
  315.   W3D_Vertex w3dv[4];
  316.  
  317.   DEBUGOUT(1, "wrpDrawQuadSmooth()\n");
  318.  
  319.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  320.   TDcontext = TDdriver->td_ctx;
  321.  
  322.   LockHardware(TDdriver, TDcontext);
  323.  
  324.   if ((v2 - 1 == v1) && (v3 - 3 == v1) && (v4 - 2 == v1)) {
  325.     tri.vertexcount = 4;
  326.     tri.v = (&TDdriver->vbuffer[v1]);
  327.     tri.tex = TDdriver->TDtex;
  328.  
  329.     if (!ctx->Polygon.StippleFlag)
  330.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  331.     else
  332.       tri.st_pattern = NULL;
  333.  
  334.     if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  335.       ClrF(TDdriver->flags, TD_ACTIVE);
  336.     SetF(TDdriver->flags, TD_DIRTY);
  337.   }
  338.   else if ((v2 - 1 == v1) && (v3 - 2 == v1) && (v4 - 3 == v1)) {
  339.     tri.vertexcount = 4;
  340.     tri.v = (&TDdriver->vbuffer[v1]);
  341.     tri.tex = TDdriver->TDtex;
  342.  
  343.     if (!ctx->Polygon.StippleFlag)
  344.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  345.     else
  346.       tri.st_pattern = NULL;
  347.  
  348.     if (W3D_DrawTriFan(TDcontext, &tri) != W3D_SUCCESS)
  349.       ClrF(TDdriver->flags, TD_ACTIVE);
  350.     SetF(TDdriver->flags, TD_DIRTY);
  351.   }
  352.   else {
  353.     tri.vertexcount = 4;
  354.     tri.v = w3dv;
  355.     tri.tex = TDdriver->TDtex;
  356.  
  357.     if (!ctx->Polygon.StippleFlag)
  358.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  359.     else
  360.       tri.st_pattern = NULL;
  361.  
  362.     TDdriver->CopyVertex(&w3dv[0], &TDdriver->vbuffer[v1]);
  363.     TDdriver->CopyVertex(&w3dv[1], &TDdriver->vbuffer[v2]);
  364.     TDdriver->CopyVertex(&w3dv[2], &TDdriver->vbuffer[v4]);
  365.     TDdriver->CopyVertex(&w3dv[3], &TDdriver->vbuffer[v3]);
  366.  
  367.     if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  368.       ClrF(TDdriver->flags, TD_ACTIVE);
  369.     SetF(TDdriver->flags, TD_DIRTY);
  370.   }
  371. }
  372.  
  373. void wrpDrawQuadSmoothTwo(GLcontext * ctx, GLuint v1, GLuint v2,
  374.                GLuint v3, GLuint v4, GLuint pv)
  375. {
  376.   struct TDdriver *TDdriver;
  377.   struct vertex_buffer *VB = ctx->VB;
  378.   W3D_Context *TDcontext;
  379.   W3D_Triangles tri;
  380.   W3D_Vertex w3dv[4];
  381.  
  382.   DEBUGOUT(1, "wrpDrawQuadSmoothTwo()\n");
  383.  
  384.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  385.   TDcontext = TDdriver->td_ctx;
  386.  
  387.   LockHardware(TDdriver, TDcontext);
  388.  
  389.   if ((v2 - 1 == v1) && (v3 - 3 == v1) && (v4 - 2 == v1)) {
  390.     tri.vertexcount = 4;
  391.     tri.v = (&TDdriver->vbuffer[v1]);
  392.     tri.tex = TDdriver->TDtex;
  393.  
  394.     if (!ctx->Polygon.StippleFlag)
  395.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  396.     else
  397.       tri.st_pattern = NULL;
  398.  
  399.     TC_Color(TDdriver->vbuffer[v1].color, VB->ColorPtr->data[v1][0], VB->ColorPtr->data[v1][1], VB->ColorPtr->data[v1][2], VB->ColorPtr->data[v1][3]);
  400.     TC_Color(TDdriver->vbuffer[v2].color, VB->ColorPtr->data[v2][0], VB->ColorPtr->data[v2][1], VB->ColorPtr->data[v2][2], VB->ColorPtr->data[v2][3]);
  401.     TC_Color(TDdriver->vbuffer[v3].color, VB->ColorPtr->data[v3][0], VB->ColorPtr->data[v3][1], VB->ColorPtr->data[v3][2], VB->ColorPtr->data[v3][3]);
  402.     TC_Color(TDdriver->vbuffer[v4].color, VB->ColorPtr->data[v4][0], VB->ColorPtr->data[v4][1], VB->ColorPtr->data[v4][2], VB->ColorPtr->data[v4][3]);
  403.  
  404.     if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  405.       ClrF(TDdriver->flags, TD_ACTIVE);
  406.     SetF(TDdriver->flags, TD_DIRTY);
  407.   }
  408.   else if ((v2 - 1 == v1) && (v3 - 2 == v1) && (v4 - 3 == v1)) {
  409.     tri.vertexcount = 4;
  410.     tri.v = (&TDdriver->vbuffer[v1]);
  411.     tri.tex = TDdriver->TDtex;
  412.  
  413.     if (!ctx->Polygon.StippleFlag)
  414.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  415.     else
  416.       tri.st_pattern = NULL;
  417.  
  418.     TC_Color(TDdriver->vbuffer[v1].color, VB->ColorPtr->data[v1][0], VB->ColorPtr->data[v1][1], VB->ColorPtr->data[v1][2], VB->ColorPtr->data[v1][3]);
  419.     TC_Color(TDdriver->vbuffer[v2].color, VB->ColorPtr->data[v2][0], VB->ColorPtr->data[v2][1], VB->ColorPtr->data[v2][2], VB->ColorPtr->data[v2][3]);
  420.     TC_Color(TDdriver->vbuffer[v3].color, VB->ColorPtr->data[v3][0], VB->ColorPtr->data[v3][1], VB->ColorPtr->data[v3][2], VB->ColorPtr->data[v3][3]);
  421.     TC_Color(TDdriver->vbuffer[v4].color, VB->ColorPtr->data[v4][0], VB->ColorPtr->data[v4][1], VB->ColorPtr->data[v4][2], VB->ColorPtr->data[v4][3]);
  422.  
  423.     if (W3D_DrawTriFan(TDcontext, &tri) != W3D_SUCCESS)
  424.       ClrF(TDdriver->flags, TD_ACTIVE);
  425.     SetF(TDdriver->flags, TD_DIRTY);
  426.   }
  427.   else {
  428.     tri.vertexcount = 4;
  429.     tri.v = w3dv;
  430.     tri.tex = TDdriver->TDtex;
  431.  
  432.     if (!ctx->Polygon.StippleFlag)
  433.       tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  434.     else
  435.       tri.st_pattern = NULL;
  436.  
  437.     TDdriver->CopyVertex(&w3dv[0], &TDdriver->vbuffer[v1]);
  438.     TDdriver->CopyVertex(&w3dv[1], &TDdriver->vbuffer[v2]);
  439.     TDdriver->CopyVertex(&w3dv[2], &TDdriver->vbuffer[v4]);
  440.     TDdriver->CopyVertex(&w3dv[3], &TDdriver->vbuffer[v3]);
  441.  
  442.     TC_Color(w3dv[0].color, VB->ColorPtr->data[v1][0], VB->ColorPtr->data[v1][1], VB->ColorPtr->data[v1][2], VB->ColorPtr->data[v1][3]);
  443.     TC_Color(w3dv[1].color, VB->ColorPtr->data[v2][0], VB->ColorPtr->data[v2][1], VB->ColorPtr->data[v2][2], VB->ColorPtr->data[v2][3]);
  444.     TC_Color(w3dv[2].color, VB->ColorPtr->data[v3][0], VB->ColorPtr->data[v3][1], VB->ColorPtr->data[v3][2], VB->ColorPtr->data[v3][3]);
  445.     TC_Color(w3dv[3].color, VB->ColorPtr->data[v4][0], VB->ColorPtr->data[v4][1], VB->ColorPtr->data[v4][2], VB->ColorPtr->data[v4][3]);
  446.  
  447.     if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  448.       ClrF(TDdriver->flags, TD_ACTIVE);
  449.     SetF(TDdriver->flags, TD_DIRTY);
  450.   }
  451. }
  452.  
  453. quad_func wrpChooseQuadFunction(GLcontext * ctx)
  454. {
  455.   struct TDdriver *TDdriver;
  456.   W3D_Context *TDcontext;
  457.  
  458.   DEBUGOUT(1, "wrpChooseQuad()\n");
  459.  
  460.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  461.   TDcontext = TDdriver->td_ctx;
  462.  
  463.   if (W3D_Query(TDcontext, W3D_Q_DRAW_TRIANGLE, NULL) != W3D_FULLY_SUPPORTED)
  464.     return NULL;
  465.  
  466. #if 0
  467.   if ((ctx->Polygon.OffsetAny) || (ctx->RasterMask & FRONT_AND_BACK_BIT))
  468.     return NULL;
  469. #endif
  470.  
  471.   if (ctx->Polygon.SmoothFlag) {
  472.     if (W3D_Query(TDcontext,W3D_Q_ANTI_POLYGON,NULL) != W3D_FULLY_SUPPORTED)
  473.       return NULL;
  474.   }
  475.  
  476.   if (ctx->Polygon.StippleFlag) {
  477.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POLY_ST, NULL) != W3D_FULLY_SUPPORTED)
  478.       return NULL;
  479.   }
  480.  
  481.   if (ctx->Light.ShadeModel == GL_SMOOTH) {
  482.     if (ctx->Light.Model.TwoSide)
  483.       return wrpDrawQuadSmoothTwo;
  484.  
  485.     return wrpDrawQuadSmooth;
  486.   }
  487.  
  488.   return wrpDrawQuadFlat;
  489. }
  490.  
  491. /**********************************************************************/
  492. /*****            Accelerated point, line, polygon rendering      *****/
  493. /**********************************************************************/
  494.  
  495. /* draw triangle strips
  496.  * this is never called, when two-sided lighting is enabled
  497.  * this is not called when flat shading is enabled, except
  498.  * when texture mapping is enabled and the env variable NOFLAT
  499.  * is set (which results in wrong behaviour, if the constant
  500.  * color is not always white and GL_DECAL/GL_MODULATE are used)
  501.  */
  502.  
  503. void wrpDrawTriStrip(GLcontext * ctx, GLuint first, GLuint last)
  504. {
  505.   struct TDdriver *TDdriver;
  506.   W3D_Context *TDcontext;
  507.   W3D_Triangles tri;
  508.  
  509.   if (last - first < 2)
  510.     return;
  511.  
  512.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  513.   TDcontext = TDdriver->td_ctx;
  514.  
  515.   LockHardware(TDdriver, TDcontext);
  516.  
  517.   tri.vertexcount = last - first + 1;
  518.   tri.v = (&TDdriver->vbuffer[first]);
  519.   tri.tex = TDdriver->TDtex;
  520.  
  521.   if (!ctx->Polygon.StippleFlag)
  522.     tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  523.   else
  524.     tri.st_pattern = NULL;
  525.  
  526.   if (W3D_DrawTriStrip(TDcontext, &tri) != W3D_SUCCESS)
  527.     ClrF(TDdriver->flags, TD_ACTIVE);
  528.   SetF(TDdriver->flags, TD_DIRTY);
  529. }
  530.  
  531. tristrip_func wrpChooseTriStripFunction(GLcontext * ctx)
  532. {
  533.   struct TDdriver *TDdriver;
  534.   W3D_Context *TDcontext;
  535.  
  536.   DEBUGOUT(1, "wrpChooseTriStrip()\n");
  537.  
  538.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  539.   TDcontext = TDdriver->td_ctx;
  540.  
  541.   if (W3D_Query(TDcontext, W3D_Q_DRAW_TRIANGLE, NULL) != W3D_FULLY_SUPPORTED)
  542.     return NULL;
  543.  
  544. #if 0
  545.   if (ctx->Polygon.OffsetAny || (ctx->RasterMask & FRONT_AND_BACK_BIT))
  546.     return NULL;
  547. #endif
  548.  
  549.   if (ctx->Polygon.SmoothFlag) {
  550.     if (W3D_Query(TDcontext, W3D_Q_ANTI_POLYGON,NULL) != W3D_FULLY_SUPPORTED)
  551.       return NULL;
  552.   }
  553.  
  554.   if (ctx->Polygon.StippleFlag) {
  555.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POLY_ST, NULL) != W3D_FULLY_SUPPORTED)
  556.       return NULL;
  557.   }
  558.  
  559.   if (ctx->Light.Model.TwoSide)
  560.     return NULL;
  561.  
  562.   return wrpDrawTriStrip;
  563. }
  564.  
  565. /**********************************************************************/
  566. /*****            Accelerated point, line, polygon rendering      *****/
  567. /**********************************************************************/
  568.  
  569. /* draw triangle fans
  570.  * this is never called, when two-sided lighting is enabled
  571.  * this is not called when flat shading is enabled, except
  572.  * when texture mapping is enabled and the env variable NOFLAT
  573.  * is set (which results in wrong behaviour, if the constant
  574.  * color is not always white and GL_DECAL/GL_MODULATE are used)
  575.  */
  576.  
  577. void wrpDrawTriFan(GLcontext * ctx, GLuint zero, GLuint first, GLuint last)
  578. {
  579.   struct TDdriver *TDdriver;
  580.   W3D_Context *TDcontext;
  581.   W3D_Triangles tri;
  582.   W3D_Vertex vtemp;
  583.  
  584.   if (last - first < 1)
  585.     return;
  586.  
  587.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  588.   TDcontext = TDdriver->td_ctx;
  589.  
  590.   LockHardware(TDdriver, TDcontext);
  591.  
  592.   if (first - zero != 1) {
  593.     TDdriver->CopyVertex(&vtemp, &TDdriver->vbuffer[first - 1]);
  594.     TDdriver->CopyVertex(&TDdriver->vbuffer[first - 1], &TDdriver->vbuffer[zero]);
  595.   }
  596.  
  597.   tri.vertexcount = last - first + 2;
  598.   tri.v = (&TDdriver->vbuffer[first - 1]);
  599.   tri.tex = TDdriver->TDtex;
  600.  
  601.   if (!ctx->Polygon.StippleFlag)
  602.     tri.st_pattern = (unsigned char *)ctx->PolygonStipple;
  603.   else
  604.     tri.st_pattern = NULL;
  605.  
  606.   if (W3D_DrawTriFan(TDcontext, &tri) != W3D_SUCCESS)
  607.     ClrF(TDdriver->flags, TD_ACTIVE);
  608.   SetF(TDdriver->flags, TD_DIRTY);
  609.  
  610.   if (first - zero != 1)
  611.     TDdriver->CopyVertex(&TDdriver->vbuffer[first - 1], &vtemp);
  612. }
  613.  
  614. trifan_func wrpChooseTriFanFunction(GLcontext * ctx)
  615. {
  616.   struct TDdriver *TDdriver;
  617.   W3D_Context *TDcontext;
  618.  
  619.   DEBUGOUT(1, "wrpChooseTriFan()\n");
  620.  
  621.   TDdriver = ((amigaMesaContext) ctx->DriverCtx)->TDdriver;
  622.   TDcontext = TDdriver->td_ctx;
  623.  
  624.   if (W3D_Query(TDcontext, W3D_Q_DRAW_TRIANGLE, NULL) != W3D_FULLY_SUPPORTED)
  625.     return NULL;
  626.  
  627. #if 0
  628.   if (ctx->Polygon.OffsetAny || (ctx->RasterMask & FRONT_AND_BACK_BIT))
  629.     return NULL;
  630. #endif
  631.  
  632.   if (ctx->Polygon.SmoothFlag) {
  633.     if (W3D_Query(TDcontext, W3D_Q_ANTI_POLYGON,NULL) != W3D_FULLY_SUPPORTED)
  634.       return NULL;
  635.   }
  636.  
  637.   if (ctx->Polygon.StippleFlag) {
  638.     if (W3D_Query(TDcontext, W3D_Q_DRAW_POLY_ST, NULL) != W3D_FULLY_SUPPORTED)
  639.       return NULL;
  640.   }
  641.  
  642.   if (ctx->Light.Model.TwoSide)
  643.     return NULL;
  644.  
  645.   return wrpDrawTriFan;
  646. }
  647.