void STATE_APIENTRY crStateGetCombinerStageParameterfvNV( GLenum stage, GLenum pname, GLfloat *params )
{
	CRContext *g = GetCurrentContext();
	CRRegCombinerState *r = &(g->regcombiner);

	stage -= GL_COMBINER0_NV;
	if( stage >= g->limits.maxGeneralCombiners )
	{
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV );
		return;
	}
	switch( pname )
	{
		case GL_CONSTANT_COLOR0_NV:
			params[0] = r->stageConstantColor0[stage].r;
			params[1] = r->stageConstantColor0[stage].g;
			params[2] = r->stageConstantColor0[stage].b;
			params[3] = r->stageConstantColor0[stage].a;
			break;
		case GL_CONSTANT_COLOR1_NV:
			params[0] = r->stageConstantColor1[stage].r;
			params[1] = r->stageConstantColor1[stage].g;
			params[2] = r->stageConstantColor1[stage].b;
			params[3] = r->stageConstantColor1[stage].a;
			break;
		default:
			crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameter passed bogus pname: 0x%x", pname );
			return;
	}
	return;
}
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);
}
Ejemplo n.º 3
0
void STATE_APIENTRY
crStateGenQueriesARB(GLsizei n, GLuint * queries)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);
	GLint start;

	FLUSH();

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

	if (n < 0) {
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
								 "glGenQueriesARB(n < 0)");
		return;
	}

	start = crHashtableAllocKeys(o->objects, n);
	if (start) {
		GLint i;
		for (i = 0; i < n; i++)
			queries[i] = (GLuint) (start + i);
	}
	else {
		crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenQueriesARB");
	}
}
Ejemplo n.º 4
0
void STATE_APIENTRY
crStateGenBuffersARB(GLsizei n, GLuint * buffers)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &(g->bufferobject);
    GLint start;

    FLUSH();

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

    if (n < 0) {
        crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
                                 "glGenBuffersARB(n < 0)");
        return;
    }

    start = crHashtableAllocKeys(g->shared->buffersTable, n);
    if (start) {
        GLint i;
        for (i = 0; i < n; i++)
            buffers[i] = (GLuint) (start + i);
    }
    else {
        crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenBuffersARB");
    }
}
Ejemplo n.º 5
0
void STATE_APIENTRY
crStateDeleteQueriesARB(GLsizei n, const GLuint *ids)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);
	/*CRStateBits *sb = GetCurrentBits();*/
	/*CROcclusionBits *bb = &(sb->occlusion);*/
	int i;

	FLUSH();

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

	if (n < 0) {
		crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
								 "glDeleteQueriesARB(n < 0)");
		return;
	}

	for (i = 0; i < n; i++) {
		if (ids[i]) {
			CROcclusionObject *q = (CROcclusionObject *)
				crHashtableSearch(o->objects, ids[i]);
			if (q) {
				crHashtableDelete(o->objects, ids[i], crFree);
			}
		}
	}
}
Ejemplo n.º 6
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);
}
Ejemplo n.º 7
0
void STATE_APIENTRY
crStateGetQueryivARB(GLenum target, GLenum pname, GLint *params)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);

	FLUSH();

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

	switch (pname) {
	case GL_QUERY_COUNTER_BITS_ARB:
		 *params = 8 * sizeof(GLuint);
		 break;
	case GL_CURRENT_QUERY_ARB:
		 *params = o->currentQueryObject;
		 break;
	default:
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
								 "glGetGetQueryivARB(pname)");
		return;
	}
}
Ejemplo n.º 8
0
void STATE_APIENTRY
crStateEndQueryARB(GLenum target)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);
	CROcclusionObject *q;

	FLUSH();

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

	if (target != GL_SAMPLES_PASSED_ARB) {
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEndQueryARB(target)");
		return;
	}

	q = (CROcclusionObject *) crHashtableSearch(o->objects, o->currentQueryObject);
	if (!q || !q->active) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								 "glEndQueryARB with glBeginQueryARB");
		return;
	}

	q->passedCounter = 0;
	q->active = GL_FALSE;
	o->currentQueryObject = 0;
}
Ejemplo n.º 9
0
void STATE_APIENTRY crStatePushClientAttrib( GLbitfield mask )
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);

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

	if (c->attribStackDepth == CR_MAX_CLIENT_ATTRIB_STACK_DEPTH - 1) {
		crStateError(__LINE__, __FILE__, GL_STACK_OVERFLOW,
								 "glPushClientAttrib called with a full stack!" );
		return;
	}

	FLUSH();

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

	if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
		c->pixelPackStoreStack[c->pixelStoreStackDepth] = c->pack;
		c->pixelUnpackStoreStack[c->pixelStoreStackDepth] = c->unpack;
		c->pixelStoreStackDepth++;
	}
	if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
		c->vertexArrayStack[c->vertexArrayStackDepth] = c->array;
		c->vertexArrayStackDepth++;
	}

	/* dirty? - no, because we haven't really changed any state */
}
Ejemplo n.º 10
0
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);
}
Ejemplo n.º 11
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);
}
Ejemplo n.º 12
0
void STATE_APIENTRY
crStateGetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);
	CROcclusionObject *q;

	FLUSH();

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

	q = (CROcclusionObject *) crHashtableSearch(o->objects, id);
	if (!q || q->active) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								"glGetQueryObjectivARB");
		return;
	}

	switch (pname) {
	case GL_QUERY_RESULT_ARB:
		*params = q->passedCounter;
		break;
	case GL_QUERY_RESULT_AVAILABLE_ARB:
		*params = GL_TRUE;
		break;
	default:
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
								 "glGetQueryObjectivARB(pname)");
		return;
   }
}
Ejemplo n.º 13
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);
}
Ejemplo n.º 14
0
void STATE_APIENTRY
crStateGetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &g->bufferobject;
    CRBufferObject *obj;

    FLUSH();

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

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

    if (pname != GL_BUFFER_MAP_POINTER_ARB) {
        crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)");
        return;
    }

    *params = obj->pointer;
}
Ejemplo n.º 15
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);
}
Ejemplo n.º 16
0
void STATE_APIENTRY crStateGetPointerv(GLenum pname, GLvoid * * params) 
{
	CRContext *g = GetCurrentContext();
	CRClientState *c = &(g->client);

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

	switch (pname) 
	{
		case GL_VERTEX_ARRAY_POINTER:
			*params = (GLvoid *) c->array.v.p;
			break;
		case GL_COLOR_ARRAY_POINTER:
			*params = (GLvoid *) c->array.c.p;
			break;
		case GL_NORMAL_ARRAY_POINTER:
			*params = (GLvoid *) c->array.n.p;
			break;
		case GL_INDEX_ARRAY_POINTER:
			*params = (GLvoid *) c->array.i.p;
			break;
		case GL_TEXTURE_COORD_ARRAY_POINTER:
			*params = (GLvoid *) c->array.t[c->curClientTextureUnit].p;
			break;
		case GL_EDGE_FLAG_ARRAY_POINTER:
			*params = (GLvoid *) c->array.e.p;
			break;
#ifdef CR_EXT_fog_coord
		case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
			*params = (GLvoid *) c->array.f.p;
			break;
#endif
#ifdef CR_EXT_secondary_color
		case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
			if( g->extensions.EXT_secondary_color ){
				*params = (GLvoid *) c->array.s.p;
			}
			else {
				crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid Enum passed to glGetPointerv: SECONDARY_COLOR_ARRAY_EXT - EXT_secondary_color is not enabled." );
				return;
			}
			break;
#endif
		case GL_FEEDBACK_BUFFER_POINTER:
		case GL_SELECTION_BUFFER_POINTER:
			/* do nothing - API switching should pick this up */
			break;
		default:
			crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
					"glGetPointerv: invalid pname: %d", pname);
			return;
	}
}
Ejemplo n.º 17
0
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;
}
Ejemplo n.º 18
0
void STATE_APIENTRY
crStateDeleteBuffersARB(GLsizei n, const GLuint *buffers)
{
    CRContext *g = GetCurrentContext();
    int i;

    FLUSH();

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

    if (n < 0) {
        crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
                                 "glDeleteBuffersARB(n < 0)");
        return;
    }

    for (i = 0; i < n; i++) {
        if (buffers[i]) {
            CRBufferObject *obj = (CRBufferObject *)
                crHashtableSearch(g->shared->buffersTable, buffers[i]);
            if (obj) {
                int j;

                ctStateBuffersRefsCleanup(g, obj, g->neg_bitid);

                CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j)
                {
                    /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info,
                     * so on restore, we set mark bits as used.
                     * This is why g_pAvailableContexts[j] could be NULL
                     * also g_pAvailableContexts[0] will hold default context, which we should discard */
                    CRContext *ctx = g_pAvailableContexts[j];
                    if (j && ctx)
                    {
                        ctStateBuffersRefsCleanup(ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified,
                                                                            * but not the current context ones*/
                    }
                    else
                        CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(obj, j);
                }

                crHashtableDelete(g->shared->buffersTable, buffers[i], crStateFreeBufferObject);
            }
        }
    }
Ejemplo n.º 19
0
void REPLICATESPU_APIENTRY replicatespu_EndList(void)
{
	GET_THREAD(thread);

	if (thread->currentContext->displayListMode == GL_FALSE) {
	    crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 
		"replicate: EndList called without a preceding NewList");
	    return;
	}

	/* All okay.  Tell the state tracker and the DLM that we've
	 * finished a new display list.
	 */
	crStateEndList();
	crDLMEndList();

	/* Remember ourselves, too, so we don't have to waste a function
	 * call to figure out whether we're in a list or not.
	 */
	thread->currentContext->displayListMode = GL_FALSE;
	thread->currentContext->displayListIdentifier = 0;

	/* Pack it up so we can send it to all the connected
	 * VNC clients.
	 */
	if (replicate_spu.swap)
	{
		crPackEndListSWAP();
	}
	else
	{
		crPackEndList();
	}
}
Ejemplo n.º 20
0
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);
}
Ejemplo n.º 21
0
void TILESORTSPU_APIENTRY tilesortspu_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
{
	GET_THREAD(thread);
	GLubyte *buffer;
	GLenum dlMode = thread->currentContext->displayListMode;
	if (dlMode != GL_FALSE) {
	    /* just creating or compiling display lists */
	    if (tilesort_spu.lazySendDLists) crDLMCompileCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
	    else if (tilesort_spu.swap) crPackCopyTexImage2DSWAP(target, level, internalFormat, x, y, width, height, border);
	    else crPackCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
	    return;
	}

	buffer = crAlloc(width * height * sizeof(GLubyte) * 4);
	if (buffer)
	{
		const GLenum format = baseFormat( internalFormat );
		const GLenum type = (format == GL_DEPTH_COMPONENT) ? GL_FLOAT : GL_UNSIGNED_BYTE;

		tilesortspu_ReadPixels( x, y, width, height, format, type, buffer );

		crStateTexImage2D( target, level, internalFormat, width, height,
											 border, format, type, buffer );

		crFree(buffer);
	}
	else
	{
		crStateError( __LINE__, __FILE__, GL_OUT_OF_MEMORY, "glCopyTexImage2D" );
	}
}
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);
}
Ejemplo n.º 23
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);
}
Ejemplo n.º 24
0
void STATE_APIENTRY
crStateBeginQueryARB(GLenum target, GLuint id)
{
	CRContext *g = GetCurrentContext();
	CROcclusionState *o = &(g->occlusion);
	CROcclusionObject *q;

	FLUSH();

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

	if (target != GL_SAMPLES_PASSED_ARB) {
		crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
								 "glBeginQueryARB(target)");
		return;
	}

	if (o->currentQueryObject) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
								 "glBeginQueryARB(target)");
		return;
	}

	q = (CROcclusionObject *) crHashtableSearch(o->objects, id);
	if (q && q->active) {
		crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBeginQueryARB");
		return;
	}
	else if (!q) {
		q = NewQueryObject(target, id);
		if (!q) {
			crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBeginQueryARB");
			return;
		}
		crHashtableAdd(o->objects, id, q);
	}
	
	q->active = GL_TRUE;
	q->passedCounter = 0;
	q->active = GL_TRUE;
	q->passedCounter = 0;
	o->currentQueryObject = id;
}
Ejemplo n.º 25
0
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;
}
Ejemplo n.º 26
0
void REPLICATESPU_APIENTRY replicatespu_NewList(GLuint listIdentifier, GLenum mode)
{
	GET_THREAD(thread);

	if (listIdentifier == 0) {
	    crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, 
		"replicate: NewList with zero list identifier");
	    return;
	}
	if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) {
	    crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, 
		"replicate: NewList with bad mode (0x%x)", mode);
	    return;
	}
	if (thread->currentContext->displayListMode != GL_FALSE) {
	    crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, 
		"replicate: NewList called while list %d was open",
		thread->currentContext->displayListIdentifier);
	    return;
	}

	/* All okay.  Tell the state tracker and the DLM that we've
	 * started a new display list.
	 */
	crStateNewList(listIdentifier, mode);
	crDLMNewList(listIdentifier, mode);

	/* Remember ourselves, too, so we don't have to waste a function
	 * call to figure out whether we're in a list or not.
	 */
	thread->currentContext->displayListMode = mode;
	thread->currentContext->displayListIdentifier = listIdentifier;

	/* Pack it up so we can send it to all the connected
	 * VNC clients.
	 */
	if (replicate_spu.swap)
	{
		crPackNewListSWAP(listIdentifier, mode);
	}
	else
	{
		crPackNewList(listIdentifier, mode);
	}
}
Ejemplo n.º 27
0
void STATE_APIENTRY
crStateGetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &g->bufferobject;
    CRBufferObject *obj;

    FLUSH();

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

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

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

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

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

    if (b->retainBufferData && obj->data) {
        crMemcpy(data, (char *) obj->data + offset, size);
    }
}
Ejemplo n.º 28
0
void * STATE_APIENTRY
crStateMapBufferARB(GLenum target, GLenum access)
{
    CRContext *g = GetCurrentContext();
    CRBufferObjectState *b = &g->bufferobject;
    CRBufferObject *obj;

    FLUSH();

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

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

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

    switch (access) {
        case GL_READ_ONLY_ARB:
        case GL_WRITE_ONLY_ARB:
        case GL_READ_WRITE_ARB:
            obj->access = access;
            break;
        default:
            crStateError(__LINE__, __FILE__, GL_INVALID_ENUM,
                                     "glMapBufferARB(access)");
            return NULL;
    }

    if (b->retainBufferData && obj->data)
        obj->pointer = obj->data;

    return obj->pointer;
}
Ejemplo n.º 29
0
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);
}
Ejemplo n.º 30
0
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);
}