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);
}
Exemple #2
0
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);
}
Exemple #3
0
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);
}
Exemple #4
0
void
crStateClientSwitch(CRClientBits *cb, CRbitvalue *bitID,
										CRContext *fromCtx, CRContext *toCtx)
{
	const CRClientState *from = &(fromCtx->client);
	const CRClientState *to = &(toCtx->client);
	int i;

	if (CHECKDIRTY(cb->clientPointer, bitID)) {
		/* one or more vertex pointers is dirty */
		if (CHECKDIRTY(cb->v, bitID)) {
			if (from->array.v.size != to->array.v.size ||
					from->array.v.type != to->array.v.type ||
					from->array.v.stride != to->array.v.stride ||
					from->array.v.buffer != to->array.v.buffer) {
				diff_api.VertexPointer(to->array.v.size, to->array.v.type,
															 to->array.v.stride, to->array.v.p);
				FILLDIRTY(cb->v);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->v, bitID);
		}
		/* normal */
		if (CHECKDIRTY(cb->n, bitID)) {
			if (from->array.n.type != to->array.n.type ||
					from->array.n.stride != to->array.n.stride ||
					from->array.n.buffer != to->array.n.buffer) {
				diff_api.NormalPointer(to->array.n.type,
															 to->array.n.stride, to->array.n.p);
				FILLDIRTY(cb->n);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->n, bitID);
		}
		/* color */
		if (CHECKDIRTY(cb->c, bitID)) {
			if (from->array.c.size != to->array.c.size ||
					from->array.c.type != to->array.c.type ||
					from->array.c.stride != to->array.c.stride ||
					from->array.c.buffer != to->array.c.buffer) {
				diff_api.ColorPointer(to->array.c.size, to->array.c.type,
															to->array.c.stride, to->array.c.p);
				FILLDIRTY(cb->c);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->c, bitID);
		}
		/* index */
		if (CHECKDIRTY(cb->i, bitID)) {
			if (from->array.i.type != to->array.i.type ||
					from->array.i.stride != to->array.i.stride ||
					from->array.i.buffer != to->array.i.buffer) {
				diff_api.IndexPointer(to->array.i.type,
															to->array.i.stride, to->array.i.p);
				FILLDIRTY(cb->i);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->i, bitID);
		}
		/* texcoords */
		for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) {
			if (CHECKDIRTY(cb->t[i], bitID)) {
				if (from->array.t[i].size != to->array.t[i].size ||
						from->array.t[i].type != to->array.t[i].type ||
						from->array.t[i].stride != to->array.t[i].stride ||
						from->array.t[i].buffer != to->array.t[i].buffer) {
					diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i);
					diff_api.TexCoordPointer(to->array.t[i].size, to->array.t[i].type,
																to->array.t[i].stride, to->array.t[i].p);
					FILLDIRTY(cb->t[i]);
					FILLDIRTY(cb->clientPointer);
				}
				CLEARDIRTY2(cb->t[i], bitID);
			}
		}
		/* edge flag */
		if (CHECKDIRTY(cb->e, bitID)) {
			if (from->array.e.stride != to->array.e.stride ||
					from->array.e.buffer != to->array.e.buffer) {
				diff_api.EdgeFlagPointer(to->array.e.stride, to->array.e.p);
				FILLDIRTY(cb->e);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->e, bitID);
		}
		/* secondary color */
		if (CHECKDIRTY(cb->s, bitID)) {
			if (from->array.s.size != to->array.s.size ||
					from->array.s.type != to->array.s.type ||
					from->array.s.stride != to->array.s.stride ||
					from->array.s.buffer != to->array.s.buffer) {
				diff_api.SecondaryColorPointerEXT(to->array.s.size, to->array.s.type,
																					to->array.s.stride, to->array.s.p);
				FILLDIRTY(cb->s);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->s, bitID);
		}
		/* fog coord */
		if (CHECKDIRTY(cb->f, bitID)) {
			if (from->array.f.type != to->array.f.type ||
					from->array.f.stride != to->array.f.stride ||
					from->array.f.buffer != to->array.f.buffer) {
				diff_api.FogCoordPointerEXT(to->array.f.type,
																		to->array.f.stride, to->array.f.p);
				FILLDIRTY(cb->f);
				FILLDIRTY(cb->clientPointer);
			}
			CLEARDIRTY2(cb->f, bitID);
		}
#if defined(CR_NV_vertex_program) || defined(CR_ARB_vertex_program)
		/* vertex attributes */
		for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) {
			if (CHECKDIRTY(cb->a[i], bitID)) {
				if (from->array.a[i].size != to->array.a[i].size ||
						from->array.a[i].type != to->array.a[i].type ||
						from->array.a[i].stride != to->array.a[i].stride ||
						from->array.a[i].normalized != to->array.a[i].normalized ||
						from->array.a[i].buffer != to->array.a[i].buffer) {
					diff_api.VertexAttribPointerARB(i, to->array.a[i].size,
																					to->array.a[i].type,
																					to->array.a[i].normalized,
																					to->array.a[i].stride,
																					to->array.a[i].p);
					FILLDIRTY(cb->a[i]);
					FILLDIRTY(cb->clientPointer);
				}
				CLEARDIRTY2(cb->a[i], bitID);
			}
		}
#endif
	}

	if (CHECKDIRTY(cb->enableClientState, bitID)) {
		/* update vertex array enable/disable flags */
		glAble able[2];
		able[0] = diff_api.Disable;
		able[1] = diff_api.Enable;
		if (from->array.v.enabled != to->array.v.enabled) {
			able[to->array.v.enabled](GL_VERTEX_ARRAY);
			FILLDIRTY(cb->enableClientState);
		}
		if (from->array.n.enabled != to->array.n.enabled) {
			able[to->array.n.enabled](GL_NORMAL_ARRAY);
			FILLDIRTY(cb->enableClientState);
		}
		if (from->array.c.enabled != to->array.c.enabled) {
			able[to->array.c.enabled](GL_COLOR_ARRAY);
			FILLDIRTY(cb->enableClientState);
		}
		if (from->array.i.enabled != to->array.i.enabled) {
			able[to->array.i.enabled](GL_INDEX_ARRAY);
			FILLDIRTY(cb->enableClientState);
		}
		for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) {
			if (from->array.t[i].enabled != to->array.t[i].enabled) {
				diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i);
				able[to->array.t[i].enabled](GL_TEXTURE_COORD_ARRAY);
				FILLDIRTY(cb->enableClientState);
			}
		}
		if (from->array.e.enabled != to->array.e.enabled) {
			able[to->array.e.enabled](GL_EDGE_FLAG_ARRAY);
			FILLDIRTY(cb->enableClientState);
		}
		if (from->array.s.enabled != to->array.s.enabled) {
			able[to->array.s.enabled](GL_SECONDARY_COLOR_ARRAY_EXT);
			FILLDIRTY(cb->enableClientState);
		}
		if (from->array.f.enabled != to->array.f.enabled) {
			able[to->array.f.enabled](GL_FOG_COORDINATE_ARRAY_EXT);
			FILLDIRTY(cb->enableClientState);
		}
		for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) {
			if (from->array.a[i].enabled != to->array.a[i].enabled) {
				able[to->array.a[i].enabled](GL_VERTEX_ATTRIB_ARRAY0_NV + i);
				FILLDIRTY(cb->enableClientState);
			}
		}
		CLEARDIRTY2(cb->enableClientState, bitID);
	}
}
static void crStateBufferObjectIntCmp(CRBufferObjectBits *bb, CRbitvalue *bitID,
                                      CRContext *fromCtx, CRContext *toCtx,
                                      GLboolean bSwitch)
{
    CRBufferObjectState *from = &(fromCtx->bufferobject);
    const CRBufferObjectState *to = &(toCtx->bufferobject);

    /* ARRAY_BUFFER */
    if (CHECKDIRTY(bb->arrayBinding, bitID)) 
    {
        if (from->arrayBuffer != to->arrayBuffer)
        {
            GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->hwid : 0;
            diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID);
            if (bSwitch)
            {
                FILLDIRTY(bb->arrayBinding);
                FILLDIRTY(bb->dirty);
            }
            else
            {
                CLEARDIRTY2(bb->arrayBinding, bitID);
                from->arrayBuffer = to->arrayBuffer;
            }
        }
        if (bSwitch) CLEARDIRTY2(bb->arrayBinding, bitID);
    }

    if (to->arrayBuffer && CHECKDIRTY(to->arrayBuffer->dirty, bitID))
    {
        /* update array buffer data */
        CRBufferObject *bufObj = to->arrayBuffer;
        CRASSERT(bufObj);
        if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 
        {
            /* update whole buffer */
            diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size,
                                   bufObj->data, bufObj->usage);
        }
        else 
        {
            /* update sub buffer */
            diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB,
                                      bufObj->dirtyStart, bufObj->dirtyLength,
                                      (char *) bufObj->data + bufObj->dirtyStart);
        }
        if (bSwitch) FILLDIRTY(bufObj->dirty);
        CLEARDIRTY2(bufObj->dirty, bitID);
    }

    /* ELEMENTS_BUFFER */
    if (CHECKDIRTY(bb->elementsBinding, bitID)) 
    {
        if (from->elementsBuffer != to->elementsBuffer)
        {
            GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->hwid : 0;
            diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID);
            if (bSwitch)
            {
                FILLDIRTY(bb->elementsBinding);
                FILLDIRTY(bb->dirty);
            }
            else
            {
                CLEARDIRTY2(bb->elementsBinding, bitID);
                from->elementsBuffer = to->elementsBuffer;
            }
        }
        if (bSwitch) CLEARDIRTY2(bb->elementsBinding, bitID);
    }

    if (to->elementsBuffer && CHECKDIRTY(to->elementsBuffer->dirty, bitID))
    {
        /* update array buffer data */
        CRBufferObject *bufObj = to->elementsBuffer;
        CRASSERT(bufObj);
        if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 
        {
            /* update whole buffer */
            diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size,
                                   bufObj->data, bufObj->usage);
        }
        else 
        {
            /* update sub buffer */
            diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
                                      bufObj->dirtyStart, bufObj->dirtyLength,
                                      (char *) bufObj->data + bufObj->dirtyStart);
        }
        if (bSwitch) FILLDIRTY(bufObj->dirty);
        CLEARDIRTY2(bufObj->dirty, bitID);
    }

#ifdef CR_ARB_pixel_buffer_object
    /* PIXEL_PACK_BUFFER */
    if (CHECKDIRTY(bb->packBinding, bitID)) 
    {
        if (from->packBuffer != to->packBuffer)
        {
            GLuint bufferID = to->packBuffer ? to->packBuffer->hwid : 0;
            diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID);
            if (bSwitch)
            {
                FILLDIRTY(bb->packBinding);
                FILLDIRTY(bb->dirty);
            }
            else
            {
                CLEARDIRTY2(bb->packBinding, bitID);
                from->packBuffer = to->packBuffer;
            }
        }
        if (bSwitch) CLEARDIRTY2(bb->packBinding, bitID);
    }

    if (to->packBuffer && CHECKDIRTY(to->packBuffer->dirty, bitID))
    {
        /* update array buffer data */
        CRBufferObject *bufObj = to->packBuffer;
        CRASSERT(bufObj);
        if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 
        {
            /* update whole buffer */
            diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size,
                                   bufObj->data, bufObj->usage);
        }
        else 
        {
            /* update sub buffer */
            diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB,
                                      bufObj->dirtyStart, bufObj->dirtyLength,
                                      (char *) bufObj->data + bufObj->dirtyStart);
        }
        if (bSwitch) FILLDIRTY(bufObj->dirty);
        CLEARDIRTY2(bufObj->dirty, bitID);
    }

    /* PIXEL_UNPACK_BUFFER */
    if (CHECKDIRTY(bb->unpackBinding, bitID)) 
    {
        if (from->unpackBuffer != to->unpackBuffer)
        {
            GLuint bufferID = to->unpackBuffer ? to->unpackBuffer->hwid : 0;
            diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID);
            if (bSwitch)
            {
                FILLDIRTY(bb->unpackBinding);
                FILLDIRTY(bb->dirty);
            }
            else
            {
                CLEARDIRTY2(bb->unpackBinding, bitID);
                from->unpackBuffer = to->unpackBuffer;
            }
        }
        if (bSwitch) CLEARDIRTY2(bb->unpackBinding, bitID);
    }

    if (to->unpackBuffer && CHECKDIRTY(to->unpackBuffer->dirty, bitID))
    {
        /* update array buffer data */
        CRBufferObject *bufObj = to->unpackBuffer;
        CRASSERT(bufObj);
        if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) 
        {
            /* update whole buffer */
            diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size,
                                   bufObj->data, bufObj->usage);
        }
        else 
        {
            /* update sub buffer */
            diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,
                                      bufObj->dirtyStart, bufObj->dirtyLength,
                                      (char *) bufObj->data + bufObj->dirtyStart);
        }
        if (bSwitch) FILLDIRTY(bufObj->dirty);
        CLEARDIRTY2(bufObj->dirty, bitID);
    }
#endif /*ifdef CR_ARB_pixel_buffer_object*/
}
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);
}
Exemple #8
0
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);
}