cogl-info: print out the chosen renderer name

This updates cogl-info to use cogl_renderer_get_winsys_id() so it can
print out the name of the chosen renderer winsys.
This commit is contained in:
Robert Bragg 2012-01-13 16:46:07 +00:00
parent 50d1285ba1
commit 7d38d9bdf2

View File

@ -106,6 +106,37 @@ struct {
} }
}; };
static const char *
get_winsys_name_for_id (CoglWinsysID winsys_id)
{
switch (winsys_id)
{
case COGL_WINSYS_ID_ANY:
g_return_val_if_reached ("ERROR");
case COGL_WINSYS_ID_STUB:
return "Stub";
case COGL_WINSYS_ID_GLX:
return "GLX";
case COGL_WINSYS_ID_EGL_XLIB:
return "EGL + Xlib platform";
case COGL_WINSYS_ID_EGL_NULL:
return "EGL + NULL window system platform";
case COGL_WINSYS_ID_EGL_GDL:
return "EGL + GDL platform";
case COGL_WINSYS_ID_EGL_WAYLAND:
return "EGL + Wayland platform";
case COGL_WINSYS_ID_EGL_KMS:
return "EGL + KMS platform";
case COGL_WINSYS_ID_EGL_ANDROID:
return "EGL + Android platform";
case COGL_WINSYS_ID_WGL:
return "EGL + Windows WGL platform";
case COGL_WINSYS_ID_SDL:
return "EGL + SDL platform";
}
g_return_val_if_reached ("Unknown");
}
static void static void
feature_cb (CoglFeatureID feature, void *user_data) feature_cb (CoglFeatureID feature, void *user_data)
{ {
@ -124,17 +155,27 @@ feature_cb (CoglFeatureID feature, void *user_data)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
CoglContext *ctx; CoglRenderer *renderer;
GError *error = NULL; CoglDisplay *display;
CoglContext *ctx;
GError *error = NULL;
CoglWinsysID winsys_id;
const char *winsys_name;
ctx = cogl_context_new (NULL, &error); ctx = cogl_context_new (NULL, &error);
if (!ctx) { if (!ctx) {
fprintf (stderr, "Failed to create context: %s\n", error->message); fprintf (stderr, "Failed to create context: %s\n", error->message);
return 1; return 1;
} }
g_print ("Features:\n"); display = cogl_context_get_display (ctx);
cogl_foreach_feature (ctx, feature_cb, NULL); renderer = cogl_display_get_renderer (display);
winsys_id = cogl_renderer_get_winsys_id (renderer);
winsys_name = get_winsys_name_for_id (winsys_id);
g_print ("Renderer: %s\n\n", winsys_name);
return 0; g_print ("Features:\n");
cogl_foreach_feature (ctx, feature_cb, NULL);
return 0;
} }