[Mesa-dev] [PATCH v2 2/7] mesa: add api check macros

Brian Paul brianp at vmware.com
Fri Jul 27 08:06:03 PDT 2012


On 07/27/2012 12:43 AM, Jordan Justen wrote:
> These macros make it easier to check for multiple API types.
>
> Signed-off-by: Jordan Justen<jordan.l.justen at intel.com>
> ---
>   src/mesa/main/mtypes.h |    4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 7d77956..7a715b3 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3340,6 +3340,10 @@ typedef enum
>      API_OPENGL_CORE,
>   } gl_api;
>
> +#define IS_CTX_IN2(ctx, api1, api2) ((ctx->API == api1) || (ctx->API == api2))
> +#define IS_CTX_DESKTOP_GL(ctx) IS_CTX_IN2(ctx, API_OPENGL, API_OPENGL_CORE)
> +#define IS_CTX_GLES(ctx) IS_CTX_IN2(ctx, API_OPENGLES, API_OPENGLES2)
> +
>   /**
>    * Driver-specific state flags.
>    *

I'd prefer inline functions such as:

static inline GLboolean
_mesa_is_desktop_gl(const struct gl_context *ctx)
{
    return ctx->API == API_OPENGL || ctx->API == API_OPENGL_CORE;
}

static inline GLboolean
_mesa_is_gles(const struct gl_context *ctx)
{
    return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
}



More information about the mesa-dev mailing list