X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=helpers%2Fglsize.hpp;h=2da217f123a24ba3ce3058548f7886c9eb23640c;hb=HEAD;hp=b4ec2512e8fca0b5d72cde652055b61d422bf104;hpb=cab5ff17fedfb682734103495d70c531c02590ab;p=apitrace diff --git a/helpers/glsize.hpp b/helpers/glsize.hpp index b4ec251..2da217f 100644 --- a/helpers/glsize.hpp +++ b/helpers/glsize.hpp @@ -329,11 +329,19 @@ _glArrayPointer_size(GLint size, GLenum type, GLsizei stride, GLsizei count) #define _glVertexAttribPointerARB_size(size, type, normalized, stride, count) _glArrayPointer_size(size, type, stride, count) #define _glVertexAttribPointerNV_size(size, type, stride, count) _glArrayPointer_size(size, type, stride, count) +/** + * Same as glGetIntegerv, but passing the result in the return value. + */ +static inline GLint +_glGetInteger(GLenum pname) { + GLint param = 0; + _glGetIntegerv(pname, ¶m); + return param; +} + static inline GLint _element_array_buffer_binding(void) { - GLint element_array_buffer = 0; - _glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &element_array_buffer); - return element_array_buffer; + return _glGetInteger(GL_ELEMENT_ARRAY_BUFFER_BINDING); } static inline GLuint @@ -807,6 +815,22 @@ _glClearBuffer_size(GLenum buffer) } } + +/** + * Helper function for determining the string lengths for glShaderSource and + * glShaderSourceARB, which is a tad too complex to inline in the specs. + */ +template +static inline size_t +_glShaderSource_length(const T * const * string, const GLint *length, GLsizei index) +{ + if (length != NULL && length[index] >= 0) { + return (size_t)length[index]; + } else { + return strlen(string[index]); + } +} + /* * attribute list, terminated by the given terminator. */