aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples/evas/evas-3d-frustum.c
blob: a89c407ddf1738c1fdcddf9ef91cd0116bd049a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
/**
 * This example shows how to work frustum culling.
 * Use 'w'/'s' key to move far frustum plane from/to the camera.
 * Use 't'/'g' key to move near frustum plane from/to the camera.
 * Use '1'/'2' key to set camera to the first/second position.
 * Use '3'/'4'/'5' key to set bounding sphere/aabb/central point mode.
 * Use 'i', 'k', 'j', 'l', 'u' and 'o' keys to move mesh node (model) in 3D.
 * Use 'z', 'x', 'c', 'Z', 'X' and 'C' keys to change scaling constants of mesh (model).
 * See in terminal output value distance to far plane of frustum and value of visibility of node
 * @see evas_canvas3d_camera_node_visible_get.
 *
 * @verbatim
 * gcc -o evas-3d-frustum evas-3d-frustum.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo` -lm
 * @endverbatim
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define PACKAGE_EXAMPLES_DIR "."
#define EFL_EO_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif

#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Evas.h>
#include <Eo.h>
#include <math.h>
#include "evas-common.h"

#define  WIDTH          800
#define  HEIGHT         600

static const char *texture_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sweet_home_reversed.png";
static const char *mesh_path = PACKAGE_EXAMPLES_DIR EVAS_MODEL_FOLDER "/sweet_home.obj";

typedef struct _Scene_Data
{
   Eo *root_node;
   Eo *camera_node;
   Eo *light_node;
   Eo *mesh_node_model;
   Eo *mesh_node;
   Eo *scene;
   Eo *camera;
   Eo *light;
   Eo *mesh_model;
   Eo *sphere;
   Eo *cube;
   Eo *mesh_sphere;
   Eo *mesh_aabb;
   Eo *material_model;
   Eo *material;
   Eo *texture_model;
} Scene_Data;

Evas *evas;
Evas_Object *background,*image;
Evas_Real obj_x = 0.0, obj_y = 0.0, obj_z = 0.0, obj_sc_x = 10.0, obj_sc_y = 10.0, obj_sc_z = 10.0;
Evas_Real fleft = -5, fright = 5, fbottom = -5, fup = 5, fnear = 20, ffar = 1000;
Evas_Real radius = 0;
Evas_Canvas3D_Frustum_Mode key = EVAS_CANVAS3D_FRUSTUM_MODE_AABB;

static void
_show_help()
{
   fprintf(stdout, "Press 'w'/'s' key to move far frustum plane from/to the camera\n");
   fprintf(stdout, "Press 't'/'g' key to move near frustum plane from/to the camera\n");
   fprintf(stdout, "Press '1'/'2' key to set camera to the first/second position\n");
   fprintf(stdout, "Press '3'/'4'/'5' key to set bounding sphere/aabb/central point mode\n");
   fprintf(stdout, "Press 'i', 'k', 'j', 'l', 'u' and 'o' keys to move mesh node in 3D\n");
   fprintf(stdout, "Press 'z', 'x', 'c', 'Z', 'X' and 'C' keys to change scaling constants of mesh\n");
}

static void
_on_delete(Ecore_Evas *ee EINA_UNUSED)
{
   ecore_main_loop_quit();
}

static void
_on_canvas_resize(Ecore_Evas *ee)
{
   int w, h;

   ecore_evas_geometry_get(ee, NULL, NULL, &w, &h);

   evas_object_resize(background, w, h);
   evas_object_resize(image, w, h);
   evas_object_move(image, 0, 0);
}

static Eina_Bool
_redraw_bounding_object(void *data)
{
   Evas_Real px, py, pz, sx, sy, sz;
   Evas_Real x0, y0, z0, x1, y1, z1, rad;
   Scene_Data *scene = (Scene_Data *)data;
   Eo *current_mesh;
   Eina_List *meshes = NULL, *l;

   eo_do(scene->mesh_node, meshes = (Eina_List *)evas_canvas3d_node_mesh_list_get());
   EINA_LIST_FOREACH(meshes, l, current_mesh)
     {
        eo_do(scene->mesh_node, evas_canvas3d_node_mesh_del(current_mesh));
     }

   switch (key)
     {
      case EVAS_CANVAS3D_FRUSTUM_MODE_BSPHERE:
      {
         eo_do(scene->mesh_node_model,
               evas_canvas3d_node_bounding_sphere_get(&x0, &y0, &z0, &rad));
         current_mesh = scene->mesh_sphere;
         px = x0;
         py = y0;
         pz = z0;
         sx = sy = sz = 2.0 * rad;
         break;
      }
      case EVAS_CANVAS3D_FRUSTUM_MODE_AABB:
      {
         eo_do(scene->mesh_node_model,
               evas_canvas3d_node_bounding_box_get(&x0, &y0, &z0,
                                             &x1, &y1, &z1));
         current_mesh = scene->mesh_aabb;
         px = (x1 + x0) / 2;
         py = (y1 + y0) / 2;
         pz = (z1 + z0) / 2;
         sx = x1 - x0;
         sy = y1 - y0;
         sz = z1 - z0;
         break;
      }
      case EVAS_CANVAS3D_FRUSTUM_MODE_CENTRAL_POINT:
      {
         eo_do(scene->mesh_node_model,
               evas_canvas3d_node_bounding_sphere_get(&x0, &y0, &z0, &rad));
         current_mesh = scene->mesh_sphere;
         px = x0;
         py = y0;
         pz = z0;
         sx = sy = sz = 0.1 * rad;
         break;
      }
      default:
         return ECORE_CALLBACK_RENEW;
     }

   eo_do(scene->mesh_node,
         evas_canvas3d_node_mesh_add(current_mesh),
         evas_canvas3d_node_position_set(px, py, pz),
         evas_canvas3d_node_scale_set(sx, sy, sz));

   return ECORE_CALLBACK_RENEW;
}

static void
_on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info)
{
   Scene_Data *scene = (Scene_Data *)data;
   Evas_Event_Key_Down *ev = event_info;
   Eina_Bool frustum;

   if (!strcmp("w", ev->key))
     {
        ffar += 20;
        eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar));
     }
   else if(!strcmp("s", ev->key))
     {
        ffar -= 20;
        eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar));
     }
   else if(!strcmp("t", ev->key))
     {
        fnear += 2;
        eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar));
     }
   else if(!strcmp("g", ev->key))
     {
        fnear -= 2;
        eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar));
     }
   else if(!strcmp("i", ev->key))
     {
        obj_y++;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
     }
   else if(!strcmp("k", ev->key))
     {
        obj_y--;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
     }
   else if(!strcmp("o", ev->key))
     {
        obj_z++;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
     }
   else if(!strcmp("u", ev->key))
     {
        obj_z--;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
     }
   else if(!strcmp("l", ev->key))
     {
        obj_x++;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
     }
   else if(!strcmp("j", ev->key))
     {
        obj_x--;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_position_set(obj_x, obj_y, obj_z));
     }
   else if(!strcmp("z", ev->key))
     {
        obj_sc_y+=0.02;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
     }
   else if(!strcmp("Z", ev->key))
     {
        obj_sc_y-=0.02;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
     }
   else if(!strcmp("x", ev->key))
     {
        obj_sc_z+=0.02;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
     }
   else if(!strcmp("X", ev->key))
     {
        obj_sc_z-=0.02;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
     }
   else if(!strcmp("c", ev->key))
     {
        obj_sc_x+=0.02;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
     }
   else if(!strcmp("C", ev->key))
     {
        obj_sc_x-=0.02;
        eo_do(scene->mesh_node_model,
              evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
     }
   else if(!strcmp("Return", ev->key))
     {
        eo_do(scene->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar));
     }
   else if (!strcmp("1", ev->key))
     {
        eo_do(scene->camera_node, evas_canvas3d_node_position_set(0.0, 0.0, 300.0),
              evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
        fprintf(stdout, "Changed position and view of camera\n");
     }
   else if (!strcmp("2", ev->key))
     {
        eo_do(scene->camera_node, evas_canvas3d_node_position_set(300.0, 300.0, 300.0);
              evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));
        fprintf(stdout, "Changed position and view of camera\n");
     }
   else if (!strcmp("3", ev->key))
     {
        key = EVAS_CANVAS3D_FRUSTUM_MODE_BSPHERE;
     }
   else if (!strcmp("4", ev->key))
     {
        key = EVAS_CANVAS3D_FRUSTUM_MODE_AABB;
     }
   else if (!strcmp("5", ev->key))
     {
        key = EVAS_CANVAS3D_FRUSTUM_MODE_CENTRAL_POINT;
     }
   else
     {
        _show_help();
     }

   _redraw_bounding_object(data);
   eo_do(scene->camera, frustum = evas_canvas3d_camera_node_visible_get(scene->camera_node, scene->mesh_node_model, key));
   fprintf(stdout, "far - %f frustum - %d radius - %f\n", ffar, frustum, radius);
}

static void
_camera_setup(Scene_Data *data)
{
   eo_add(data->camera, EVAS_CANVAS3D_CAMERA_CLASS, evas);
   eo_add(data->camera_node, EVAS_CANVAS3D_NODE_CLASS, evas,
                                     evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_CAMERA));
   eo_do(data->camera_node,
         evas_canvas3d_node_camera_set(data->camera),
         evas_canvas3d_node_position_set(0.0, 0.0, 300.0);
         evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 1.0, 0.0));

   eo_do(data->camera, evas_canvas3d_camera_projection_frustum_set(fleft, fright, fbottom, fup, fnear, ffar));

   eo_do(data->root_node, evas_canvas3d_node_member_add(data->camera_node));
}

static void
_light_setup(Scene_Data *data)
{
   eo_add(data->light, EVAS_CANVAS3D_LIGHT_CLASS, evas);
   eo_do(data->light,
         evas_canvas3d_light_ambient_set( 0.2, 0.2, 0.2, 1.0);
         evas_canvas3d_light_diffuse_set(1.0, 1.0, 1.0, 1.0);
         evas_canvas3d_light_specular_set(1.0, 1.0, 1.0, 1.0));

   eo_add(data->light_node, EVAS_CANVAS3D_NODE_CLASS,evas,
                                    evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_LIGHT));
   eo_do(data->light_node,
         evas_canvas3d_node_light_set(data->light),
         evas_canvas3d_node_position_set(0.0, 0.0, 200.0),
         evas_canvas3d_node_look_at_set(EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 0.0, EVAS_CANVAS3D_SPACE_PARENT, 0.0, 0.0, 1.0));

   eo_do(data->root_node, evas_canvas3d_node_member_add(data->light_node));
}

static void
_mesh_setup(Scene_Data *data)
{
   eo_add(data->material, EVAS_CANVAS3D_MATERIAL_CLASS, evas);

   eo_do(data->material,
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE),
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE),
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE),

         evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.2, 0.2, 0.2, 1.0),
         evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 0.8, 0.8, 0.8, 1.0),
         evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0),
         evas_canvas3d_material_shininess_set(100.0));

   eo_add(data->cube, EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
   eo_do(data->cube,
         evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_CUBE));

   eo_add(data->sphere, EVAS_CANVAS3D_PRIMITIVE_CLASS, evas);
   eo_do(data->sphere,
         evas_canvas3d_primitive_form_set(EVAS_CANVAS3D_MESH_PRIMITIVE_SPHERE),
         evas_canvas3d_primitive_precision_set(20));

   eo_add(data->mesh_aabb, EVAS_CANVAS3D_MESH_CLASS, evas);
   eo_do(data->mesh_aabb,
         evas_canvas3d_mesh_from_primitive_set(0, data->cube),
         evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES),
         evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE),
         evas_canvas3d_mesh_frame_material_set(0, data->material));

   eo_add(data->mesh_sphere, EVAS_CANVAS3D_MESH_CLASS, evas);
   eo_do(data->mesh_sphere,
         evas_canvas3d_mesh_from_primitive_set(0, data->sphere),
         evas_canvas3d_mesh_vertex_assembly_set(EVAS_CANVAS3D_VERTEX_ASSEMBLY_LINES),
         evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE),
         evas_canvas3d_mesh_frame_material_set(0, data->material));

   eo_add(data->mesh_node, EVAS_CANVAS3D_NODE_CLASS, evas, evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
   eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node));
   eo_do(data->mesh_node, evas_canvas3d_node_mesh_add(data->mesh_aabb));
}

static void
_mesh_setup_model(Scene_Data *data)
{
   eo_add(data->mesh_model, EVAS_CANVAS3D_MESH_CLASS, evas);
   eo_add(data->material_model, EVAS_CANVAS3D_MATERIAL_CLASS, evas);
   eo_add(data->texture_model, EVAS_CANVAS3D_TEXTURE_CLASS, evas);

   eo_do(data->texture_model,
         evas_canvas3d_texture_file_set(texture_path, NULL),
         evas_canvas3d_texture_filter_set(EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST, EVAS_CANVAS3D_TEXTURE_FILTER_NEAREST),
         evas_canvas3d_texture_wrap_set(EVAS_CANVAS3D_WRAP_MODE_REPEAT, EVAS_CANVAS3D_WRAP_MODE_REPEAT));

   eo_do(data->material_model,
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE),
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, EINA_TRUE),
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, EINA_TRUE),
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, EINA_TRUE);
         evas_canvas3d_material_enable_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_NORMAL, EINA_TRUE),
         evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_AMBIENT, 0.01, 0.01, 0.01, 1.0),
         evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, 1.0, 1.0, 1.0, 1.0),
         evas_canvas3d_material_color_set(EVAS_CANVAS3D_MATERIAL_ATTRIB_SPECULAR, 1.0, 1.0, 1.0, 1.0),
         evas_canvas3d_material_texture_set( EVAS_CANVAS3D_MATERIAL_ATTRIB_DIFFUSE, data->texture_model),
         evas_canvas3d_material_shininess_set(100.0));

   eo_do(data->mesh_model,
         efl_file_set(mesh_path, NULL),
         evas_canvas3d_mesh_frame_material_set(0, data->material_model),
         evas_canvas3d_mesh_shade_mode_set(EVAS_CANVAS3D_SHADE_MODE_DIFFUSE));
}

static void
_scene_setup(Scene_Data *data)
{
   eo_add(data->scene, EVAS_CANVAS3D_SCENE_CLASS, evas);

   eo_add(data->root_node, EVAS_CANVAS3D_NODE_CLASS, evas,
                                   evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_NODE));

   _light_setup(data);
   _mesh_setup_model(data);
   _camera_setup(data);

   eo_add(data->mesh_node_model, EVAS_CANVAS3D_NODE_CLASS, evas,
                                      evas_canvas3d_node_constructor(EVAS_CANVAS3D_NODE_TYPE_MESH));
   eo_do(data->mesh_node_model,
         evas_canvas3d_node_position_set(obj_x, obj_y, obj_z),
         evas_canvas3d_node_orientation_angle_axis_set(-90, 1.0, 0.0, 0.0),
         evas_canvas3d_node_scale_set(obj_sc_x, obj_sc_y, obj_sc_z));
   eo_do(data->root_node, evas_canvas3d_node_member_add(data->mesh_node_model));
   eo_do(data->mesh_node_model, evas_canvas3d_node_mesh_add(data->mesh_model));

   _mesh_setup(data);

    eo_do(data->scene,
         evas_canvas3d_scene_size_set( WIDTH, HEIGHT),
         evas_canvas3d_scene_background_color_set(0.5, 0.5, 0.5, 0.0),
         evas_canvas3d_scene_root_node_set(data->root_node);
         evas_canvas3d_scene_camera_node_set(data->camera_node));
}

int
main(void)
{
   Scene_Data data;
   Ecore_Evas *ecore_evas = NULL;

   if (!ecore_evas_init()) return 0;

   setenv("ECORE_EVAS_ENGINE", "opengl_x11", 1);
   ecore_evas = ecore_evas_new("opengl_x11", 0, 0, WIDTH, HEIGHT, NULL);

   if (!ecore_evas) return 0;

   ecore_evas_callback_delete_request_set(ecore_evas, _on_delete);
   ecore_evas_callback_resize_set(ecore_evas, _on_canvas_resize);
   ecore_evas_show(ecore_evas);

   evas = ecore_evas_get(ecore_evas);

   _scene_setup(&data);

   background = evas_object_rectangle_add(evas);

   evas_object_color_set(background, 0, 0, 0, 255);
   evas_object_move(background, 0, 0);
   evas_object_resize(background, WIDTH, HEIGHT);
   evas_object_show(background);

   image = evas_object_image_filled_add(evas);
   evas_object_move(image, 0, 0);
   evas_object_resize(image, WIDTH, HEIGHT);
   evas_object_show(image);

   evas_object_focus_set(image, EINA_TRUE);
   eo_do(image, evas_obj_image_scene_set(data.scene));

   _redraw_bounding_object(&data);
   _show_help();

   evas_object_event_callback_add(image, EVAS_CALLBACK_KEY_DOWN, _on_key_down, &data);
   ecore_main_loop_begin();

   ecore_evas_free(ecore_evas);
   ecore_evas_shutdown();

   return 0;
}