Example #1
0
int crdlm_pointers_CompressedTexImage3DARB(struct instanceCompressedTexImage3DARB *instance, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data)
{
    unsigned int size = imagesize;

    if (instance && size > 0) {
	crMemcpy(instance->data, data, size);
    }

    return size;
}
void crUnpackClipPlane(PCrUnpackerState pState)
{
	GLdouble equation[4];
    CHECK_BUFFER_SIZE_STATIC(pState, 4 + sizeof(equation));

	GLenum plane = READ_DATA(pState, 0, GLenum );
	crMemcpy( equation, DATA_POINTER(pState, 4, GLdouble ), sizeof(equation) );

	pState->pDispatchTbl->ClipPlane( plane, equation );
	INCR_DATA_PTR(pState, sizeof( GLenum ) + 4*sizeof( GLdouble ));
}
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;
}
Example #4
0
int crdlm_pointers_ZPixCR( struct instanceZPixCR *instance, GLsizei width, 
			 GLsizei height, GLenum format, GLenum type, 
			 GLenum ztype, GLint zparm, GLint length, 
			 const GLvoid *pixels, CRClientState *c)
{
     unsigned int size = length;
     if (instance && size > 0) {
	  crMemcpy(instance->pixels,pixels,length);
     }
     
     return size;
}
Example #5
0
void PACK_APIENTRY crPackCallListsSWAP(GLint n, GLenum type,
                                       const GLvoid *lists )
{
    unsigned char *data_ptr;
    int packet_length;
    GLshort *shortPtr;
    GLint   *intPtr;
    int i;

    int bytesPerList = __gl_CallListsNumBytes( type );
    int numBytes = bytesPerList * n;

    if (numBytes < 0)
    {
        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
                     "crPackCallLists(bad type)" );
        return;
    }

    packet_length = sizeof( n ) +
                    sizeof( type ) +
                    numBytes;

    data_ptr = (unsigned char *) crPackAlloc( packet_length );
    WRITE_DATA( 0, GLint, SWAP32(n) );
    WRITE_DATA( 4, GLenum, SWAP32(type) );

    crMemcpy( data_ptr + 8, lists, numBytes );
    shortPtr = (GLshort *) (data_ptr + 8);
    intPtr   = (GLint *) (data_ptr + 8);

    if (bytesPerList > 1)
    {
        for ( i = 0 ; i < n ; i++)
        {
            switch( bytesPerList )
            {
            case 2:
                *shortPtr = SWAP16(*shortPtr);
                shortPtr+=1;
                break;
            case 4:
                *intPtr = SWAP32(*intPtr);
                intPtr+=1;
                break;
            }
        }
    }

    crHugePacket( CR_CALLLISTS_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
Example #6
0
void crUnpackExtendProgramNamedParameter4fvNV(void)
{
	GLenum id = READ_DATA(8, GLuint);
	GLsizei len = READ_DATA(12, GLsizei);
	GLfloat params[4];
	GLubyte *name = crAlloc(len);
	params[0] = READ_DATA(16, GLfloat);
	params[1] = READ_DATA(20, GLfloat);
	params[2] = READ_DATA(24, GLfloat);
	params[3] = READ_DATA(28, GLfloat);
	crMemcpy(name, DATA_POINTER(32, GLubyte), len);
	cr_unpackDispatch.ProgramNamedParameter4fvNV(id, len, name, params);
}
Example #7
0
void crUnpackExtendProgramNamedParameter4dNV(void)
{
	GLuint id = READ_DATA(8, GLuint);
	GLsizei len = READ_DATA(12, GLsizei);
	GLdouble params[4];
	GLubyte *name = crAlloc (len);
	params[0] = READ_DOUBLE(16);
	params[1] = READ_DOUBLE(24);
	params[2] = READ_DOUBLE(32);
	params[3] = READ_DOUBLE(40);
	crMemcpy(name, DATA_POINTER(48, GLubyte), len);
	cr_unpackDispatch.ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]);
}
Example #8
0
void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data )
{
	unsigned char *data_ptr;
	int packet_length;
	int isnull = (data == NULL);

	/* All extended opcodes have their first 8 bytes predefined:
	 * the first four indicate the packet size, and the next four
	 * indicate the actual extended opcode.
	 */
	packet_length = 
		sizeof( GLenum) + /* extended opcode */
		sizeof( target ) +
		sizeof( level ) +
		sizeof( xoffset ) +
		sizeof( yoffset ) +
		sizeof( zoffset ) +
		sizeof( width ) + 
		sizeof( height ) + 
		sizeof( depth ) + 
		sizeof( format ) +
		sizeof( imagesize ) +
		sizeof( int ); /* isnull */

	if (data)
	{
		packet_length += imagesize;
	}

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) );
	WRITE_DATA( 4, GLenum, SWAP32(target) );
	WRITE_DATA( 8, GLint, SWAP32(level) );
	WRITE_DATA( 12, GLint, SWAP32(xoffset) );
	WRITE_DATA( 16, GLint, SWAP32(yoffset) );
	WRITE_DATA( 20, GLint, SWAP32(zoffset) );
	WRITE_DATA( 24, GLsizei, SWAP32(width) );
	WRITE_DATA( 28, GLsizei, SWAP32(height) );
	WRITE_DATA( 32, GLsizei, SWAP32(depth) );
	WRITE_DATA( 36, GLenum, SWAP32(format) );
	WRITE_DATA( 40, GLsizei, SWAP32(imagesize) );
	WRITE_DATA( 44, int, SWAP32(isnull) );

	if (data) {
		crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize);
	}

	crHugePacket( CR_EXTEND_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
void PACK_APIENTRY crPackDrawBuffers(GLsizei n, const GLenum *bufs)
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(n) + n*sizeof(*bufs);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA_AI(int, packet_length);
    WRITE_DATA_AI(GLenum, CR_DRAWBUFFERS_EXTEND_OPCODE);
    WRITE_DATA_AI(GLsizei, n);
    crMemcpy(data_ptr, bufs, n*sizeof(*bufs));
    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
void STATE_APIENTRY crStateGetPolygonStipple(PCRStateTracker pState, GLubyte *b )
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *poly = &(g->polygon);

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

    crMemcpy((char*)b, (char*)poly->stipple, 128);
}
Example #11
0
void crPackAppendBuffer( const CRPackBuffer *src )
{
	GET_PACKER_CONTEXT(pc);
	const int num_data = crPackNumData(src);
	const int num_opcode = crPackNumOpcodes(src);

	CRASSERT(num_data >= 0);
	CRASSERT(num_opcode >= 0);

	/* don't append onto ourself! */
	CRASSERT(pc->currentBuffer);
	CRASSERT(pc->currentBuffer != src);

	if (!crPackCanHoldBuffer(src))
	{
		if (src->holds_BeginEnd)
		{
			crWarning( "crPackAppendBuffer: overflowed the destination!" );
			return;
		}
		else
			crError( "crPackAppendBuffer: overflowed the destination!" );
	}

	/* Copy the buffer data/operands which are at the head of the buffer */
	crMemcpy( pc->buffer.data_current, src->data_start, num_data );
	pc->buffer.data_current += num_data;

	/* Copy the buffer opcodes which are at the tail of the buffer */
	CRASSERT( pc->buffer.opcode_current - num_opcode >= pc->buffer.opcode_end );
	crMemcpy( pc->buffer.opcode_current + 1 - num_opcode, src->opcode_current + 1,
			num_opcode );
	pc->buffer.opcode_current -= num_opcode;
	pc->buffer.holds_BeginEnd |= src->holds_BeginEnd;
	pc->buffer.in_BeginEnd = src->in_BeginEnd;
	pc->buffer.holds_List |= src->holds_List;
}
Example #12
0
void PACK_APIENTRY crPackDeleteProgramsARB(GLsizei n, const GLuint *ids)
{
    unsigned char *data_ptr;
    int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*ids);

    if (!ids)
        return;

    data_ptr = (unsigned char *) crPackAlloc(packet_length);
    WRITE_DATA(0, GLenum, CR_DELETEPROGRAMSARB_EXTEND_OPCODE);
    WRITE_DATA(4, GLsizei, n);
    crMemcpy(data_ptr + 8, ids, n * sizeof(*ids));
    crHugePacket(CR_EXTEND_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
void PACK_APIENTRY crPackUniform4iv(GLint location, GLsizei count, const GLint *value)
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 4*count*sizeof(*value);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA_AI(int, packet_length);
    WRITE_DATA_AI(GLenum, CR_UNIFORM4IV_EXTEND_OPCODE);
    WRITE_DATA_AI(GLint, location);
    WRITE_DATA_AI(GLsizei, count);
    crMemcpy(data_ptr, value, 4*count*sizeof(*value));
    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
void crUnpackTexGendv( void )
{
    GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
    GLdouble params[4];
    unsigned int n_param = READ_DATA( 0, int ) - ( sizeof(int) + 8 );

    if ( n_param > sizeof(params) )
        crError( "crUnpackTexGendv: n_param=%d, expected <= %d\n", n_param,
                 (unsigned int)sizeof(params) );
    crMemcpy( params, DATA_POINTER( sizeof( int ) + 8, GLdouble ), n_param );

    cr_unpackDispatch.TexGendv( coord, pname, params );
    INCR_VAR_PTR();
}
Example #15
0
void crNetworkPointerWrite( CRNetworkPointer *dst, void *src )
{
	/* init CRNetworkPointer with invalid values */
	dst->ptrAlign[0] = 0xDeadBeef;
	dst->ptrAlign[1] = 0xCafeBabe;
	/* copy the pointer's value into the CRNetworkPointer */
	crMemcpy( dst, &src, sizeof(src) );

	/* if either assertion fails, it probably means that a packer function
	 * (which returns a value) was called without setting up the writeback
	 * pointer, or something like that.
	 */
	CRASSERT(dst->ptrAlign[0] != 0xffffffff);
	CRASSERT(dst->ptrAlign[0] != 0xDeadBeef);
}
Example #16
0
void PACK_APIENTRY
crPackDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
                                                GLenum type, const GLvoid *indices)
{
    unsigned char *data_ptr, *start_ptr;
    int packet_length = sizeof(int) + sizeof(mode) + sizeof(start)
        + sizeof(end) + sizeof(count) + sizeof(type) + sizeof(GLuint);
    GLsizei indexsize;

#ifdef CR_ARB_vertex_buffer_object
    CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer;
    packet_length += sizeof(GLint);
    if (elementsBuffer && elementsBuffer->id)
    {
        /*@todo not sure it's possible, and not sure what to do*/
        if (!elementsBuffer->data)
        {
            crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring.");
            return;
        }
        indexsize = 0;
    }
    else
#endif
    {
      indexsize = crPackElementsIndexSize(type);
    }

    packet_length += count * indexsize;

    start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
    WRITE_DATA_AI(GLenum, CR_DRAWRANGEELEMENTS_EXTEND_OPCODE);
    WRITE_DATA_AI(GLenum, mode);
    WRITE_DATA_AI(GLuint, start);
    WRITE_DATA_AI(GLuint, end);
    WRITE_DATA_AI(GLsizei, count);
    WRITE_DATA_AI(GLenum, type);
    WRITE_DATA_AI(GLuint, (GLuint) ((uintptr_t) indices));
#ifdef CR_ARB_vertex_buffer_object
    WRITE_DATA_AI(GLint, (GLint) (indexsize>0));
#endif
    if (indexsize>0)
    {
        crMemcpy(data_ptr, indices, count * indexsize);
    }
    crHugePacket(CR_EXTEND_OPCODE, start_ptr);
    crPackFree(start_ptr);
}
Example #17
0
void PACK_APIENTRY
crPackDeleteBuffersARBSWAP(GLsizei n, const GLuint * buffers)
{
	unsigned char *data_ptr;
	int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*buffers);

	if (!buffers)
		return;

	data_ptr = (unsigned char *) crPackAlloc(packet_length);
	WRITE_DATA( 0, GLenum, SWAP32(CR_DELETEBUFFERSARB_EXTEND_OPCODE) );
	WRITE_DATA( 4, GLsizei, SWAP32(n) );
	crMemcpy( data_ptr + 8, buffers, n * sizeof(*buffers) );
	crHugePacket( CR_EXTEND_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
void PACK_APIENTRY 
crPackDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
{
    unsigned char *data_ptr;
    int packet_length = sizeof(GLenum) + sizeof(n) + n*sizeof(*framebuffers);

    if (!framebuffers)
        return;

    data_ptr = (unsigned char *) crPackAlloc(packet_length);
    WRITE_DATA(0, GLenum, CR_DELETEFRAMEBUFFERSEXT_EXTEND_OPCODE);
    WRITE_DATA(4, GLsizei, n);
    crMemcpy(data_ptr + 8, framebuffers, n* sizeof(*framebuffers));
    crHugePacket(CR_EXTEND_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
Example #19
0
void PACK_APIENTRY crPackLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program)
{
    const int packet_length = 20 + len;
    unsigned char *data_ptr;
    CR_GET_PACKER_CONTEXT(pc);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA(0, int, packet_length);
    WRITE_DATA(4, GLenum, CR_LOADPROGRAMNV_EXTEND_OPCODE);
    WRITE_DATA(8, GLenum, target);
    WRITE_DATA(12, GLuint, id);
    WRITE_DATA(16, GLsizei, len);
    crMemcpy((void *) (data_ptr + 20), program, len);
    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
Example #20
0
void PACK_APIENTRY  crPackProgramStringARB(GLenum target, GLenum format, GLsizei len, const void *string)
{
    const int packet_length = 20 + len;
    unsigned char *data_ptr;
    CR_GET_PACKER_CONTEXT(pc);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA(0, int, packet_length);
    WRITE_DATA(4, GLenum, CR_PROGRAMSTRINGARB_EXTEND_OPCODE);
    WRITE_DATA(8, GLenum, target);
    WRITE_DATA(12, GLuint, format);
    WRITE_DATA(16, GLsizei, len);
    crMemcpy((void *) (data_ptr + 20), string, len);
    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
Example #21
0
void PACK_APIENTRY crPackProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params)
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    int packet_length = sizeof(int) + sizeof(target) + sizeof(index) + sizeof(num) + num * 4 * sizeof(GLfloat);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA(0, int, packet_length);
    WRITE_DATA(sizeof(int) + 0, GLenum, target);
    WRITE_DATA(sizeof(int) + 4, GLuint, index);
    WRITE_DATA(sizeof(int) + 8, GLuint, num);
    crMemcpy(data_ptr + sizeof(int) + 12, params, num * 4 * sizeof(GLfloat));

    WRITE_OPCODE(pc, CR_PROGRAMPARAMETERS4FVNV_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + 3*3*count*sizeof(*value);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA_AI(int, packet_length);
    WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX3FV_EXTEND_OPCODE);
    WRITE_DATA_AI(GLint, location);
    WRITE_DATA_AI(GLsizei, count);
    WRITE_DATA_AI(GLboolean, transpose);
    crMemcpy(data_ptr, value, 3*3*count*sizeof(*value));
    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
void PACK_APIENTRY crPackBindAttribLocation(GLuint program, GLuint index, const char *name)
{
    CR_GET_PACKER_CONTEXT(pc);
    unsigned char *data_ptr;
    int cbName = crStrlen(name)+1;
    int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(program)+sizeof(index) + cbName*sizeof(*name);

    CR_GET_BUFFERED_POINTER(pc, packet_length);
    WRITE_DATA_AI(int, packet_length);
    WRITE_DATA_AI(GLenum, CR_BINDATTRIBLOCATION_EXTEND_OPCODE);
    WRITE_DATA_AI(GLuint, program);
    WRITE_DATA_AI(GLuint, index);
    crMemcpy(data_ptr, name, cbName*sizeof(*name));
    WRITE_OPCODE(pc, CR_EXTEND_OPCODE);
    CR_UNLOCK_PACKER_CONTEXT(pc);
}
Example #24
0
char *crStrdup( const char *str )
{
	int len;
	char *ret;
	
	/* Allow strdup'ing of NULL strings -- this makes the __fillin functions 
	 * much cleaner. */
	
	if (str == NULL) return NULL;
	
	len = crStrlen(str);
	ret = (char*)crAlloc( len+1 );
	crMemcpy( ret, str, len );
	ret[len] = '\0';
	return ret;
}
Example #25
0
void
CRUT_APIENTRY
crutGetMenuXML( CRUTAPI *crut_api )
{
    char response[8096];
    
    if (!crut_api->mothershipConn)
	crError("Checking for Menu XML but no connection!"); 
    
    crMothershipGetParam( crut_api->mothershipConn, "crut_menu_xml", response );
    
    if (crStrlen(response) < MENU_MAX_SIZE)
		crMemcpy(crut_api->menuBuffer, response, crStrlen(response));
    else
		crError("Menu XML is too long for buffer");
}
void PACK_APIENTRY
crPackDeleteFencesNV(GLsizei n, const GLuint * fences)
{
    unsigned char *data_ptr;
    int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*fences);

    if( !fences )
        return;

    data_ptr = (unsigned char *) crPackAlloc(packet_length);
    WRITE_DATA(0, GLenum, CR_DELETEFENCESNV_EXTEND_OPCODE);
    WRITE_DATA(4, GLsizei, n);
    crMemcpy(data_ptr + 8, fences, n * sizeof(*fences));
    crHugePacket(CR_EXTEND_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
Example #27
0
File: net.c Project: L3oV1nc3/VMGL
/**
 * Receive a chunk of a CR_MESSAGE_MULTI_BODY/TAIL transmission.
 * \param conn  the network connection
 * \param msg  the incoming multi-part message
 * \param len  number of bytes in the message
 */
static void
crNetRecvMulti( CRConnection *conn, CRMessageMulti *msg, unsigned int len )
{
	CRMultiBuffer *multi = &(conn->multi);
	unsigned char *src, *dst;

	CRASSERT( len > sizeof(*msg) );
	len -= sizeof(*msg);

	/* Check if there's enough room in the multi-buffer to append 'len' bytes */
	if ( len + multi->len > multi->max )
	{
		if ( multi->max == 0 )
		{
			multi->len = conn->sizeof_buffer_header;
			multi->max = 8192;  /* arbitrary initial size */
		}
		/* grow the buffer by 2x until it's big enough */
		while ( len + multi->len > multi->max )
		{
			multi->max <<= 1;
		}
		crRealloc( &multi->buf, multi->max );
	}

	dst = (unsigned char *) multi->buf + multi->len;
	src = (unsigned char *) msg + sizeof(*msg);
	crMemcpy( dst, src, len );
	multi->len += len;

	if (msg->header.type == CR_MESSAGE_MULTI_TAIL)
	{
		/* OK, we've collected the last chunk of the multi-part message */
		conn->HandleNewMessage(
				conn,
				(CRMessage *) (((char *) multi->buf) + conn->sizeof_buffer_header),
				multi->len - conn->sizeof_buffer_header );

		/* clean this up before calling the user */
		multi->buf = NULL;
		multi->len = 0;
		multi->max = 0;
	}

	/* Don't do this too early! */
	conn->InstantReclaim( conn, (CRMessage *) msg );
}
Example #28
0
/*
       ZPix - compressed DrawPixels
*/
void PACK_APIENTRY crPackZPixCR( GLsizei width, GLsizei height, 
        GLenum format, GLenum type,
        GLenum ztype, GLint zparm, GLint length,
        const GLvoid *pixels,
        const CRPixelPackState *unpackstate )
{
    unsigned char *data_ptr;
    int packet_length;
    (void)unpackstate;

    if (pixels == NULL)
    {
        return;
    }

    packet_length = 
        sizeof( int ) +  /* packet size */
        sizeof( GLenum ) +  /* extended opcode */
        sizeof( width ) +
        sizeof( height ) +
        sizeof( format ) +
        sizeof( type ) +
        sizeof( ztype ) +
        sizeof( zparm ) +
        sizeof( length );

    packet_length += length;

/* XXX JAG
  crDebug("PackZPixCR: fb %d x %d, state %d, zlen = %d, plen = %d",
                               width, height, ztype, length, packet_length);
*/
    data_ptr = (unsigned char *) crPackAlloc( packet_length );
    WRITE_DATA(  0, GLenum , CR_ZPIXCR_EXTEND_OPCODE );
    WRITE_DATA(  4, GLsizei, width );
    WRITE_DATA(  8, GLsizei, height );
    WRITE_DATA( 12, GLenum,  format );
    WRITE_DATA( 16, GLenum,  type );
    WRITE_DATA( 20, GLenum,  ztype );
    WRITE_DATA( 24, GLint,   zparm );
    WRITE_DATA( 28, GLint,   length );

    crMemcpy((void *) (data_ptr+32), pixels, length);

    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
Example #29
0
int crdlm_pointers_Lightfv( struct instanceLightfv *instance, GLenum light, GLenum pname, const GLfloat *params )
{
    unsigned int size;
    switch(pname) {
	case GL_AMBIENT: case GL_DIFFUSE: case GL_SPECULAR: case GL_POSITION:
	    size = 4 * sizeof(GLfloat);
	    break;
	case GL_SPOT_DIRECTION:
	    size = 3 * sizeof(GLfloat);
	    break;
	default:
	    size = 1 * sizeof(GLfloat);
	    break;
    }
    if (instance) crMemcpy(instance->params, params, size);
    return size;
}
Example #30
0
static void crServerCopySubImage(char *pDst, char* pSrc, CRrecti *pRect, int srcWidth, int srcHeight)
{
    int i;
    int dstrowsize = 4*(pRect->x2-pRect->x1);
    int srcrowsize = 4*srcWidth;
    int height = pRect->y2-pRect->y1;

    pSrc += 4*pRect->x1 + srcrowsize*(srcHeight-1-pRect->y1);

    for (i=0; i<height; ++i)
    {
        crMemcpy(pDst, pSrc, dstrowsize);

        pSrc -= srcrowsize;
        pDst += dstrowsize;
    }
}