diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index 3014a97..5f4f705 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -39,6 +39,29 @@ extern "C" { #include "shaderapi.h" } + +/** Convert a GLhandleARB to GLuint */ +static INLINE GLuint +handle_to_uint(GLhandleARB handle) +{ +#ifdef __APPLE__ + /* As of glext.h version 20130624, on Mac OS X, GLhandleARB is defined + * as a pointer instead of an unsigned int. We use a union here to do + * the conversion and assume that the bits we care about are in the least + * significant bits of the handle, and we're on a little-endian system. + */ + union handle_uint { + GLhandleARB handle; + GLuint ui; + } temp; + temp.handle = handle; + return temp.ui; +#else + return handle; +#endif +} + + void GLAPIENTRY _mesa_BindAttribLocation(GLhandleARB program, GLuint index, const GLcharARB *name) @@ -46,7 +69,8 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index, GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation"); + _mesa_lookup_shader_program_err(ctx, handle_to_uint(program), + "glBindAttribLocation"); if (!shProg) return; @@ -84,7 +108,8 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *shProg; - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); + shProg = _mesa_lookup_shader_program_err(ctx, handle_to_uint(program), + "glGetActiveAttrib"); if (!shProg) return; @@ -136,7 +161,8 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name) { GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glGetAttribLocation"); + _mesa_lookup_shader_program_err(ctx, handle_to_uint(program), + "glGetAttribLocation"); if (!shProg) { return -1;