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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/*
* GLX Hardware Device Driver for Matrox Millenium G200
* Copyright (C) 1999 Wittawat Yamwong
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
* Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
*/
#ifndef MGATIS_INC
#define MGATIS_INC
#include "types.h"
extern void mgaDDChooseRenderState(GLcontext *ctx);
extern void mgaDDTrifuncInit( void );
/* Todo:
* - multidraw, ...
* - Antialiasing (?)
* - line and polygon stipple
* - select and feedback
* - stencil
* - point parameters
* -
*/
#define MGA_ANTIALIAS_BIT 0 /* ignored for now, no fallback */
#define MGA_FLAT_BIT 0x1
#define MGA_OFFSET_BIT 0x2 /* 3.1 only */
#define MGA_TWOSIDE_BIT 0x4 /* 3.1 only */
#define MGA_NODRAW_BIT 0x8
#define MGA_FALLBACK_BIT 0x10
/* Not in use:
*/
#define MGA_FEEDBACK_BIT 0x20
#define MGA_SELECT_BIT 0x40
#define MGA_POINT_PARAM_BIT 0x80 /* not needed? */
static __inline void mga_draw_triangle( mgaContextPtr mmesa,
mgaVertex *v0,
mgaVertex *v1,
mgaVertex *v2 )
{
mgaUI32 vertsize = mmesa->vertsize;
mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 3 * vertsize );
int j;
for (j = 0 ; j < vertsize ; j++)
wv[j] = v0->ui[j];
wv += vertsize;
for (j = 0 ; j < vertsize ; j++)
wv[j] = v1->ui[j];
wv += vertsize;
for (j = 0 ; j < vertsize ; j++)
wv[j] = v2->ui[j];
}
static __inline void mga_draw_point( mgaContextPtr mmesa,
mgaVertex *tmp, float sz )
{
mgaUI32 vertsize = mmesa->vertsize;
mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6*vertsize);
int j;
*(float *)&wv[0] = tmp->warp1.x - sz;
*(float *)&wv[1] = tmp->warp1.y - sz;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp->warp1.x + sz;
*(float *)&wv[1] = tmp->warp1.y - sz;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp->warp1.x + sz;
*(float *)&wv[1] = tmp->warp1.y + sz;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp->warp1.x + sz;
*(float *)&wv[1] = tmp->warp1.y + sz;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp->warp1.x - sz;
*(float *)&wv[1] = tmp->warp1.y + sz;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp->warp1.x - sz;
*(float *)&wv[1] = tmp->warp1.y - sz;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp->ui[j];
}
static __inline void mga_draw_line( mgaContextPtr mmesa,
const mgaVertex *tmp0,
const mgaVertex *tmp1,
float width )
{
mgaUI32 vertsize = mmesa->vertsize;
mgaUI32 *wv = mgaAllocVertexDwords( mmesa, 6 * vertsize );
float dx, dy, ix, iy;
int j;
dx = tmp0->warp1.x - tmp1->warp1.x;
dy = tmp0->warp1.y - tmp1->warp1.y;
ix = width * .5; iy = 0;
if ((ix<.5) && (ix>0.1)) ix = .5; /* I want to see lines with width
0.5 also */
if (dx * dx > dy * dy) {
iy = ix; ix = 0;
}
*(float *)&wv[0] = tmp0->warp1.x - ix;
*(float *)&wv[1] = tmp0->warp1.y - iy;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp0->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp1->warp1.x + ix;
*(float *)&wv[1] = tmp1->warp1.y + iy;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp1->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp0->warp1.x + ix;
*(float *)&wv[1] = tmp0->warp1.y + iy;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp0->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp0->warp1.x - ix;
*(float *)&wv[1] = tmp0->warp1.y - iy;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp0->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp1->warp1.x - ix;
*(float *)&wv[1] = tmp1->warp1.y - iy;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp1->ui[j];
wv += vertsize;
*(float *)&wv[0] = tmp1->warp1.x + ix;
*(float *)&wv[1] = tmp1->warp1.y + iy;
for (j = 2 ; j < vertsize ; j++)
wv[j] = tmp1->ui[j];
wv += vertsize;
}
#endif
|