diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c index 7bd4746ca..0ca3edd2e 100644 --- a/cogl/cogl-renderer.c +++ b/cogl/cogl-renderer.c @@ -35,6 +35,7 @@ #include "cogl-internal.h" #include "cogl-private.h" #include "cogl-object.h" +#include "cogl-context-private.h" #include "cogl-renderer.h" #include "cogl-renderer-private.h" @@ -394,3 +395,18 @@ _cogl_renderer_get_proc_address (CoglRenderer *renderer, return winsys->renderer_get_proc_address (renderer, name); } + +int +cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer) +{ + int n = 0; + + _COGL_GET_CONTEXT (ctx, 0); + +#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2) + if (ctx->driver == COGL_DRIVER_GL || ctx->driver == COGL_DRIVER_GLES2) + GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n)); +#endif + + return n; +} diff --git a/cogl/cogl-renderer.h b/cogl/cogl-renderer.h index 5061c40ca..15c0ff4b6 100644 --- a/cogl/cogl-renderer.h +++ b/cogl/cogl-renderer.h @@ -114,6 +114,22 @@ cogl_renderer_set_winsys_id (CoglRenderer *renderer, CoglWinsysID cogl_renderer_get_winsys_id (CoglRenderer *renderer); +/** + * cogl_renderer_get_n_fragment_texture_units: + * @renderer: A #CoglRenderer + * + * Queries how many texture units can be used from fragment programs + * + * Returns: the number of texture image units. + * + * Since: 1.8 + * Stability: Unstable + */ +#define cogl_renderer_get_n_fragment_texture_units \ + cogl_renderer_get_n_fragment_texture_units_EXP +int +cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer); + #define cogl_renderer_check_onscreen_template \ cogl_renderer_check_onscreen_template_EXP gboolean diff --git a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt index 2237345ad..571c84bad 100644 --- a/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt +++ b/doc/reference/cogl-2.0-experimental/cogl-2.0-experimental-sections.txt @@ -14,6 +14,7 @@ cogl_object_set_user_data cogl-renderer CoglRenderer: Connect to a backend renderer cogl_renderer_new +cogl_renderer_get_n_fragment_texture_units cogl_renderer_connect