void crStateBufferObjectInit (CRContext *ctx)
{
    CRStateBits *sb          = GetCurrentBits();
    CRBufferObjectBits *bb = &sb->bufferobject;
    CRBufferObjectState *b = &ctx->bufferobject;

    RESET(bb->dirty, ctx->bitid);
    RESET(bb->arrayBinding, ctx->bitid);
    RESET(bb->elementsBinding, ctx->bitid);
#ifdef CR_ARB_pixel_buffer_object
    RESET(bb->unpackBinding, ctx->bitid);
    RESET(bb->packBinding, ctx->bitid);
#endif

#ifdef IN_GUEST
    b->retainBufferData = GL_TRUE;
#else
    b->retainBufferData = GL_FALSE;
#endif

    b->nullBuffer = AllocBufferObject(0);
    b->arrayBuffer = b->nullBuffer;
    b->elementsBuffer = b->nullBuffer;
    b->nullBuffer->refCount += 2;
#ifdef CR_ARB_pixel_buffer_object
    b->packBuffer = b->nullBuffer;
    b->unpackBuffer = b->nullBuffer;
    b->nullBuffer->refCount += 2;
#endif

    ctx->shared->bVBOResyncNeeded = GL_FALSE;
}
Beispiel #2
0
void STATE_APIENTRY crStateFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *p) 
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	if (type != GL_BYTE && type != GL_UNSIGNED_BYTE &&
			type != GL_SHORT && type != GL_UNSIGNED_SHORT &&
			type != GL_INT && type != GL_UNSIGNED_INT &&
			type != GL_FLOAT && type != GL_DOUBLE)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glFogCoordPointerEXT: invalid type: 0x%x", type);
		return;
	}
	if (stride < 0) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glFogCoordPointerEXT: stride was negative: %d", stride);
		return;
	}

	crStateClientSetPointer(&(c->array.f), 1, type, GL_FALSE, stride, p);
	DIRTY(cb->dirty, g->neg_bitid);
	DIRTY(cb->clientPointer, g->neg_bitid);
	DIRTY(cb->f, g->neg_bitid);
}
Beispiel #3
0
void STATE_APIENTRY crStateTexCoordPointer(GLint size, GLenum type, 
		GLsizei stride, const GLvoid *p) 
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	if (size != 1 && size != 2 && size != 3 && size != 4)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexCoordPointer: invalid size: %d", size);
		return;
	}
	if (type != GL_SHORT && type != GL_INT &&
			type != GL_FLOAT && type != GL_DOUBLE)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexCoordPointer: invalid type: 0x%x", type);
		return;
	}
	if (stride < 0) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexCoordPointer: stride was negative: %d", stride);
		return;
	}

	crStateClientSetPointer(&(c->array.t[c->curClientTextureUnit]), size, type, GL_FALSE, stride, p);
	DIRTY(cb->dirty, g->neg_bitid);
	DIRTY(cb->clientPointer, g->neg_bitid);
	DIRTY(cb->t[c->curClientTextureUnit], g->neg_bitid);
}
void STATE_APIENTRY crStateClearAccum (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearAccum called in begin/end");
        return;
    }
    
    FLUSH();

    if (red < -1.0f) red = 0.0f;
    if (red > 1.0f) red = 1.0f;
    if (green < -1.0f) green = 0.0f;
    if (green > 1.0f) green = 1.0f;
    if (blue < -1.0f) blue = 0.0f;
    if (blue > 1.0f) blue = 1.0f;
    if (alpha < -1.0f) alpha = 0.0f;
    if (alpha > 1.0f) alpha = 1.0f;

    b->accumClearValue.r = red;
    b->accumClearValue.g = green;
    b->accumClearValue.b = blue;
    b->accumClearValue.a = alpha;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->clearAccum, g->neg_bitid);
}
Beispiel #5
0
void STATE_APIENTRY crStatePolygonStipple (const GLubyte *p) 
{
	CRContext *g = GetCurrentContext();
	CRPolygonState *poly = &(g->polygon);
        CRStateBits *sb = GetCurrentBits();
	CRPolygonBits *pb = &(sb->polygon);

	if (g->current.inBeginEnd) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
				"glPolygonStipple called in begin/end");
		return;
	}

	FLUSH();

	if (!p)
	{
		crStateError(__LINE__, __FILE__, GL_NO_ERROR,
				"Void pointer passed to PolygonStipple");
		return;
	}

	crMemcpy((char*)poly->stipple, (char*)p, 128);

	DIRTY(pb->dirty, g->neg_bitid);
	DIRTY(pb->stipple, g->neg_bitid);
}
Beispiel #6
0
void crStateUpdateColorBits(void)
{
    /* This is a hack to force updating the 'current' attribs */
    CRStateBits *sb = GetCurrentBits();
    FILLDIRTY(sb->current.dirty);
    FILLDIRTY(sb->current.vertexAttrib[VERT_ATTRIB_COLOR0]);
}
Beispiel #7
0
void STATE_APIENTRY crStateCullFace(GLenum mode) 
{
	CRContext *g = GetCurrentContext();
	CRPolygonState *p = &(g->polygon);
        CRStateBits *sb = GetCurrentBits();
	CRPolygonBits *pb = &(sb->polygon);

	if (g->current.inBeginEnd) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
				"glCullFace called in begin/end");
		return;
	}

	FLUSH();

	if (mode != GL_FRONT && mode != GL_BACK && mode != GL_FRONT_AND_BACK)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
				"glCullFace called with bogus mode: 0x%x", mode);
		return;
	}

	p->cullFaceMode = mode;
	DIRTY(pb->mode, g->neg_bitid);
	DIRTY(pb->dirty, g->neg_bitid);
}
void crStatePolygonInit(CRContext *ctx)
{
    CRPolygonState *p = &ctx->polygon;
        CRStateBits *sb = GetCurrentBits(ctx->pStateTracker);
    CRPolygonBits *pb = &(sb->polygon);
    int i;

    p->polygonSmooth = GL_FALSE;
    p->polygonOffsetFill = GL_FALSE;
    p->polygonOffsetLine = GL_FALSE;
    p->polygonOffsetPoint = GL_FALSE;
    p->polygonStipple = GL_FALSE;
    p->cullFace = GL_FALSE;
    RESET(pb->enable, ctx->bitid);

    p->offsetFactor = 0;
    p->offsetUnits = 0;
    RESET(pb->offset, ctx->bitid);

    p->cullFaceMode = GL_BACK;
    p->frontFace = GL_CCW;
    p->frontMode = GL_FILL;
    p->backMode = GL_FILL;
    RESET(pb->mode, ctx->bitid);

    for (i=0; i<32; i++)
        p->stipple[i] = 0xFFFFFFFF;
    RESET(pb->stipple, ctx->bitid);

    RESET(pb->dirty, ctx->bitid);
}
void STATE_APIENTRY crStatePolygonStipple (PCRStateTracker pState, const GLubyte *p) 
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *poly = &(g->polygon);
        CRStateBits *sb = GetCurrentBits(pState);
    CRPolygonBits *pb = &(sb->polygon);

    if (g->current.inBeginEnd) 
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
                "glPolygonStipple called in begin/end");
        return;
    }

    FLUSH();

    if (!p && !crStateIsBufferBound(pState, GL_PIXEL_UNPACK_BUFFER_ARB))
    {
        crDebug("Void pointer passed to PolygonStipple");
        return;
    }

    /** @todo track mask if buffer is bound?*/
    if (!crStateIsBufferBound(pState, GL_PIXEL_UNPACK_BUFFER_ARB))
    {
        crMemcpy((char*)poly->stipple, (char*)p, 128);
    }

    DIRTY(pb->dirty, g->neg_bitid);
    DIRTY(pb->stipple, g->neg_bitid);
}
void STATE_APIENTRY crStateFrontFace (PCRStateTracker pState, GLenum mode) 
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *p = &(g->polygon);
        CRStateBits *sb = GetCurrentBits(pState);
    CRPolygonBits *pb = &(sb->polygon);

    if (g->current.inBeginEnd) 
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
                "glFrontFace called in begin/end");
        return;
    }

    FLUSH();

    if (mode != GL_CW && mode != GL_CCW)
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
                "glFrontFace called with bogus mode: 0x%x", mode);
        return;
    }

    p->frontFace = mode;
    DIRTY(pb->mode, g->neg_bitid);
    DIRTY(pb->dirty, g->neg_bitid);
}
void STATE_APIENTRY crStatePointSize(GLfloat size) 
{
	CRContext *g = GetCurrentContext();
	CRPointState *p = &(g->point);
	CRStateBits *sb = GetCurrentBits();
	CRPointBits *pb = &(sb->point);

	if (g->current.inBeginEnd)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointSize called in begin/end");
		return;
	}

	FLUSH();

	if (size <= 0.0f) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointSize called with size <= 0.0: %f", size);
		return;
	}
		
	p->pointSize = size;
	DIRTY(pb->size, g->neg_bitid);
	DIRTY(pb->dirty, g->neg_bitid);
}
void crStateFogInit (CRContext *ctx)
{
	CRFogState *f = &ctx->fog;
	CRStateBits *sb = GetCurrentBits(ctx->pStateTracker);
	CRFogBits *fb = &(sb->fog);
	GLcolorf black = {0.0f, 0.0f, 0.0f, 0.0f};

	f->color = black;
	RESET(fb->color, ctx->bitid);
	f->density = 1.0f;
	RESET(fb->density, ctx->bitid);
	f->end = 1.0f;
	RESET(fb->end, ctx->bitid);
	f->start = 0.0f;
	RESET(fb->start, ctx->bitid);
	f->mode = GL_EXP;
	RESET(fb->mode, ctx->bitid);
	f->index = 0;
	RESET(fb->index, ctx->bitid);
	f->enable = GL_FALSE;
	RESET(fb->enable, ctx->bitid);

#ifdef CR_NV_fog_distance
	f->fogDistanceMode = GL_EYE_PLANE_ABSOLUTE_NV;
	RESET(fb->fogDistanceMode, ctx->bitid);
#endif
#ifdef CR_EXT_fog_coord
	f->fogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
	RESET(fb->fogCoordinateSource, ctx->bitid);
#endif
	RESET(fb->dirty, ctx->bitid);
}
void STATE_APIENTRY
crStateBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &g->bufferobject;
    CRBufferObject *obj;
    CRStateBits *sb = GetCurrentBits();
    CRBufferObjectBits *bb = &sb->bufferobject;

    FLUSH();

    if (g->current.inBeginEnd) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
                                 "glBufferSubDataARB called in begin/end");
        return;
    }

    obj = crStateGetBoundBufferObject(target, b);
    if (!obj)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)");
        return;
    }

    if (obj->id == 0) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
                                 "glBufferSubDataARB");
        return;
    }

    if (obj->pointer) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
                                 "glBufferSubDataARB(buffer is mapped)");
        return;
    }

    if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
                                 "glBufferSubDataARB(bad offset and/or size)");
        return;
    }

    if (b->retainBufferData && obj->data) {
        crMemcpy((char *) obj->data + offset, data, size);
    }

    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(obj->dirty, g->neg_bitid);
    /* grow dirty region */
    if (offset + size > obj->dirtyStart + obj->dirtyLength)
        obj->dirtyLength = offset + size;
    if (offset < obj->dirtyStart)
        obj->dirtyStart = offset;
}
Beispiel #14
0
void STATE_APIENTRY crStateDisableClientState (GLenum array) 
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	setClientState(c, cb, g->neg_bitid, array, GL_FALSE);
}
Beispiel #15
0
void STATE_APIENTRY crStateDisable (GLenum cap)
{
	CRContext *g = GetCurrentContext();
	CRStateBits *sb = GetCurrentBits();

	if (g->current.inBeginEnd)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDisable called in begin/end");
		return;
	}

	FLUSH();

	__enableSet(g, sb, g->neg_bitid, cap, GL_FALSE);
}
Beispiel #16
0
void STATE_APIENTRY crStatePopClientAttrib( void )
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);
	CRbitvalue mask;

	if (g->current.inBeginEnd) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								 "glPopClientAttrib called in Begin/End");
		return;
	}

	if (c->attribStackDepth == 0) {
		crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW,
								 "glPopClientAttrib called with an empty stack!" );
		return;
	}

	FLUSH();

	mask = c->pushMaskStack[--c->attribStackDepth];

	if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
		if (c->pixelStoreStackDepth == 0) {
			crError("bug in glPopClientAttrib (pixel store) ");
			return;
		}
		c->pixelStoreStackDepth--;
		c->pack = c->pixelPackStoreStack[c->pixelStoreStackDepth];
		c->unpack = c->pixelUnpackStoreStack[c->pixelStoreStackDepth];
		DIRTY(cb->pack, g->neg_bitid);
	}

	if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
		if (c->vertexArrayStackDepth == 0) {
			crError("bug in glPopClientAttrib (vertex array) ");
			return;
		}
		c->vertexArrayStackDepth--;
		c->array = c->vertexArrayStack[c->vertexArrayStackDepth];
		DIRTY(cb->clientPointer, g->neg_bitid);
	}

	DIRTY(cb->dirty, g->neg_bitid);
}
GLboolean STATE_APIENTRY
crStateUnmapBufferARB(GLenum target)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &g->bufferobject;
    CRBufferObject *obj;
    CRStateBits *sb = GetCurrentBits();
    CRBufferObjectBits *bb = &sb->bufferobject;

    FLUSH();

    if (g->current.inBeginEnd) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
                                 "glUnmapBufferARB called in begin/end");
        return GL_FALSE;
    }

    obj = crStateGetBoundBufferObject(target, b);
    if (!obj)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)");
        return GL_FALSE;
    }

    if (obj->id == 0) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");
        return GL_FALSE;
    }

    if (!obj->pointer) {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB");
        return GL_FALSE;
    }

    obj->pointer = NULL;

    if (obj->access != GL_READ_ONLY_ARB) {
        /* the data was most likely modified */
        DIRTY(bb->dirty, g->neg_bitid);
        DIRTY(obj->dirty, g->neg_bitid);
        obj->dirtyStart = 0;
        obj->dirtyLength = obj->size;
    }

    return GL_TRUE;
}
void crStatePointInit (CRContext *ctx)
{
	CRPointState *p = &ctx->point;
	CRStateBits *sb = GetCurrentBits();
	CRPointBits *pb = &(sb->point);
	int i;

	p->pointSmooth = GL_FALSE;
	RESET(pb->enableSmooth, ctx->bitid);
	p->pointSize = 1.0f;
	RESET(pb->size, ctx->bitid);
#ifdef CR_ARB_point_parameters
	p->minSize = 0.0f;
	RESET(pb->minSize, ctx->bitid);
	p->maxSize = CR_ALIASED_POINT_SIZE_MAX;
	RESET(pb->maxSize, ctx->bitid);
	p->fadeThresholdSize = 1.0f;
	RESET(pb->fadeThresholdSize, ctx->bitid);
	p->distanceAttenuation[0] = 1.0f;
	p->distanceAttenuation[1] = 0.0f;
	p->distanceAttenuation[2] = 0.0f;
	RESET(pb->distanceAttenuation, ctx->bitid);
#endif
#ifdef CR_ARB_point_sprite
	p->pointSprite = GL_FALSE;
	RESET(pb->enableSprite, ctx->bitid);
	for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) {
		p->coordReplacement[i] = GL_FALSE;
		RESET(pb->coordReplacement[i], ctx->bitid);
	}
#endif

	p->spriteCoordOrigin = (GLfloat)GL_UPPER_LEFT;
	RESET(pb->spriteCoordOrigin, ctx->bitid);

	RESET(pb->dirty, ctx->bitid);

	/*
	 *p->aliasedpointsizerange_min = c->aliasedpointsizerange_min; 
	 *p->aliasedpointsizerange_max = c->aliasedpointsizerange_max; 
	 *p->aliasedpointsizegranularity = c->aliasedpointsizegranularity; 
	 *p->smoothpointsizerange_min = c->smoothpointsizerange_min; 
	 *p->smoothpointsizerange_max = c->smoothpointsizerange_max; 
	 *p->smoothpointgranularity = c->smoothpointgranularity;
	 */
}
void STATE_APIENTRY crStateClearIndex (GLfloat c) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearIndex called in begin/end");
        return;
    }

    b->indexClearValue = c;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->clearIndex, g->neg_bitid);
}
void STATE_APIENTRY crStateLogicOp (GLenum opcode) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sb = GetCurrentBits();
    CRBufferBits *bb = &(sb->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLogicOp called in begin/end");
        return;
    }

    FLUSH();

    switch (opcode) 
    {
        case GL_CLEAR:
        case GL_SET:
        case GL_COPY:
        case GL_COPY_INVERTED:
        case GL_NOOP:
        case GL_INVERT:
        case GL_AND:
        case GL_NAND:
        case GL_OR:
        case GL_NOR:
        case GL_XOR:
        case GL_EQUIV:
        case GL_AND_REVERSE:
        case GL_AND_INVERTED:
        case GL_OR_REVERSE:
        case GL_OR_INVERTED:
            break;
        default:
            crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLogicOp called with bogus opcode: %d", opcode);
            return;
    }

    b->logicOpMode = opcode;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->logicOp, g->neg_bitid);
    DIRTY(bb->indexLogicOp, g->neg_bitid);
}
void STATE_APIENTRY crStateDepthMask (GLboolean b) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *bs = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "DepthMask called in begin/end");
        return;
    }

    FLUSH();

    bs->depthMask = b;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->depthMask, g->neg_bitid);
}
void STATE_APIENTRY crStateIndexMask (GLuint mask) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end");
        return;
    }

    FLUSH();

    b->indexWriteMask = mask;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->indexMask, g->neg_bitid);
}
void STATE_APIENTRY crStateCombinerParameterfvNV( GLenum pname, const GLfloat *params )
{
	CRContext *g = GetCurrentContext();
	CRRegCombinerState *r = &(g->regcombiner);
	CRStateBits *sb = GetCurrentBits();
	CRRegCombinerBits *rb = &(sb->regcombiner);

	switch( pname )
	{
		case GL_CONSTANT_COLOR0_NV:
			r->constantColor0.r = params[0];
			r->constantColor0.g = params[1];
			r->constantColor0.b = params[2];
			r->constantColor0.a = params[3];
			DIRTY(rb->regCombinerColor0, g->neg_bitid);
			break;
		case GL_CONSTANT_COLOR1_NV:
			r->constantColor1.r = params[0];
			r->constantColor1.g = params[1];
			r->constantColor1.b = params[2];
			r->constantColor1.a = params[3];
			DIRTY(rb->regCombinerColor1, g->neg_bitid);
			break;
		case GL_NUM_GENERAL_COMBINERS_NV:
			if( *params < 1 || *params > g->limits.maxGeneralCombiners )
			{
				crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerParameter passed invalid NUM_GENERAL_COMBINERS param: %d", (GLint)*params );
				return;
			}
			r->numGeneralCombiners = (GLint)*params;
			DIRTY(rb->regCombinerVars, g->neg_bitid);
			break;
		case GL_COLOR_SUM_CLAMP_NV:
			r->colorSumClamp = (GLboolean)*params;
			DIRTY(rb->regCombinerVars, g->neg_bitid);
			break;
		default:
			crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerParameter passed bogus pname: 0x%x", pname );
			return;
	}

	DIRTY(rb->dirty, g->neg_bitid);
}
void STATE_APIENTRY crStateBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sb = GetCurrentBits();
    CRBufferBits *bb = &(sb->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendColorEXT called inside a Begin/End" );
        return;
    }

    b->blendColor.r = red;
    b->blendColor.g = green;
    b->blendColor.b = blue;
    b->blendColor.a = alpha;
    DIRTY(bb->blendColor, g->neg_bitid);
    DIRTY(bb->dirty, g->neg_bitid);
}
Beispiel #25
0
void STATE_APIENTRY crStateEdgeFlagPointer(GLsizei stride, const GLvoid *p) 
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	if (stride < 0) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexCoordPointer: stride was negative: %d", stride);
		return;
	}

	crStateClientSetPointer(&(c->array.e), 1, GL_UNSIGNED_BYTE, GL_FALSE, stride, p);
	DIRTY(cb->dirty, g->neg_bitid);
	DIRTY(cb->clientPointer, g->neg_bitid);
	DIRTY(cb->e, g->neg_bitid);
}
void  STATE_APIENTRY crStatePolygonMode (PCRStateTracker pState, GLenum face, GLenum mode) 
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *p = &(g->polygon);
        CRStateBits *sb = GetCurrentBits(pState);
    CRPolygonBits *pb = &(sb->polygon);

    if (g->current.inBeginEnd) 
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
                "glPolygonMode called in begin/end");
        return;
    }

    FLUSH();

    if (mode != GL_POINT && mode != GL_LINE && mode != GL_FILL)
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
                "glPolygonMode called with bogus mode: 0x%x", mode);
        return;
    }

    switch (face) {
        case GL_FRONT:
            p->frontMode = mode;
            break;
        case GL_FRONT_AND_BACK:
            p->frontMode = mode;
            RT_FALL_THRU();
        case GL_BACK:
            p->backMode = mode;
            break;
        default:
            crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
                    "glPolygonMode called with bogus face: 0x%x", face);
            return;
    }
    DIRTY(pb->mode, g->neg_bitid);
    DIRTY(pb->dirty, g->neg_bitid);
}
Beispiel #27
0
void STATE_APIENTRY crStateSecondaryColorPointerEXT(GLint size,
		GLenum type, GLsizei stride, const GLvoid *p)
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);
	CRStateBits *sb = GetCurrentBits();
	CRClientBits *cb = &(sb->client);

	FLUSH();

	if ( !g->extensions.EXT_secondary_color )
	{
		crError( "glSecondaryColorPointerEXT called but EXT_secondary_color is disabled." );
		return;
	}

	if (size != 3)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glSecondaryColorPointerEXT: invalid size: %d", size);
		return;
	}
	if (type != GL_BYTE && type != GL_UNSIGNED_BYTE &&
			type != GL_SHORT && type != GL_UNSIGNED_SHORT &&
			type != GL_INT && type != GL_UNSIGNED_INT &&
			type != GL_FLOAT && type != GL_DOUBLE)
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glSecondaryColorPointerEXT: invalid type: 0x%x", type);
		return;
	}
	if (stride < 0) 
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glSecondaryColorPointerEXT: stride was negative: %d", stride);
		return;
	}

	crStateClientSetPointer(&(c->array.s), size, type, GL_TRUE, stride, p);
	DIRTY(cb->dirty, g->neg_bitid);
	DIRTY(cb->clientPointer, g->neg_bitid);
	DIRTY(cb->s, g->neg_bitid);
}
void STATE_APIENTRY crStatePolygonOffset (PCRStateTracker pState, GLfloat factor, GLfloat units) 
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *p = &(g->polygon);
        CRStateBits *sb = GetCurrentBits(pState);
    CRPolygonBits *pb = &(sb->polygon);

    if (g->current.inBeginEnd) 
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
                "glPolygonOffset called in begin/end");
        return;
    }

    FLUSH();

    p->offsetFactor = factor;
    p->offsetUnits = units;

    DIRTY(pb->offset, g->neg_bitid);
    DIRTY(pb->dirty, g->neg_bitid);
}
void STATE_APIENTRY crStateClearDepth (GLclampd depth) 
{
    CRContext *g = GetCurrentContext();
    CRBufferState *b = &(g->buffer);
    CRStateBits *sp = GetCurrentBits();
    CRBufferBits *bb = &(sp->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearDepth called in begin/end");
        return;
    }

    FLUSH();

    if (depth < 0.0) depth = 0.0;
    if (depth > 1.0) depth = 1.0;

    b->depthClearValue = (GLdefault) depth;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->clearDepth, g->neg_bitid);
}
void STATE_APIENTRY crStateAlphaFunc (GLenum func, GLclampf ref) 
{
    CRContext *g             = GetCurrentContext();
    CRBufferState *b         = &(g->buffer);
    CRStateBits *sb          = GetCurrentBits();
    CRBufferBits *bb = &(sb->buffer);

    if (g->current.inBeginEnd)
    {
        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glAlphaFunc called in begin/end");
        return;
    }

    FLUSH();

    switch (func) 
    {
        case GL_NEVER:
        case GL_LESS:
        case GL_EQUAL:
        case GL_LEQUAL:
        case GL_GREATER:
        case GL_GEQUAL:
        case GL_NOTEQUAL:
        case GL_ALWAYS:
            break;
        default:
            crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glAlphaFunc:  Invalid func: %d", func);
            return;
    }

    if (ref < 0.0f) ref = 0.0f;
    if (ref > 1.0f) ref = 1.0f;

    b->alphaTestFunc = func;
    b->alphaTestRef = ref;
    DIRTY(bb->dirty, g->neg_bitid);
    DIRTY(bb->alphaFunc, g->neg_bitid);
}