From 6386d6f674677e59276e10bfde50ea20fe426d06 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 22 Apr 2015 23:21:28 +0100 Subject: [PATCH] shader_query: use a function to convert from GLhandleARB to GLuint --- src/mesa/main/shader_query.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index bc6fec5..b5a44a0 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -41,6 +41,27 @@ 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 +} + static GLint program_resource_location(struct gl_shader_program *shProg, struct gl_program_resource *res, const char *name); @@ -68,7 +89,7 @@ _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; @@ -136,7 +157,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index, return; } - shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib"); + shProg = _mesa_lookup_shader_program_err(ctx, handle_to_uint(program), "glGetActiveAttrib"); if (!shProg) return; @@ -250,7 +271,7 @@ _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; -- 2.3.2 (Apple Git-55)