int rcUpdateColorBuffer_enc(void *self , uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void* pixels)
{

	renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
	IOStream *stream = ctx->m_stream;

	const unsigned int __size_pixels =  (((glUtilsPixelBitSize(format, type) * width) >> 3) * height);
	 unsigned char *ptr;
	 const size_t packetSize = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + __size_pixels + 1*4;
	ptr = stream->alloc(8 + 4 + 4 + 4 + 4 + 4 + 4 + 4);
	int tmp = OP_rcUpdateColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
	memcpy(ptr, &packetSize, 4);  ptr += 4;

		memcpy(ptr, &colorbuffer, 4); ptr += 4;
		memcpy(ptr, &x, 4); ptr += 4;
		memcpy(ptr, &y, 4); ptr += 4;
		memcpy(ptr, &width, 4); ptr += 4;
		memcpy(ptr, &height, 4); ptr += 4;
		memcpy(ptr, &format, 4); ptr += 4;
		memcpy(ptr, &type, 4); ptr += 4;
	stream->flush();
	stream->writeFully(&__size_pixels,4);
	stream->writeFully(pixels, __size_pixels);

	int retval;
	stream->readback(&retval, 4);
	return retval;
}
Esempio n. 2
0
void glUtilsWritePackPointerData(void* _stream, unsigned char *src,
                                 int size, GLenum type, unsigned int stride,
                                 unsigned int datalen)
{
    IOStream* stream = reinterpret_cast<IOStream*>(_stream);

    unsigned int  vsize = size * glSizeof(type);
    if (stride == 0) stride = vsize;

    if (stride == vsize) {
        stream->writeFully(src, datalen);
    } else {
        for (unsigned int i = 0; i < datalen; i += vsize) {
            stream->writeFully(src, (size_t)vsize);
            src += stride;
        }
    }
}