void crStateMultisampleSwitch(CRMultisampleBits *b, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { CRMultisampleState *from = &(fromCtx->multisample); CRMultisampleState *to = &(toCtx->multisample); unsigned int j; CRbitvalue nbitID[CR_MAX_BITARRAY]; for (j=0;j<CR_MAX_BITARRAY;j++) nbitID[j] = ~bitID[j]; if (CHECKDIRTY(b->enable, bitID)) { glAble able[2]; able[0] = diff_api.Disable; able[1] = diff_api.Enable; if (from->enabled != to->enabled) { able[to->enabled](GL_MULTISAMPLE_ARB); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } if (from->sampleAlphaToCoverage != to->sampleAlphaToCoverage) { able[to->sampleAlphaToCoverage](GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } if (from->sampleAlphaToOne != to->sampleAlphaToOne) { able[to->sampleAlphaToOne](GL_SAMPLE_ALPHA_TO_ONE_ARB); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } if (from->sampleCoverage != to->sampleCoverage) { able[to->sampleCoverage](GL_SAMPLE_COVERAGE_ARB); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } CLEARDIRTY(b->enable, nbitID); } if (CHECKDIRTY(b->sampleCoverageValue, bitID)) { if (from->sampleCoverageValue != to->sampleCoverageValue || from->sampleCoverageInvert != to->sampleCoverageInvert) { diff_api.SampleCoverageARB (to->sampleCoverageValue, to->sampleCoverageInvert); FILLDIRTY(b->sampleCoverageValue); FILLDIRTY(b->dirty); } CLEARDIRTY(b->sampleCoverageValue, nbitID); } CLEARDIRTY(b->dirty, nbitID); }
void crStateLineSwitch(CRLineBits *b, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { CRLineState *from = &(fromCtx->line); CRLineState *to = &(toCtx->line); unsigned int j, i; CRbitvalue nbitID[CR_MAX_BITARRAY]; for (j=0;j<CR_MAX_BITARRAY;j++) nbitID[j] = ~bitID[j]; i = 0; /* silence compiler */ if (CHECKDIRTY(b->enable, bitID)) { glAble able[2]; able[0] = diff_api.Disable; able[1] = diff_api.Enable; if (from->lineSmooth != to->lineSmooth) { able[to->lineSmooth](GL_LINE_SMOOTH); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } if (from->lineStipple != to->lineStipple) { able[to->lineStipple](GL_LINE_STIPPLE); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } CLEARDIRTY(b->enable, nbitID); } if (CHECKDIRTY(b->width, bitID)) { if (from->width != to->width) { diff_api.LineWidth (to->width); FILLDIRTY(b->width); FILLDIRTY(b->dirty); } CLEARDIRTY(b->width, nbitID); } if (CHECKDIRTY(b->stipple, bitID)) { if (from->repeat != to->repeat || from->pattern != to->pattern) { diff_api.LineStipple (to->repeat, to->pattern); FILLDIRTY(b->stipple); FILLDIRTY(b->dirty); } CLEARDIRTY(b->stipple, nbitID); } CLEARDIRTY(b->dirty, nbitID); }
void crStateViewportSwitch(CRViewportBits *b, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { CRViewportState *from = &(fromCtx->viewport); CRViewportState *to = &(toCtx->viewport); unsigned int j, i; CRbitvalue nbitID[CR_MAX_BITARRAY]; for (j=0;j<CR_MAX_BITARRAY;j++) nbitID[j] = ~bitID[j]; i = 0; /* silence compiler */ if (CHECKDIRTY(b->enable, bitID)) { glAble able[2]; able[0] = diff_api.Disable; able[1] = diff_api.Enable; if (from->scissorTest != to->scissorTest) { able[to->scissorTest](GL_SCISSOR_TEST); FILLDIRTY(b->enable); FILLDIRTY(b->dirty); } CLEARDIRTY(b->enable, nbitID); } if (CHECKDIRTY(b->s_dims, bitID)) { if (from->scissorX != to->scissorX || from->scissorY != to->scissorY || from->scissorW != to->scissorW || from->scissorH != to->scissorH) { diff_api.Scissor (to->scissorX, to->scissorY, to->scissorW, to->scissorH); FILLDIRTY(b->s_dims); FILLDIRTY(b->dirty); } CLEARDIRTY(b->s_dims, nbitID); } if (CHECKDIRTY(b->v_dims, bitID)) { if (from->viewportX != to->viewportX || from->viewportY != to->viewportY || from->viewportW != to->viewportW || from->viewportH != to->viewportH) { diff_api.Viewport (to->viewportX, to->viewportY, to->viewportW, to->viewportH); FILLDIRTY(b->v_dims); FILLDIRTY(b->dirty); } CLEARDIRTY(b->v_dims, nbitID); } if (CHECKDIRTY(b->depth, bitID)) { if (from->nearClip != to->nearClip || from->farClip != to->farClip) { diff_api.DepthRange (to->nearClip, to->farClip); FILLDIRTY(b->depth); FILLDIRTY(b->dirty); } CLEARDIRTY(b->depth, nbitID); } CLEARDIRTY(b->dirty, nbitID); }
void crStatePointSwitch(CRPointBits *b, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { PCRStateTracker pState = fromCtx->pStateTracker; CRPointState *from = &(fromCtx->point); CRPointState *to = &(toCtx->point); unsigned int j, i; GLboolean fEnabled; CRbitvalue nbitID[CR_MAX_BITARRAY]; CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker); for (j=0;j<CR_MAX_BITARRAY;j++) nbitID[j] = ~bitID[j]; i = 0; /* silence compiler */ if (CHECKDIRTY(b->enableSmooth, bitID)) { glAble able[2]; able[0] = pState->diff_api.Disable; able[1] = pState->diff_api.Enable; if (from->pointSmooth != to->pointSmooth) { able[to->pointSmooth](GL_POINT_SMOOTH); FILLDIRTY(b->enableSmooth); FILLDIRTY(b->dirty); } CLEARDIRTY(b->enableSmooth, nbitID); } if (CHECKDIRTY(b->size, bitID)) { if (from->pointSize != to->pointSize) { pState->diff_api.PointSize (to->pointSize); FILLDIRTY(b->size); FILLDIRTY(b->dirty); } CLEARDIRTY(b->size, nbitID); } if (CHECKDIRTY(b->minSize, bitID)) { if (from->minSize != to->minSize) { pState->diff_api.PointParameterfARB (GL_POINT_SIZE_MIN_ARB, to->minSize); FILLDIRTY(b->minSize); FILLDIRTY(b->dirty); } CLEARDIRTY(b->minSize, nbitID); } if (CHECKDIRTY(b->maxSize, bitID)) { if (from->maxSize != to->maxSize) { pState->diff_api.PointParameterfARB (GL_POINT_SIZE_MAX_ARB, to->maxSize); FILLDIRTY(b->maxSize); FILLDIRTY(b->dirty); } CLEARDIRTY(b->maxSize, nbitID); } if (CHECKDIRTY(b->fadeThresholdSize, bitID)) { if (from->fadeThresholdSize != to->fadeThresholdSize) { pState->diff_api.PointParameterfARB (GL_POINT_FADE_THRESHOLD_SIZE_ARB, to->fadeThresholdSize); FILLDIRTY(b->fadeThresholdSize); FILLDIRTY(b->dirty); } CLEARDIRTY(b->fadeThresholdSize, nbitID); } if (CHECKDIRTY(b->spriteCoordOrigin, bitID)) { if (from->spriteCoordOrigin != to->spriteCoordOrigin) { pState->diff_api.PointParameterfARB (GL_POINT_SPRITE_COORD_ORIGIN, to->spriteCoordOrigin); FILLDIRTY(b->spriteCoordOrigin); FILLDIRTY(b->dirty); } CLEARDIRTY(b->spriteCoordOrigin, nbitID); } if (CHECKDIRTY(b->distanceAttenuation, bitID)) { if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) { pState->diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation); FILLDIRTY(b->distanceAttenuation); FILLDIRTY(b->dirty); } CLEARDIRTY(b->distanceAttenuation, nbitID); } fEnabled = from->pointSprite; { unsigned int activeUnit = (unsigned int) -1; for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { if (CHECKDIRTY(b->coordReplacement[i], bitID)) { if (!fEnabled) { pState->diff_api.Enable(GL_POINT_SPRITE_ARB); fEnabled = GL_TRUE; } #if 0 /*don't set coord replacement, it will be set just before drawing points when necessary, * to work around gpu driver bugs * See crServerDispatch[Begin|End|Draw*] */ GLint replacement = to->coordReplacement[i]; if (activeUnit != i) { diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB ); activeUnit = i; } diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement); #endif CLEARDIRTY(b->coordReplacement[i], nbitID); } } if (activeUnit != toCtx->texture.curTextureUnit) pState->diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit); } if (CHECKDIRTY(b->enableSprite, bitID)) { glAble able[2]; able[0] = pState->diff_api.Disable; able[1] = pState->diff_api.Enable; if (fEnabled != to->pointSprite) { able[to->pointSprite](GL_POINT_SPRITE_ARB); FILLDIRTY(b->enableSprite); FILLDIRTY(b->dirty); } CLEARDIRTY(b->enableSprite, nbitID); } else if (fEnabled != to->pointSprite) { glAble able[2]; able[0] = pState->diff_api.Disable; able[1] = pState->diff_api.Enable; able[to->pointSprite](GL_POINT_SPRITE_ARB); } CLEARDIRTY(b->dirty, nbitID); }
void crStatePointDiff(CRPointBits *b, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { PCRStateTracker pState = fromCtx->pStateTracker; CRPointState *from = &(fromCtx->point); CRPointState *to = &(toCtx->point); unsigned int j, i; CRbitvalue nbitID[CR_MAX_BITARRAY]; Assert(0); /** @todo Is this never called? */ CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker); for (j=0;j<CR_MAX_BITARRAY;j++) nbitID[j] = ~bitID[j]; i = 0; /* silence compiler */ if (CHECKDIRTY(b->enableSmooth, bitID)) { glAble able[2]; able[0] = pState->diff_api.Disable; able[1] = pState->diff_api.Enable; if (from->pointSmooth != to->pointSmooth) { able[to->pointSmooth](GL_POINT_SMOOTH); from->pointSmooth = to->pointSmooth; } CLEARDIRTY(b->enableSmooth, nbitID); } if (CHECKDIRTY(b->size, bitID)) { if (from->pointSize != to->pointSize) { pState->diff_api.PointSize (to->pointSize); from->pointSize = to->pointSize; } CLEARDIRTY(b->size, nbitID); } if (CHECKDIRTY(b->minSize, bitID)) { if (from->minSize != to->minSize) { pState->diff_api.PointParameterfARB (GL_POINT_SIZE_MIN_ARB, to->minSize); from->minSize = to->minSize; } CLEARDIRTY(b->minSize, nbitID); } if (CHECKDIRTY(b->maxSize, bitID)) { if (from->maxSize != to->maxSize) { pState->diff_api.PointParameterfARB (GL_POINT_SIZE_MAX_ARB, to->maxSize); from->maxSize = to->maxSize; } CLEARDIRTY(b->maxSize, nbitID); } if (CHECKDIRTY(b->fadeThresholdSize, bitID)) { if (from->fadeThresholdSize != to->fadeThresholdSize) { pState->diff_api.PointParameterfARB (GL_POINT_FADE_THRESHOLD_SIZE_ARB, to->fadeThresholdSize); from->fadeThresholdSize = to->fadeThresholdSize; } CLEARDIRTY(b->fadeThresholdSize, nbitID); } if (CHECKDIRTY(b->spriteCoordOrigin, bitID)) { if (from->spriteCoordOrigin != to->spriteCoordOrigin) { pState->diff_api.PointParameterfARB (GL_POINT_SPRITE_COORD_ORIGIN, to->spriteCoordOrigin); from->spriteCoordOrigin = to->spriteCoordOrigin; } CLEARDIRTY(b->spriteCoordOrigin, nbitID); } if (CHECKDIRTY(b->distanceAttenuation, bitID)) { if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) { pState->diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation); from->distanceAttenuation[0] = to->distanceAttenuation[0]; from->distanceAttenuation[1] = to->distanceAttenuation[1]; from->distanceAttenuation[2] = to->distanceAttenuation[2]; } CLEARDIRTY(b->distanceAttenuation, nbitID); } if (CHECKDIRTY(b->enableSprite, bitID)) { glAble able[2]; able[0] = pState->diff_api.Disable; able[1] = pState->diff_api.Enable; if (from->pointSprite != to->pointSprite) { able[to->pointSprite](GL_POINT_SPRITE_ARB); from->pointSprite = to->pointSprite; } CLEARDIRTY(b->enableSprite, nbitID); } { unsigned int activeUnit = (unsigned int) -1; for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { if (CHECKDIRTY(b->coordReplacement[i], bitID)) { GLint replacement = to->coordReplacement[i]; if (activeUnit != i) { pState->diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB ); activeUnit = i; } pState->diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement); from->coordReplacement[i] = to->coordReplacement[i]; CLEARDIRTY(b->coordReplacement[i], nbitID); } } if (activeUnit != toCtx->texture.curTextureUnit) pState->diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit); } CLEARDIRTY(b->dirty, nbitID); }
void crStatePolygonDiff(CRPolygonBits *b, CRbitvalue *bitID, CRContext *fromCtx, CRContext *toCtx) { CRPolygonState *from = &(fromCtx->polygon); CRPolygonState *to = &(toCtx->polygon); unsigned int j; CRbitvalue nbitID[CR_MAX_BITARRAY]; for (j=0;j<CR_MAX_BITARRAY;j++) nbitID[j] = ~bitID[j]; if (CHECKDIRTY(b->enable, bitID)) { glAble able[2]; able[0] = diff_api.Disable; able[1] = diff_api.Enable; if (from->polygonSmooth != to->polygonSmooth) { able[to->polygonSmooth](GL_POLYGON_SMOOTH); from->polygonSmooth = to->polygonSmooth; } if (from->polygonOffsetFill != to->polygonOffsetFill) { able[to->polygonOffsetFill](GL_POLYGON_OFFSET_FILL); from->polygonOffsetFill = to->polygonOffsetFill; } if (from->polygonOffsetLine != to->polygonOffsetLine) { able[to->polygonOffsetLine](GL_POLYGON_OFFSET_LINE); from->polygonOffsetLine = to->polygonOffsetLine; } if (from->polygonOffsetPoint != to->polygonOffsetPoint) { able[to->polygonOffsetPoint](GL_POLYGON_OFFSET_POINT); from->polygonOffsetPoint = to->polygonOffsetPoint; } if (from->polygonStipple != to->polygonStipple) { able[to->polygonStipple](GL_POLYGON_STIPPLE); from->polygonStipple = to->polygonStipple; } if (from->cullFace != to->cullFace) { able[to->cullFace](GL_CULL_FACE); from->cullFace = to->cullFace; } CLEARDIRTY(b->enable, nbitID); } if (CHECKDIRTY(b->offset, bitID)) { if (from->offsetFactor != to->offsetFactor || from->offsetUnits != to->offsetUnits) { diff_api.PolygonOffset (to->offsetFactor, to->offsetUnits); from->offsetFactor = to->offsetFactor; from->offsetUnits = to->offsetUnits; } CLEARDIRTY(b->offset, nbitID); } if (CHECKDIRTY(b->mode, bitID)) { if (from->frontFace != to->frontFace) { diff_api.FrontFace (to->frontFace); from->frontFace = to->frontFace; } if (from->cullFaceMode != to->cullFaceMode) { diff_api.CullFace (to->cullFaceMode); from->cullFaceMode = to->cullFaceMode; } if (from->backMode != to->backMode) { diff_api.PolygonMode (GL_BACK, to->backMode); from->backMode = to->backMode; } if (from->frontMode != to->frontMode) { diff_api.PolygonMode (GL_FRONT, to->frontMode); from->frontMode = to->frontMode; } CLEARDIRTY(b->mode, nbitID); } if (CHECKDIRTY(b->stipple, bitID)) { int j; diff_api.PolygonStipple ((GLubyte *) to->stipple); for (j=0; j<32; j++) { from->stipple[j] = to->stipple[j]; } CLEARDIRTY(b->stipple, nbitID); } CLEARDIRTY(b->dirty, nbitID); }