예제 #1
0
void PACK_APIENTRY
crPackBufferDataARBSWAP( GLenum target, GLsizeiptrARB size,
                                         const GLvoid * data, GLenum usage )
{
    unsigned char *data_ptr, *start_ptr;
    int packet_length;

    packet_length = sizeof(GLenum)
        + sizeof(target) + sizeof(GLuint) + sizeof(usage) + sizeof(GLint);

    /*Note: it's valid to pass a NULL pointer here, which tells GPU drivers to allocate memory for the VBO*/
    if (data) packet_length += size;

    start_ptr = data_ptr = (unsigned char *) crPackAlloc( packet_length );

    WRITE_DATA_AI(GLenum, SWAP32(CR_BUFFERDATAARB_EXTEND_OPCODE) );
    WRITE_DATA_AI(GLenum, SWAP32(target) );
    WRITE_DATA_AI(GLuint, SWAP32((GLuint) size) );
    WRITE_DATA_AI(GLenum, SWAP32(usage) );
    WRITE_DATA_AI(GLint, SWAP32((GLint) (data!=NULL)) );
    if (data)
         crMemcpy(data_ptr, data, size);

    crHugePacket( CR_EXTEND_OPCODE, start_ptr );
    crPackFree( start_ptr );
}
예제 #2
0
void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1, 
        GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, 
        GLint vstride, GLint vorder, const GLdouble *points)
{
    unsigned char *data_ptr;
    int u,v;
    int comp;
    GLdouble *dest_data, *src_data;
    int packet_length = 
        sizeof(target) + 
        sizeof(u1) +
        sizeof(u2) +
        sizeof(uorder) +
        sizeof(ustride) +
        sizeof(v1) +
        sizeof(v2) + 
        sizeof(vorder) +
        sizeof(vstride);

    int num_components = __gl_Map2NumComponents(target);
    if (num_components < 0)
    {
        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
                                 "crPackMap2d(bad target)");
        return;
    }

    packet_length += num_components*uorder*vorder*sizeof(*points);

    data_ptr = (unsigned char *) crPackAlloc(packet_length);

    WRITE_DATA(0, GLenum, SWAP32(target));
    WRITE_SWAPPED_DOUBLE(4, u1);
    WRITE_SWAPPED_DOUBLE(12, u2);
    WRITE_DATA(20, GLint, SWAP32(num_components));
    WRITE_DATA(24, GLint, SWAP32(uorder));
    WRITE_SWAPPED_DOUBLE(28, v1);
    WRITE_SWAPPED_DOUBLE(36, v2);
    WRITE_DATA(44, GLint, SWAP32(num_components*uorder));
    WRITE_DATA(48, GLint, SWAP32(vorder));

    dest_data = (GLdouble *) (data_ptr + 52);
    src_data = (GLdouble *) points;
    for (v = 0 ; v < vorder ; v++)
    {
        for (u = 0 ; u < uorder ; u++)
        {
            for (comp = 0 ; comp < num_components ; comp++)
            {
                WRITE_SWAPPED_DOUBLE(((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp));
            }
            dest_data += num_components;
            src_data += ustride;
        }
        src_data += vstride - ustride*uorder;
    }

    crHugePacket(CR_MAP2D_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
예제 #3
0
void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level, 
		GLint xoffset, GLsizei width, GLenum format, GLenum type,
		const GLvoid *pixels, const CRPixelPackState *unpackstate )
{
	unsigned char *data_ptr;
	int packet_length;
    CRPixelPackState tmpUnpackState = *unpackstate;

	packet_length = 
		sizeof( target ) +
		sizeof( level ) +
		sizeof( xoffset ) +
		sizeof( width ) +
		sizeof( format ) +
		sizeof( type ) +
		crImageSize( format, type, width, 1 );

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32(target) );
	WRITE_DATA( 4, GLint, SWAP32(level) );
	WRITE_DATA( 8, GLint, SWAP32(xoffset) );
	WRITE_DATA( 12, GLsizei, SWAP32(width) );
	WRITE_DATA( 16, GLenum, SWAP32(format) );
	WRITE_DATA( 20, GLenum, SWAP32(type) );

	/* flip application-requested swapBytes state */
	tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;

	crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type,
								pixels, format, type, width, &tmpUnpackState );

	crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
예제 #4
0
void PACK_APIENTRY crPackLockArraysEXT(GLint first, GLint count)
{
    CRContext *g = crStateGetCurrent();
    CRClientState *c = &g->client;
    unsigned char *data_ptr, *start_ptr;
    int packet_length = sizeof(int); /*extopcode*/
    int vertex_size, i, numenabled;

    packet_length += sizeof(first) + sizeof(count); /*params*/
    numenabled = crPack_GetNumEnabledArrays(c, &vertex_size);
    packet_length += sizeof(int) + numenabled*sizeof(int); /*numenabled + indices*/
    packet_length += vertex_size * count; /*vertices data*/

    start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
    WRITE_DATA_AI(GLenum, CR_LOCKARRAYSEXT_EXTEND_OPCODE );
    WRITE_DATA_AI(GLint, first);
    WRITE_DATA_AI(GLint, count);
    WRITE_DATA_AI(int, numenabled);
    for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
    {
        crPackLockClientPointer(first, count, &data_ptr, i, c);
    }
    crHugePacket(CR_EXTEND_OPCODE, start_ptr);
    crPackFree(start_ptr);
}
예제 #5
0
void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n,
		const GLuint *textures, const GLclampf *priorities )
{
	unsigned char *data_ptr;
	int packet_length = 
		sizeof( n ) + 
		n*sizeof( *textures ) + 
		n*sizeof( *priorities );
	int i;

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLsizei, SWAP32(n) );
	for ( i = 0 ; i < n ; i++)
	{
		WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]));
	}
	for ( i = 0 ; i < n ; i++)
	{
		WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ),
				GLuint, SWAPFLOAT(priorities[i]));
	}

	crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
예제 #6
0
void PACK_APIENTRY crPackPixelMapusvSWAP(GLenum map, GLsizei mapsize, 
		const GLushort *values )
{
	unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );

	crHugePacket( CR_PIXELMAPUSV_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
예제 #7
0
/*
 * Put the given buffer list into the free buffer pool.  We do this when
 * we've finished rendering a frame and no longer need the buffer list.
 */
void hiddenlineReclaimPackBuffer( BufList *bl )
{
	if (bl->can_reclaim)
	{
		GET_CONTEXT(context);
		crBufferPoolPush( context->bufpool, bl->buf, hiddenline_spu.buffer_size );
	}
	else
	{
		crPackFree( bl->buf );
	}
}
예제 #8
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 );
}
예제 #9
0
void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level, 
		GLint internalformat, GLsizei width, GLsizei height, GLint border, 
		GLenum format, GLenum type, const GLvoid *pixels,
		const CRPixelPackState *unpackstate )
{
	unsigned char *data_ptr;
	int packet_length;
	int isnull = (pixels == NULL);

	packet_length = 
		sizeof( target ) +
		sizeof( level ) +
		sizeof( internalformat ) +
		sizeof( width ) +
		sizeof( height ) + 
		sizeof( border ) +
		sizeof( format ) +
		sizeof( type ) +
		sizeof( int );

	if (pixels)
	{
		packet_length += crImageSize( format, type, width, height );
	}

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32(target) );
	WRITE_DATA( 4, GLint, SWAP32(level) );
	WRITE_DATA( 8, GLint, SWAP32(internalformat) );
	WRITE_DATA( 12, GLsizei, SWAP32(width) );
	WRITE_DATA( 16, GLsizei, SWAP32(height) );
	WRITE_DATA( 20, GLint, SWAP32(border) );
	WRITE_DATA( 24, GLenum, SWAP32(format) );
	WRITE_DATA( 28, GLenum, SWAP32(type) );
	WRITE_DATA( 32, int, SWAP32(isnull) );

	if (pixels)
	{
		CRPixelPackState tmpUnpackState = *unpackstate;
		/* flip application-requested swapBytes state */
		tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;

		crPixelCopy2D( width, height,
									 (void *)(data_ptr + 36), format, type, NULL,  /* dst */
									 pixels, format, type, &tmpUnpackState );  /* src */
	}

	crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
예제 #10
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 );
}
예제 #11
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);
}
예제 #12
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);
}
예제 #13
0
void PACK_APIENTRY crPackMap1fSWAP(GLenum target, GLfloat u1,
        GLfloat u2, GLint stride, GLint order, const GLfloat *points)
{
    unsigned char *data_ptr;
    int packet_length = 
        sizeof(target) + 
        sizeof(u1) +
        sizeof(u2) + 
        sizeof(stride) + 
        sizeof(order);

    int num_components = __gl_Map1NumComponents(target);
    GLfloat *src_data, *dest_data;
    int u;
    int comp;

    if (num_components < 0)
    {
        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
                                 "crPackMap1f(bad target)");
        return;
    }

    packet_length += num_components * order * sizeof(*points);

    data_ptr = (unsigned char *) crPackAlloc(packet_length);

    WRITE_DATA(0, GLenum, SWAP32(target));
    WRITE_DATA(4, GLuint, SWAPFLOAT(u1));
    WRITE_DATA(8, GLuint, SWAPFLOAT(u2));
    WRITE_DATA(12, GLint, SWAP32(num_components));
    WRITE_DATA(16, GLint, SWAP32(order));

    dest_data = (GLfloat *) (data_ptr + 20);
    src_data = (GLfloat *) points;
    for (u = 0 ; u < order ; u++)
    {
        for (comp = 0 ; comp < num_components ; comp++)
        {
            WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp)));
        }
        dest_data += num_components;
        src_data += stride;
    }

    crHugePacket(CR_MAP1F_OPCODE, data_ptr);
    crPackFree(data_ptr);
}
예제 #14
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 );
}
예제 #15
0
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);
}
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);
}
예제 #17
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 );
}
예제 #18
0
void PACK_APIENTRY crPackDrawPixels(GLsizei width, GLsizei height, 
                                    GLenum format, GLenum type,
                                    const GLvoid *pixels,
                                    const CRPixelPackState *unpackstate )
{
    unsigned char *data_ptr;
    int packet_length, imagesize;
    int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB);

    packet_length = 
        sizeof( width ) +
        sizeof( height ) +
        sizeof( format ) +
        sizeof( type ) + sizeof(int) + sizeof(GLint);

    if (!noimagedata)
    {
        imagesize = crImageSize( format, type, width, height );

        if (imagesize<=0)
        {
            crDebug("crPackDrawPixels: 0 image size, ignoring");
            return;
        }
        packet_length += imagesize;
    }

    data_ptr = (unsigned char *) crPackAlloc( packet_length );
    WRITE_DATA( 0, GLsizei, width );
    WRITE_DATA( 4, GLsizei, height );
    WRITE_DATA( 8, GLenum, format );
    WRITE_DATA( 12, GLenum, type );
    WRITE_DATA( 16, GLint, noimagedata );
    WRITE_DATA( 20, GLint, (GLint) (uintptr_t) pixels );

    if (!noimagedata)
    {
        crPixelCopy2D(width, height,
                      (void *) (data_ptr + 24), format, type, NULL, /* dst */
                      pixels, format, type, unpackstate);  /* src */
    }

    crHugePacket( CR_DRAWPIXELS_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
예제 #19
0
void PACK_APIENTRY crPackDeleteTexturesSWAP( GLsizei n, const GLuint *textures )
{
	unsigned char *data_ptr;
	int i;

	int packet_length = 
		sizeof( n ) + 
		n*sizeof( *textures );

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLsizei, SWAP32(n) );

	for ( i = 0 ; i < n ; i++)
	{
		WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]) );
	}
	crHugePacket( CR_DELETETEXTURES_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
예제 #20
0
void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, 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( internalformat ) +
		sizeof( width ) + 
		sizeof( border ) +
		sizeof( imagesize ) +
		sizeof( int );

	if (data)
	{
		packet_length += imagesize;
	}

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) );
	WRITE_DATA( 4, GLenum, SWAP32(target) );
	WRITE_DATA( 8, GLint, SWAP32(level) );
	WRITE_DATA( 12, GLint, SWAP32(internalformat) );
	WRITE_DATA( 16, GLsizei, SWAP32(width) );
	WRITE_DATA( 20, GLint, SWAP32(border) );
	WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
	WRITE_DATA( 28, int, SWAP32(isnull) );

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

	crHugePacket( CR_EXTEND_OPCODE, data_ptr );
	crPackFree( data_ptr );
}
예제 #21
0
void PACK_APIENTRY crPackTexSubImage3DSWAP (GLenum target, GLint level,
                GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
                GLenum format, GLenum type, const GLvoid *pixels,
                const CRPixelPackState *unpackstate )
{
        unsigned char *data_ptr;
        int packet_length;

        packet_length =
                sizeof( target ) +
                sizeof( level ) +
                sizeof( xoffset ) +
                sizeof( yoffset ) +
		sizeof( zoffset ) +
                sizeof( width ) +
                sizeof( height ) +
		sizeof( depth ) +
                sizeof( format ) +
                sizeof( type ) +
                crTextureSize( format, type, width, height, depth );

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

        crPixelCopy3D( width, height, depth,
                                                                 (GLvoid *) (data_ptr + 36), format, type, NULL,  /* dst */
                                                                 pixels, format, type, unpackstate );  /* src */

        crHugePacket( CR_TEXSUBIMAGE3D_OPCODE, data_ptr );
        crPackFree( data_ptr );
}
예제 #22
0
void PACK_APIENTRY crPackBitmap(GLsizei width, GLsizei height, 
                                GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
                                const GLubyte *bitmap, const CRPixelPackState *unpack )
{
    const int noimagedata = (bitmap == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB);
    unsigned char *data_ptr;
    int data_length = 0;
    GLubyte *destBitmap = NULL;
    int packet_length = 
        sizeof( width ) + 
        sizeof( height ) +
        sizeof( xorig ) + 
        sizeof( yorig ) + 
        sizeof( xmove ) + 
        sizeof( ymove ) +
        sizeof( GLuint ) + sizeof(GLint);

    if (!noimagedata)
    {
        data_length = CEIL8(width) * height / 8;
        packet_length += data_length;
    }

    data_ptr = (unsigned char *) crPackAlloc( packet_length );

    WRITE_DATA( 0, GLsizei, width );
    WRITE_DATA( 4, GLsizei, height );
    WRITE_DATA( 8, GLfloat, xorig );
    WRITE_DATA( 12, GLfloat, yorig );
    WRITE_DATA( 16, GLfloat, xmove );
    WRITE_DATA( 20, GLfloat, ymove );
    WRITE_DATA( 24, GLuint, noimagedata );
    WRITE_DATA( 28, GLint, (GLint) (uintptr_t) bitmap);

    if (!noimagedata)
        crBitmapCopy(width, height, (GLubyte *)(data_ptr + 32), bitmap, unpack);

    crHugePacket( CR_BITMAP_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
예제 #23
0
void PACK_APIENTRY
crPackBufferDataARBSWAP( GLenum target, GLsizeiptrARB size,
										 const GLvoid * data, GLenum usage )
{
	unsigned char *data_ptr;
	int packet_length;

	packet_length = sizeof(GLenum)
		+ sizeof(target) + sizeof(size) + sizeof(usage) + size;

	data_ptr = (unsigned char *) crPackAlloc( packet_length );

	WRITE_DATA( 0, GLenum, SWAP32(CR_BUFFERDATAARB_EXTEND_OPCODE) );
	WRITE_DATA( 4, GLenum, SWAP32(target) );
	WRITE_DATA( 8, GLsizeiptrARB, SWAP32(size) );
	WRITE_DATA( 12, GLenum, SWAP32(usage) );
	if (data)
		 crMemcpy( data_ptr + 16, data, size );

	crHugePacket( CR_EXTEND_OPCODE, data_ptr );
    crPackFree( data_ptr );
}
예제 #24
0
void PACK_APIENTRY
crPackBufferSubDataARBSWAP( GLenum target, GLintptrARB offset, GLsizeiptrARB size,
                                                const GLvoid * data )
{
    unsigned char *data_ptr, *start_ptr;
    int packet_length;

    if (!data)
        return;

    packet_length = sizeof(GLenum)
        + sizeof(target) + sizeof(GLuint) + sizeof(GLuint) + size;

    start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length);
    WRITE_DATA_AI(GLenum, SWAP32(CR_BUFFERSUBDATAARB_EXTEND_OPCODE) );
    WRITE_DATA_AI(GLenum, SWAP32(target) );
    WRITE_DATA_AI(GLuint, SWAP32((GLuint) offset) );
    WRITE_DATA_AI(GLuint, SWAP32((GLuint) size) );
    crMemcpy(data_ptr, data, size);

    crHugePacket(CR_EXTEND_OPCODE, start_ptr);
    crPackFree(start_ptr);
}
예제 #25
0
void PACK_APIENTRY crPackTexImage3DSWAP(GLenum target, GLint level,
																				GLint internalformat,
																				GLsizei width, GLsizei height,
																				GLsizei depth, GLint border,
																				GLenum format, GLenum type,
																				const GLvoid *pixels,
																				const CRPixelPackState *unpackstate )
{
	unsigned char *data_ptr;
	int packet_length;
	int isnull = (pixels == NULL);
	int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
	int distrib_buf_len = 0;
	int tex_size = 0;

	packet_length =
		sizeof( target ) +
		sizeof( level ) +
		sizeof( internalformat ) +
		sizeof( width ) +
		sizeof( height ) +
		sizeof( depth ) +
		sizeof( border ) +
		sizeof( format ) +
		sizeof( type ) +
		sizeof( int );

	if (pixels)
	{
		if ( is_distrib )
		{
			distrib_buf_len = crStrlen( pixels ) + 1 +
				( (type == GL_TRUE) ? width*height*3 : 0 ) ;
			packet_length += distrib_buf_len ;
		}
		else
		{
			tex_size = crTextureSize( format, type, width, height, depth );
			packet_length += tex_size;
		}
	}

	data_ptr = (unsigned char *) crPackAlloc( packet_length );
	WRITE_DATA( 0, GLenum, SWAP32( target ) );
	WRITE_DATA( 4, GLint, SWAP32( level ) );
	WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
	WRITE_DATA( 12, GLsizei, SWAP32( width ) );
	WRITE_DATA( 16, GLsizei, SWAP32( height ) );
	WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
	WRITE_DATA( 24, GLint, SWAP32( border ) );
	WRITE_DATA( 28, GLenum, SWAP32( format ) );
	WRITE_DATA( 32, GLenum, SWAP32( type ) );
	WRITE_DATA( 36, int, SWAP32( isnull ) );

	if (pixels)
	{
		if ( is_distrib )
		{
			crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
		}
		else
		{
			CRPixelPackState tmpUnpackState = *unpackstate;
			/* flip application-requested swapBytes state */
			tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;

			crPixelCopy3D( width, height, depth,
										 (void *)(data_ptr + 40), format, type, NULL,
										 pixels, format, type, &tmpUnpackState );
		}
	}

	crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr );
	crPackFree( data_ptr );
}