1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
static __inline__ void TAG(triangle)( GLcontext *ctx, GLuint e0,
GLuint e1, GLuint e2, GLuint pv )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
struct vertex_buffer *VB = ctx->VB;
i810VertexPtr i810VB = I810_DRIVER_DATA(VB)->verts;
const i810_vertex *v0 = &i810VB[e0].v;
const i810_vertex *v1 = &i810VB[e1].v;
const i810_vertex *v2 = &i810VB[e2].v;
#if (IND & I810_OFFSET_BIT)
GLfloat offset = ctx->Polygon.OffsetUnits * 1.0/0x10000;
#endif
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
int c0 = *(int *)&i810VB[pv].v.color;
int c1 = c0;
int c2 = c0;
#endif
#if (IND & (I810_TWOSIDE_BIT|I810_OFFSET_BIT))
{
GLfloat ex = v0->x - v2->x;
GLfloat ey = v0->y - v2->y;
GLfloat fx = v1->x - v2->x;
GLfloat fy = v1->y - v2->y;
GLfloat c = ex*fy-ey*fx;
#if (IND & I810_TWOSIDE_BIT)
{
GLuint facing = (c>0.0) ^ ctx->Polygon.FrontBit;
GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
if (IND & I810_FLAT_BIT) {
I810_COLOR((char *)&c0,vbcolor[pv]);
c2 = c1 = c0;
} else {
I810_COLOR((char *)&c0,vbcolor[e0]);
I810_COLOR((char *)&c1,vbcolor[e1]);
I810_COLOR((char *)&c2,vbcolor[e2]);
}
}
#endif
#if (IND & I810_OFFSET_BIT)
{
if (c * c > 1e-16) {
GLfloat factor = ctx->Polygon.OffsetFactor;
GLfloat ez = v0->z - v2->z;
GLfloat fz = v1->z - v2->z;
GLfloat a = ey*fz-ez*fy;
GLfloat b = ez*fx-ex*fz;
GLfloat ic = 1.0 / c;
GLfloat ac = a * ic;
GLfloat bc = b * ic;
if (ac<0.0F) ac = -ac;
if (bc<0.0F) bc = -bc;
offset += MAX2( ac, bc ) * factor;
}
}
#endif
}
#endif
{
i810_vertex *wv = i810AllocTriangles( imesa, 1 );
wv[0] = *v0;
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
*((int *)(&wv[0].color)) = c0;
#endif
#if (IND & I810_OFFSET_BIT)
wv[0].z = v0->z + offset;
#endif
wv[1] = *v1;
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
*((int *)(&wv[1].color)) = c1;
#endif
#if (IND & I810_OFFSET_BIT)
wv[1].z = v1->z + offset;
#endif
wv[2] = *v2;
#if (IND & (I810_FLAT_BIT|I810_TWOSIDE_BIT))
*((int *)(&wv[2].color)) = c2;
#endif
#if (IND & I810_OFFSET_BIT)
wv[2].z = v2->z + offset;
#endif
}
}
static void TAG(quad)( GLcontext *ctx, GLuint v0,
GLuint v1, GLuint v2, GLuint v3,
GLuint pv )
{
TAG(triangle)( ctx, v0, v1, v3, pv );
TAG(triangle)( ctx, v1, v2, v3, pv );
}
static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
i810VertexPtr i810VB = I810_DRIVER_DATA(ctx->VB)->verts;
int tmp0, tmp1;
(void) tmp0; (void) tmp1;
if (IND & I810_FLAT_BIT) {
tmp0 = *(int *)&i810VB[v0].v.color;
tmp1 = *(int *)&i810VB[v1].v.color;
i810VB[v0].v.color = i810VB[pv].v.color;
i810VB[v1].v.color = i810VB[pv].v.color;
}
if (IND & I810_WIDE_LINE_BIT)
{
i810_draw_tri_line( imesa, &i810VB[v0].v, &i810VB[v1].v,
ctx->Line.Width );
}
else
{
i810_draw_line_line( imesa, &i810VB[v0].v, &i810VB[v1].v );
}
if (IND & I810_FLAT_BIT) {
*(int *)&i810VB[v0].v.color = tmp0;
*(int *)&i810VB[v1].v.color = tmp1;
}
}
static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
struct vertex_buffer *VB = ctx->VB;
i810VertexPtr i810VB = I810_DRIVER_DATA(VB)->verts;
GLfloat sz = ctx->Point.Size * .5;
int i;
/* Culling is disabled automatically via. the
* ctx->Driver.ReducedPrimitiveChange() callback.
*/
for(i=first;i<=last;i++) {
if(VB->ClipMask[i]==0) {
i810_vertex *tmp = &i810VB[i].v;
i810_draw_point( imesa, tmp, sz );
}
}
}
static void TAG(init)( void )
{
tri_tab[IND] = TAG(triangle);
quad_tab[IND] = TAG(quad);
line_tab[IND] = TAG(line);
points_tab[IND] = TAG(points);
}
#undef IND
#undef TAG
|