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 {
29 void (*PutRowRGB) (struct gl_context * ctx, struct gl_renderbuffer * rb,
30 unsigned int count, int x, int y,
33 struct gl_framebuffer {
34 struct gl_renderbuffer *_ColorDrawBuffers[8];
37 struct gl_framebuffer *DrawBuffer;
38 struct gl_texture_attrib Texture;
43 typedef struct sw_span {
46 float attrStepX[30][4];
47 int intTex[2], intTexStep[2];
49 static void simple_textured_triangle(const SWvertex * v1)
51 struct gl_context *ctx;
68 const int snapMask = ~127;
78 ((((v0->attrib[0][1] -
79 0.5F) * (float)2048) >=
80 0.0F) ? (((v0->attrib[0][1] - 0.5F) *
82 0.5F) : (((v0->attrib[0][1] - 0.5F) *
83 (float)2048) - 0.5F)))) & snapMask;
86 ((((v1->attrib[0][1] -
87 0.5F) * (float)2048) >=
88 0.0F) ? (((v1->attrib[0][1] - 0.5F) *
90 0.5F) : (((v1->attrib[0][1] - 0.5F) *
91 (float)2048) - 0.5F)))) & snapMask;
94 ((((v2->attrib[0][1] -
95 0.5F) * (float)2048) >=
96 0.0F) ? (((v2->attrib[0][1] - 0.5F) *
98 0.5F) : (((v2->attrib[0][1] - 0.5F) *
99 (float)2048) - 0.5F)))) & snapMask;
109 ((((vMin->attrib[0][0] +
110 0.5F) * (float)2048) >=
111 0.0F) ? (((vMin->attrib[0][0] + 0.5F) *
113 0.5F) : (((vMin->attrib[0][0] + 0.5F) *
114 (float)2048) - 0.5F)))) & snapMask;
117 ((((vMid->attrib[0][0] +
118 0.5F) * (float)2048) >=
119 0.0F) ? (((vMid->attrib[0][0] + 0.5F) *
121 0.5F) : (((vMid->attrib[0][0] + 0.5F) *
122 (float)2048) - 0.5F)))) & snapMask;
123 eMaj.dx = ((vMax_fx - vMin_fx) * (1.0F / (float)2048));
124 eMaj.dy = ((vMax_fy - vMin_fy) * (1.0F / (float)2048));
125 eTop.dx = ((vMax_fx - vMid_fx) * (1.0F / (float)2048));
126 eBot.dy = ((vMid_fy - vMin_fy) * (1.0F / (float)2048));
127 const float area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
128 if (IS_INF_OR_NAN(area) || area == 0.0F)
130 oneOverArea = 1.0F / area;
131 if (eBot.lines > 0) {
134 int scan_from_left_to_right;
135 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0];
136 const struct gl_texture_object *obj =
137 ctx->Texture.Unit[0].CurrentTex[8];
138 const struct gl_texture_image *texImg = obj->Image[0][obj->BaseLevel];
139 const float twidth = (float)texImg->Width;
140 const int twidth_log2 = texImg->WidthLog2;
141 const unsigned char *texture = (const unsigned char *)texImg->Data;
142 const int smask = texImg->Width - 1;
143 const int tmask = texImg->Height - 1;
144 if (!rb || !texture) {
148 (vMax->attrib[4][0] -
149 vMin->attrib[4][0]) * twidth;
151 (vMid->attrib[4][0] -
152 vMin->attrib[4][0]) * twidth;
153 span.attrStepX[4][0] =
154 oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
157 ((((span.attrStepX[4][0]) * (float)2048) >=
158 0.0F) ? (((span.attrStepX[4][0]) *
160 0.5F) : (((span.attrStepX[4][0]) *
161 (float)2048) - 0.5F))));
166 for (subTriangle = 0; subTriangle <= 1; subTriangle++) {
169 if (subTriangle == 0) {
170 if (scan_from_left_to_right) {
172 lines = eRight->lines;
178 if (scan_from_left_to_right)
182 fxRightEdge = eRight->fsx - 1;
185 const int right = fxRightEdge >> 11;
186 span.x = fxLeftEdge >> 11;
190 span.end = right - span.x;
191 span.intTex[0] = sLeft;
192 if (span.end > 0 && span.y >= 0) {
194 unsigned char rgb[16384][3];
195 for (i = 0; i < span.end; i++) {
197 ((span.intTex[0]) >> 11) & smask;
199 ((span.intTex[1]) >> 11) & tmask;
200 int pos = (t << twidth_log2) + s;
201 rgb[i][0] = texture[pos + 2];
202 span.intTex[0] += span.intTexStep[0];
204 rb->PutRowRGB(ctx, rb, span.end, span.x, span.y,
213 return simple_textured_triangle;