/* $Id: pack_shaders.c 20511 2009-06-12 13:00:53Z vboxsync $ */ /** @file * VBox OpenGL DRI driver functions */ /* * Copyright (C) 2009 Sun Microsystems, Inc. * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 USA or visit http://www.sun.com if you need * additional information or have any questions. */ #include "packer.h" #include "cr_error.h" #include "cr_string.h" void PACK_APIENTRY crPackBindAttribLocation(GLuint program, GLuint index, const char *name) { 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); 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); } void PACK_APIENTRY crPackShaderSource(GLuint shader, GLsizei count, const char **string, const GLint *length) { GET_PACKER_CONTEXT(pc); unsigned char *data_ptr; GLint *pLocalLength; int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(shader)+sizeof(count)+sizeof(GLint)+count*sizeof(*pLocalLength); GLsizei i; if ((0==count) || (!string)) return; pLocalLength = crAlloc(count*sizeof(*length)); if (!pLocalLength) return; for (i=0; i=0)) ? length[i] : crStrlen(string[i])+1; packet_length += pLocalLength[i]; } if (length) { packet_length += count*sizeof(*length); } GET_BUFFERED_POINTER(pc, packet_length); WRITE_DATA_AI(int, packet_length); WRITE_DATA_AI(GLenum, CR_SHADERSOURCE_EXTEND_OPCODE); WRITE_DATA_AI(GLuint, shader); WRITE_DATA_AI(GLsizei, count); WRITE_DATA_AI(GLint, (GLint)(length ? 1:0)); crMemcpy(data_ptr, pLocalLength, count*sizeof(*pLocalLength)); data_ptr += count*sizeof(*pLocalLength); if (length) { crMemcpy(data_ptr, length, count*sizeof(*length)); data_ptr += count*sizeof(*length); } for (i=0; i