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 {
20 struct gl_framebuffer {
21 struct gl_renderbuffer *_ColorDrawBuffers[8];
24 struct gl_framebuffer *DrawBuffer;
29 typedef struct sw_span {
32 float attrStepX[30][4];
33 int intTex[2], intTexStep[2];
35 static void simple_textured_triangle(const SWvertex * v1)
37 struct gl_context *ctx;
54 const int snapMask = ~127;
64 ((((v0->attrib[0][1] - 0) * (float)2048) >=
65 0) ? (((v0->attrib[0][1] - 0) * (float)2048) +
66 0) : (((v0->attrib[0][1] - 0) * (float)2048) -
70 ((((v1->attrib[0][1] - 0) * (float)2048) >=
71 0.0F) ? (((v1->attrib[0][1] - 0) * (float)2048) +
72 0) : (((v1->attrib[0][1] - 0) * (float)2048) -
76 ((((v2->attrib[0][1] - 0) * (float)2048) >=
77 0.0F) ? (((v2->attrib[0][1] - 0) * (float)2048) +
78 0) : (((v2->attrib[0][1] - 0) * (float)2048) -
88 ((((vMin->attrib[0][0] + 0.5F) * (float)2048) >=
89 0.0F) ? (((vMin->attrib[0][0] + 0.5F) * (float)2048) +
90 0.5F) : (((vMin->attrib[0][0] + 0.5F) * (float)2048) -
94 ((((vMid->attrib[0][0] + 0.5F) * (float)2048) >=
95 0.0F) ? (((vMid->attrib[0][0] + 0.5F) * (float)2048) +
96 0.5F) : (((vMid->attrib[0][0] + 0.5F) * (float)2048) -
98 eMaj.dx = ((vMax_fx - vMin_fx) * (1.0F / (float)2048));
99 eMaj.dy = ((vMax_fy - vMin_fy) * (1.0F / (float)2048));
100 eTop.dx = ((vMax_fx - vMid_fx) * (1.0F / (float)2048));
101 eBot.dy = ((vMid_fy - vMin_fy) * (1.0F / (float)2048));
102 const float area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
103 if (IS_INF_OR_NAN(area))
105 oneOverArea = 1.0F / area;
107 int scan_from_left_to_right;
108 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
109 const struct gl_texture_image *texImg;
111 const int twidth_log2;
112 const unsigned char *texture = texImg->Data;
113 const int smask = texImg->Width;
114 const int tmask = texImg->Height;
115 float eMaj_ds = (vMax->attrib[4][0] - vMin->attrib[4][0]) * twidth;
117 span.attrStepX[4][0] =
118 oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
121 ((((span.attrStepX[4][0]) * (float)2048) >=
122 0.0F) ? (((span.attrStepX[4][0]) * (float)2048) +
123 0.5F) : (((span.attrStepX[4][0]) * (float)2048) -
129 for (subTriangle = 0; subTriangle <= 1; subTriangle++) {
132 if (subTriangle == 0) {
133 if (scan_from_left_to_right) {
135 lines = eRight->lines;
140 if (scan_from_left_to_right) {
143 fxRightEdge = eRight->fsx - 1;
146 const int right = fxRightEdge >> 11;
147 span.x = fxLeftEdge >> 11;
151 span.end = right - span.x;
152 span.intTex[0] = sLeft;
153 if (span.end > 0 && span.y >= 0) {
155 unsigned char rgb[16384][3];
156 for (i = 0; i < span.end; i++) {
158 ((span.intTex[0]) >> 11) & smask;
160 ((span.intTex[1]) >> 11) & tmask;
161 int pos = (t << twidth_log2) + s;
162 rgb[i][0] = texture[pos + 2];
163 span.intTex[0] += span.intTexStep[0];
173 return simple_textured_triangle;