diff options
-rw-r--r-- | src/extantz/Evas_3D_demo.c | 87 | ||||
-rwxr-xr-x | src/extantz/build.lua | 6 | ||||
-rw-r--r-- | src/extantz/crappisspuke.cpp | 2 | ||||
-rw-r--r-- | src/extantz/extantz.c | 421 | ||||
-rw-r--r-- | src/extantz/extantz.h | 79 | ||||
-rw-r--r-- | src/extantz/extantzCamera.cpp | 2 | ||||
-rw-r--r-- | src/extantz/woMan.c | 11 |
7 files changed, 242 insertions, 366 deletions
diff --git a/src/extantz/Evas_3D_demo.c b/src/extantz/Evas_3D_demo.c index b5b4614..5f33fed 100644 --- a/src/extantz/Evas_3D_demo.c +++ b/src/extantz/Evas_3D_demo.c | |||
@@ -1,37 +1,6 @@ | |||
1 | #include "extantz.h" | 1 | #include "extantz.h" |
2 | 2 | ||
3 | 3 | ||
4 | typedef struct _Scene_Data | ||
5 | { | ||
6 | Evas_Object *image; // Our Elm image. | ||
7 | Evas_3D_Scene *scene; | ||
8 | Evas_3D_Node *root_node; | ||
9 | Evas_3D_Node *camera_node; | ||
10 | Evas_3D_Node *light_node; | ||
11 | |||
12 | Evas_3D_Camera *camera; | ||
13 | Evas_3D_Light *light; | ||
14 | |||
15 | Evas_3D_Mesh *mesh; | ||
16 | Evas_3D_Node *mesh_node; | ||
17 | Evas_3D_Material *material0; | ||
18 | Evas_3D_Material *material1; | ||
19 | Evas_3D_Texture *texture0; | ||
20 | Evas_3D_Texture *texture1; | ||
21 | Evas_3D_Texture *texture_normal; | ||
22 | |||
23 | Evas_3D_Mesh *mesh2; | ||
24 | Evas_3D_Node *mesh2_node; | ||
25 | Evas_3D_Material *material2; | ||
26 | Evas_3D_Texture *texture2; | ||
27 | |||
28 | Evas_3D_Mesh *mesh3; | ||
29 | Evas_3D_Node *mesh3_node; | ||
30 | Evas_3D_Material *material3; | ||
31 | Evas_3D_Texture *texture_diffuse; | ||
32 | |||
33 | } Scene_Data; | ||
34 | |||
35 | static Scene_Data ourScene; | 4 | static Scene_Data ourScene; |
36 | 5 | ||
37 | 6 | ||
@@ -161,15 +130,6 @@ _normalize(const vec3 *v) | |||
161 | return vec; | 130 | return vec; |
162 | } | 131 | } |
163 | 132 | ||
164 | static void | ||
165 | _sphere_fini() | ||
166 | { | ||
167 | if (sphere_vertices) | ||
168 | free(sphere_vertices); | ||
169 | |||
170 | if (sphere_indices) | ||
171 | free(sphere_indices); | ||
172 | } | ||
173 | 133 | ||
174 | static void | 134 | static void |
175 | _sphere_init(int precision) | 135 | _sphere_init(int precision) |
@@ -306,8 +266,7 @@ _sphere_init(int precision) | |||
306 | } | 266 | } |
307 | 267 | ||
308 | 268 | ||
309 | static Eina_Bool | 269 | Eina_Bool _animate_scene(void *data) |
310 | _animate_scene(void *data) | ||
311 | { | 270 | { |
312 | static float angle = 0.0f; | 271 | static float angle = 0.0f; |
313 | static float earthAngle = 0.0f; | 272 | static float earthAngle = 0.0f; |
@@ -393,6 +352,8 @@ _light_setup(globals *ourGlobals, Scene_Data *scene) | |||
393 | 352 | ||
394 | static void _cube_setup(globals *ourGlobals, Scene_Data *scene) | 353 | static void _cube_setup(globals *ourGlobals, Scene_Data *scene) |
395 | { | 354 | { |
355 | char buf[PATH_MAX]; | ||
356 | |||
396 | // Setup cube materials. | 357 | // Setup cube materials. |
397 | scene->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | 358 | scene->material0 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
398 | scene->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | 359 | scene->material1 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
@@ -431,7 +392,8 @@ static void _cube_setup(globals *ourGlobals, Scene_Data *scene) | |||
431 | eo_do(scene->texture1, | 392 | eo_do(scene->texture1, |
432 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) | 393 | evas_3d_texture_data_set(EVAS_3D_COLOR_FORMAT_RGBA, EVAS_3D_PIXEL_FORMAT_8888, 4, 4, &pixels1[0]) |
433 | ); | 394 | ); |
434 | eo_do(scene->texture_normal, evas_3d_texture_file_set("media/normal_lego.png", NULL)); | 395 | snprintf(buf, sizeof(buf), "%s/normal_lego.png", elm_app_data_dir_get()); |
396 | eo_do(scene->texture_normal, evas_3d_texture_file_set(buf, NULL)); | ||
435 | 397 | ||
436 | eo_do(scene->material0, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture0)); | 398 | eo_do(scene->material0, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture0)); |
437 | eo_do(scene->material1, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture1)); | 399 | eo_do(scene->material1, evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture1)); |
@@ -469,10 +431,13 @@ static void _cube_setup(globals *ourGlobals, Scene_Data *scene) | |||
469 | 431 | ||
470 | static void _sonic_setup(globals *ourGlobals, Scene_Data *scene) | 432 | static void _sonic_setup(globals *ourGlobals, Scene_Data *scene) |
471 | { | 433 | { |
434 | char buf[PATH_MAX]; | ||
435 | |||
472 | // Setup an MD2 mesh. | 436 | // Setup an MD2 mesh. |
473 | scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); | 437 | scene->mesh2 = eo_add(EVAS_3D_MESH_CLASS, ourGlobals->evas); |
438 | snprintf(buf, sizeof(buf), "%s/sonic.md2", elm_app_data_dir_get()); | ||
474 | eo_do(scene->mesh2, | 439 | eo_do(scene->mesh2, |
475 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, "media/sonic.md2", NULL) | 440 | evas_3d_mesh_file_set(EVAS_3D_MESH_FILE_TYPE_MD2, buf, NULL) |
476 | ); | 441 | ); |
477 | 442 | ||
478 | scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | 443 | scene->material2 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
@@ -481,8 +446,9 @@ static void _sonic_setup(globals *ourGlobals, Scene_Data *scene) | |||
481 | ); | 446 | ); |
482 | 447 | ||
483 | scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); | 448 | scene->texture2 = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); |
449 | snprintf(buf, sizeof(buf), "%s/sonic.png", elm_app_data_dir_get()); | ||
484 | eo_do(scene->texture2, | 450 | eo_do(scene->texture2, |
485 | evas_3d_texture_file_set("media/sonic.png", NULL), | 451 | evas_3d_texture_file_set(buf, NULL), |
486 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), | 452 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), |
487 | evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT) | 453 | evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, EVAS_3D_WRAP_MODE_REPEAT) |
488 | ); | 454 | ); |
@@ -517,12 +483,15 @@ static void _sonic_setup(globals *ourGlobals, Scene_Data *scene) | |||
517 | 483 | ||
518 | static void _earth_setup(globals *ourGlobals, Scene_Data *scene) | 484 | static void _earth_setup(globals *ourGlobals, Scene_Data *scene) |
519 | { | 485 | { |
486 | char buf[PATH_MAX]; | ||
487 | |||
520 | // Setup earth material. | 488 | // Setup earth material. |
521 | scene->material3 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); | 489 | scene->material3 = eo_add(EVAS_3D_MATERIAL_CLASS, ourGlobals->evas); |
522 | 490 | ||
523 | scene->texture_diffuse = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); | 491 | scene->texture_diffuse = eo_add(EVAS_3D_TEXTURE_CLASS, ourGlobals->evas); |
492 | snprintf(buf, sizeof(buf), "%s/EarthDiffuse.png", elm_app_data_dir_get()); | ||
524 | eo_do(scene->texture_diffuse, | 493 | eo_do(scene->texture_diffuse, |
525 | evas_3d_texture_file_set("media/EarthDiffuse.png", NULL), | 494 | evas_3d_texture_file_set(buf, NULL), |
526 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR)); | 495 | evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_LINEAR, EVAS_3D_TEXTURE_FILTER_LINEAR)); |
527 | eo_do(scene->material3, | 496 | eo_do(scene->material3, |
528 | evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture_diffuse), | 497 | evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, scene->texture_diffuse), |
@@ -597,7 +566,6 @@ _scene_setup(globals *ourGlobals, Scene_Data *scene) | |||
597 | } | 566 | } |
598 | 567 | ||
599 | 568 | ||
600 | |||
601 | static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) | 569 | static void _on_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *einfo) |
602 | { | 570 | { |
603 | Scene_Data *scene = data; | 571 | Scene_Data *scene = data; |
@@ -649,7 +617,7 @@ static void _on_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void | |||
649 | Evas_3D_Node *n; | 617 | Evas_3D_Node *n; |
650 | Evas_3D_Mesh *m; | 618 | Evas_3D_Mesh *m; |
651 | Eina_Bool pick; | 619 | Eina_Bool pick; |
652 | char *name; | 620 | char *name = NULL; |
653 | 621 | ||
654 | evas_object_geometry_get(o, &x, &y, &w, &h); | 622 | evas_object_geometry_get(o, &x, &y, &w, &h); |
655 | 623 | ||
@@ -685,18 +653,8 @@ void Evas_3D_Demo_add(globals *ourGlobals) | |||
685 | { | 653 | { |
686 | Evas_Object *obj, *temp; | 654 | Evas_Object *obj, *temp; |
687 | 655 | ||
688 | _scene_setup(ourGlobals, &ourScene); | 656 | ourGlobals->scene = &ourScene; |
689 | 657 | _scene_setup(ourGlobals, &ourScene); | |
690 | // Add a background image object. | ||
691 | obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win); | ||
692 | eo_do(obj, | ||
693 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), | ||
694 | elm_obj_image_fill_outside_set(EINA_TRUE), | ||
695 | elm_obj_image_file_set("media/sky_01.jpg", NULL), | ||
696 | evas_obj_visibility_set(EINA_TRUE) | ||
697 | ); | ||
698 | elm_win_resize_object_add(ourGlobals->win, obj); | ||
699 | eo_unref(obj); | ||
700 | 658 | ||
701 | // Add an image object for 3D scene rendering. | 659 | // Add an image object for 3D scene rendering. |
702 | obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win); | 660 | obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win); |
@@ -716,7 +674,14 @@ void Evas_3D_Demo_add(globals *ourGlobals) | |||
716 | evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move, &ourScene); | 674 | evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move, &ourScene); |
717 | evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, &ourScene); | 675 | evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, &ourScene); |
718 | elm_win_resize_object_add(ourGlobals->win, obj); | 676 | elm_win_resize_object_add(ourGlobals->win, obj); |
677 | // elm_box_pack_end(ourGlobals->gld.bx, obj); | ||
719 | 678 | ||
720 | // Add animation timer callback. | 679 | // Add animation timer callback. |
721 | ecore_timer_add(0.016, _animate_scene, &ourScene); | 680 | // ecore_timer_add(0.016, _animate_scene, &ourScene); |
722 | } | 681 | } |
682 | |||
683 | void Evas_3D_Demo_fini() | ||
684 | { | ||
685 | free(sphere_vertices); | ||
686 | free(sphere_indices); | ||
687 | } \ No newline at end of file | ||
diff --git a/src/extantz/build.lua b/src/extantz/build.lua index c7ad5a1..2871ae6 100755 --- a/src/extantz/build.lua +++ b/src/extantz/build.lua | |||
@@ -20,7 +20,7 @@ libs = libs .. ' -lIrrlicht -lGL -lbz2' | |||
20 | removeFiles(dir, {'../../extantz', 'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', 'fangWin.o', 'chat.o', 'woMan.o', '../../media/extantz.edj'}) | 20 | removeFiles(dir, {'../../extantz', 'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', 'fangWin.o', 'chat.o', 'woMan.o', '../../media/extantz.edj'}) |
21 | 21 | ||
22 | runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj') | 22 | runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj') |
23 | runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) | 23 | runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) |
24 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) | 24 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) |
25 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -O3 -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) | 25 | runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) |
26 | compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'Evas_3D_demo', 'fangWin', 'chat', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o') | 26 | compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'Evas_3D_demo', 'fangWin', 'chat', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o') |
diff --git a/src/extantz/crappisspuke.cpp b/src/extantz/crappisspuke.cpp index d0ec23d..04cebca 100644 --- a/src/extantz/crappisspuke.cpp +++ b/src/extantz/crappisspuke.cpp | |||
@@ -25,7 +25,9 @@ EAPI int startIrr(GLData *gld) | |||
25 | IrrlichtDevice *device; | 25 | IrrlichtDevice *device; |
26 | IVideoDriver *driver; | 26 | IVideoDriver *driver; |
27 | ISceneManager *smgr; | 27 | ISceneManager *smgr; |
28 | #if USE_DEMO | ||
28 | bool additive = true; | 29 | bool additive = true; |
30 | #endif | ||
29 | #endif | 31 | #endif |
30 | 32 | ||
31 | if (!gld->useIrr) | 33 | if (!gld->useIrr) |
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 31264fd..28df70f 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c | |||
@@ -6,7 +6,6 @@ globals ourGlobals; | |||
6 | 6 | ||
7 | static void gldata_init(GLData *gld) | 7 | static void gldata_init(GLData *gld) |
8 | { | 8 | { |
9 | gld->useEGL = USE_EGL; | ||
10 | gld->useIrr = USE_IRR; | 9 | gld->useIrr = USE_IRR; |
11 | 10 | ||
12 | gld->view_rotx = -20.0; | 11 | gld->view_rotx = -20.0; |
@@ -72,126 +71,33 @@ static void _resize_gl(Evas_Object *obj) | |||
72 | _resize(gld); | 71 | _resize(gld); |
73 | } | 72 | } |
74 | 73 | ||
75 | static void on_pixels(void *data, Evas_Object *obj) | ||
76 | { | ||
77 | GLData *gld = data; | ||
78 | Evas_GL_API *gl = gld->glApi; | ||
79 | |||
80 | // get the image size in case it changed with evas_object_image_size_set() | ||
81 | if (gld->r1) | ||
82 | { | ||
83 | Evas_Coord w, h; | ||
84 | |||
85 | // Poor mans resize check. coz Elm wont do it easily. | ||
86 | evas_object_image_size_get(gld->r1, &w, &h); | ||
87 | if ((gld->img_w != w) || (gld->img_h != h)) | ||
88 | { | ||
89 | // No idea where this crap came from. | ||
90 | //float new_w = ((float) gld->scr_w / ((float) gld->scr_w * (float) w)); | ||
91 | //float new_h = ((float) gld->scr_h / ((float) gld->scr_h * (float) h)); | ||
92 | |||
93 | //gld->sfc_w = new_w; | ||
94 | //gld->sfc_h = new_h; | ||
95 | //evas_object_image_fill_set(gld->r1, 0, 0, gld->sfc_w, gld->sfc_h); | ||
96 | gld->img_w = w; | ||
97 | gld->img_h = h; | ||
98 | gld->resized = 1; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | if (gld->useEGL) | ||
103 | { | ||
104 | // Yes, we DO need to do our own make current, coz aparently the Irrlicht one is useless. | ||
105 | // Hopefully Elm_GL has done this for us by now. | ||
106 | // Evas_GL needs it to. | ||
107 | if (gld->ctx) | ||
108 | evas_gl_make_current(gld->evasGl, gld->sfc, gld->ctx); | ||
109 | } | ||
110 | |||
111 | if (!gld->doneIrr) | ||
112 | gld->doneIrr = startIrr(gld); // Needs to be after gld->win is shown, and needs to be done in the render thread. | ||
113 | #if DO_GEARS | ||
114 | if (!gld->gearsInited) | ||
115 | gears_init(gld); | ||
116 | #endif | ||
117 | |||
118 | if (gld->resized) | ||
119 | _resize(gld); | ||
120 | |||
121 | drawIrr_start(gld); | ||
122 | |||
123 | #if DO_GEARS | ||
124 | if (gld->useEGL) | ||
125 | drawGears(gld); | ||
126 | #endif | ||
127 | |||
128 | drawIrr_end(gld); | ||
129 | |||
130 | #if USE_IR | ||
131 | #else | ||
132 | // This might get done deep within drawIrr_end, but only if we are using Irrlicht. | ||
133 | |||
134 | // Optional - Flush the GL pipeline | ||
135 | gl->glFlush(); | ||
136 | // gl->glFinish(); | ||
137 | #endif | ||
138 | |||
139 | gld->resized = 0; | ||
140 | } | ||
141 | |||
142 | static void _draw_gl(Evas_Object *obj) | ||
143 | { | ||
144 | // Evas_GL_API *gl = elm_glview_gl_api_get(obj); | ||
145 | GLData *gld = evas_object_data_get(obj, "gld"); | ||
146 | if (!gld) return; | ||
147 | |||
148 | on_pixels(gld, obj); | ||
149 | } | ||
150 | |||
151 | // Callback from Evas, also used as the general callback for deleting the GL stuff. | 74 | // Callback from Evas, also used as the general callback for deleting the GL stuff. |
152 | static void _clean_gl(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 75 | static void _clean_gl(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
153 | { | 76 | { |
154 | GLData *gld = data; | 77 | GLData *gld = data; |
155 | Evas_GL_API *gl = gld->glApi; | ||
156 | 78 | ||
157 | ecore_animator_del(gld->animator); | 79 | ecore_animator_del(gld->animator); |
158 | 80 | ||
159 | if (gld->useEGL) | 81 | // Do a make_current before deleting all the GL stuff. |
160 | { | 82 | // evas_gl_make_current(NULL, NULL, NULL); |
161 | // Do a make_current before deleting all the GL stuff. | ||
162 | evas_gl_make_current(gld->evasGl, gld->sfc, gld->ctx); | ||
163 | 83 | ||
164 | } | 84 | // TODO - Since this is created on the render thread, better hope this is being deleted on the render thread. |
85 | finishIrr(gld); | ||
86 | |||
87 | #if DO_GEARS | ||
88 | Evas_GL_API *gl = gld->glApi; | ||
165 | 89 | ||
166 | gl->glDeleteShader(gld->vtx_shader); | 90 | gl->glDeleteShader(gld->vtx_shader); |
167 | gl->glDeleteShader(gld->fgmt_shader); | 91 | gl->glDeleteShader(gld->fgmt_shader); |
168 | gl->glDeleteProgram(gld->program); | 92 | gl->glDeleteProgram(gld->program); |
169 | 93 | ||
170 | if (gld->evasGl) | 94 | gl->glDeleteBuffers(1, &gld->gear1->vbo); |
171 | { | 95 | gl->glDeleteBuffers(1, &gld->gear2->vbo); |
172 | // Irrlicht wants to destroy the context and surface, so only do this if Irrlicht wont. | 96 | gl->glDeleteBuffers(1, &gld->gear3->vbo); |
173 | if (!gld->doneIrr) | ||
174 | { | ||
175 | evas_gl_surface_destroy(gld->evasGl, gld->sfc); | ||
176 | evas_gl_context_destroy(gld->evasGl, gld->ctx); | ||
177 | } | ||
178 | // TODO - hope this is OK, considering the context and surface might get dealt with by Irrlicht. | ||
179 | // Might be better to teach Irrlicht to not destroy shit it did not create. | ||
180 | evas_gl_config_free(gld->cfg); | ||
181 | evas_gl_free(gld->evasGl); | ||
182 | } | ||
183 | 97 | ||
184 | // TODO - Since this is created on the render thread, better hope this is being deleted on the render thread. | 98 | free_gear(gld->gear1); |
185 | finishIrr(gld); | 99 | free_gear(gld->gear2); |
186 | 100 | free_gear(gld->gear3); | |
187 | #if DO_GEARS | ||
188 | gl->glDeleteBuffers(1, &gld->gear1->vbo); | ||
189 | gl->glDeleteBuffers(1, &gld->gear2->vbo); | ||
190 | gl->glDeleteBuffers(1, &gld->gear3->vbo); | ||
191 | |||
192 | free_gear(gld->gear1); | ||
193 | free_gear(gld->gear2); | ||
194 | free_gear(gld->gear3); | ||
195 | #endif | 101 | #endif |
196 | } | 102 | } |
197 | 103 | ||
@@ -218,31 +124,74 @@ static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info | |||
218 | elm_exit(); | 124 | elm_exit(); |
219 | } | 125 | } |
220 | 126 | ||
221 | // Callback from the animator. | 127 | static void _draw_gl(Evas_Object *obj) |
222 | static Eina_Bool doFrame(void *data) | ||
223 | { | 128 | { |
224 | GLData *gld = data; | 129 | globals *ourGlobals = evas_object_data_get(obj, "glob"); |
130 | GLData *gld = &ourGlobals->gld; | ||
131 | |||
132 | if (!gld->doneIrr) gld->doneIrr = startIrr(gld); // Needs to be after gld->win is shown, and needs to be done in the render thread. | ||
133 | #if DO_GEARS | ||
134 | if (!gld->gearsInited) gears_init(gld); | ||
135 | #endif | ||
136 | |||
137 | // if (gld->resized) _resize(gld); | ||
138 | |||
139 | drawIrr_start(gld); | ||
140 | |||
141 | #if DO_GEARS | ||
142 | drawGears(gld); | ||
143 | #endif | ||
144 | |||
145 | _animate_scene(ourGlobals->scene); | ||
146 | |||
147 | drawIrr_end(gld); | ||
148 | |||
149 | #if USE_IRR | ||
150 | #else | ||
151 | // This might get done deep within drawIrr_end, but only if we are using Irrlicht. | ||
152 | |||
153 | // Optional - Flush the GL pipeline | ||
154 | // gl->glFlush(); | ||
155 | // gl->glFinish(); | ||
156 | #endif | ||
225 | 157 | ||
226 | // Mark the pixels as dirty, so they get rerendered each frame, then Irrlicht can draw it's stuff each frame. | 158 | gld->resized = 0; |
227 | // This causes on_pixel to be triggered by Evas_GL, and _draw_gl for Elm_glview. | 159 | } |
228 | if (gld->r1) | ||
229 | evas_object_image_pixels_dirty_set(gld->r1, EINA_TRUE); | ||
230 | if (gld->elmGl) | ||
231 | elm_glview_changed_set(gld->elmGl); | ||
232 | 160 | ||
233 | // If not using Evas_GL, we need to call on_pixel() manually. | 161 | static void on_pixels(void *data, Evas_Object *obj) |
234 | if (!gld->useEGL) | 162 | { |
235 | on_pixels(gld, gld->r1); | 163 | _draw_gl(obj); |
164 | } | ||
236 | 165 | ||
237 | return EINA_TRUE; // Keep calling us. | 166 | // Callback from the animator. |
167 | static Eina_Bool doFrame(void *data) | ||
168 | { | ||
169 | globals *ourGlobals = data; | ||
170 | GLData *gld = &ourGlobals->gld; | ||
171 | |||
172 | // Mark the pixels as dirty, so they get rerendered each frame, then Irrlicht can draw it's stuff each frame. | ||
173 | // This causes on_pixel to be triggered by Evas_3D, or _draw_gl for Elm_glview. | ||
174 | // Either way, _draw_gl gets called eventully. | ||
175 | if (gld->elmGl) | ||
176 | elm_glview_changed_set(gld->elmGl); | ||
177 | else if (ourGlobals->scene->image) | ||
178 | { | ||
179 | // evas_object_image_pixels_dirty_set(elm_image_object_get(ourGlobals->scene->image), EINA_TRUE); | ||
180 | _draw_gl(elm_image_object_get(ourGlobals->scene->image)); | ||
181 | } | ||
182 | |||
183 | return EINA_TRUE; // Keep calling us. | ||
238 | } | 184 | } |
239 | 185 | ||
240 | static void init_evas_gl(GLData *gld) | 186 | static void init_evas_gl(globals *ourGlobals) |
241 | { | 187 | { |
242 | if (!gld->useEGL) | 188 | GLData *gld = &ourGlobals->gld; |
243 | return; | 189 | |
190 | gld->sfc_w = gld->win_w; | ||
191 | gld->sfc_h = gld->win_h; | ||
244 | 192 | ||
245 | gld->sfc_w = gld->win_w; | 193 | if (USE_IRR || DO_GEARS) |
194 | { | ||
246 | gld->sfc_h = gld->win_h; | 195 | gld->sfc_h = gld->win_h; |
247 | 196 | ||
248 | // 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. | 197 | // 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. |
@@ -251,7 +200,6 @@ static void init_evas_gl(GLData *gld) | |||
251 | // Get the Ecore_Evas that wraps an Evas. | 200 | // Get the Ecore_Evas that wraps an Evas. |
252 | gld->ee = ecore_evas_ecore_evas_get(gld->canvas); // Only use this on Evas that was created with Ecore_Evas. | 201 | gld->ee = ecore_evas_ecore_evas_get(gld->canvas); // Only use this on Evas that was created with Ecore_Evas. |
253 | 202 | ||
254 | #if USE_ELM_GL | ||
255 | // Add a GLView | 203 | // Add a GLView |
256 | gld->elmGl = elm_glview_add(gld->win); | 204 | gld->elmGl = elm_glview_add(gld->win); |
257 | evas_object_size_hint_align_set(gld->elmGl, EVAS_HINT_FILL, EVAS_HINT_FILL); | 205 | evas_object_size_hint_align_set(gld->elmGl, EVAS_HINT_FILL, EVAS_HINT_FILL); |
@@ -272,82 +220,19 @@ static void init_evas_gl(GLData *gld) | |||
272 | //elm_win_resize_object_add(gld->win, gld->elmGl); | 220 | //elm_win_resize_object_add(gld->win, gld->elmGl); |
273 | gld->glApi = elm_glview_gl_api_get(gld->elmGl); | 221 | gld->glApi = elm_glview_gl_api_get(gld->elmGl); |
274 | evas_object_data_set(gld->elmGl, "gld", gld); | 222 | evas_object_data_set(gld->elmGl, "gld", gld); |
223 | evas_object_data_set(gld->elmGl, "glob", ourGlobals); | ||
275 | evas_object_show(gld->elmGl); | 224 | evas_object_show(gld->elmGl); |
276 | elm_box_pack_end(gld->bx, gld->elmGl); | 225 | elm_box_pack_end(gld->bx, gld->elmGl); |
277 | #else | 226 | } |
278 | // get the evas gl handle for doing gl things | ||
279 | gld->evasGl = evas_gl_new(gld->canvas); | ||
280 | gld->glApi = evas_gl_api_get(gld->evasGl); | ||
281 | |||
282 | // Set a surface config | ||
283 | gld->cfg = evas_gl_config_new(); | ||
284 | gld->cfg->color_format = EVAS_GL_RGBA_8888; | ||
285 | gld->cfg->depth_bits = EVAS_GL_DEPTH_BIT_32; | ||
286 | gld->cfg->stencil_bits = EVAS_GL_STENCIL_NONE; | ||
287 | gld->cfg->options_bits = EVAS_GL_OPTIONS_DIRECT; | ||
288 | |||
289 | // create a surface and context | ||
290 | gld->sfc = evas_gl_surface_create(gld->evasGl, gld->cfg, gld->sfc_w, gld->sfc_h); | ||
291 | gld->ctx = evas_gl_context_create(gld->evasGl, NULL); // The second NULL is for sharing contexts I think, which might be what we want to do with Irrlicht. It's not documented. | ||
292 | |||
293 | // Set up the image object, a filled one by default. | ||
294 | gld->r1 = evas_object_image_filled_add(gld->canvas); | ||
295 | |||
296 | // attach important data we need to the object using key names. This just | ||
297 | // avoids some global variables and means we can do nice cleanup. You can | ||
298 | // avoid this if you are lazy | ||
299 | // Not actually needed, with evas we can pass data pointers to stuff. | ||
300 | //evas_object_data_set(gld->r1, "gld", gld); | ||
301 | |||
302 | // when the object is deleted - call the on_del callback. like the above, | ||
303 | // this is just being clean | ||
304 | evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_DEL, _clean_gl, gld); | ||
305 | |||
306 | // set up an actual pixel size for the buffer data. it may be different | ||
307 | // to the output size. any windowing system has something like this, just | ||
308 | // evas has 2 sizes, a pixel size and the output object size | ||
309 | evas_object_image_size_set(gld->r1, gld->sfc_w, gld->sfc_h); | ||
310 | // Not actualy needed, as we create the image already filled. | ||
311 | //evas_object_image_fill_set(gld->r1, 0, 0, gld->sfc_w, gld->sfc_h); | ||
312 | |||
313 | // These two are not in the original example, but I get black r1 when I leave them out. | ||
314 | evas_object_size_hint_align_set(gld->r1, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
315 | evas_object_size_hint_weight_set(gld->r1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
316 | |||
317 | // set up the native surface info to use the context and surface created | ||
318 | // above | ||
319 | evas_gl_native_surface_get(gld->evasGl, gld->sfc, &(gld->ns)); | ||
320 | evas_object_image_native_surface_set(gld->r1, &(gld->ns)); | ||
321 | evas_object_image_pixels_get_callback_set(gld->r1, on_pixels, gld); | ||
322 | |||
323 | // move the image object somewhere, resize it and show it. any windowing | ||
324 | // system would need this kind of thing - place a child "window" | ||
325 | // Hmm, no need to resize it anyway, it's sized above. | ||
326 | evas_object_move(gld->r1, 0, 0); | ||
327 | //evas_object_resize(gld->r1, gld->sfc_w, gld->sfc_h); | ||
328 | elm_win_resize_object_add(gld->win, gld->r1); | ||
329 | evas_object_show(gld->r1); | ||
330 | elm_box_pack_end(gld->bx, gld->r1); | ||
331 | |||
332 | // evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_GL, gld); | ||
333 | // evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld); | ||
334 | // evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld); | ||
335 | #endif | ||
336 | 227 | ||
337 | // NOTE: if you delete r1, this animator will keep running trying to access | 228 | // 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. |
338 | // r1 so you'd better delete this animator with ecore_animator_del() or | 229 | // That still leaves the problem of the Irrlicht setup being in the main thread. Which also should be done in on_pixel, as that's done in the correct thread. |
339 | // structure how you do animation differently. you can also attach it like | 230 | |
340 | // evasGl, sfc, etc. etc. if this animator is specific to this object | 231 | // Jiggling this seems to produce a trade off between flickering and frame rate. Nothing else changed the flickering. |
341 | // only and delete it in the del handler for the obj. | 232 | ecore_animator_frametime_set(0.04); // Default is 1/30, or 0.033333 |
342 | // | 233 | gld->animator = ecore_animator_add(doFrame, ourGlobals); // This animator will be called every frame tick, which defaults to 1/30 seconds. |
343 | // 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 on_pixel call set above. | 234 | |
344 | // That still leaves the problem of the Irrlicht setup being in the main thread. Which also should be done in on_pixel, as that's done in the correct thread. | 235 | return; |
345 | |||
346 | // Jiggling this seems to produce a trade off between flickering and frame rate. Nothing else changed the flickering. | ||
347 | ecore_animator_frametime_set(0.04); // Default is 1/30, or 0.033333 | ||
348 | gld->animator = ecore_animator_add(doFrame, gld); // This animator will be called every frame tick, which defaults to 1/30 seconds. | ||
349 | |||
350 | return; | ||
351 | } | 236 | } |
352 | 237 | ||
353 | 238 | ||
@@ -358,7 +243,6 @@ static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *l | |||
358 | { | 243 | { |
359 | Evas_Object *menu= NULL; | 244 | Evas_Object *menu= NULL; |
360 | Elm_Object_Item *tb_it; | 245 | Elm_Object_Item *tb_it; |
361 | //, *menu_it; | ||
362 | 246 | ||
363 | tb_it = elm_toolbar_item_append(tb, NULL, label, NULL, NULL); | 247 | tb_it = elm_toolbar_item_append(tb, NULL, label, NULL, NULL); |
364 | elm_toolbar_item_menu_set(tb_it, EINA_TRUE); | 248 | elm_toolbar_item_menu_set(tb_it, EINA_TRUE); |
@@ -370,11 +254,64 @@ static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *l | |||
370 | return menu; | 254 | return menu; |
371 | } | 255 | } |
372 | 256 | ||
257 | static void makeMainMenu(GLData *gld) | ||
258 | { | ||
259 | Evas_Object *menu, *tb; | ||
260 | Elm_Object_Item *tb_it; | ||
261 | |||
262 | // A toolbar thingy. | ||
263 | tb = eo_add(ELM_OBJ_TOOLBAR_CLASS, gld->win); | ||
264 | eo_do(tb, | ||
265 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), | ||
266 | evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), | ||
267 | elm_obj_toolbar_shrink_mode_set(ELM_TOOLBAR_SHRINK_SCROLL), | ||
268 | evas_obj_size_set(gld->win_w, 25), | ||
269 | evas_obj_position_set(0, 0), | ||
270 | elm_obj_toolbar_align_set(0.0) | ||
271 | ); | ||
272 | |||
273 | // Menus. | ||
274 | menu = _toolbar_menu_add(gld->win, tb, "file"); | ||
275 | elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); | ||
276 | |||
277 | menu = _toolbar_menu_add(gld->win, tb, "edit"); | ||
278 | elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL); | ||
279 | |||
280 | menu = _toolbar_menu_add(gld->win, tb, "view"); | ||
281 | menu = _toolbar_menu_add(gld->win, tb, "world"); | ||
282 | menu = _toolbar_menu_add(gld->win, tb, "tools"); | ||
283 | |||
284 | menu = _toolbar_menu_add(gld->win, tb, "help"); | ||
285 | elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL); | ||
286 | elm_menu_item_separator_add(menu, NULL); | ||
287 | elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL); | ||
288 | elm_menu_item_add(menu, NULL, NULL, "extantz forum", NULL, NULL); | ||
289 | elm_menu_item_separator_add(menu, NULL); | ||
290 | elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL); | ||
291 | |||
292 | menu = _toolbar_menu_add(gld->win, tb, "advanced"); | ||
293 | elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL); | ||
294 | |||
295 | menu = _toolbar_menu_add(gld->win, tb, "god"); | ||
296 | |||
297 | // Other stuff in the toolbar. | ||
298 | tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); | ||
299 | elm_toolbar_item_separator_set(tb_it, EINA_TRUE); | ||
300 | tb_it = elm_toolbar_item_append(tb, NULL, "restriction icons", NULL, NULL); | ||
301 | tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); | ||
302 | elm_toolbar_item_separator_set(tb_it, EINA_TRUE); | ||
303 | tb_it = elm_toolbar_item_append(tb, NULL, "hop://localhost/Anarchadia 152, 155, 51 - Lost plot (Adult)", NULL, NULL); | ||
304 | tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); | ||
305 | elm_toolbar_item_separator_set(tb_it, EINA_TRUE); | ||
306 | tb_it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL); | ||
307 | |||
308 | evas_object_show(tb); | ||
309 | eo_unref(tb); | ||
310 | } | ||
373 | 311 | ||
374 | EAPI_MAIN int elm_main(int argc, char **argv) | 312 | EAPI_MAIN int elm_main(int argc, char **argv) |
375 | { | 313 | { |
376 | Evas_Object *obj, *menu, *tb; | 314 | Evas_Object *obj; |
377 | Elm_Object_Item *tb_it; | ||
378 | EPhysics_World *world; | 315 | EPhysics_World *world; |
379 | GLData *gld = NULL; | 316 | GLData *gld = NULL; |
380 | char buf[PATH_MAX]; | 317 | char buf[PATH_MAX]; |
@@ -398,16 +335,15 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
398 | elm_config_finger_size_set(0); | 335 | elm_config_finger_size_set(0); |
399 | elm_config_scale_set(1.0); | 336 | elm_config_scale_set(1.0); |
400 | 337 | ||
401 | // alloc a data struct to hold our relevant gl info in | 338 | gld = &ourGlobals.gld; |
402 | if (!(gld = calloc(1, sizeof(GLData)))) return 1; | ||
403 | gldata_init(gld); | 339 | gldata_init(gld); |
404 | 340 | ||
405 | // Set the engine to opengl_x11, then open our window. | 341 | // Set the engine to opengl_x11, then open our window. |
406 | if (gld->useEGL) | 342 | elm_config_preferred_engine_set("opengl_x11"); |
407 | elm_config_preferred_engine_set("opengl_x11"); | ||
408 | gld->win = elm_win_add(NULL, "extantz", ELM_WIN_BASIC); | ||
409 | gld->win = elm_win_util_standard_add("extantz", "extantz virtual world viewer"); | 343 | gld->win = elm_win_util_standard_add("extantz", "extantz virtual world viewer"); |
410 | ourGlobals.win = gld->win; | 344 | ourGlobals.win = gld->win; |
345 | // 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. | ||
346 | ourGlobals.evas = evas_object_evas_get(gld->win); | ||
411 | 347 | ||
412 | // Set preferred engine back to default from config | 348 | // Set preferred engine back to default from config |
413 | elm_config_preferred_engine_set(NULL); | 349 | elm_config_preferred_engine_set(NULL); |
@@ -425,9 +361,6 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
425 | gld->win_w = gld->scr_w / 2; | 361 | gld->win_w = gld->scr_w / 2; |
426 | gld->win_h = gld->scr_h - 30; | 362 | gld->win_h = gld->scr_h - 30; |
427 | 363 | ||
428 | // 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. | ||
429 | ourGlobals.evas = evas_object_evas_get(gld->win); | ||
430 | |||
431 | // Add a background image object. | 364 | // Add a background image object. |
432 | obj = eo_add(ELM_OBJ_IMAGE_CLASS, gld->win); | 365 | obj = eo_add(ELM_OBJ_IMAGE_CLASS, gld->win); |
433 | snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get()); | 366 | snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get()); |
@@ -440,15 +373,16 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
440 | elm_win_resize_object_add(gld->win, obj); | 373 | elm_win_resize_object_add(gld->win, obj); |
441 | eo_unref(obj); | 374 | eo_unref(obj); |
442 | 375 | ||
443 | Evas_3D_Demo_add(&ourGlobals); | ||
444 | 376 | ||
445 | gld->bx = elm_box_add(gld->win); | 377 | gld->bx = eo_add(ELM_OBJ_BOX_CLASS, gld->win); |
446 | evas_object_size_hint_weight_set(gld->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | 378 | eo_do(gld->bx, |
447 | evas_object_size_hint_align_set(gld->bx, EVAS_HINT_FILL, EVAS_HINT_FILL); | 379 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), |
380 | evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), | ||
381 | evas_obj_visibility_set(EINA_TRUE) | ||
382 | ); | ||
448 | elm_win_resize_object_add(gld->win, gld->bx); | 383 | elm_win_resize_object_add(gld->win, gld->bx); |
449 | evas_object_show(gld->bx); | ||
450 | 384 | ||
451 | overlay_add(gld); | 385 | // overlay_add(gld); |
452 | woMan_add(gld); | 386 | woMan_add(gld); |
453 | // TODO - This is what causes it to hang after quitting. Fix it. | 387 | // TODO - This is what causes it to hang after quitting. Fix it. |
454 | // chat_add(gld); | 388 | // chat_add(gld); |
@@ -456,60 +390,16 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
456 | // Gotta do this after adding the windows, otherwise the menu renders under the window. | 390 | // Gotta do this after adding the windows, otherwise the menu renders under the window. |
457 | // This sucks, gotta redefine this menu each time we create a new window? | 391 | // This sucks, gotta redefine this menu each time we create a new window? |
458 | // Also, GL focus gets lost when any menu is used. sigh | 392 | // Also, GL focus gets lost when any menu is used. sigh |
459 | 393 | makeMainMenu(gld); | |
460 | // A toolbar thingy. | ||
461 | tb = elm_toolbar_add(gld->win); | ||
462 | evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0); | ||
463 | evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
464 | elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_SCROLL); | ||
465 | elm_toolbar_align_set(tb, 0.0); | ||
466 | |||
467 | // Menus. | ||
468 | menu = _toolbar_menu_add(gld->win, tb, "file"); | ||
469 | elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); | ||
470 | |||
471 | menu = _toolbar_menu_add(gld->win, tb, "edit"); | ||
472 | elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL); | ||
473 | |||
474 | menu = _toolbar_menu_add(gld->win, tb, "view"); | ||
475 | menu = _toolbar_menu_add(gld->win, tb, "world"); | ||
476 | menu = _toolbar_menu_add(gld->win, tb, "tools"); | ||
477 | |||
478 | menu = _toolbar_menu_add(gld->win, tb, "help"); | ||
479 | elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL); | ||
480 | elm_menu_item_separator_add(menu, NULL); | ||
481 | elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL); | ||
482 | elm_menu_item_add(menu, NULL, NULL, "extantz forum", NULL, NULL); | ||
483 | elm_menu_item_separator_add(menu, NULL); | ||
484 | elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL); | ||
485 | |||
486 | menu = _toolbar_menu_add(gld->win, tb, "advanced"); | ||
487 | elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL); | ||
488 | |||
489 | menu = _toolbar_menu_add(gld->win, tb, "god"); | ||
490 | |||
491 | // Other stuff in the toolbar. | ||
492 | tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); | ||
493 | elm_toolbar_item_separator_set(tb_it, EINA_TRUE); | ||
494 | tb_it = elm_toolbar_item_append(tb, NULL, "restriction icons", NULL, NULL); | ||
495 | tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); | ||
496 | elm_toolbar_item_separator_set(tb_it, EINA_TRUE); | ||
497 | tb_it = elm_toolbar_item_append(tb, NULL, "hop://localhost/Anarchadia 152, 155, 51 - Lost plot (Adult)", NULL, NULL); | ||
498 | tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); | ||
499 | elm_toolbar_item_separator_set(tb_it, EINA_TRUE); | ||
500 | tb_it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL); | ||
501 | |||
502 | // The toolbar needs to be packed into the box AFTER the menus are added. | ||
503 | evas_object_show(tb); | ||
504 | elm_box_pack_start(gld->bx, tb); | ||
505 | 394 | ||
506 | // This does elm_box_pack_end(), so needs to be after the others. | 395 | // This does elm_box_pack_end(), so needs to be after the others. |
507 | init_evas_gl(gld); | 396 | init_evas_gl(&ourGlobals); |
508 | 397 | ||
509 | evas_object_show(gld->bx); | 398 | Evas_3D_Demo_add(&ourGlobals); |
399 | evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals); | ||
400 | evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals); | ||
510 | 401 | ||
511 | #if USE_PHYSICS | 402 | #if USE_PHYSICS |
512 | // ePhysics stuff. | ||
513 | world = ephysicsAdd(gld); | 403 | world = ephysicsAdd(gld); |
514 | #endif | 404 | #endif |
515 | 405 | ||
@@ -528,9 +418,10 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
528 | 418 | ||
529 | if (gld->win) | 419 | if (gld->win) |
530 | { | 420 | { |
421 | eo_unref(gld->bx); | ||
422 | Evas_3D_Demo_fini(); | ||
531 | evas_object_del(gld->win); | 423 | evas_object_del(gld->win); |
532 | } | 424 | } |
533 | free(gld); | ||
534 | 425 | ||
535 | if (ourGlobals.logDom >= 0) | 426 | if (ourGlobals.logDom >= 0) |
536 | { | 427 | { |
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index 6e0e03e..c475fa8 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h | |||
@@ -1,9 +1,6 @@ | |||
1 | #define USE_EO 0 | ||
2 | #define USE_PHYSICS 1 | 1 | #define USE_PHYSICS 1 |
3 | #define USE_EGL 1 // If using Evas_GL, though it might be via Elm. | 2 | #define USE_IRR 1 |
4 | #define USE_ELM_GL 1 | 3 | #define USE_DEMO 1 |
5 | #define USE_IRR 0 | ||
6 | #define USE_DEMO 0 | ||
7 | #define DO_GEARS 0 | 4 | #define DO_GEARS 0 |
8 | 5 | ||
9 | 6 | ||
@@ -60,16 +57,6 @@ typedef struct ICameraSceneNode ICameraSceneNode; | |||
60 | #endif | 57 | #endif |
61 | 58 | ||
62 | 59 | ||
63 | typedef struct _globals | ||
64 | { | ||
65 | Evas *evas; | ||
66 | Evas_Object *win; // Our Elm window. | ||
67 | Eina_Clist widgets; // Our windows widgets. | ||
68 | int logDom; // Our logging domain. | ||
69 | } globals; | ||
70 | |||
71 | extern globals ourGlobals; | ||
72 | |||
73 | 60 | ||
74 | typedef struct _Gear Gear; | 61 | typedef struct _Gear Gear; |
75 | typedef struct _GLData GLData; | 62 | typedef struct _GLData GLData; |
@@ -141,20 +128,46 @@ struct _Gear | |||
141 | int count; | 128 | int count; |
142 | }; | 129 | }; |
143 | 130 | ||
131 | typedef struct _Scene_Data | ||
132 | { | ||
133 | Evas_Object *image; // Our Elm image. | ||
134 | Evas_3D_Scene *scene; | ||
135 | Evas_3D_Node *root_node; | ||
136 | Evas_3D_Node *camera_node; | ||
137 | Evas_3D_Node *light_node; | ||
138 | |||
139 | Evas_3D_Camera *camera; | ||
140 | Evas_3D_Light *light; | ||
141 | |||
142 | Evas_3D_Mesh *mesh; | ||
143 | Evas_3D_Node *mesh_node; | ||
144 | Evas_3D_Material *material0; | ||
145 | Evas_3D_Material *material1; | ||
146 | Evas_3D_Texture *texture0; | ||
147 | Evas_3D_Texture *texture1; | ||
148 | Evas_3D_Texture *texture_normal; | ||
149 | |||
150 | Evas_3D_Mesh *mesh2; | ||
151 | Evas_3D_Node *mesh2_node; | ||
152 | Evas_3D_Material *material2; | ||
153 | Evas_3D_Texture *texture2; | ||
154 | |||
155 | Evas_3D_Mesh *mesh3; | ||
156 | Evas_3D_Node *mesh3_node; | ||
157 | Evas_3D_Material *material3; | ||
158 | Evas_3D_Texture *texture_diffuse; | ||
159 | |||
160 | } Scene_Data; | ||
161 | |||
144 | // GL related data here. | 162 | // GL related data here. |
145 | struct _GLData | 163 | struct _GLData |
146 | { | 164 | { |
147 | Evas_Object *win, *winwin; | 165 | Evas_Object *win, *winwin; |
148 | 166 | ||
149 | Ecore_Evas *ee; | 167 | Ecore_Evas *ee; |
150 | Evas *canvas; | 168 | Evas *canvas; |
151 | Evas_Native_Surface ns; | ||
152 | 169 | ||
153 | Evas_GL_Context *ctx; | 170 | Evas_Object *elmGl; |
154 | Evas_GL_Surface *sfc; | ||
155 | Evas_GL_Config *cfg; | ||
156 | Evas_GL *evasGl; // The Evas way. | ||
157 | Evas_Object *elmGl; // The Elm way. | ||
158 | Evas_GL_API *glApi; | 171 | Evas_GL_API *glApi; |
159 | 172 | ||
160 | GLuint program; | 173 | GLuint program; |
@@ -164,14 +177,13 @@ struct _GLData | |||
164 | int win_w, win_h; // The size of the window. | 177 | int win_w, win_h; // The size of the window. |
165 | int win_x, win_y; // The position of the window. | 178 | int win_x, win_y; // The position of the window. |
166 | int sfc_w, sfc_h; // This is what Irrlicht is using, size of the GL image surface / glview. | 179 | int sfc_w, sfc_h; // This is what Irrlicht is using, size of the GL image surface / glview. |
167 | int img_w, img_h; // Size of the viewport. DON'T reuse sfc_* here. Despite the fach that sfc_* is only used in the init when Irricht is disabled? WTF? | 180 | int img_w, img_h; // Size of the viewport. DON'T reuse sfc_* here. Despite the fact that sfc_* is only used in the init when Irricht is disabled? WTF? |
168 | int useEGL : 1; | ||
169 | int useIrr : 1; | 181 | int useIrr : 1; |
170 | int doneIrr : 1; | 182 | int doneIrr : 1; |
171 | int gearsInited : 1; | 183 | int gearsInited : 1; |
172 | int resized : 1; | 184 | int resized : 1; |
173 | 185 | ||
174 | Evas_Object *bx, *r1; | 186 | Evas_Object *bx;//, *r1; |
175 | Ecore_Animator *animator; | 187 | Ecore_Animator *animator; |
176 | 188 | ||
177 | IrrlichtDevice *device; | 189 | IrrlichtDevice *device; |
@@ -200,6 +212,19 @@ struct _GLData | |||
200 | GLfloat light[3]; | 212 | GLfloat light[3]; |
201 | }; | 213 | }; |
202 | 214 | ||
215 | typedef struct _globals | ||
216 | { | ||
217 | Evas *evas; | ||
218 | Evas_Object *win; // Our Elm window. | ||
219 | Eina_Clist widgets; // Our windows widgets. | ||
220 | int logDom; // Our logging domain. | ||
221 | |||
222 | struct _GLData gld; | ||
223 | Scene_Data *scene; | ||
224 | } globals; | ||
225 | |||
226 | extern globals ourGlobals; | ||
227 | |||
203 | 228 | ||
204 | void gears_init(GLData *gld); | 229 | void gears_init(GLData *gld); |
205 | void drawGears(GLData *gld); | 230 | void drawGears(GLData *gld); |
@@ -213,6 +238,8 @@ EAPI void drawIrr_end(GLData *gld); | |||
213 | EAPI void finishIrr(GLData *gld); | 238 | EAPI void finishIrr(GLData *gld); |
214 | 239 | ||
215 | EAPI void Evas_3D_Demo_add(globals *ourGlobals); | 240 | EAPI void Evas_3D_Demo_add(globals *ourGlobals); |
241 | Eina_Bool _animate_scene(void *data); | ||
242 | void Evas_3D_Demo_fini(void); | ||
216 | 243 | ||
217 | Evas_Object *fang_win_add(GLData *gld); | 244 | Evas_Object *fang_win_add(GLData *gld); |
218 | void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h); | 245 | void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h); |
diff --git a/src/extantz/extantzCamera.cpp b/src/extantz/extantzCamera.cpp index 6a7d36a..4d13054 100644 --- a/src/extantz/extantzCamera.cpp +++ b/src/extantz/extantzCamera.cpp | |||
@@ -49,7 +49,7 @@ ICameraSceneNode *addExtantzCamera(ISceneManager* sm, ISceneNode* parent, s32 id | |||
49 | //extantzCamera::extantzCamera(gui::ICursorControl* cursorControl) | 49 | //extantzCamera::extantzCamera(gui::ICursorControl* cursorControl) |
50 | // : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(0.4f), RotateSpeed(100.0f), JumpSpeed(3.0f), | 50 | // : CursorControl(cursorControl), MaxVerticalAngle(88.0f), MoveSpeed(0.4f), RotateSpeed(100.0f), JumpSpeed(3.0f), |
51 | extantzCamera::extantzCamera() | 51 | extantzCamera::extantzCamera() |
52 | : MaxVerticalAngle(88.0f), MouseYDirection(1.0f), LastAnimationTime(0), NoVerticalMovement(false) | 52 | : NoVerticalMovement(false), MouseYDirection(1.0f), MaxVerticalAngle(88.0f), LastAnimationTime(0) |
53 | { | 53 | { |
54 | #ifdef _DEBUG | 54 | #ifdef _DEBUG |
55 | setDebugName("extantzCamera"); | 55 | setDebugName("extantzCamera"); |
diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index 6eac003..3bb42fe 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c | |||
@@ -274,9 +274,6 @@ void woMan_add(GLData *gld) | |||
274 | tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it); | 274 | tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it); |
275 | elm_box_pack_end(bx, nf); | 275 | elm_box_pack_end(bx, nf); |
276 | 276 | ||
277 | #if USE_EO | ||
278 | // Not ready for prime time yet, or I'm missing a step. Causes it to hang after closing the window. | ||
279 | // Slightly better now, it bitches instead of hanging. | ||
280 | bt = eo_add(ELM_OBJ_BUTTON_CLASS, win); | 277 | bt = eo_add(ELM_OBJ_BUTTON_CLASS, win); |
281 | elm_object_text_set(bt, "Login"); // No eo interface for this that I can find. | 278 | elm_object_text_set(bt, "Login"); // No eo interface for this that I can find. |
282 | eo_do(bt, | 279 | eo_do(bt, |
@@ -285,15 +282,9 @@ void woMan_add(GLData *gld) | |||
285 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), | 282 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), |
286 | evas_obj_visibility_set(EINA_TRUE) | 283 | evas_obj_visibility_set(EINA_TRUE) |
287 | ); | 284 | ); |
288 | #else | ||
289 | bt = elm_button_add(win); | ||
290 | elm_object_text_set(bt, "Login"); | ||
291 | evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
292 | evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0); | ||
293 | evas_object_show(bt); | ||
294 | #endif | ||
295 | // evas_object_smart_callback_add(bt, "clicked", NULL, NULL); | 285 | // evas_object_smart_callback_add(bt, "clicked", NULL, NULL); |
296 | elm_box_pack_end(bx, bt); | 286 | elm_box_pack_end(bx, bt); |
287 | eo_unref(bt); | ||
297 | evas_object_show(bx); | 288 | evas_object_show(bx); |
298 | 289 | ||
299 | fang_win_complete(gld, win, 30, 30, gld->win_w / 3, gld->win_h / 3); | 290 | fang_win_complete(gld, win, 30, 30, gld->win_w / 3, gld->win_h / 3); |