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();
|
---|
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( GLfloat r, GLfloat g, GLfloat b )
|
---|
73 | {
|
---|
74 | crStateColor4f(r, g, b, 1.0F);
|
---|
75 | }
|
---|
76 |
|
---|
77 | void STATE_APIENTRY crStateColor3fv( const GLfloat *color )
|
---|
78 | {
|
---|
79 | crStateColor4f( color[0], color[1], color[2], 1.0F );
|
---|
80 | }
|
---|
81 |
|
---|
82 | void STATE_APIENTRY crStateColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
|
---|
83 | {
|
---|
84 | CRContext *g = GetCurrentContext();
|
---|
85 | CRCurrentState *c = &(g->current);
|
---|
86 | CRStateBits *sb = GetCurrentBits();
|
---|
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( const GLfloat *color )
|
---|
101 | {
|
---|
102 | crStateColor4f( 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 | crMemset(&(current->c.index), 0, sizeof(GLindex_p));
|
---|
114 | crMemset(&(current->c.vertexAttrib), 0, sizeof(GLvertexattrib_p));
|
---|
115 | crMemset(&(current->c.fogCoord), 0, sizeof(GLfogcoord_p));
|
---|
116 | crMemset(&(current->c.edgeFlag), 0, sizeof(GLedgeflag_p));
|
---|
117 | crMemset(&(current->c.normal), 0, sizeof(GLnormal_p));
|
---|
118 | crMemset(&(current->c.color), 0, sizeof(GLcolor_p));
|
---|
119 | crMemset(&(current->c.secondaryColor), 0, sizeof(GLsecondarycolor_p));
|
---|
120 | crMemset(&(current->c.texCoord), 0, sizeof(GLtexcoord_p));
|
---|
121 | /*
|
---|
122 | current->attribsUsedMask = 0;
|
---|
123 | */
|
---|
124 | }
|
---|
125 |
|
---|
126 | void STATE_APIENTRY crStateBegin( GLenum mode )
|
---|
127 | {
|
---|
128 | CRContext *g = GetCurrentContext();
|
---|
129 | CRCurrentState *c = &(g->current);
|
---|
130 |
|
---|
131 | if (mode > GL_POLYGON)
|
---|
132 | {
|
---|
133 | crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Begin called with invalid mode: %d", mode);
|
---|
134 | return;
|
---|
135 | }
|
---|
136 |
|
---|
137 | if (c->inBeginEnd)
|
---|
138 | {
|
---|
139 | crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glBegin called inside Begin/End");
|
---|
140 | return;
|
---|
141 | }
|
---|
142 |
|
---|
143 | c->attribsUsedMask = 0;
|
---|
144 | c->inBeginEnd = GL_TRUE;
|
---|
145 | c->mode = mode;
|
---|
146 | c->beginEndNum++;
|
---|
147 | }
|
---|
148 |
|
---|
149 | void STATE_APIENTRY crStateEnd( void )
|
---|
150 | {
|
---|
151 | CRContext *g = GetCurrentContext();
|
---|
152 | CRCurrentState *c = &(g->current);
|
---|
153 |
|
---|
154 | if (!c->inBeginEnd)
|
---|
155 | {
|
---|
156 | crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glEnd called outside Begin/End" );
|
---|
157 | return;
|
---|
158 | }
|
---|
159 |
|
---|
160 | c->inBeginEnd = GL_FALSE;
|
---|
161 | }
|
---|
162 |
|
---|
163 | void crStateCurrentSwitch( CRCurrentBits *c, CRbitvalue *bitID,
|
---|
164 | CRContext *fromCtx, CRContext *toCtx )
|
---|
165 | {
|
---|
166 | const CRCurrentState *from = &(fromCtx->current);
|
---|
167 | const CRCurrentState *to = &(toCtx->current);
|
---|
168 | const GLuint maxTextureUnits = fromCtx->limits.maxTextureUnits;
|
---|
169 | unsigned int i, j;
|
---|
170 | CRbitvalue nbitID[CR_MAX_BITARRAY];
|
---|
171 |
|
---|
172 | for (j=0;j<CR_MAX_BITARRAY;j++)
|
---|
173 | nbitID[j] = ~bitID[j];
|
---|
174 |
|
---|
175 | if (CHECKDIRTY(c->rasterPos, bitID)) {
|
---|
176 | if (to->rasterValid) {
|
---|
177 | const GLfloat fromX = from->rasterAttrib[VERT_ATTRIB_POS][0];
|
---|
178 | const GLfloat fromY = from->rasterAttrib[VERT_ATTRIB_POS][1];
|
---|
179 | const GLfloat fromZ = from->rasterAttrib[VERT_ATTRIB_POS][2];
|
---|
180 | const GLfloat toX = to->rasterAttrib[VERT_ATTRIB_POS][0];
|
---|
181 | const GLfloat toY = to->rasterAttrib[VERT_ATTRIB_POS][1];
|
---|
182 | const GLfloat toZ = to->rasterAttrib[VERT_ATTRIB_POS][2];
|
---|
183 | if (toX != fromX || toY != fromY || toZ != fromZ) {
|
---|
184 | /* Use glWindowPos (which updates raster color) */
|
---|
185 | diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]);
|
---|
186 | FILLDIRTY(c->rasterPos);
|
---|
187 | FILLDIRTY(c->dirty);
|
---|
188 | }
|
---|
189 | }
|
---|
190 | CLEARDIRTY(c->rasterPos, nbitID);
|
---|
191 | }
|
---|
192 |
|
---|
193 | /* Vertex Current State Switch Code */
|
---|
194 |
|
---|
195 | /* Its important that we don't do a value check here because
|
---|
196 | ** current may not actaully have the correct values, I think...
|
---|
197 | ** We also need to restore the current state tracking pointer
|
---|
198 | ** since the packing functions will set it.
|
---|
199 | */
|
---|
200 |
|
---|
201 | if (CHECKDIRTY(c->colorIndex, bitID)) {
|
---|
202 | if (to->colorIndex != from->colorIndex) {
|
---|
203 | diff_api.Indexf(to->colorIndex);
|
---|
204 | FILLDIRTY(c->colorIndex);
|
---|
205 | FILLDIRTY(c->dirty);
|
---|
206 | }
|
---|
207 | CLEARDIRTY(c->colorIndex, nbitID);
|
---|
208 | }
|
---|
209 |
|
---|
210 | if (CHECKDIRTY(c->edgeFlag, bitID)) {
|
---|
211 | if (to->edgeFlag != from->edgeFlag) {
|
---|
212 | diff_api.EdgeFlag(to->edgeFlag);
|
---|
213 | FILLDIRTY(c->edgeFlag);
|
---|
214 | FILLDIRTY(c->dirty);
|
---|
215 | }
|
---|
216 | CLEARDIRTY(c->edgeFlag, nbitID);
|
---|
217 | }
|
---|
218 |
|
---|
219 | /* If using a vertex program, update the generic vertex attributes,
|
---|
220 | * which may or may not be aliased with conventional attributes.
|
---|
221 | */
|
---|
222 | #if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_progra)
|
---|
223 | if (toCtx->program.vpEnabled &&
|
---|
224 | (toCtx->extensions.ARB_vertex_program ||
|
---|
225 | (toCtx->extensions.NV_vertex_program))) {
|
---|
226 | const unsigned attribsUsedMask = toCtx->current.attribsUsedMask;
|
---|
227 | for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { /* skip zero */
|
---|
228 | if ((attribsUsedMask & (1 << i))
|
---|
229 | && CHECKDIRTY(c->vertexAttrib[i], bitID)) {
|
---|
230 | if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) {
|
---|
231 | diff_api.VertexAttrib4fvARB(i, &(to->vertexAttrib[i][0]));
|
---|
232 | FILLDIRTY(c->vertexAttrib[i]);
|
---|
233 | FILLDIRTY(c->dirty);
|
---|
234 | }
|
---|
235 | CLEARDIRTY(c->vertexAttrib[i], nbitID);
|
---|
236 | }
|
---|
237 | }
|
---|
238 | }
|
---|
239 | /* Fall-through so that attributes which don't have their bit set in the
|
---|
240 | * attribsUsedMask get handled via the conventional attribute functions.
|
---|
241 | */
|
---|
242 | #endif
|
---|
243 |
|
---|
244 | {
|
---|
245 | /* use conventional attribute functions */
|
---|
246 |
|
---|
247 | /* NEED TO FIX THIS!!!!!! */
|
---|
248 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) {
|
---|
249 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttrib[VERT_ATTRIB_COLOR0])) {
|
---|
250 | diff_api.Color4fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR0]));
|
---|
251 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0]);
|
---|
252 | FILLDIRTY(c->dirty);
|
---|
253 | }
|
---|
254 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], nbitID);
|
---|
255 | }
|
---|
256 |
|
---|
257 | /* NEED TO FIX THIS, ALSO?!!!!! */
|
---|
258 | #ifdef CR_EXT_secondary_color
|
---|
259 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) {
|
---|
260 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttrib[VERT_ATTRIB_COLOR1])) {
|
---|
261 | diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR1]));
|
---|
262 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1]);
|
---|
263 | FILLDIRTY(c->dirty);
|
---|
264 | }
|
---|
265 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], nbitID);
|
---|
266 | }
|
---|
267 | #endif
|
---|
268 |
|
---|
269 | /* NEED TO FIX THIS, ALSO?!!!!! */
|
---|
270 | #ifdef CR_EXT_fog_coord
|
---|
271 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) {
|
---|
272 | if (from->vertexAttrib[VERT_ATTRIB_FOG][0] != to->vertexAttrib[VERT_ATTRIB_FOG][0] ) {
|
---|
273 | diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_FOG][0] ));
|
---|
274 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG]);
|
---|
275 | FILLDIRTY(c->dirty);
|
---|
276 | }
|
---|
277 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], nbitID);
|
---|
278 | }
|
---|
279 | #endif
|
---|
280 |
|
---|
281 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) {
|
---|
282 | if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttrib[VERT_ATTRIB_NORMAL])) {
|
---|
283 | diff_api.Normal3fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_NORMAL][0]));
|
---|
284 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL]);
|
---|
285 | FILLDIRTY(c->dirty);
|
---|
286 | }
|
---|
287 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], nbitID);
|
---|
288 | }
|
---|
289 |
|
---|
290 | for (i = 0; i < maxTextureUnits; i++) {
|
---|
291 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) {
|
---|
292 | if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) {
|
---|
293 | diff_api.MultiTexCoord4fvARB (i+GL_TEXTURE0_ARB, (GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_TEX0+ i][0]));
|
---|
294 | FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i]);
|
---|
295 | FILLDIRTY(c->dirty);
|
---|
296 | }
|
---|
297 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], nbitID);
|
---|
298 | }
|
---|
299 | }
|
---|
300 | }
|
---|
301 |
|
---|
302 | CLEARDIRTY(c->dirty, nbitID);
|
---|
303 | }
|
---|
304 |
|
---|
305 | void
|
---|
306 | crStateCurrentDiff( CRCurrentBits *c, CRbitvalue *bitID,
|
---|
307 | CRContext *fromCtx, CRContext *toCtx )
|
---|
308 | {
|
---|
309 | CRCurrentState *from = &(fromCtx->current);
|
---|
310 | const CRCurrentState *to = &(toCtx->current);
|
---|
311 | unsigned int i, j;
|
---|
312 | CRbitvalue nbitID[CR_MAX_BITARRAY];
|
---|
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 | 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 | 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 | 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 | int i;
|
---|
375 | for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { /* skip zero */
|
---|
376 | if ((attribsUsedMask & (1 << i))
|
---|
377 | && CHECKDIRTY(c->vertexAttrib[i], bitID)) {
|
---|
378 | if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) {
|
---|
379 | diff_api.VertexAttrib4fvARB(i, &(to->vertexAttribPre[i][0]));
|
---|
380 | }
|
---|
381 | COPY_4V(from->vertexAttrib[i] , to->vertexAttrib[i]);
|
---|
382 | CLEARDIRTY(c->vertexAttrib[i], nbitID);
|
---|
383 | }
|
---|
384 | }
|
---|
385 | }
|
---|
386 | /* Fall-through so that attributes which don't have their bit set in the
|
---|
387 | * attribsUsedMask get handled via the conventional attribute functions.
|
---|
388 | */
|
---|
389 | #endif
|
---|
390 |
|
---|
391 | {
|
---|
392 | /* use conventional attribute functions */
|
---|
393 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) {
|
---|
394 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttribPre[VERT_ATTRIB_COLOR0])) {
|
---|
395 | diff_api.Color4fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR0]));
|
---|
396 | }
|
---|
397 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR0] , to->vertexAttrib[VERT_ATTRIB_COLOR0]);
|
---|
398 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], nbitID);
|
---|
399 | }
|
---|
400 |
|
---|
401 | #ifdef CR_EXT_secondary_color
|
---|
402 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) {
|
---|
403 | if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttribPre[VERT_ATTRIB_COLOR1])) {
|
---|
404 | diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR1]));
|
---|
405 | }
|
---|
406 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR1] , to->vertexAttrib[VERT_ATTRIB_COLOR1]);
|
---|
407 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], nbitID);
|
---|
408 | }
|
---|
409 | #endif
|
---|
410 |
|
---|
411 | #ifdef CR_EXT_fog_coord
|
---|
412 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) {
|
---|
413 | if (from->vertexAttrib[VERT_ATTRIB_FOG] != to->vertexAttribPre[VERT_ATTRIB_FOG]) {
|
---|
414 | diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_FOG]));
|
---|
415 | }
|
---|
416 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_FOG] , to->vertexAttrib[VERT_ATTRIB_FOG]);
|
---|
417 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], nbitID);
|
---|
418 | }
|
---|
419 | #endif
|
---|
420 |
|
---|
421 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) {
|
---|
422 | if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttribPre[VERT_ATTRIB_NORMAL])) {
|
---|
423 | diff_api.Normal3fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_NORMAL]));
|
---|
424 | }
|
---|
425 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_NORMAL] , to->vertexAttrib[VERT_ATTRIB_NORMAL]);
|
---|
426 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], nbitID);
|
---|
427 | }
|
---|
428 |
|
---|
429 | for ( i = 0 ; i < fromCtx->limits.maxTextureUnits ; i++)
|
---|
430 | {
|
---|
431 | if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) {
|
---|
432 | if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) {
|
---|
433 | diff_api.MultiTexCoord4fvARB (GL_TEXTURE0_ARB + i, (GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_TEX0 + i]));
|
---|
434 | }
|
---|
435 | COPY_4V(from->vertexAttrib[VERT_ATTRIB_TEX0 + i] , to->vertexAttrib[VERT_ATTRIB_TEX0 + i]);
|
---|
436 | CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], nbitID);
|
---|
437 | }
|
---|
438 | }
|
---|
439 | }
|
---|
440 |
|
---|
441 | CLEARDIRTY(c->dirty, nbitID);
|
---|
442 | }
|
---|