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 {
15 unsigned int WidthLog2;
18 struct gl_texture_object {
20 struct gl_texture_image *Image[6][15];
22 struct gl_texture_unit {
23 struct gl_texture_object *CurrentTex[9];
25 struct gl_texture_attrib {
26 struct gl_texture_unit Unit[(16 + 16)];
28 struct gl_renderbuffer {
31 struct gl_framebuffer {
32 struct gl_renderbuffer *_ColorDrawBuffers[8];
35 struct gl_framebuffer *DrawBuffer;
36 struct gl_texture_attrib Texture;
41 typedef struct sw_span {
44 float attrStepX[30][4];
45 int intTex[2], intTexStep[2];
47 static void simple_textured_triangle(const SWvertex * v1)
49 struct gl_context *ctx;
66 const int snapMask = ~127;
76 ((((v0->attrib[0][1] -
77 0.5F) * (float)2048) >=
78 0.0F) ? (((v0->attrib[0][1] - 0.5F) *
80 0.5F) : (((v0->attrib[0][1] - 0.5F) *
81 (float)2048) - 0.5F)))) & snapMask;
84 ((((v1->attrib[0][1] -
85 0.5F) * (float)2048) >=
86 0.0F) ? (((v1->attrib[0][1] - 0.5F) *
88 0.5F) : (((v1->attrib[0][1] - 0.5F) *
89 (float)2048) - 0.5F)))) & snapMask;
92 ((((v2->attrib[0][1] -
93 0.5F) * (float)2048) >=
94 0.0F) ? (((v2->attrib[0][1] - 0.5F) *
96 0.5F) : (((v2->attrib[0][1] - 0.5F) *
97 (float)2048) - 0.5F)))) & snapMask;
107 ((((vMin->attrib[0][0] +
108 0.5F) * (float)2048) >=
109 0.0F) ? (((vMin->attrib[0][0] + 0.5F) *
111 0.5F) : (((vMin->attrib[0][0] + 0.5F) *
112 (float)2048) - 0.5F)))) & snapMask;
115 ((((vMid->attrib[0][0] +
116 0.5F) * (float)2048) >=
117 0.0F) ? (((vMid->attrib[0][0] + 0.5F) *
119 0.5F) : (((vMid->attrib[0][0] + 0.5F) *
120 (float)2048) - 0.5F)))) & snapMask;
121 eMaj.dx = ((vMax_fx - vMin_fx) * (1.0F / (float)2048));
122 eMaj.dy = ((vMax_fy - vMin_fy) * (1.0F / (float)2048));
123 eTop.dx = ((vMax_fx - vMid_fx) * (1.0F / (float)2048));
124 eBot.dy = ((vMid_fy - vMin_fy) * (1.0F / (float)2048));
125 const float area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
126 if (IS_INF_OR_NAN(area))
128 oneOverArea = 1.0F / area;
130 int scan_from_left_to_right;
131 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
132 const struct gl_texture_object *obj;
133 const struct gl_texture_image *texImg;
135 const int twidth_log2;
136 const unsigned char *texture = texImg->Data;
137 const int smask = texImg->Width;
138 const int tmask = texImg->Height;
140 (vMax->attrib[4][0] -
141 vMin->attrib[4][0]) * twidth;
143 span.attrStepX[4][0] =
144 oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
147 ((((span.attrStepX[4][0]) * (float)2048) >=
148 0.0F) ? (((span.attrStepX[4][0]) *
150 0.5F) : (((span.attrStepX[4][0]) *
151 (float)2048) - 0.5F))));
156 for (subTriangle = 0; subTriangle <= 1; subTriangle++) {
159 if (subTriangle == 0) {
160 if (scan_from_left_to_right) {
162 lines = eRight->lines;
168 if (scan_from_left_to_right)
172 fxRightEdge = eRight->fsx - 1;
176 const int right = fxRightEdge >> 11;
177 span.x = fxLeftEdge >> 11;
181 span.end = right - span.x;
182 span.intTex[0] = sLeft;
183 if (span.end > 0 && span.y >= 0)
186 unsigned char rgb[16384][3];
187 for (i = 0; i < span.end; i++)
189 int s = ((span.intTex[0]) >> 11) & smask;
191 ((span.intTex[1]) >> 11) & tmask;
192 int pos = (t << twidth_log2) + s;
193 rgb[i][0] = texture[pos + 2];
194 span.intTex[0] += span.intTexStep[0];
206 return simple_textured_triangle;