Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1901 serge 1
 
2
 * Mesa 3-D graphics library
3
 * Version:  3.5
4
 *
5
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a
8
 * copy of this software and associated documentation files (the "Software"),
9
 * to deal in the Software without restriction, including without limitation
10
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11
 * and/or sell copies of the Software, and to permit persons to whom the
12
 * Software is furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included
15
 * in all copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
 *
24
 * Authors:
25
 *    Keith Whitwell 
26
 */
27
28
 
29
 * as defined in t_dd_vertex.h.
30
 *
31
 * See t_dd_vbtmp.h for definitions of arguments to this file.
32
 * Unfortunately it seems necessary to duplicate a lot of that code.
33
 */
34
35
 
36
#define LOCALVARS
37
#endif
38
39
 
40
 
41
 
42
 */
43
static void TAG(emit_vfmt)( struct gl_context *ctx, VERTEX *v )
44
{
45
   LOCALVARS
46
      ;
47
48
 
49
    */
50
   if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES)
51
   {
52
      const GLubyte *col = GET_HARDWARE_COLOR();
53
      if (HAVE_RGBA_COLOR) {
54
	 v->v.ui[4] = *(GLuint *)&col;
55
      } else {
56
	 v->v.color.blue  = col[2];
57
	 v->v.color.green = col[1];
58
	 v->v.color.red   = col[0];
59
	 v->v.color.alpha = col[3];
60
      }
61
   }
62
   else {
63
      if (HAVE_RGBA_COLOR) {
64
	 v->v.ui[3] = *(GLuint *)col;
65
      }
66
      else {
67
	 v->tv.color.blue  = col[2];
68
	 v->tv.color.green = col[1];
69
	 v->tv.color.red   = col[0];
70
	 v->tv.color.alpha = col[3];
71
      }
72
   }
73
74
 
75
      GLfloat *tc = ctx->Current.Texture[0];
76
      v->v.u0 = tc[0];
77
      v->v.v0 = tc[1];
78
      if (DO_PTEX) {
79
	 if (HAVE_PTEX_VERTICES) {
80
	    v->pv.q0 = tc[3];
81
	 }
82
	 else {
83
	    float rhw = 1.0 / tc[3];
84
	    v->v.w *= tc[3];
85
	    v->v.u0 *= rhw;
86
	    v->v.v0 *= rhw;
87
	 }
88
      }
89
   }
90
   if (DO_TEX1) {
91
      GLfloat *tc = ctx->Current.Texture[1];
92
      if (DO_PTEX) {
93
	 v->pv.u1 = tc[0];
94
	 v->pv.v1 = tc[1];
95
	 v->pv.q1 = tc[3];
96
      }
97
      else {
98
	 v->v.u1 = tc[0];
99
	 v->v.v1 = tc[1];
100
      }
101
   }
102
   else if (DO_PTEX) {
103
      *(GLuint *)&v->pv.q1 = 0;	/* avoid culling on radeon */
104
   }
105
   if (DO_TEX2) {
106
      GLfloat *tc = ctx->Current.Texture[2];
107
      if (DO_PTEX) {
108
	 v->pv.u2 = tc[0];
109
	 v->pv.v2 = tc[1];
110
	 v->pv.q2 = tc[3];
111
      }
112
      else {
113
	 v->v.u2 = tc[0];
114
	 v->v.v2 = tc[1];
115
      }
116
   }
117
   if (DO_TEX3) {
118
      GLfloat *tc = ctx->Current.Texture[3];
119
      if (DO_PTEX) {
120
	 v->pv.u3 = tc[0];
121
	 v->pv.v3 = tc[1];
122
	 v->pv.q3 = tc[3];
123
      }
124
      else {
125
	 v->v.u3 = tc[0];
126
	 v->v.v3 = tc[1];
127
      }
128
   }
129
}
130
131
 
132
 
133
 
134
 
135
			 GLfloat t,
136
			 TNL_VERTEX *dst,
137
			 TNL_VERTEX *in,
138
			 TNL_VERTEX *out )
139
{
140
   LOCALVARS
141
   const GLfloat *s = GET_VIEWPORT_MAT();
142
   GLfloat w;
143
144
 
145
146
 
147
      VIEWPORT_X( dst->v.v.x, dst->clip[0] );
148
      VIEWPORT_Y( dst->v.v.y, dst->clip[1] );
149
      VIEWPORT_Z( dst->v.v.z, dst->clip[2] );
150
      w = dstclip[3];
151
   }
152
   else {
153
      w = 1.0 / dst->clip[3];
154
      VIEWPORT_X( dst->v.v.x, dst->clip[0] * w );
155
      VIEWPORT_Y( dst->v.v.y, dst->clip[1] * w );
156
      VIEWPORT_Z( dst->v.v.z, dst->clip[2] * w );
157
   }
158
159
 
160
161
 
162
163
 
164
      INTERP_UB( t, dst->v.ub4[4][1], out->v.ub4[4][1], in->v.ub4[4][1] );
165
      INTERP_UB( t, dst->v.ub4[4][2], out->v.ub4[4][2], in->v.ub4[4][2] );
166
      INTERP_UB( t, dst->v.ub4[4][3], out->v.ub4[4][3], in->v.ub4[4][3] );
167
168
 
169
	 if (DO_PTEX) {
170
	    if (HAVE_PTEX_VERTICES) {
171
	       INTERP_F( t, dst->v.pv.u0, out->v.pv.u0, in->v.pv.u0 );
172
	       INTERP_F( t, dst->v.pv.v0, out->v.pv.v0, in->v.pv.v0 );
173
	       INTERP_F( t, dst->v.pv.q0, out->v.pv.q0, in->v.pv.q0 );
174
	    } else {
175
	       GLfloat wout = out->clip[3]; /* projected clip */
176
	       GLfloat win = in->clip[3]; /* projected clip */
177
	       GLfloat qout = out->v.pv.w / wout;
178
	       GLfloat qin = in->v.pv.w / win;
179
	       GLfloat qdst, rqdst;
180
181
 
182
183
 
184
	       INTERP_F( t, dst->v.v.v0, out->v.v.v0 * qout, in->v.v.v0 * qin );
185
	       INTERP_F( t, qdst, qout, qin );
186
187
 
188
	       dst->v.v.u0 *= rqdst;
189
	       dst->v.v.v0 *= rqdst;
190
	       dst->v.v.w *= rqdst;
191
	    }
192
	 }
193
	 else {
194
	    INTERP_F( t, dst->v.v.u0, out->v.v.u0, in->v.v.u0 );
195
	    INTERP_F( t, dst->v.v.v0, out->v.v.v0, in->v.v.v0 );
196
	 }
197
      }
198
      if (DO_TEX1) {
199
	 if (DO_PTEX) {
200
	    INTERP_F( t, dst->v.pv.u1, out->v.pv.u1, in->v.pv.u1 );
201
	    INTERP_F( t, dst->v.pv.v1, out->v.pv.v1, in->v.pv.v1 );
202
	    INTERP_F( t, dst->v.pv.q1, out->v.pv.q1, in->v.pv.q1 );
203
	 } else {
204
	    INTERP_F( t, dst->v.v.u1, out->v.v.u1, in->v.v.u1 );
205
	    INTERP_F( t, dst->v.v.v1, out->v.v.v1, in->v.v.v1 );
206
	 }
207
      }
208
      else if (DO_PTEX) {
209
	 dst->v.pv.q0 = 0.0;	/* must be a valid float on radeon */
210
      }
211
      if (DO_TEX2) {
212
	 if (DO_PTEX) {
213
	    INTERP_F( t, dst->v.pv.u2, out->v.pv.u2, in->v.pv.u2 );
214
	    INTERP_F( t, dst->v.pv.v2, out->v.pv.v2, in->v.pv.v2 );
215
	    INTERP_F( t, dst->v.pv.q2, out->v.pv.q2, in->v.pv.q2 );
216
	 } else {
217
	    INTERP_F( t, dst->v.v.u2, out->v.v.u2, in->v.v.u2 );
218
	    INTERP_F( t, dst->v.v.v2, out->v.v.v2, in->v.v.v2 );
219
	 }
220
      }
221
      if (DO_TEX3) {
222
	 if (DO_PTEX) {
223
	    INTERP_F( t, dst->v.pv.u3, out->v.pv.u3, in->v.pv.u3 );
224
	    INTERP_F( t, dst->v.pv.v3, out->v.pv.v3, in->v.pv.v3 );
225
	    INTERP_F( t, dst->v.pv.q3, out->v.pv.q3, in->v.pv.q3 );
226
	 } else {
227
	    INTERP_F( t, dst->v.v.u3, out->v.v.u3, in->v.v.u3 );
228
	    INTERP_F( t, dst->v.v.v3, out->v.v.v3, in->v.v.v3 );
229
	 }
230
      }
231
   } else {
232
      /* 4-dword vertex.  Color is in v[3] and there is no oow coordinate.
233
       */
234
      INTERP_UB( t, dst->v.ub4[3][0], out->v.ub4[3][0], in->v.ub4[3][0] );
235
      INTERP_UB( t, dst->v.ub4[3][1], out->v.ub4[3][1], in->v.ub4[3][1] );
236
      INTERP_UB( t, dst->v.ub4[3][2], out->v.ub4[3][2], in->v.ub4[3][2] );
237
      INTERP_UB( t, dst->v.ub4[3][3], out->v.ub4[3][3], in->v.ub4[3][3] );
238
   }
239
}
240
241
 
242
 
243
				   TNL_VERTEX *dst,
244
				   TNL_VERTEX *src )
245
{
246
   if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES) {
247
      dst->v.v.ui[4] = src->v.v.ui[4];
248
   }
249
   else {
250
      dst->v.v.ui[3] = src->v.v.ui[3];
251
   }
252
}
253
254
 
255
 
256
 
257
{
258
   setup_tab[IND].emit = TAG(emit_vfmt);
259
   setup_tab[IND].interp = TAG(interp_vfmt);
260
}
261
262
 
263
 
264
#undef TAG
265