1 /* $Id: t_dd_vb.c,v 1.8 2001/03/30 00:39:02 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Keith Whitwell <keithw@valinux.com>
30 #if (HAVE_HW_VIEWPORT)
31 #define UNVIEWPORT_VARS
32 #define UNVIEWPORT_X(x) x
33 #define UNVIEWPORT_Y(x) x
34 #define UNVIEWPORT_Z(x) x
41 /* These don't need to be duplicated, but there's currently nowhere
42 * really convenient to put them. Need to build some actual .o files in
45 static void copy_pv_rgba4_spec5( GLcontext
*ctx
, GLuint edst
, GLuint esrc
)
48 GLubyte
*verts
= GET_VERTEX_STORE();
49 GLuint shift
= GET_VERTEX_STRIDE_SHIFT();
50 GLuint
*dst
= (GLuint
*)(verts
+ (edst
<< shift
));
51 GLuint
*src
= (GLuint
*)(verts
+ (esrc
<< shift
));
56 static void copy_pv_rgba4( GLcontext
*ctx
, GLuint edst
, GLuint esrc
)
59 GLubyte
*verts
= GET_VERTEX_STORE();
60 GLuint shift
= GET_VERTEX_STRIDE_SHIFT();
61 GLuint
*dst
= (GLuint
*)(verts
+ (edst
<< shift
));
62 GLuint
*src
= (GLuint
*)(verts
+ (esrc
<< shift
));
66 static void copy_pv_rgba3( GLcontext
*ctx
, GLuint edst
, GLuint esrc
)
69 GLubyte
*verts
= GET_VERTEX_STORE();
70 GLuint shift
= GET_VERTEX_STRIDE_SHIFT();
71 GLuint
*dst
= (GLuint
*)(verts
+ (edst
<< shift
));
72 GLuint
*src
= (GLuint
*)(verts
+ (esrc
<< shift
));
77 void TAG(translate_vertex
)(GLcontext
*ctx
,
82 GLuint format
= GET_VERTEX_FORMAT();
83 GLfloat
*s
= ctx
->Viewport
._WindowMap
.m
;
86 if (format
== TINY_VERTEX_FORMAT
) {
87 if (HAVE_HW_VIEWPORT
) {
88 dst
->win
[0] = s
[0] * src
->v
.x
+ s
[12];
89 dst
->win
[1] = s
[5] * src
->v
.y
+ s
[13];
90 dst
->win
[2] = s
[10] * src
->v
.z
+ s
[14];
93 dst
->win
[0] = UNVIEWPORT_X( src
->v
.x
);
94 dst
->win
[1] = UNVIEWPORT_Y( src
->v
.y
);
95 dst
->win
[2] = UNVIEWPORT_Z( src
->v
.z
);
99 dst
->color
[0] = src
->tv
.color
.red
;
100 dst
->color
[1] = src
->tv
.color
.green
;
101 dst
->color
[2] = src
->tv
.color
.blue
;
102 dst
->color
[3] = src
->tv
.color
.alpha
;
105 GLfloat oow
= (HAVE_HW_DIVIDE
) ? 1.0 / src
->v
.w
: src
->v
.w
;
107 if (HAVE_HW_VIEWPORT
) {
108 if (HAVE_HW_DIVIDE
) {
109 dst
->win
[0] = s
[0] * src
->v
.x
* oow
+ s
[12];
110 dst
->win
[1] = s
[5] * src
->v
.y
* oow
+ s
[13];
111 dst
->win
[2] = s
[10] * src
->v
.z
* oow
+ s
[14];
114 dst
->win
[0] = s
[0] * src
->v
.x
+ s
[12];
115 dst
->win
[1] = s
[5] * src
->v
.y
+ s
[13];
116 dst
->win
[2] = s
[10] * src
->v
.z
+ s
[14];
120 dst
->win
[0] = UNVIEWPORT_X( src
->v
.x
);
121 dst
->win
[1] = UNVIEWPORT_Y( src
->v
.y
);
122 dst
->win
[2] = UNVIEWPORT_Z( src
->v
.z
);
126 dst
->color
[0] = src
->v
.color
.red
;
127 dst
->color
[1] = src
->v
.color
.green
;
128 dst
->color
[2] = src
->v
.color
.blue
;
129 dst
->color
[3] = src
->v
.color
.alpha
;
131 dst
->specular
[0] = src
->v
.specular
.red
;
132 dst
->specular
[1] = src
->v
.specular
.green
;
133 dst
->specular
[2] = src
->v
.specular
.blue
;
135 dst
->fog
= src
->v
.specular
.alpha
/255.0;
137 if (HAVE_PTEX_VERTICES
&&
138 ((HAVE_TEX2_VERTICES
&& format
== PROJ_TEX3_VERTEX_FORMAT
) ||
139 (format
== PROJ_TEX1_VERTEX_FORMAT
))) {
141 dst
->texcoord
[0][0] = src
->pv
.u0
;
142 dst
->texcoord
[0][1] = src
->pv
.v0
;
143 dst
->texcoord
[0][3] = src
->pv
.q0
;
145 dst
->texcoord
[1][0] = src
->pv
.u1
;
146 dst
->texcoord
[1][1] = src
->pv
.v1
;
147 dst
->texcoord
[1][3] = src
->pv
.q1
;
149 if (HAVE_TEX2_VERTICES
) {
150 dst
->texcoord
[2][0] = src
->pv
.u2
;
151 dst
->texcoord
[2][1] = src
->pv
.v2
;
152 dst
->texcoord
[2][3] = src
->pv
.q2
;
155 if (HAVE_TEX3_VERTICES
) {
156 dst
->texcoord
[3][0] = src
->pv
.u3
;
157 dst
->texcoord
[3][1] = src
->pv
.v3
;
158 dst
->texcoord
[3][3] = src
->pv
.q3
;
162 dst
->texcoord
[0][0] = src
->v
.u0
;
163 dst
->texcoord
[0][1] = src
->v
.v0
;
164 dst
->texcoord
[0][3] = 1.0;
166 dst
->texcoord
[1][0] = src
->v
.u1
;
167 dst
->texcoord
[1][1] = src
->v
.v1
;
168 dst
->texcoord
[1][3] = 1.0;
170 if (HAVE_TEX2_VERTICES
) {
171 dst
->texcoord
[2][0] = src
->v
.u2
;
172 dst
->texcoord
[2][1] = src
->v
.v2
;
173 dst
->texcoord
[2][3] = 1.0;
176 if (HAVE_TEX3_VERTICES
) {
177 dst
->texcoord
[3][0] = src
->v
.u3
;
178 dst
->texcoord
[3][1] = src
->v
.v3
;
179 dst
->texcoord
[3][3] = 1.0;
184 dst
->pointSize
= ctx
->Point
._Size
;
189 void TAG(print_vertex
)( GLcontext
*ctx
, const VERTEX
*v
)
192 GLuint format
= GET_VERTEX_FORMAT();
194 if (format
== TINY_VERTEX_FORMAT
) {
195 fprintf(stderr
, "x %f y %f z %f\n", v
->v
.x
, v
->v
.y
, v
->v
.z
);
196 fprintf(stderr
, "r %d g %d b %d a %d\n",
203 fprintf(stderr
, "x %f y %f z %f oow %f\n",
204 v
->v
.x
, v
->v
.y
, v
->v
.z
, v
->v
.w
);
205 fprintf(stderr
, "r %d g %d b %d a %d\n",
212 fprintf(stderr
, "\n");