emulator opengl - encode glShaderSource
glShaderSource strings are concatenated into a single string before sent over the wire protocol. The wire protocol transfer is done using a special api call 'glShaderString' Change-Id: I90c157df66fe82fee17c460a1e7852d370c77088
This commit is contained in:
committed by
David 'Digit' Turner
parent
d10c96517b
commit
0c814b227c
@@ -363,24 +363,37 @@ int glUtilsPixelBitSize(GLenum format, GLenum type)
|
||||
return pixelsize;
|
||||
}
|
||||
|
||||
|
||||
int glUtilsSumArrayValues(GLint *array, GLsizei count)
|
||||
// pack a list of strings into one.
|
||||
void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count)
|
||||
{
|
||||
int sum = 0;
|
||||
char *p = ptr;
|
||||
*p = '\0';
|
||||
for (int i = 0; i < count; i++) {
|
||||
sum += *array;
|
||||
array++;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void glUtilsPackStrings(void *ptr, char **strings, GLint *length, GLsizei count)
|
||||
{
|
||||
unsigned char *p = (unsigned char *)ptr;
|
||||
for (int i = 0; i < count; i++) {
|
||||
memcpy(p, *strings, *length);
|
||||
p += *length;
|
||||
strings++;
|
||||
length++;
|
||||
int l;
|
||||
if (length == NULL || length[i] < 0) {
|
||||
l = strlen(strings[i]);
|
||||
strcat(p, strings[i]);
|
||||
} else {
|
||||
l = length[i];
|
||||
strncat(p, strings[i], l);
|
||||
}
|
||||
p += l;
|
||||
}
|
||||
}
|
||||
|
||||
// claculate the length of a list of strings
|
||||
int glUtilsCalcShaderSourceLen( char **strings, GLint *length, GLsizei count)
|
||||
{
|
||||
int len = 0;
|
||||
for (int i = 0; i < count; i++) {
|
||||
int l;
|
||||
if (length == NULL || length[i] < 0) {
|
||||
l = strlen(strings[i]);
|
||||
} else {
|
||||
l = length[i];
|
||||
}
|
||||
len += l;
|
||||
}
|
||||
return len;
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ extern "C" {
|
||||
int size, GLenum type, unsigned int stride,
|
||||
unsigned int datalen);
|
||||
int glUtilsPixelBitSize(GLenum format, GLenum type);
|
||||
int glUtilsSumArrayValues(GLint *array, GLsizei count);
|
||||
void glUtilsPackStrings(void *ptr, char **strings, GLint *length, GLsizei count);
|
||||
void glUtilsPackStrings(char *ptr, char **strings, GLint *length, GLsizei count);
|
||||
int glUtilsCalcShaderSourceLen(char **strings, GLint *length, GLsizei count);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user