~darkxst/ubuntu/raring/cogl/lp1163025

« back to all changes in this revision

Viewing changes to examples/cogl-info.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-13 19:11:11 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120313191111-3hgk529qkh9m6uk2
Tags: 1.9.8-0ubuntu1
* New upstream release (LP: #941617)
* Updated symbols & library name for soname update
* debian/control.in: Bump minimum glib to 2.28
* debian/patches/02_disable_armv5t_specific_optimization.patch: Disabled

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cogl/cogl.h>
 
2
#include <glib.h>
 
3
#include <stdio.h>
 
4
 
 
5
struct {
 
6
  CoglFeatureID feature;
 
7
  const char *short_description;
 
8
  const char *long_description;
 
9
} features[] =
 
10
{
 
11
  {
 
12
    COGL_FEATURE_ID_TEXTURE_NPOT_BASIC,
 
13
    "Non power of two textures (basic)",
 
14
    "The hardware supports non power of two textures, but you also "
 
15
    "need to check the COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP and "
 
16
    "COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT features to know if the "
 
17
    "hardware supports npot texture mipmaps or repeat modes other "
 
18
    "than COGL_RENDERER_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE respectively."
 
19
  },
 
20
  {
 
21
    COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP,
 
22
    "Non power of two textures (+ mipmap)",
 
23
    "Mipmapping is supported in conjuntion with non power of two "
 
24
    "textures."
 
25
  },
 
26
  {
 
27
    COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT,
 
28
    "Non power of two textures (+ repeat modes)",
 
29
    "Repeat modes other than "
 
30
    "COGL_RENDERER_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE are supported by "
 
31
    "the hardware in conjunction with non power of two textures."
 
32
  },
 
33
  {
 
34
    COGL_FEATURE_ID_TEXTURE_NPOT,
 
35
    "Non power of two textures (fully featured)",
 
36
    "Non power of two textures are supported by the hardware. This "
 
37
    "is a equivalent to the COGL_FEATURE_ID_TEXTURE_NPOT_BASIC, "
 
38
    "COGL_FEATURE_ID_TEXTURE_NPOT_MIPMAP and "
 
39
    "COGL_FEATURE_ID_TEXTURE_NPOT_REPEAT features combined."
 
40
  },
 
41
  {
 
42
    COGL_FEATURE_ID_TEXTURE_RECTANGLE,
 
43
    "Unnormalized coordinate, rectangle textures",
 
44
    "Support for rectangular textures with non-normalized texture "
 
45
    "coordinates."
 
46
  },
 
47
  {
 
48
    COGL_FEATURE_ID_TEXTURE_3D,
 
49
    "3D texture support",
 
50
    "3D texture support"
 
51
  },
 
52
  {
 
53
    COGL_FEATURE_ID_OFFSCREEN,
 
54
    "Offscreen rendering support",
 
55
    "Offscreen rendering support"
 
56
  },
 
57
  {
 
58
    COGL_FEATURE_ID_OFFSCREEN_MULTISAMPLE,
 
59
    "Offscreen rendering with multisampling support",
 
60
    "Offscreen rendering with multisampling support"
 
61
  },
 
62
  {
 
63
    COGL_FEATURE_ID_ONSCREEN_MULTIPLE,
 
64
    "Multiple onscreen framebuffers supported",
 
65
    "Multiple onscreen framebuffers supported"
 
66
  },
 
67
  {
 
68
    COGL_FEATURE_ID_GLSL,
 
69
    "GLSL support",
 
70
    "GLSL support"
 
71
  },
 
72
  {
 
73
    COGL_FEATURE_ID_ARBFP,
 
74
    "ARBFP support",
 
75
    "ARBFP support"
 
76
  },
 
77
  {
 
78
    COGL_FEATURE_ID_UNSIGNED_INT_INDICES,
 
79
    "Unsigned integer indices",
 
80
    "COGL_RENDERER_INDICES_TYPE_UNSIGNED_INT is supported in cogl_indices_new()."
 
81
  },
 
82
  {
 
83
    COGL_FEATURE_ID_DEPTH_RANGE,
 
84
    "cogl_pipeline_set_depth_range() support",
 
85
    "cogl_pipeline_set_depth_range() support",
 
86
  },
 
87
  {
 
88
    COGL_FEATURE_ID_POINT_SPRITE,
 
89
    "Point sprite coordinates",
 
90
    "cogl_pipeline_set_layer_point_sprite_coords_enabled() is supported"
 
91
  },
 
92
  {
 
93
    COGL_FEATURE_ID_MAP_BUFFER_FOR_READ,
 
94
    "Mapping buffers for reading",
 
95
    "Mapping buffers for reading"
 
96
  },
 
97
  {
 
98
    COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE,
 
99
    "Mapping buffers for writing",
 
100
    "Mapping buffers for writing"
 
101
  },
 
102
  {
 
103
    COGL_FEATURE_ID_MIRRORED_REPEAT,
 
104
    "Mirrored repeat wrap modes",
 
105
    "Mirrored repeat wrap modes"
 
106
  }
 
107
};
 
108
 
 
109
static const char *
 
110
get_winsys_name_for_id (CoglWinsysID winsys_id)
 
111
{
 
112
  switch (winsys_id)
 
113
    {
 
114
    case COGL_WINSYS_ID_ANY:
 
115
      g_return_val_if_reached ("ERROR");
 
116
    case COGL_WINSYS_ID_STUB:
 
117
      return "Stub";
 
118
    case COGL_WINSYS_ID_GLX:
 
119
      return "GLX";
 
120
    case COGL_WINSYS_ID_EGL_XLIB:
 
121
      return "EGL + Xlib platform";
 
122
    case COGL_WINSYS_ID_EGL_NULL:
 
123
      return "EGL + NULL window system platform";
 
124
    case COGL_WINSYS_ID_EGL_GDL:
 
125
      return "EGL + GDL platform";
 
126
    case COGL_WINSYS_ID_EGL_WAYLAND:
 
127
      return "EGL + Wayland platform";
 
128
    case COGL_WINSYS_ID_EGL_KMS:
 
129
      return "EGL + KMS platform";
 
130
    case COGL_WINSYS_ID_EGL_ANDROID:
 
131
      return "EGL + Android platform";
 
132
    case COGL_WINSYS_ID_WGL:
 
133
      return "EGL + Windows WGL platform";
 
134
    case COGL_WINSYS_ID_SDL:
 
135
      return "EGL + SDL platform";
 
136
    }
 
137
  g_return_val_if_reached ("Unknown");
 
138
}
 
139
 
 
140
static void
 
141
feature_cb (CoglFeatureID feature, void *user_data)
 
142
{
 
143
  int i;
 
144
  for (i = 0; i < sizeof(features) / sizeof(features[0]); i++)
 
145
    {
 
146
      if (features[i].feature == feature)
 
147
        {
 
148
          printf (" » %s\n", features[i].short_description);
 
149
          return;
 
150
        }
 
151
    }
 
152
  printf (" » Unknown feature %d\n", feature);
 
153
}
 
154
 
 
155
int
 
156
main (int argc, char **argv)
 
157
{
 
158
  CoglRenderer *renderer;
 
159
  CoglDisplay *display;
 
160
  CoglContext *ctx;
 
161
  GError *error = NULL;
 
162
  CoglWinsysID winsys_id;
 
163
  const char *winsys_name;
 
164
 
 
165
  ctx = cogl_context_new (NULL, &error);
 
166
  if (!ctx) {
 
167
      fprintf (stderr, "Failed to create context: %s\n", error->message);
 
168
      return 1;
 
169
  }
 
170
 
 
171
  display = cogl_context_get_display (ctx);
 
172
  renderer = cogl_display_get_renderer (display);
 
173
  winsys_id = cogl_renderer_get_winsys_id (renderer);
 
174
  winsys_name = get_winsys_name_for_id (winsys_id);
 
175
  g_print ("Renderer: %s\n\n", winsys_name);
 
176
 
 
177
  g_print ("Features:\n");
 
178
  cogl_foreach_feature (ctx, feature_cb, NULL);
 
179
 
 
180
  return 0;
 
181
}