1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "cr_mem.h"
|
---|
8 | #include "state.h"
|
---|
9 | #include "state_internals.h"
|
---|
10 |
|
---|
11 | /*
|
---|
12 | * Note: regardless of GL_NV_vertex_program, we store all per-vertex
|
---|
13 | * attributes in an array now, instead of specially named attributes
|
---|
14 | * like color, normal, texcoord, etc.
|
---|
15 | */
|
---|
16 |
|
---|
17 |
|
---|
18 | void crStateCurrentInit( CRContext *ctx )
|
---|
19 | {
|
---|
20 | CRCurrentState *c = &ctx->current;
|
---|
21 | CRStateBits *sb = GetCurrentBits(ctx->pStateTracker);
|
---|
22 | CRCurrentBits *cb = &(sb->current);
|
---|
23 | static const GLfloat default_normal[4] = {0.0f, 0.0f, 1.0f, 1.0f};
|
---|
24 | static const GLfloat default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
---|
25 | static const GLfloat default_secondaryColor[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
---|
26 | static const GLfloat default_attrib[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
---|
27 | unsigned int i;
|
---|
28 |
|
---|
29 | /*
|
---|
30 | * initialize all vertex attributes to <0,0,0,1> for starters
|
---|
31 | */
|
---|
32 | for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) {
|
---|
33 | COPY_4V(c->vertexAttrib[i], default_attrib);
|
---|
34 | COPY_4V(c->vertexAttribPre[i], default_attrib);
|
---|
35 | }
|
---|
36 | /* now re-do the exceptions */
|
---|
37 | COPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], default_color);
|
---|
38 | COPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1], default_secondaryColor);
|
---|
39 | COPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], default_normal);
|
---|
40 |
|
---|
41 | c->rasterIndex = 1.0f;
|
---|
42 | c->colorIndex = c->colorIndexPre = 1.0;
|
---|
43 | c->edgeFlag = c->edgeFlagPre = GL_TRUE;
|
---|
44 |
|
---|
45 | /* Set the "pre" values and raster position attributes */
|
---|
46 | for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) {
|
---|
47 | COPY_4V(c->vertexAttribPre[i], c->vertexAttrib[i]);
|
---|
48 | COPY_4V(c->rasterAttrib[i], c->vertexAttrib[i]);
|
---|
49 | COPY_4V(c->rasterAttribPre[i], c->vertexAttrib[i]);
|
---|
50 | }
|
---|
51 |
|
---|
52 | c->rasterValid = GL_TRUE;
|
---|
53 |
|
---|
54 | c->inBeginEnd = GL_FALSE;
|
---|
55 | c->beginEndNum = 0;
|
---|
56 | /*c->beginEndMax = cfg->beginend_max;*/
|
---|
57 | c->mode = 0x10; /* Undefined Mode */
|
---|
58 | c->flushOnEnd = 0;
|
---|
59 |
|
---|
60 | c->current = 0; /* picked up by crStateSetCurrentPointers() */
|
---|
61 |
|
---|
62 | /* init dirty bits */
|
---|
63 | RESET(cb->dirty, ctx->bitid);
|
---|
64 | for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) {
|
---|
65 | RESET(cb->vertexAttrib[i], ctx->bitid);
|
---|
66 | }
|
---|
67 | RESET(cb->edgeFlag, ctx->bitid);
|
---|
68 | RESET(cb->colorIndex, ctx->bitid);
|
---|
69 | RESET(cb->rasterPos, ctx->bitid);
|
---|
70 | }
|
---|
71 |
|
---|
72 | void STATE_APIENTRY crStateColor3f(PCRStateTracker pState, GLfloat r, GLfloat g, GLfloat b )
|
---|
73 | {
|
---|
74 | crStateColor4f(pState, r, g, b, 1.0F);
|
---|
75 | }
|
---|
76 |
|
---|
77 | void STATE_APIENTRY crStateColor3fv(PCRStateTracker pState, const GLfloat *color )
|
---|
78 | {
|
---|
79 | crStateColor4f(pState, color[0], color[1], color[2], 1.0F );
|
---|
80 | }
|
---|
81 |
|
---|
82 | void STATE_APIENTRY crStateColor4f(PCRStateTracker pState, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
|
---|
83 | {
|
---|
84 | CRContext *g = GetCurrentContext(pState);
|
---|
85 | CRCurrentState *c = &(g->current);
|
---|
86 | CRStateBits *sb = GetCurrentBits(pState);
|
---|
87 | CRCurrentBits *cb = &(sb->current);
|
---|
88 |
|
---|
89 | FLUSH();
|
---|
90 |
|
---|
91 | c->vertexAttrib[VERT_ATTRIB_COLOR0][0] = red;
|
---|
92 | c->vertexAttrib[VERT_ATTRIB_COLOR0][1] = green;
|
---|
93 | c->vertexAttrib[VERT_ATTRIB_COLOR0][2] = blue;
|
---|
94 | c->vertexAttrib[VERT_ATTRIB_COLOR0][3] = alpha;
|
---|
95 |
|
---|
96 | DIRTY(cb->dirty, g->neg_bitid);
|
---|
97 | DIRTY(cb->vertexAttrib[VERT_ATTRIB_COLOR0], g->neg_bitid);
|
---|
98 | }
|
---|
99 |
|
---|
100 | void STATE_APIENTRY crStateColor4fv(PCRStateTracker pState, const GLfloat *color )
|
---|
101 | {
|
---|
102 | crStateColor4f(pState, color[0], color[1], color[2], color[3] );
|
---|
103 | }
|
---|
104 |
|
---|
105 | void crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current )
|
---|
106 | {
|
---|
107 | CRCurrentState *c = &(ctx->current);
|
---|
108 | c->current = current;
|
---|
109 | }
|
---|
110 |
|
---|
111 | void crStateResetCurrentPointers( CRCurrentStatePointers *current )
|
---|
112 | {
|
---|
113 | uint32_t attribsUsedMask = current->attribsUsedMask;
|
---|
114 |
|
---|
115 | crMemset(current, 0, sizeof (*current));
|
---|
116 |
|
---|
117 | current->attribsUsedMask = attribsUsedMask;
|
---|
118 | }
|
---|
119 |
|
---|
120 | void STATE_APIENTRY crStateBegin(PCRStateTracker pState, GLenum mode )
|
---|
121 | {
|
---|
122 | CRContext *g = GetCurrentContext(pState);
|
---|
123 | CRCurrentState *c = &(g->current);
|
---|
124 |
|
---|
125 | if (mode > GL_POLYGON)
|
---|
126 | {
|
---|
127 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM, "Begin called with invalid mode: %d", mode);
|
---|
128 | return;
|
---|
129 | }
|
---|
130 |
|
---|
131 | if (c->inBeginEnd)
|
---|
132 | {
|
---|
133 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glBegin called inside Begin/End");
|
---|
134 | return;
|
---|
135 | }
|
---|
136 |
|
---|
137 | c->attribsUsedMask = 0;
|
---|
138 | c->inBeginEnd = GL_TRUE;
|
---|
139 | c->mode = mode;
|
---|
140 | c->beginEndNum++;
|
---|
141 | }
|
---|
142 |
|
---|
143 | void STATE_APIENTRY crStateEnd(PCRStateTracker pState)
|
---|
144 | {
|
---|
145 | CRContext *g = GetCurrentContext(pState);
|
---|
146 | CRCurrentState *c = &(g->current);
|
---|
147 |
|
---|
148 | if (!c->inBeginEnd)
|
---|
149 | {
|
---|
150 | crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION, "glEnd called outside Begin/End" );
|
---|
151 | return;
|
---|
152 | }
|
---|
153 |
|
---|
154 | c->inBeginEnd = GL_FALSE;
|
---|
155 | }
|
---|
156 |
|
---|
157 | void crStateCurrentSwitch( CRCurrentBits *c, CRbitvalue *bitID,
|
---|
158 | CRContext *fromCtx, CRContext *toCtx )
|
---|
159 | {
|
---|
160 | PCRStateTracker pState = fromCtx->pStateTracker;
|
---|
161 | const CRCurrentState *from = &(fromCtx->current);
|
---|
162 | const CRCurrentState *to = &(toCtx->current);
|
---|
163 | const GLuint maxTextureUnits = fromCtx->limits.maxTextureUnits;
|
---|
164 | unsigned int i, j;
|
---|
165 | CRbitvalue nbitID[CR_MAX_BITARRAY];
|
---|
166 |
|
---|
167 | CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
|
---|
168 |
|
---|
169 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
170 | nbitID[j] = ~bitID[j];
|
---|
171 |
|
---|
172 | if (CHECKDIRTY(c->rasterPos, bitID)) {
|
---|
173 | if (to->rasterValid) {
|
---|
174 | const GLfloat fromX = from->rasterAttrib[VERT_ATTRIB_POS][0];
|
---|
175 | const GLfloat fromY = from->rasterAttrib[VERT_ATTRIB_POS][1];
|
---|
176 | const GLfloat fromZ = from->rasterAttrib[VERT_ATTRIB_POS][2];
|
---|
177 | const GLfloat toX = to->rasterAttrib[VERT_ATTRIB_POS][0];
|
---|
178 | const GLfloat toY = to->rasterAttrib[VERT_ATTRIB_POS][1];
|
---|
179 | const GLfloat toZ = to->rasterAttrib[VERT_ATTRIB_POS][2];
|
---|
180 | if (toX != fromX || toY != fromY || toZ != fromZ) {
|
---|
181 | /* Use glWindowPos (which updates raster color) */
|
---|
182 | pState->diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
|
---|
183 | FILLDIRTY(c->rasterPos);
|
---|
184 | FILLDIRTY(c->dirty);
|
---|
185 | }
|
---|
186 | }
|
---|
187 | CLEARDIRTY(c->rasterPos, nbitID);
|
---|
188 | }
|
---|
189 |
|
---|
190 | /* Vertex Current State Switch Code */
|
---|
191 |
|
---|
192 | /* Its important that we don't do a value check here because
|
---|
193 | ** current may not actually have the correct values, I think...
|
---|
194 | ** We also need to restore the current state tracking pointer
|
---|
195 | ** since the packing functions will set it.
|
---|
196 | */
|
---|
197 |
|
---|
198 | if (CHECKDIRTY(c->colorIndex, bitID)) {
|
---|
199 | if (to->colorIndex != from->colorIndex) {
|
---|
200 | pState->diff_api.Indexf(to->colorIndex);
|
---|
201 | FILLDIRTY(c->colorIndex);
|
---|
202 | FILLDIRTY(c->dirty);
|
---|
203 | }
|
---|
204 | CLEARDIRTY(c->colorIndex, nbitID);
|
---|
205 | }
|
---|
206 |
|
---|
207 | if (CHECKDIRTY(c->edgeFlag, bitID)) {
|
---|
208 | if (to->edgeFlag != from->edgeFlag) {
|
---|
209 | pState->diff_api.EdgeFlag(to->edgeFlag);
|
---|
210 | FILLDIRTY(c->edgeFlag);
|
---|
211 | FILLDIRTY(c->dirty);
|
---|
212 | }
|
---|
213 | CLEARDIRTY(c->edgeFlag, nbitID);
|
---|
214 | }
|
---|
215 |
|
---|
216 | /* If using a vertex program, update the generic vertex attributes,
|
---|
217 | * which may or may not be aliased with conventional attributes.
|
---|
218 | */
|
---|
219 | #if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_progra)
|
---|
220 | if (toCtx->program.vpEnabled &&
|
---|
221 | (toCtx->extensions.ARB_vertex_program ||
|
---|
222 | (toCtx->extensions.NV_vertex_program))) {
|
---|
223 | const unsigned attribsUsedMask = toCtx->current.attribsUsedMask;
|
---|
224 | for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { /* skip zero */
|
---|
225 | if ((attribsUsedMask & (1 << i))
|
---|
226 | && CHECKDIRTY(c->vertexAttrib[i], bitID)) {
|
---|
227 | if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) {
|
---|
228 | pState->diff_api.VertexAttrib4fvARB(i, &(to->vertexAttrib[i][0]));
|
---|
229 | FILLDIRTY(c->vertexAttrib[i]);
|
---|
230 | FILLDIRTY(c->dirty);
|
---|
231 | }
|
---|
232 | CLEARDIRTY(c->vertexAttrib[i], nbitID);
|
---|
233 | }
|
---|
234 | }
|
---|
235 | }
|
---|
236 | /* Fall-through so that attributes which don't have their bit set in the
|
---|
237 | * attribsUsedMask get handled via the conventional attribute functions.
|
---|
238 | */
|
---|
239 | #endif
|
---|
240 |
|
---|
241 | {
|
---|
242 | /* use conventional attribute functions */
|
---|
243 |
|
---|
244 | /* NEED TO FIX THIS!!!!!! */
|
---|
245 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) {
|
---|
246 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttrib[VERT_ATTRIB_COLOR0])) {
|
---|
247 | pState->diff_api.Color4fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR0]));
|
---|
248 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0]);
|
---|
249 | FILLDIRTY(c->dirty);
|
---|
250 | }
|
---|
251 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], nbitID);
|
---|
252 | }
|
---|
253 |
|
---|
254 | /* NEED TO FIX THIS, ALSO?!!!!! */
|
---|
255 | #ifdef CR_EXT_secondary_color
|
---|
256 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) {
|
---|
257 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttrib[VERT_ATTRIB_COLOR1])) {
|
---|
258 | pState->diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR1]));
|
---|
259 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1]);
|
---|
260 | FILLDIRTY(c->dirty);
|
---|
261 | }
|
---|
262 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], nbitID);
|
---|
263 | }
|
---|
264 | #endif
|
---|
265 |
|
---|
266 | /* NEED TO FIX THIS, ALSO?!!!!! */
|
---|
267 | #ifdef CR_EXT_fog_coord
|
---|
268 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) {
|
---|
269 | if (from->vertexAttrib[VERT_ATTRIB_FOG][0] != to->vertexAttrib[VERT_ATTRIB_FOG][0] ) {
|
---|
270 | pState->diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_FOG][0] ));
|
---|
271 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG]);
|
---|
272 | FILLDIRTY(c->dirty);
|
---|
273 | }
|
---|
274 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], nbitID);
|
---|
275 | }
|
---|
276 | #endif
|
---|
277 |
|
---|
278 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) {
|
---|
279 | if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttrib[VERT_ATTRIB_NORMAL])) {
|
---|
280 | pState->diff_api.Normal3fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_NORMAL][0]));
|
---|
281 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL]);
|
---|
282 | FILLDIRTY(c->dirty);
|
---|
283 | }
|
---|
284 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], nbitID);
|
---|
285 | }
|
---|
286 |
|
---|
287 | for (i = 0; i < maxTextureUnits; i++) {
|
---|
288 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) {
|
---|
289 | if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) {
|
---|
290 | pState->diff_api.MultiTexCoord4fvARB (i+GL_TEXTURE0_ARB, (GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_TEX0+ i][0]));
|
---|
291 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i]);
|
---|
292 | FILLDIRTY(c->dirty);
|
---|
293 | }
|
---|
294 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], nbitID);
|
---|
295 | }
|
---|
296 | }
|
---|
297 | }
|
---|
298 |
|
---|
299 | CLEARDIRTY(c->dirty, nbitID);
|
---|
300 | }
|
---|
301 |
|
---|
302 | void
|
---|
303 | crStateCurrentDiff( CRCurrentBits *c, CRbitvalue *bitID,
|
---|
304 | CRContext *fromCtx, CRContext *toCtx )
|
---|
305 | {
|
---|
306 | PCRStateTracker pState = fromCtx->pStateTracker;
|
---|
307 | CRCurrentState *from = &(fromCtx->current);
|
---|
308 | const CRCurrentState *to = &(toCtx->current);
|
---|
309 | unsigned int i, j;
|
---|
310 | CRbitvalue nbitID[CR_MAX_BITARRAY];
|
---|
311 |
|
---|
312 | CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
|
---|
313 |
|
---|
314 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
315 | nbitID[j] = ~bitID[j];
|
---|
316 |
|
---|
317 | if (CHECKDIRTY(c->rasterPos, bitID)) {
|
---|
318 | from->rasterValid = to->rasterValid;
|
---|
319 | if (to->rasterValid) {
|
---|
320 | const GLfloat fromX = from->rasterAttrib[VERT_ATTRIB_POS][0];
|
---|
321 | const GLfloat fromY = from->rasterAttrib[VERT_ATTRIB_POS][1];
|
---|
322 | const GLfloat fromZ = from->rasterAttrib[VERT_ATTRIB_POS][2];
|
---|
323 | const GLfloat toX = to->rasterAttrib[VERT_ATTRIB_POS][0];
|
---|
324 | const GLfloat toY = to->rasterAttrib[VERT_ATTRIB_POS][1];
|
---|
325 | const GLfloat toZ = to->rasterAttrib[VERT_ATTRIB_POS][2];
|
---|
326 | if (toX != fromX || toY != fromY || toZ != fromZ) {
|
---|
327 | /* Use glWindowPos (which updates raster color) */
|
---|
328 | pState->diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
|
---|
329 | from->rasterAttrib[VERT_ATTRIB_POS][0] = toX;
|
---|
330 | from->rasterAttrib[VERT_ATTRIB_POS][1] = toY;
|
---|
331 | from->rasterAttrib[VERT_ATTRIB_POS][2] = toZ;
|
---|
332 | }
|
---|
333 | }
|
---|
334 | CLEARDIRTY(c->rasterPos, nbitID);
|
---|
335 | }
|
---|
336 |
|
---|
337 | /* Vertex Current State Sync Code */
|
---|
338 | /* Some things to note here:
|
---|
339 | ** 1) Compare is done against the pre value since the
|
---|
340 | ** current value includes the geometry info.
|
---|
341 | ** 2) Update is done with the current value since
|
---|
342 | ** the server will be getting the geometry block
|
---|
343 | ** 3) Copy is done outside of the compare to ensure
|
---|
344 | ** that it happens.
|
---|
345 | */
|
---|
346 |
|
---|
347 | /* edge flag */
|
---|
348 | if (CHECKDIRTY(c->edgeFlag, bitID)) {
|
---|
349 | if (from->edgeFlag != to->edgeFlagPre) {
|
---|
350 | pState->diff_api.EdgeFlag (to->edgeFlagPre);
|
---|
351 | }
|
---|
352 | from->edgeFlag = to->edgeFlag;
|
---|
353 | CLEARDIRTY(c->edgeFlag, nbitID);
|
---|
354 | }
|
---|
355 |
|
---|
356 | /* color index */
|
---|
357 | if (CHECKDIRTY(c->colorIndex, bitID)) {
|
---|
358 | if (from->colorIndex != to->colorIndexPre) {
|
---|
359 | pState->diff_api.Indexf (to->colorIndex);
|
---|
360 | }
|
---|
361 | from->colorIndex = to->colorIndex;
|
---|
362 | CLEARDIRTY(c->colorIndex, nbitID);
|
---|
363 | }
|
---|
364 |
|
---|
365 |
|
---|
366 | /* If using a vertex program, update the generic vertex attributes,
|
---|
367 | * which may or may not be aliased with conventional attributes.
|
---|
368 | */
|
---|
369 | #if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_progra)
|
---|
370 | if (toCtx->program.vpEnabled &&
|
---|
371 | (toCtx->extensions.ARB_vertex_program ||
|
---|
372 | (toCtx->extensions.NV_vertex_program))) {
|
---|
373 | const unsigned attribsUsedMask = toCtx->current.attribsUsedMask;
|
---|
374 | for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { /* skip zero */
|
---|
375 | if ((attribsUsedMask & (1 << i))
|
---|
376 | && CHECKDIRTY(c->vertexAttrib[i], bitID)) {
|
---|
377 | if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) {
|
---|
378 | pState->diff_api.VertexAttrib4fvARB(i, &(to->vertexAttribPre[i][0]));
|
---|
379 | }
|
---|
380 | COPY_4V(from->vertexAttrib[i] , to->vertexAttrib[i]);
|
---|
381 | CLEARDIRTY(c->vertexAttrib[i], nbitID);
|
---|
382 | }
|
---|
383 | }
|
---|
384 | }
|
---|
385 | /* Fall-through so that attributes which don't have their bit set in the
|
---|
386 | * attribsUsedMask get handled via the conventional attribute functions.
|
---|
387 | */
|
---|
388 | #endif
|
---|
389 |
|
---|
390 | {
|
---|
391 | /* use conventional attribute functions */
|
---|
392 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) {
|
---|
393 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttribPre[VERT_ATTRIB_COLOR0])) {
|
---|
394 | pState->diff_api.Color4fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR0]));
|
---|
395 | }
|
---|
396 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR0] , to->vertexAttrib[VERT_ATTRIB_COLOR0]);
|
---|
397 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], nbitID);
|
---|
398 | }
|
---|
399 |
|
---|
400 | #ifdef CR_EXT_secondary_color
|
---|
401 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) {
|
---|
402 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttribPre[VERT_ATTRIB_COLOR1])) {
|
---|
403 | pState->diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR1]));
|
---|
404 | }
|
---|
405 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR1] , to->vertexAttrib[VERT_ATTRIB_COLOR1]);
|
---|
406 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], nbitID);
|
---|
407 | }
|
---|
408 | #endif
|
---|
409 |
|
---|
410 | #ifdef CR_EXT_fog_coord
|
---|
411 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) {
|
---|
412 | if (from->vertexAttrib[VERT_ATTRIB_FOG] != to->vertexAttribPre[VERT_ATTRIB_FOG]) {
|
---|
413 | pState->diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_FOG]));
|
---|
414 | }
|
---|
415 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_FOG] , to->vertexAttrib[VERT_ATTRIB_FOG]);
|
---|
416 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], nbitID);
|
---|
417 | }
|
---|
418 | #endif
|
---|
419 |
|
---|
420 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) {
|
---|
421 | if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttribPre[VERT_ATTRIB_NORMAL])) {
|
---|
422 | pState->diff_api.Normal3fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_NORMAL]));
|
---|
423 | }
|
---|
424 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_NORMAL] , to->vertexAttrib[VERT_ATTRIB_NORMAL]);
|
---|
425 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], nbitID);
|
---|
426 | }
|
---|
427 |
|
---|
428 | for ( i = 0 ; i < fromCtx->limits.maxTextureUnits ; i++)
|
---|
429 | {
|
---|
430 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) {
|
---|
431 | if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) {
|
---|
432 | pState->diff_api.MultiTexCoord4fvARB (GL_TEXTURE0_ARB + i, (GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_TEX0 + i]));
|
---|
433 | }
|
---|
434 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_TEX0 + i] , to->vertexAttrib[VERT_ATTRIB_TEX0 + i]);
|
---|
435 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], nbitID);
|
---|
436 | }
|
---|
437 | }
|
---|
438 | }
|
---|
439 |
|
---|
440 | CLEARDIRTY(c->dirty, nbitID);
|
---|
441 | }
|
---|