aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/extantz/extantz.c234
-rw-r--r--src/extantz/extantz.h7
2 files changed, 125 insertions, 116 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 9f8eaef..7e3e227 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -241,8 +241,8 @@ static void init_evas_gl(globals *ourGlobals)
241 elm_glview_resize_func_set(gld->elmGl, _resize_gl); 241 elm_glview_resize_func_set(gld->elmGl, _resize_gl);
242 elm_glview_render_func_set(gld->elmGl, (Elm_GLView_Func_Cb) _draw_gl); 242 elm_glview_render_func_set(gld->elmGl, (Elm_GLView_Func_Cb) _draw_gl);
243 243
244 elm_win_resize_object_add(ourGlobals->win, gld->elmGl);
244 evas_object_show(gld->elmGl); 245 evas_object_show(gld->elmGl);
245 elm_box_pack_end(ourGlobals->bx, gld->elmGl);
246 } 246 }
247 247
248 // TODO - apparently the proper way to deal with the new async rendering is to have this animator do the dirty thing, and call the Irrlicht rendering stuff in the _draw_gl call set above. 248 // TODO - apparently the proper way to deal with the new async rendering is to have this animator do the dirty thing, and call the Irrlicht rendering stuff in the _draw_gl call set above.
@@ -385,50 +385,53 @@ void overlay_add(globals *ourGlobals)
385 385
386EAPI_MAIN int elm_main(int argc, char **argv) 386EAPI_MAIN int elm_main(int argc, char **argv)
387{ 387{
388 Evas_Object *obj; 388 EPhysics_World *world;
389 EPhysics_World *world; 389 GLData *gld = NULL;
390 GLData *gld = NULL; 390 char buf[PATH_MAX];
391 char buf[PATH_MAX]; 391// Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't.
392// Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. 392
393 393 /* Set the locale according to the system pref.
394 /* Set the locale according to the system pref. 394 * If you don't do so the file selector will order the files list in
395 * If you don't do so the file selector will order the files list in 395 * a case sensitive manner
396 * a case sensitive manner 396 */
397 */ 397 setlocale(LC_ALL, "");
398 setlocale(LC_ALL, ""); 398
399 399 elm_need_ethumb();
400 elm_need_ethumb(); 400 elm_need_efreet();
401 elm_need_efreet(); 401
402 402 HamrTime(elm_main, "extantz");
403 HamrTime(elm_main, "extantz"); 403 fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get());
404 fprintf(stdout, "prefix was set to: %s\n", elm_app_prefix_dir_get()); 404 fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get());
405 fprintf(stdout, "data directory is: %s\n", elm_app_data_dir_get()); 405 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get());
406 fprintf(stdout, "library directory is: %s\n", elm_app_lib_dir_get()); 406 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get());
407 fprintf(stdout, "locale directory is: %s\n", elm_app_locale_dir_get()); 407
408 408 logDom = loggingStartup("extantz", logDom);
409 logDom = loggingStartup("extantz", logDom); 409
410 410 // Don't do this, we need to clean up other stuff to, so set a clean up function below.
411 // Don't do this, we need to clean up other stuff to, so set a clean up function below. 411 //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
412 //elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 412 elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE);
413 elm_policy_set(ELM_POLICY_EXIT, ELM_POLICY_EXIT_NONE); 413 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE);
414 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_NONE); 414 elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_HIDDEN_ALWAYS);
415 elm_policy_set(ELM_POLICY_THROTTLE, ELM_POLICY_THROTTLE_HIDDEN_ALWAYS); 415
416 416 // These are set via the elementary_config tool, which is hard to find.
417 // These are set via the elementary_config tool, which is hard to find. 417 elm_config_finger_size_set(0);
418 elm_config_finger_size_set(0); 418 elm_config_scale_set(1.0);
419 elm_config_scale_set(1.0);
420
421 gld = &ourGlobals.gld;
422 gldata_init(gld);
423
424 // Set the engine to opengl_x11, then open our window.
425 elm_config_preferred_engine_set("opengl_x11");
426
427 ourGlobals.mainWindow = winFangAdd(NULL, 0, 0, 50, 20, "extantz virtual world viewer", "extantz");
428 ourGlobals.win = ourGlobals.mainWindow->win;
429 // Set preferred engine back to default from config
430 elm_config_preferred_engine_set(NULL);
431 419
420#if USE_PHYSICS
421 if (!ephysics_init())
422 return 1;
423#endif
424
425 gld = &ourGlobals.gld;
426 gldata_init(gld);
427
428 // Set the engine to opengl_x11, then open our window.
429 elm_config_preferred_engine_set("opengl_x11");
430 ourGlobals.mainWindow = winFangAdd(NULL, 0, 0, 50, 20, "extantz virtual world viewer", "extantz");
431 // Set preferred engine back to default from config
432 elm_config_preferred_engine_set(NULL);
433
434 ourGlobals.win = ourGlobals.mainWindow->win;
432 // TODO, or not TODO - I keep getting rid of these, but keep bringing them back. 435 // TODO, or not TODO - I keep getting rid of these, but keep bringing them back.
433 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas. 436 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas.
434 ourGlobals.evas = evas_object_evas_get(ourGlobals.win); 437 ourGlobals.evas = evas_object_evas_get(ourGlobals.win);
@@ -438,92 +441,99 @@ EAPI_MAIN int elm_main(int argc, char **argv)
438 ourGlobals.ee = ecore_evas_ecore_evas_get(ourGlobals.evas); // Only use this on Evas that was created with Ecore_Evas. 441 ourGlobals.ee = ecore_evas_ecore_evas_get(ourGlobals.evas); // Only use this on Evas that was created with Ecore_Evas.
439#endif 442#endif
440 443
441#if USE_PHYSICS 444 evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals);
442 if (!ephysics_init())
443 return 1;
444#endif
445 445
446 evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals); 446 // Get the screen size.
447 447 elm_win_screen_size_get(ourGlobals.win, &ourGlobals.win_x, &ourGlobals.win_y, &ourGlobals.scr_w, &ourGlobals.scr_h);
448 // Get the screen size. 448 ourGlobals.win_x = ourGlobals.win_x + (ourGlobals.scr_w / 3);
449 elm_win_screen_size_get(ourGlobals.win, &ourGlobals.win_x, &ourGlobals.win_y, &ourGlobals.scr_w, &ourGlobals.scr_h); 449 ourGlobals.win_w = ourGlobals.scr_w / 2;
450 ourGlobals.win_x = ourGlobals.win_x + (ourGlobals.scr_w / 3); 450 ourGlobals.win_h = ourGlobals.scr_h - 30;
451 ourGlobals.win_w = ourGlobals.scr_w / 2; 451 evas_object_move(ourGlobals.win, ourGlobals.win_x, ourGlobals.win_y);
452 ourGlobals.win_h = ourGlobals.scr_h - 30; 452 evas_object_resize(ourGlobals.win, ourGlobals.win_w, ourGlobals.win_h);
453
454 // Add a background image object.
455 snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get());
456 obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals.win,
457 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
458 elm_obj_image_fill_outside_set(EINA_TRUE),
459 elm_obj_image_file_set(buf, NULL),
460 evas_obj_visibility_set(EINA_TRUE)
461 );
462 elm_win_resize_object_add(ourGlobals.win, obj);
463 eo_unref(obj);
464 453
465 ourGlobals.bx = eo_add(ELM_OBJ_BOX_CLASS, ourGlobals.win, 454 /* Our "layers".
466 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), 455
467 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), 456 Elm win - our real main window
468 evas_obj_visibility_set(EINA_TRUE) 457 These have some sort of inlined image if they are internal.
469 ); 458 Elm image - purple shaded sky image
470 elm_win_resize_object_add(ourGlobals.win, ourGlobals.bx); 459 Elm box - so everyone gets a freebie
460
461 Elm glview - added by init_evas_gl() if this is Irrlicht
471 462
472// overlay_add(&ourGlobals); 463 Elm image - added by Evas_3D_Demo_add() -> scenriAdd()
473 woMan_add(&ourGlobals); 464 Evas image is extracted to pass to Evas_3d functions,
474 chat_add(&ourGlobals); 465 to catch hovers and clicks
475 ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); 466 and to catch input for the camera
476 char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL};
477 GuiLuaDo(5, args, ourGlobals.mainWindow);
478 467
479 // Gotta do this after adding the windows, otherwise the menu renders under the window. 468// Elm win - added by overlay_add()
480 // This sucks, gotta redefine this menu each time we create a new window? 469// Evas rectangle added, a fully transparent one to catch clicks
481 // Also, GL focus gets lost when any menu is used. sigh 470// added to evas_object_evas_get(gld->winwin)
482 makeMainMenu(&ourGlobals);
483 471
484 // This does elm_box_pack_end(), so needs to be after the others. 472 The various internal windows.
485 init_evas_gl(&ourGlobals);
486 473
487 Evas_3D_Demo_add(&ourGlobals); 474 Elm toolbar
488 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move. 475
489 ourGlobals.gld.move = ourGlobals.scene->move; 476 Ephysics objects
490 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals); 477 */
491 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals); 478
479 // Override the background image
480 snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get());
481 eo_do(ourGlobals.mainWindow->bg,
482 elm_obj_image_file_set(buf, NULL),
483 evas_obj_color_set(255, 255, 255, 255)
484 );
485
486 init_evas_gl(&ourGlobals);
487// elm_box_pack_end(ourGlobals.mainWindow->box, gld->elmGl);
488
489 Evas_3D_Demo_add(&ourGlobals);
490 // TODO - Just a temporary hack so Irrlicht and Evas_3D can share the camera move.
491 ourGlobals.gld.move = ourGlobals.scene->move;
492 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals);
493 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals);
494
495// overlay_add(&ourGlobals);
496 woMan_add(&ourGlobals);
497 chat_add(&ourGlobals);
498 ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE);
499 char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL};
500 GuiLuaDo(5, args, ourGlobals.mainWindow);
501
502 // Gotta do this after adding the windows, otherwise the menu renders under the window.
503 // This sucks, gotta redefine this menu each time we create a new window?
504 // Also, GL focus gets lost when any menu is used. sigh
505 makeMainMenu(&ourGlobals);
492 506
493#if USE_PHYSICS 507#if USE_PHYSICS
494 world = ephysicsAdd(&ourGlobals); 508 world = ephysicsAdd(&ourGlobals);
495#endif 509#endif
496 510
497 evas_object_move(ourGlobals.win, ourGlobals.win_x, ourGlobals.win_y); 511 evas_object_show(ourGlobals.mainWindow->box);
498 evas_object_resize(ourGlobals.win, ourGlobals.win_w, ourGlobals.win_h); 512 _resize_winwin(gld);
499 evas_object_show(ourGlobals.win);
500 513
501 _resize_winwin(gld); 514 elm_run();
502
503 elm_run();
504 515
505#if USE_PHYSICS 516#if USE_PHYSICS
506 ephysics_world_del(world); 517 ephysics_world_del(world);
507 ephysics_shutdown(); 518 ephysics_shutdown();
508#endif 519#endif
509 520
510 if (ourGlobals.win) 521 if (ourGlobals.win)
511 { 522 {
512 Evas_3D_Demo_fini(&ourGlobals); 523 Evas_3D_Demo_fini(&ourGlobals);
513 eo_unref(ourGlobals.tb); 524 eo_unref(ourGlobals.tb);
514 eo_unref(ourGlobals.bx); 525 winFangDel(ourGlobals.mainWindow);
515 winFangDel(ourGlobals.mainWindow); 526 }
516 }
517 527
518 if (logDom >= 0) 528 if (logDom >= 0)
519 { 529 {
520 eina_log_domain_unregister(logDom); 530 eina_log_domain_unregister(logDom);
521 logDom = -1; 531 logDom = -1;
522 } 532 }
523 533
524 elm_shutdown(); 534 elm_shutdown();
525 535
526 return 0; 536 return 0;
527} 537}
528ELM_MAIN() 538ELM_MAIN()
529 539
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h
index 502420b..4a12a06 100644
--- a/src/extantz/extantz.h
+++ b/src/extantz/extantz.h
@@ -2,8 +2,8 @@
2#define _EXTANTZ_H_ 2#define _EXTANTZ_H_
3 3
4#define USE_PHYSICS 1 4#define USE_PHYSICS 1
5#define USE_IRR 0 5#define USE_IRR 1
6#define USE_DEMO 0 6#define USE_DEMO 1
7#define DO_GEARS 0 7#define DO_GEARS 0
8 8
9 9
@@ -213,7 +213,6 @@ typedef struct _globals
213 Evas *evas; 213 Evas *evas;
214 Evas_Object *win; // Our Elm window. 214 Evas_Object *win; // Our Elm window.
215 Evas_Object *tb; // Our Elm toolbar. 215 Evas_Object *tb; // Our Elm toolbar.
216 Evas_Object *bx; // Our box.
217 int logDom; // Our logging domain. 216 int logDom; // Our logging domain.
218 217
219 winFang *mainWindow; 218 winFang *mainWindow;
@@ -253,7 +252,7 @@ EAPI void Evas_3D_Demo_add(globals *ourGlobals);
253Eina_Bool _animate_scene(globals *ourGlobals); 252Eina_Bool _animate_scene(globals *ourGlobals);
254void Evas_3D_Demo_fini(globals *ourGlobals); 253void Evas_3D_Demo_fini(globals *ourGlobals);
255 254
256Scene_Data *scenriAdd(Evas *evas, Evas_Object *win); 255Scene_Data *scenriAdd(Evas_Object *win);
257Evas_3D_Node *cameraAdd(Evas *evas, Scene_Data *scene, Evas_Object *win); 256Evas_3D_Node *cameraAdd(Evas *evas, Scene_Data *scene, Evas_Object *win);
258Eina_Bool animateCamera(Scene_Data *scene); 257Eina_Bool animateCamera(Scene_Data *scene);
259 258