1 static __inline__ int IS_INF_OR_NAN(float x)
14 typedef struct sw_span {
18 float attrStepX[30][4];
22 static void simple_textured_triangle( SWvertex * v1)
47 int fy0 = v0->attrib[0][1];
48 int fy1 = v1->attrib[0][1];
49 int fy2 = v2->attrib[0][1];
55 vMin_fx = vMin->attrib[0][0];
58 ((vMid->attrib[4][0] * (float)2048) + 0.5F) :
59 ((vMid->attrib[4][0] * (float)2048) - 0.5F));
60 eMaj.dx = (vMax_fx - vMin_fx) * (1.0F / (float)2048);
61 eMaj.dy = (vMax_fy - vMin_fy) * (1.0F / (float)2048);
62 eTop.dx = (vMax_fx - vMid_fx) * (1.0F / (float)2048);
63 eBot.dy = (vMid_fy - vMin_fy) * (1.0F / (float)2048);
64 float area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
65 if (IS_INF_OR_NAN(area))
67 oneOverArea = 1.0F / area;
69 int scan_from_left_to_right;
72 float eMaj_ds = (vMax->attrib[4][0] - vMin->attrib[4][0]);
74 span.attrStepX[4][0] =
75 oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
78 ((span.attrStepX[4][0] >=
79 0.0F) ? span.attrStepX[4][0] :
80 (span.attrStepX[4][0] * (float)2048) - 0.5F);
83 for (subTriangle = 0; subTriangle <= 1; subTriangle++) {
86 if (subTriangle == 0) {
87 if (scan_from_left_to_right) {
89 lines = eRight->lines;
94 if (scan_from_left_to_right) {
97 fxRightEdge = eRight->fsx;
101 if (fxRightEdge <= span.x)
104 span.end = fxRightEdge - span.x;
106 if (span.end > 0 && span.y >= 0) {
109 for (i = 0; i < span.end; i++) {
110 rgb[i] = texture[span.intTex[0]];
111 span.intTex[0] += span.intTexStep[0];
121 return simple_textured_triangle;