Re: [PATCH 5/5] wined3d: Use the core version of the shader object functions.
On 21 January 2015 at 18:32, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
+ typedef void (WINE_GLAPI *gl_shader_source_type)(GLuint, GLsizei, const GLchar * const *, const GLint*); + ... + #define MAP_GL_FUNCTION_CAST(core_func, cast, ext_func) \ + do \ + { \ + if (!gl_info->gl_ops.ext.p_##core_func) \ + gl_info->gl_ops.ext.p_##core_func = (cast)gl_info->gl_ops.ext.p_##ext_func; \ + } while (0) ... + MAP_GL_FUNCTION_CAST(glShaderSource, gl_shader_source_type, glShaderSourceARB); I'm not sure that's really much better than just adding a (void *) cast.
2015-01-22 13:22 GMT+01:00 Henri Verbeet <hverbeet(a)gmail.com>:
On 21 January 2015 at 18:32, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
+ typedef void (WINE_GLAPI *gl_shader_source_type)(GLuint, GLsizei, const GLchar * const *, const GLint*); + ... + #define MAP_GL_FUNCTION_CAST(core_func, cast, ext_func) \ + do \ + { \ + if (!gl_info->gl_ops.ext.p_##core_func) \ + gl_info->gl_ops.ext.p_##core_func = (cast)gl_info->gl_ops.ext.p_##ext_func; \ + } while (0) ... + MAP_GL_FUNCTION_CAST(glShaderSource, gl_shader_source_type, glShaderSourceARB); I'm not sure that's really much better than just adding a (void *) cast.
Do you prefer I just unconditionally add the (void *) cast to MAP_GL_FUNCTION or still add the separate define and only cast there? For the records, the only other used function requiring a cast is glTexImageEXT, because of the GLenum <-> GLint internalformat mismatch.
On 22 January 2015 at 15:34, Matteo Bruni <matteo.mystral(a)gmail.com> wrote:
Do you prefer I just unconditionally add the (void *) cast to MAP_GL_FUNCTION or still add the separate define and only cast there? I don't have a strong opinion, but there's probably some value in explicitly marking the functions that do that kind of cast, so I guess it makes sense to have a separate macro.
On 01/22/2015 04:22 AM, Henri Verbeet wrote:
I'm not sure that's really much better than just adding a (void *) cast.
C doesn't technically allow casting function pointers to/from void*, <https://stackoverflow.com/questions/5579835/c-function-pointer-casting-to-void-pointer>.
On 22 January 2015 at 21:10, Chris Robinson <chris.kcat(a)gmail.com> wrote:
C doesn't technically allow casting function pointers to/from void*, <https://stackoverflow.com/questions/5579835/c-function-pointer-casting-to-void-pointer>. Strictly speaking that's true, but I think that's in the same category as e.g. NULL not being guaranteed to be defined as "(void *)0". I.e., it should be safe on any platform we'll realistically support.
participants (3)
-
Chris Robinson -
Henri Verbeet -
Matteo Bruni