5 static __inline__ int IS_INF_OR_NAN(float x)
9 return !(int)((unsigned int)((tmp.i & 0x7fffffff) - 0x7f800000) >> 31);
12 struct gl_texture_image {
17 struct gl_renderbuffer {
23 typedef struct sw_span {
26 float attrStepX[30][4];
27 int intTex[2]; int intTexStep[2];
29 static void simple_textured_triangle(const SWvertex * v1)
54 const int fy0 = v0->attrib[0][1];
55 const int fy1 = v1->attrib[0][1];
56 const int fy2 = v2->attrib[0][1];
63 vMin_fx = vMin->attrib[0][0];
66 ((vMid->attrib[0][0] >=
67 0) ? ((vMid->attrib[0][0] * (float)2048
69 0.5F) : (((vMid->attrib[0][0]) * (float)2048) -
71 eMaj.dx = ((vMax_fx - vMin_fx) * (1.0F / (float)2048));
72 eMaj.dy = ((vMax_fy - vMin_fy) * (1.0F / (float)2048));
73 eTop.dx = ((vMax_fx - vMid_fx) * (1.0F / (float)2048));
74 eBot.dy = ((vMid_fy - vMin_fy) * (1.0F / (float)2048));
75 const float area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
76 if (IS_INF_OR_NAN(area))
78 oneOverArea = 1.0F / area;
80 int scan_from_left_to_right;
81 struct gl_renderbuffer *rb;
82 const struct gl_texture_image *texImg;
84 const int twidth_log2;
85 const unsigned char *texture = texImg->Data;
86 const int smask = texImg->Width;
87 const int tmask = texImg->Height;
88 float eMaj_ds = (vMax->attrib[4][0] - vMin->attrib[4][0]) * twidth;
90 span.attrStepX[4][0] =
91 oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
94 ((((span.attrStepX[4][0]) * (float)2048) >=
95 0.0F) ? (((span.attrStepX[4][0]) * (float)2048) +
96 0.5F) : (((span.attrStepX[4][0]) * (float)2048) -
102 for (subTriangle = 0; subTriangle <= 1; subTriangle++) {
105 if (subTriangle == 0) {
106 if (scan_from_left_to_right) {
108 lines = eRight->lines;
113 if (scan_from_left_to_right) {
116 fxRightEdge = eRight->fsx ;
119 const int right = fxRightEdge ;
124 span.end = right - span.x;
126 if (span.end > 0 && span.y >= 0) {
128 unsigned char rgb[16384][3];
129 for (i = 0; i < span.end; i++)
131 int s = span.intTex[0];
132 int t = span.intTex[1];
133 int pos = (t << twidth_log2) + s;
134 rgb[i][0] = texture[pos ];
135 span.intTex[0] += span.intTexStep[0];
145 return simple_textured_triangle;