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
#include "math/m_translate.h"
28
29
 
30
#define UNVIEWPORT_VARS
31
#define UNVIEWPORT_X(x) x
32
#define UNVIEWPORT_Y(x) x
33
#define UNVIEWPORT_Z(x) x
34
#endif
35
36
 
37
#define LOCALVARS
38
#endif
39
40
 
41
#define CHECK_HW_DIVIDE 1
42
#endif
43
44
 
45
 * really convenient to put them.  Need to build some actual .o files in
46
 * this directory?
47
 */
48
static void copy_pv_rgba4_spec5( struct gl_context *ctx, GLuint edst, GLuint esrc )
49
{
50
   LOCALVARS
51
   GLubyte *verts = GET_VERTEX_STORE();
52
   GLuint size = GET_VERTEX_SIZE();
53
   GLuint *dst = (GLuint *)(verts + (edst * size));
54
   GLuint *src = (GLuint *)(verts + (esrc * size));
55
   dst[4] = src[4];
56
   dst[5] = src[5];
57
}
58
59
 
60
{
61
   LOCALVARS
62
   GLubyte *verts = GET_VERTEX_STORE();
63
   GLuint size = GET_VERTEX_SIZE();
64
   GLuint *dst = (GLuint *)(verts + (edst * size));
65
   GLuint *src = (GLuint *)(verts + (esrc * size));
66
   dst[4] = src[4];
67
}
68
69
 
70
{
71
   LOCALVARS
72
   GLubyte *verts = GET_VERTEX_STORE();
73
   GLuint size = GET_VERTEX_SIZE();
74
   GLuint *dst = (GLuint *)(verts + (edst * size));
75
   GLuint *src = (GLuint *)(verts + (esrc * size));
76
   dst[3] = src[3];
77
}
78
79
 
80
 
81
			   const VERTEX *src,
82
			   SWvertex *dst)
83
{
84
   LOCALVARS
85
   GLuint format = GET_VERTEX_FORMAT();
86
   GLfloat *s = ctx->Viewport._WindowMap.m;
87
   UNVIEWPORT_VARS;
88
89
 
90
      if (HAVE_HW_VIEWPORT) {
91
	 dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0]  * src->v.x + s[12];
92
	 dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5]  * src->v.y + s[13];
93
	 dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z + s[14];
94
	 dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
95
      } else {
96
	 dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( src->v.x );
97
	 dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( src->v.y );
98
	 dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( src->v.z );
99
	 dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
100
      }
101
102
 
103
      dst->color[1] = src->tv.color.green;
104
      dst->color[2] = src->tv.color.blue;
105
      dst->color[3] = src->tv.color.alpha;
106
   }
107
   else {
108
      if (HAVE_HW_VIEWPORT) {
109
	 if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
110
	    GLfloat oow = 1.0 / src->v.w;
111
	    dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0]  * src->v.x * oow + s[12];
112
	    dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5]  * src->v.y * oow + s[13];
113
	    dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z * oow + s[14];
114
	    dst->attrib[FRAG_ATTRIB_WPOS][3] = oow;
115
	 } else {
116
	    dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0]  * src->v.x + s[12];
117
	    dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5]  * src->v.y + s[13];
118
	    dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z + s[14];
119
	    dst->attrib[FRAG_ATTRIB_WPOS][3] = src->v.w;
120
	 }
121
      } else {
122
	 dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( src->v.x );
123
	 dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( src->v.y );
124
	 dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( src->v.z );
125
	 dst->attrib[FRAG_ATTRIB_WPOS][3] = src->v.w;
126
      }
127
128
 
129
      dst->color[1] = src->v.color.green;
130
      dst->color[2] = src->v.color.blue;
131
      dst->color[3] = src->v.color.alpha;
132
133
 
134
      dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(src->v.specular.green);
135
      dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(src->v.specular.blue);
136
137
 
138
139
 
140
	  ((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) ||
141
	   (format == PROJ_TEX1_VERTEX_FORMAT))) {
142
143
 
144
	 dst->attrib[FRAG_ATTRIB_TEX0][1] = src->pv.v0;
145
	 dst->attrib[FRAG_ATTRIB_TEX0][3] = src->pv.q0;
146
147
 
148
	 dst->attrib[FRAG_ATTRIB_TEX1][1] = src->pv.v1;
149
	 dst->attrib[FRAG_ATTRIB_TEX1][3] = src->pv.q1;
150
151
 
152
	    dst->attrib[FRAG_ATTRIB_TEX2][0] = src->pv.u2;
153
	    dst->attrib[FRAG_ATTRIB_TEX2][1] = src->pv.v2;
154
	    dst->attrib[FRAG_ATTRIB_TEX2][3] = src->pv.q2;
155
	 }
156
157
 
158
	    dst->attrib[FRAG_ATTRIB_TEX3][0] = src->pv.u3;
159
	    dst->attrib[FRAG_ATTRIB_TEX3][1] = src->pv.v3;
160
	    dst->attrib[FRAG_ATTRIB_TEX3][3] = src->pv.q3;
161
	 }
162
      }
163
      else {
164
	 dst->attrib[FRAG_ATTRIB_TEX0][0] = src->v.u0;
165
	 dst->attrib[FRAG_ATTRIB_TEX0][1] = src->v.v0;
166
	 dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
167
168
 
169
	 dst->attrib[FRAG_ATTRIB_TEX1][1] = src->v.v1;
170
	 dst->attrib[FRAG_ATTRIB_TEX1][3] = 1.0;
171
172
 
173
	    dst->attrib[FRAG_ATTRIB_TEX2][0] = src->v.u2;
174
	    dst->attrib[FRAG_ATTRIB_TEX2][1] = src->v.v2;
175
	    dst->attrib[FRAG_ATTRIB_TEX2][3] = 1.0;
176
	 }
177
178
 
179
	    dst->attrib[FRAG_ATTRIB_TEX3][0] = src->v.u3;
180
	    dst->attrib[FRAG_ATTRIB_TEX3][1] = src->v.v3;
181
	    dst->attrib[FRAG_ATTRIB_TEX3][3] = 1.0;
182
	 }
183
      }
184
   }
185
186
 
187
}
188
189
 
190
 
191
void TAG(print_vertex)( struct gl_context *ctx, const VERTEX *v );
192
193
 
194
 
195
{
196
   LOCALVARS
197
   GLuint format = GET_VERTEX_FORMAT();
198
199
 
200
201
 
202
#if HAVE_TINY_VERTICES
203
   case TINY_VERTEX_FORMAT:
204
      fprintf(stderr, "xyz %.4f,%.4f,%.4f rgba %x:%x:%x:%x\n",
205
	      v->v.x, v->v.y, v->v.z,
206
	      v->tv.color.red,
207
	      v->tv.color.green,
208
	      v->tv.color.blue,
209
	      v->tv.color.alpha);
210
      break;
211
#endif
212
#if HAVE_NOTEX_VERTICES
213
   case NOTEX_VERTEX_FORMAT:
214
      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x spec %x:%x:%x:%x\n",
215
	      v->v.x, v->v.y, v->v.z, v->v.w,
216
	      v->v.color.red,
217
	      v->v.color.green,
218
	      v->v.color.blue,
219
	      v->v.color.alpha,
220
	      v->v.specular.red,
221
	      v->v.specular.green,
222
	      v->v.specular.blue,
223
	      v->v.specular.alpha);
224
      break;
225
#endif
226
#if HAVE_TEX0_VERTICES
227
   case TEX0_VERTEX_FORMAT:
228
      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f\n",
229
	      v->v.x, v->v.y, v->v.z, v->v.w,
230
	      v->v.color.red,
231
	      v->v.color.green,
232
	      v->v.color.blue,
233
	      v->v.color.alpha,
234
	      v->v.u0,
235
	      v->v.v0);
236
      break;
237
#endif
238
#if HAVE_TEX1_VERTICES
239
   case TEX1_VERTEX_FORMAT:
240
      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f st %.4f,%.4f\n",
241
	      v->v.x, v->v.y, v->v.z, v->v.w,
242
	      v->v.color.red,
243
	      v->v.color.green,
244
	      v->v.color.blue,
245
	      v->v.color.alpha,
246
	      v->v.u0,
247
	      v->v.v0,
248
	      v->v.u1,
249
	      v->v.u2);
250
      break;
251
#endif
252
#if HAVE_PTEX_VERTICES
253
   case PROJ_TEX1_VERTEX_FORMAT:
254
      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x stq %.4f,%.4f,%.4f stq %.4f,%.4f,%.4f\n",
255
	      v->v.x, v->v.y, v->v.z, v->v.w,
256
	      v->v.color.red,
257
	      v->v.color.green,
258
	      v->v.color.blue,
259
	      v->v.color.alpha,
260
	      v->pv.u0,
261
	      v->pv.v0,
262
	      v->pv.q0,
263
	      v->pv.u1,
264
	      v->pv.v1,
265
	      v->pv.q1);
266
      break;
267
#endif
268
   default:
269
      fprintf(stderr, "???\n");
270
      break;
271
   }
272
273
 
274
}
275
276
 
277
 
278
 
279
 * vertices.
280
 *
281
 * NOTE: All these arrays are guarenteed by tnl to be writeable and
282
 * have good stride.
283
 */
284
#ifndef INTERP_QUALIFIER
285
#define INTERP_QUALIFIER static
286
#endif
287
288
 
289
290
 
291
 
292
					  GLfloat t,
293
					  GLuint dst, GLuint out, GLuint in,
294
					  GLboolean force_boundary )
295
{
296
   LOCALVARS
297
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
298
299
 
300
      assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
301
302
 
303
		    GET_COLOR(VB->BackfaceColorPtr, dst),
304
		    GET_COLOR(VB->BackfaceColorPtr, out),
305
		    GET_COLOR(VB->BackfaceColorPtr, in) );
306
307
 
308
	 INTERP_3F( t,
309
		       GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
310
		       GET_COLOR(VB->BackfaceSecondaryColorPtr, out),
311
		       GET_COLOR(VB->BackfaceSecondaryColorPtr, in) );
312
      }
313
   }
314
315
 
316
      VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
317
   }
318
319
 
320
}
321
322
 
323
					   GLuint dst, GLuint src )
324
{
325
   LOCALVARS
326
      struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
327
328
 
329
      COPY_4FV( GET_COLOR(VB->BackfaceColorPtr, dst),
330
		GET_COLOR(VB->BackfaceColorPtr, src) );
331
332
 
333
	 COPY_4FV( GET_COLOR(VB->BackfaceSecondaryColorPtr, dst),
334
		   GET_COLOR(VB->BackfaceSecondaryColorPtr, src) );
335
      }
336
   }
337
338
 
339
}
340
341
 
342
 
343
#undef GET_COLOR
344
345
 
346
#undef TAG
347