}
-template<class T>
+/**
+ * Helper function for determining the string lengths for glShaderSource and
+ * glShaderSourceARB, which is a tad too complex to inline in the specs.
+ */
+template<class Char>
static inline size_t
-_glStrLen(const T * string, GLsizei length)
+_glShaderSource_length(const Char * const * string, const GLint *length, GLsizei index)
{
- if (length >= 0) {
- return length;
+ if (length != NULL && length[index] >= 0) {
+ return (size_t)length[index];
} else {
- return strlen(string);
+ return strlen(string[index]);
}
}
-
/**
- * Helper function for determining the string lengths for glShaderSource and
- * glShaderSourceARB, which is a tad too complex to inline in the specs.
+ * Helper function for determining the string lengths for glGetDebugMessageLog*.
*/
-template<class T>
+template<class Char>
static inline size_t
-_glShaderSource_length(const T * const * string, const GLint *length, GLsizei index)
+_glGetDebugMessageLog_length(const Char * string, const GLsizei *lengths, GLuint count)
{
- if (length != NULL && length[index] >= 0) {
- return (size_t)length[index];
+ size_t size = 0;
+ GLuint index;
+ if (lengths) {
+ for (index = 0; index < count; ++index) {
+ size += lengths[index];
+ }
} else {
- return strlen(string[index]);
+ for (index = 0; index < count; ++index) {
+ size += strlen(&string[size]) + 1;
+ }
}
+ if (size) {
+ // Remove the last null terminator
+ --size;
+ }
+ return size;
}
/*