aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ClientHamr/extantz
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-01-13 00:44:33 +1000
committerDavid Walter Seikel2014-01-13 00:44:33 +1000
commit469329e0b46350053ef28bf814dc91e76463625e (patch)
tree6908aed67a04b48272e96438f2e98db294206326 /ClientHamr/extantz
parentBit more anti bit rot and standards conforming comments. (diff)
downloadSledjHamr-469329e0b46350053ef28bf814dc91e76463625e.zip
SledjHamr-469329e0b46350053ef28bf814dc91e76463625e.tar.gz
SledjHamr-469329e0b46350053ef28bf814dc91e76463625e.tar.bz2
SledjHamr-469329e0b46350053ef28bf814dc91e76463625e.tar.xz
Fix EFL 1.7 -> 1.8 bit rot, make it work with Elm_glview to, and lots of cleanup.
Diffstat (limited to 'ClientHamr/extantz')
-rw-r--r--ClientHamr/extantz/crappisspuke.cpp18
-rw-r--r--ClientHamr/extantz/extantz.c504
-rw-r--r--ClientHamr/extantz/extantz.h50
3 files changed, 344 insertions, 228 deletions
diff --git a/ClientHamr/extantz/crappisspuke.cpp b/ClientHamr/extantz/crappisspuke.cpp
index 5bfb6e2..15cb523 100644
--- a/ClientHamr/extantz/crappisspuke.cpp
+++ b/ClientHamr/extantz/crappisspuke.cpp
@@ -3,7 +3,6 @@
3#include "extantz.h" 3#include "extantz.h"
4#include "CDemo.h" 4#include "CDemo.h"
5 5
6#define USE_DEMO 1
7 6
8SExposedVideoData videoData; 7SExposedVideoData videoData;
9 8
@@ -28,7 +27,7 @@ EAPI int startIrr(GLData *gld)
28 bool additive = true; 27 bool additive = true;
29 28
30 if (!gld->useIrr) 29 if (!gld->useIrr)
31 return 0; 30 return 1; // Return 1 so that the caller stops asking on each frame.
32 31
33#if USE_IRR 32#if USE_IRR
34 void *display = NULL; 33 void *display = NULL;
@@ -39,12 +38,9 @@ EAPI int startIrr(GLData *gld)
39 myDemo = new CDemo(gld, additive); 38 myDemo = new CDemo(gld, additive);
40#endif 39#endif
41 40
42 evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx);
43
44 display = glXGetCurrentDisplay(); 41 display = glXGetCurrentDisplay();
45 sfc = ecore_evas_window_get(ecore_evas_ecore_evas_get(evas_object_evas_get(gld->win))); 42 sfc = ecore_evas_window_get(gld->ee);
46 ctx = glXGetCurrentContext(); 43 ctx = glXGetCurrentContext();
47
48 /* For using a pre existing X11 window (with optional OpenGL). */ 44 /* For using a pre existing X11 window (with optional OpenGL). */
49 videoData = SExposedVideoData(); 45 videoData = SExposedVideoData();
50 videoData.OpenGLLinux.X11Display = display; // void * - Connection to the X server. 46 videoData.OpenGLLinux.X11Display = display; // void * - Connection to the X server.
@@ -116,10 +112,11 @@ EAPI int startIrr(GLData *gld)
116 driver = device->getVideoDriver(); gld->driver = driver; 112 driver = device->getVideoDriver(); gld->driver = driver;
117 smgr = device->getSceneManager(); gld->smgr = smgr; 113 smgr = device->getSceneManager(); gld->smgr = smgr;
118 114
119 device->setResizable(true); 115 // FIXME - this is what makes the window vanish in EFL 1.8, but worked fine in 1.7 I think.
120 driver->OnResize(dimension2d<u32>(gld->sfc_w, gld->sfc_h)); 116// device->setResizable(true);
117 driver->OnResize(dimension2d<u32>(gld->img_w, gld->img_h));
121 // Just gives me a blank screen. grrrr 118 // Just gives me a blank screen. grrrr
122// driver->setViewPort(rect<s32>(0, 0, gld->sfc_w, gld->sfc_h)); 119// driver->setViewPort(rect<s32>(0, 0, gld->img_w, gld->img_h));
123 120
124 // set ambient light 121 // set ambient light
125 smgr->setAmbientLight (video::SColorf(0x00c0c0c0)); 122 smgr->setAmbientLight (video::SColorf(0x00c0c0c0));
@@ -191,6 +188,7 @@ EAPI void drawIrr_start(GLData *gld)
191 const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds 188 const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
192 then = now; 189 then = now;
193 190
191
194#if USE_DEMO 192#if USE_DEMO
195 myDemo->preDraw(gld, now); 193 myDemo->preDraw(gld, now);
196#else 194#else
@@ -206,7 +204,7 @@ EAPI void drawIrr_start(GLData *gld)
206 the GUI Environment draw their content. With the endScene() 204 the GUI Environment draw their content. With the endScene()
207 call everything is presented on the screen. 205 call everything is presented on the screen.
208 */ 206 */
209 driver->beginScene(true, true, SColor(255, 100, 101, 140), videoData, NULL); // This does the context change, then clearBuffers() 207 driver->beginScene(true, true, SColor(255, 255, 255, 255), videoData, NULL); // This does the context change, then clearBuffers()
210 208
211 smgr->drawAll(); 209 smgr->drawAll();
212 } 210 }
diff --git a/ClientHamr/extantz/extantz.c b/ClientHamr/extantz/extantz.c
index 6eda717..832003a 100644
--- a/ClientHamr/extantz/extantz.c
+++ b/ClientHamr/extantz/extantz.c
@@ -1,9 +1,6 @@
1#include "extantz.h" 1#include "extantz.h"
2 2
3 3
4#define DO_GEARS 0
5#define USE_EO 0
6
7int _log_domain = -1; 4int _log_domain = -1;
8 5
9Eina_Hash *grids; 6Eina_Hash *grids;
@@ -40,9 +37,6 @@ static Elm_Genlist_Item_Class *grid_gic = NULL;
40static Elm_Genlist_Item_Class *account_gic = NULL; 37static Elm_Genlist_Item_Class *account_gic = NULL;
41static Elm_Genlist_Item_Class *viewer_gic = NULL; 38static Elm_Genlist_Item_Class *viewer_gic = NULL;
42 39
43static int x, y, w, h;
44
45
46static const char *img1 = PACKAGE_DATA_DIR "/images/plant_01.jpg"; 40static const char *img1 = PACKAGE_DATA_DIR "/images/plant_01.jpg";
47static const char *img2 = PACKAGE_DATA_DIR "/images/sky_01.jpg"; 41static const char *img2 = PACKAGE_DATA_DIR "/images/sky_01.jpg";
48static const char *img3 = PACKAGE_DATA_DIR "/images/rock_01.jpg"; 42static const char *img3 = PACKAGE_DATA_DIR "/images/rock_01.jpg";
@@ -51,8 +45,6 @@ static const char *img3 = PACKAGE_DATA_DIR "/images/rock_01.jpg";
51#define EPHYSICS_TEST_THEME "extantz" 45#define EPHYSICS_TEST_THEME "extantz"
52 46
53 47
54static void free_gear(Gear *gear);
55
56//--------------------------------// 48//--------------------------------//
57// Gear Stuff. 49// Gear Stuff.
58 50
@@ -87,7 +79,7 @@ static Gear *make_gear(GLData *gld, GLfloat inner_radius, GLfloat outer_radius,
87 double s[5], c[5]; 79 double s[5], c[5];
88 GLfloat normal[3]; 80 GLfloat normal[3];
89 const int tris_per_tooth = 20; 81 const int tris_per_tooth = 20;
90 Evas_GL_API *gl = gld->glapi; 82 Evas_GL_API *gl = gld->glApi;
91 83
92 gear = (Gear*)malloc(sizeof(Gear)); 84 gear = (Gear*)malloc(sizeof(Gear));
93 if (gear == NULL) 85 if (gear == NULL)
@@ -227,7 +219,7 @@ static void translate(GLfloat *m, GLfloat x, GLfloat y, GLfloat z)
227 219
228static void draw_gear(GLData *gld, Gear *gear, GLfloat *m, GLfloat x, GLfloat y, GLfloat angle, const GLfloat *color) 220static void draw_gear(GLData *gld, Gear *gear, GLfloat *m, GLfloat x, GLfloat y, GLfloat angle, const GLfloat *color)
229{ 221{
230 Evas_GL_API *gl = gld->glapi; 222 Evas_GL_API *gl = gld->glApi;
231 GLfloat tmp[16]; 223 GLfloat tmp[16];
232 224
233 memcpy(tmp, m, sizeof tmp); 225 memcpy(tmp, m, sizeof tmp);
@@ -296,7 +288,7 @@ static const char vertex_shader[] =
296 288
297static GLuint load_shader(GLData *gld, GLenum type, const char *shader_src) 289static GLuint load_shader(GLData *gld, GLenum type, const char *shader_src)
298{ 290{
299 Evas_GL_API *gl = gld->glapi; 291 Evas_GL_API *gl = gld->glApi;
300 GLuint shader; 292 GLuint shader;
301 GLint compiled = 0; 293 GLint compiled = 0;
302 294
@@ -330,6 +322,68 @@ static GLuint load_shader(GLData *gld, GLenum type, const char *shader_src)
330 return shader; 322 return shader;
331} 323}
332 324
325static void gears_init(GLData *gld)
326{
327 Evas_GL_API *gl = gld->glApi;
328 GLint linked = 0;
329
330 char msg[512];
331
332 gl->glEnable(GL_CULL_FACE);
333 gl->glEnable(GL_DEPTH_TEST);
334 gl->glEnable(GL_BLEND);
335
336 // Load the vertex/fragment shaders
337 gld->vtx_shader = load_shader(gld, GL_VERTEX_SHADER, vertex_shader);
338 gld->fgmt_shader = load_shader(gld, GL_FRAGMENT_SHADER, fragment_shader);
339
340 // Create the program object
341 if (!(gld->program = gl->glCreateProgram()))
342 return;
343
344 gl->glAttachShader(gld->program, gld->vtx_shader);
345 gl->glAttachShader(gld->program, gld->fgmt_shader);
346
347 // Bind shader attributes.
348 gl->glBindAttribLocation(gld->program, 0, "position");
349 gl->glBindAttribLocation(gld->program, 1, "normal");
350
351 // Link the program
352 gl->glLinkProgram(gld->program);
353 gld->glApi->glGetProgramiv(gld->program, GL_LINK_STATUS, &linked);
354
355 if (!linked)
356 {
357 GLint len = 0;
358
359 gld->glApi->glGetProgramiv(gld->program, GL_INFO_LOG_LENGTH, &len);
360 if (len > 1)
361 {
362 char *info = malloc(sizeof(char) * len);
363
364 if (info)
365 {
366 gld->glApi->glGetProgramInfoLog(gld->program, len, NULL, info);
367 printf("Error linking program:\n%s\n", info);
368 free(info);
369 }
370 }
371 gld->glApi->glDeleteProgram(gld->program);
372 }
373
374 gl->glUseProgram(gld->program);
375 gld->proj_location = gl->glGetUniformLocation(gld->program, "proj");
376 gld->light_location = gl->glGetUniformLocation(gld->program, "light");
377 gld->color_location = gl->glGetUniformLocation(gld->program, "color");
378
379 /* make the gears */
380 gld->gear1 = make_gear(gld, 1.0, 4.0, 1.0, 20, 0.7);
381 gld->gear2 = make_gear(gld, 0.5, 2.0, 2.0, 10, 0.7);
382 gld->gear3 = make_gear(gld, 1.3, 2.0, 0.5, 10, 0.7);
383
384 gld->gearsInited = EINA_TRUE;
385}
386
333static void _cb_mouse_down_GL(void *data, Evas *evas, Evas_Object *obj, void *event_info) 387static void _cb_mouse_down_GL(void *data, Evas *evas, Evas_Object *obj, void *event_info)
334{ 388{
335 GLData *gld = data; 389 GLData *gld = data;
@@ -501,9 +555,11 @@ static void _on_camera_input_up(void *data, Evas *evas, Evas_Object *obj, void *
501 } 555 }
502} 556}
503 557
558
559// Called from on_pixels (), or the Elm_gliew resize callback.
504static void _resize(GLData *gld) 560static void _resize(GLData *gld)
505{ 561{
506 Evas_GL_API *gl = gld->glapi; 562 Evas_GL_API *gl = gld->glApi;
507 563
508#if DO_GEARS 564#if DO_GEARS
509 GLfloat ar, m[16] = { 565 GLfloat ar, m[16] = {
@@ -524,17 +580,25 @@ static void _resize(GLData *gld)
524 m[5] = 0.1 * ar / gld->img_h; 580 m[5] = 0.1 * ar / gld->img_h;
525 memcpy(gld->proj, m, sizeof gld->proj); 581 memcpy(gld->proj, m, sizeof gld->proj);
526#endif 582#endif
527// gl->glViewport(0, 0, (GLint) gld->img_w, (GLint) gld->img_h); 583 gl->glViewport(0, 0, (GLint) gld->img_w, (GLint) gld->img_h);
584}
585
586static void _resize_gl(Evas_Object *obj)
587{
588 int w, h;
589 GLData *gld = evas_object_data_get(obj, "gld");
590
591 elm_glview_size_get(obj, &w, &h);
592
593 gld->img_w = w;
594 gld->img_h = h;
595 _resize(gld);
528} 596}
529 597
530static void on_pixels(void *data, Evas_Object *obj) 598static void on_pixels(void *data, Evas_Object *obj)
531{ 599{
532 static int count = 0;
533 GLData *gld = data; 600 GLData *gld = data;
534 if (!gld) 601 Evas_GL_API *gl = gld->glApi;
535 return;
536
537 Evas_GL_API *gl = gld->glapi;
538 602
539 // get the image size in case it changed with evas_object_image_size_set() 603 // get the image size in case it changed with evas_object_image_size_set()
540 if (gld->r1) 604 if (gld->r1)
@@ -542,15 +606,18 @@ static void on_pixels(void *data, Evas_Object *obj)
542 Evas_Coord w, h; 606 Evas_Coord w, h;
543 607
544 // Poor mans resize check. coz Elm wont do it easily. 608 // Poor mans resize check. coz Elm wont do it easily.
545 evas_object_geometry_get(gld->r1, NULL, NULL, &w, &h); 609 evas_object_image_size_get(gld->r1, &w, &h);
546 if ((gld->img_w != w) || (gld->img_h != h)) 610 if ((gld->img_w != w) || (gld->img_h != h))
547 { 611 {
548 float new_w = ((float) gld->scr_w / ((float) gld->scr_w * (float) w)); 612 // No idea where this crap came from.
549 float new_h = ((float) gld->scr_h / ((float) gld->scr_h * (float) h)); 613 //float new_w = ((float) gld->scr_w / ((float) gld->scr_w * (float) w));
614 //float new_h = ((float) gld->scr_h / ((float) gld->scr_h * (float) h));
550 615
551 gld->img_w = new_w; 616 //gld->sfc_w = new_w;
552 gld->img_h = new_h; 617 //gld->sfc_h = new_h;
553 evas_object_image_fill_set(gld->r1, 0, 0, gld->img_w, gld->img_h); 618 //evas_object_image_fill_set(gld->r1, 0, 0, gld->sfc_w, gld->sfc_h);
619 gld->img_w = w;
620 gld->img_h = h;
554 gld->resized = 1; 621 gld->resized = 1;
555 } 622 }
556 } 623 }
@@ -558,29 +625,36 @@ static void on_pixels(void *data, Evas_Object *obj)
558 if (gld->useEGL) 625 if (gld->useEGL)
559 { 626 {
560 // Yes, we DO need to do our own make current, coz aparently the Irrlicht one is useless. 627 // Yes, we DO need to do our own make current, coz aparently the Irrlicht one is useless.
561 evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); 628 // Hopefully Elm_GL has done this for us by now.
562 if (gld->resized) 629 // Evas_GL needs it to.
563 _resize(gld); 630 if (gld->ctx)
631 evas_gl_make_current(gld->evasGl, gld->sfc, gld->ctx);
564 } 632 }
565 633
566 if (!gld->doneIrr) 634 if (!gld->doneIrr)
567 gld->doneIrr = startIrr(gld); // Needs to be after gld->win is shown, and needs to be done in the render thread. 635 gld->doneIrr = startIrr(gld); // Needs to be after gld->win is shown, and needs to be done in the render thread.
636#if DO_GEARS
637 if (!gld->gearsInited)
638 gears_init(gld);
639#endif
640
641 if (gld->resized)
642 _resize(gld);
568 643
569 drawIrr_start(gld); 644 drawIrr_start(gld);
570 645
646#if DO_GEARS
571 if (gld->useEGL) 647 if (gld->useEGL)
572 { 648 {
573#if DO_GEARS
574 static const GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 }; 649 static const GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
575 static const GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 }; 650 static const GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
576 static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 }; 651 static const GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
577 GLfloat m[16]; 652 GLfloat m[16];
578 653
579
580 // Draw the gears. 654 // Draw the gears.
581 if (!gld->useIrr) 655 if (!gld->useIrr)
582 { 656 {
583 gl->glClearColor(0.8, 0.8, 0.1, 0.1); 657 gl->glClearColor(0.7, 0.0, 1.0, 1.0);
584 gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 658 gl->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
585 } 659 }
586 660
@@ -593,101 +667,163 @@ static void on_pixels(void *data, Evas_Object *obj)
593 draw_gear(gld, gld->gear2, m, 3.1, -2.0, -2 * gld->angle - 9.0, green); 667 draw_gear(gld, gld->gear2, m, 3.1, -2.0, -2 * gld->angle - 9.0, green);
594 draw_gear(gld, gld->gear3, m, -3.1, 4.2, -2 * gld->angle - 25.0, blue); 668 draw_gear(gld, gld->gear3, m, -3.1, 4.2, -2 * gld->angle - 25.0, blue);
595 gld->angle += 2.0; 669 gld->angle += 2.0;
596#endif
597 } 670 }
671#endif
598 672
599 drawIrr_end(gld); 673 drawIrr_end(gld);
600 count++; 674
675#if USE_IR
676#else
677 // This might get done deep within drawIrr_end, but only if we are using Irrlicht.
678
679 // Optional - Flush the GL pipeline
680 gl->glFlush();
681// gl->glFinish();
682#endif
683
601 gld->resized = 0; 684 gld->resized = 0;
602} 685}
603 686
604static void on_del(void *data, Evas *e, Evas_Object *obj, void *event_info) 687static void _draw_gl(Evas_Object *obj)
605{ 688{
606 // on delete of our object clean up some things that don't get auto 689 Evas_GL_API *gl = elm_glview_gl_api_get(obj);
607 // deleted for us as they are not intrinsically bound to the image 690 GLData *gld = evas_object_data_get(obj, "gld");
608 // object as such (you could use the same context and surface across
609 // multiple image objects and re-use the evasgl handle too multiple times.
610 // here we bind them to 1 object only though by doing this.
611 GLData *gld = data;
612 if (!gld) return; 691 if (!gld) return;
613 Evas_GL_API *gl = gld->glapi; 692
693 on_pixels(gld, obj);
694}
695
696// Callback from Evas, also used as the general callback for deleting the GL stuff.
697static void _clean_gl(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
698{
699 GLData *gld = data;
700 Evas_GL_API *gl = gld->glApi;
614 701
615 ecore_animator_del(gld->animator); 702 ecore_animator_del(gld->animator);
616 703
617 if (gld->useEGL) 704 if (gld->useEGL)
618 { 705 {
619 // Do a make_current before deleting all the GL stuff. 706 // Do a make_current before deleting all the GL stuff.
620 evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx); 707 evas_gl_make_current(gld->evasGl, gld->sfc, gld->ctx);
621
622#if DO_GEARS
623 gl->glDeleteShader(gld->vtx_shader);
624 gl->glDeleteShader(gld->fgmt_shader);
625 gl->glDeleteProgram(gld->program);
626 708
627 gl->glDeleteBuffers(1, &gld->gear1->vbo); 709 }
628 gl->glDeleteBuffers(1, &gld->gear2->vbo);
629 gl->glDeleteBuffers(1, &gld->gear3->vbo);
630 710
631 free_gear(gld->gear1); 711 gl->glDeleteShader(gld->vtx_shader);
632 free_gear(gld->gear2); 712 gl->glDeleteShader(gld->fgmt_shader);
633 free_gear(gld->gear3); 713 gl->glDeleteProgram(gld->program);
634#endif
635 714
715 if (gld->evasGl)
716 {
636 // Irrlicht wants to destroy the context and surface, so only do this if Irrlicht wont. 717 // Irrlicht wants to destroy the context and surface, so only do this if Irrlicht wont.
637 if (!gld->doneIrr) 718 if (!gld->doneIrr)
638 { 719 {
639 evas_gl_surface_destroy(gld->evasgl, gld->sfc); 720 evas_gl_surface_destroy(gld->evasGl, gld->sfc);
640 evas_gl_context_destroy(gld->evasgl, gld->ctx); 721 evas_gl_context_destroy(gld->evasGl, gld->ctx);
641 } 722 }
642 // TODO - hope this is OK, considering the context and surface might get dealt with by Irrlicht. 723 // TODO - hope this is OK, considering the context and surface might get dealt with by Irrlicht.
643 // Might be better to teach Irrlicht to not destroy shit it did not create. 724 // Might be better to teach Irrlicht to not destroy shit it did not create.
644 evas_gl_config_free(gld->cfg); 725 evas_gl_config_free(gld->cfg);
645 evas_gl_free(gld->evasgl); 726 evas_gl_free(gld->evasGl);
646 } 727 }
647 728
648 // TODO - Since this is created on the render thread, better hope this is being deleted on the render thread. 729 // TODO - Since this is created on the render thread, better hope this is being deleted on the render thread.
649 finishIrr(gld); 730 finishIrr(gld);
650 731
651 free(gld); 732#if DO_GEARS
733 gl->glDeleteBuffers(1, &gld->gear1->vbo);
734 gl->glDeleteBuffers(1, &gld->gear2->vbo);
735 gl->glDeleteBuffers(1, &gld->gear3->vbo);
736
737 free_gear(gld->gear1);
738 free_gear(gld->gear2);
739 free_gear(gld->gear3);
740#endif
741}
742
743// Callback from Elm, coz they do shit different.
744static void _del_gl(Evas_Object *obj)
745{
746 GLData *gld = evas_object_data_get(obj, "gld");
747 if (!gld)
748 {
749 printf("Unable to get GLData. \n");
750 return;
751 }
752
753 _clean_gl(gld, NULL, NULL, NULL);
754
755 evas_object_data_del((Evas_Object*)obj, "gld");
756}
757
758// Callback for when the app quits.
759static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
760{
761 GLData *gld = data;
762
763 evas_object_del(gld->win);
764 free(gld);
765 elm_exit();
652} 766}
653 767
768// Callback from the animator.
654static Eina_Bool doFrame(void *data) 769static Eina_Bool doFrame(void *data)
655{ 770{
656 GLData *gld = data; 771 GLData *gld = data;
657 772
658 // Mark the pixels as dirty, so they get rerendered each frame, then Irrlicht can draw it's stuff each frame. 773 // Mark the pixels as dirty, so they get rerendered each frame, then Irrlicht can draw it's stuff each frame.
659 // This causes on_pixel to be triggered by Evas_GL. 774 // This causes on_pixel to be triggered by Evas_GL, and _draw_gl for Elm_glview.
660 if (gld->r1) 775 if (gld->r1)
661 evas_object_image_pixels_dirty_set(gld->r1, EINA_TRUE); 776 evas_object_image_pixels_dirty_set(gld->r1, EINA_TRUE);
777 if (gld->elmGl)
778 elm_glview_changed_set(gld->elmGl);
662 779
663 // If not using Evas_GL, we need to call on_pixel() manually. 780 // If not using Evas_GL, we need to call on_pixel() manually.
664 if (!gld->useEGL) 781 if (!gld->useEGL)
665 on_pixels(gld, gld->r1); 782 on_pixels(gld, gld->r1);
666 783
667 return EINA_TRUE; 784 return EINA_TRUE; // Keep calling us.
668} 785}
669 786
670static void init_evas_gl(GLData *gld, int w, int h) 787static void init_evas_gl(GLData *gld)
671{ 788{
672 Ecore_Evas *ee;
673 Evas *canvas;
674 Evas_Native_Surface ns;
675
676 if (!gld->useEGL) 789 if (!gld->useEGL)
677 return; 790 return;
678 791
679 w *= 2; // Compensate for the original halving of the window. 792 gld->sfc_w = gld->win_w;
680 w -= 1; 793 gld->sfc_h = gld->win_h;
681 h -= 1; 794
682 795 // 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.
683 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(gld->win)); 796 gld->canvas = evas_object_evas_get(gld->win);
684 canvas = ecore_evas_get(ee); 797 // An Ecore_Evas holds an Evas.
685 798 // Get the Ecore_Evas that wraps an Evas.
686 //-//-//-// THIS IS WHERE GL INIT STUFF HAPPENS (ALA EGL) 799 gld->ee = ecore_evas_ecore_evas_get(gld->canvas); // Only use this on Evas that was created with Ecore_Evas.
687 //-// 800
801#if USE_ELM_GL
802 // Add a GLView
803 gld->elmGl = elm_glview_add(gld->win);
804 evas_object_size_hint_align_set(gld->elmGl, EVAS_HINT_FILL, EVAS_HINT_FILL);
805 evas_object_size_hint_weight_set(gld->elmGl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
806 elm_glview_mode_set(gld->elmGl, 0 | ELM_GLVIEW_ALPHA | ELM_GLVIEW_DEPTH | ELM_GLVIEW_DIRECT);
807 elm_glview_resize_policy_set(gld->elmGl, ELM_GLVIEW_RESIZE_POLICY_RECREATE); // Destroy the current surface on a resize and create a new one.
808 elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);
809// elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ALWAYS);
810 // These get called in the render thread I think.
811 //elm_glview_init_func_set(gld->elmGl, _init_gl); // Not actually needed, it gets done in on_pixels.
812 elm_glview_del_func_set(gld->elmGl, _del_gl);
813 elm_glview_resize_func_set(gld->elmGl, _resize_gl);
814 elm_glview_render_func_set(gld->elmGl, (Elm_GLView_Func_Cb) _draw_gl);
815
816 elm_box_pack_end(gld->bx, gld->elmGl);
817 elm_win_resize_object_add(gld->win, gld->elmGl);
818 evas_object_show(gld->elmGl);
819
820 elm_object_focus_set(gld->elmGl, EINA_TRUE);
821 gld->glApi = elm_glview_gl_api_get(gld->elmGl);
822 evas_object_data_set(gld->elmGl, "gld", gld);
823#else
688 // get the evas gl handle for doing gl things 824 // get the evas gl handle for doing gl things
689 gld->evasgl = evas_gl_new(canvas); 825 gld->evasGl = evas_gl_new(gld->canvas);
690 gld->glapi = evas_gl_api_get(gld->evasgl); 826 gld->glApi = evas_gl_api_get(gld->evasGl);
691 827
692 // Set a surface config 828 // Set a surface config
693 gld->cfg = evas_gl_config_new(); 829 gld->cfg = evas_gl_config_new();
@@ -697,121 +833,69 @@ static void init_evas_gl(GLData *gld, int w, int h)
697 gld->cfg->options_bits = EVAS_GL_OPTIONS_DIRECT; 833 gld->cfg->options_bits = EVAS_GL_OPTIONS_DIRECT;
698 834
699 // create a surface and context 835 // create a surface and context
700 gld->sfc_w = gld->scr_w; 836 gld->sfc = evas_gl_surface_create(gld->evasGl, gld->cfg, gld->sfc_w, gld->sfc_h);
701 gld->sfc_h = gld->scr_h; 837 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.
702 gld->sfc = evas_gl_surface_create(gld->evasgl, gld->cfg, gld->sfc_w, gld->sfc_h); 838
703 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. 839 // Set up the image object, a filled one by default.
704 //-// 840 gld->r1 = evas_object_image_filled_add(gld->canvas);
705 //-//-//-// END GL INIT BLOB 841
706 842 // attach important data we need to the object using key names. This just
707 // set up the image object. a filled one by default 843 // avoids some global variables and means we can do nice cleanup. You can
708 gld->r1 = evas_object_image_add(canvas); 844 // avoid this if you are lazy
709 evas_object_image_filled_set(gld->r1, EINA_FALSE); 845 // Not actually needed, with evas we can pass data pointers to stuff.
846 //evas_object_data_set(gld->r1, "gld", gld);
847
848 // when the object is deleted - call the on_del callback. like the above,
849 // this is just being clean
850 evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_DEL, _clean_gl, gld);
851
852 // set up an actual pixel size for the buffer data. it may be different
853 // to the output size. any windowing system has something like this, just
854 // evas has 2 sizes, a pixel size and the output object size
855 evas_object_image_size_set(gld->r1, gld->sfc_w, gld->sfc_h);
856 // Not actualy needed, as we create the image already filled.
857 //evas_object_image_fill_set(gld->r1, 0, 0, gld->sfc_w, gld->sfc_h);
858
859 // These two are not in the original example, but I get black r1 when I leave them out.
710 evas_object_size_hint_align_set(gld->r1, EVAS_HINT_FILL, EVAS_HINT_FILL); 860 evas_object_size_hint_align_set(gld->r1, EVAS_HINT_FILL, EVAS_HINT_FILL);
711 evas_object_size_hint_weight_set(gld->r1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 861 evas_object_size_hint_weight_set(gld->r1, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
712 elm_win_resize_object_add(gld->win, gld->r1); 862
713 // when the object is deleted - call the on_del callback. like the above, 863 // set up the native surface info to use the context and surface created
714 // this is just being clean 864 // above
715 evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_DEL, on_del, gld); 865 evas_gl_native_surface_get(gld->evasGl, gld->sfc, &(gld->ns));
716 // set up an actual pixel size for the buffer data. it may be different 866 evas_object_image_native_surface_set(gld->r1, &(gld->ns));
717 // to the output size. any windowing system has something like this, just
718 // evas has 2 sizes, a pixel size and the output object size
719 evas_object_image_size_set(gld->r1, gld->scr_w, gld->scr_h);
720 evas_object_image_fill_set(gld->r1, 0, 0, w, h);
721 // set up the native surface info to use the context and surface created
722 // above
723
724 // The ELM version does these as well.
725// elm_glview_resize_policy_set(gld->gl, ELM_GLVIEW_RESIZE_POLICY_RECREATE); // Destroy the current surface on a resize and create a new one.
726// elm_glview_render_policy_set(gld->gl, ELM_GLVIEW_RENDER_POLICY_ALWAYS); // Always render, even if not visible.
727
728 //-//-//-// THIS IS WHERE GL INIT STUFF HAPPENS (ALA EGL)
729 //-//
730 evas_gl_native_surface_get(gld->evasgl, gld->sfc, &ns);
731 evas_object_image_native_surface_set(gld->r1, &ns);
732 evas_object_image_pixels_get_callback_set(gld->r1, on_pixels, gld); 867 evas_object_image_pixels_get_callback_set(gld->r1, on_pixels, gld);
733 //-//
734 //-//-//-// END GL INIT BLOB
735 868
869 // move the image object somewhere, resize it and show it. any windowing
870 // system would need this kind of thing - place a child "window"
871 // Hmm, no need to resize it anyway, it's sized above.
872 evas_object_move(gld->r1, 0, 0);
873 //evas_object_resize(gld->r1, gld->sfc_w, gld->sfc_h);
874 elm_win_resize_object_add(gld->win, gld->r1);
736 evas_object_show(gld->r1); 875 evas_object_show(gld->r1);
737 // Might be good to pack it when I get the menu / address / indicator bar working. 876 elm_box_pack_end(gld->bx, gld->r1);
738// elm_box_pack_end(gld->bx, gld->r1);
739
740 evas_gl_make_current(gld->evasgl, gld->sfc, gld->ctx);
741
742 gld->glapi->glEnable(GL_CULL_FACE);
743 gld->glapi->glEnable(GL_DEPTH_TEST);
744 gld->glapi->glEnable(GL_BLEND);
745 gld->glapi->glViewport(0, 0, (GLint) gld->sfc_w, (GLint) gld->sfc_h);
746
747#if DO_GEARS
748 GLint linked = 0;
749
750 // Load the vertex/fragment shaders
751 gld->vtx_shader = load_shader(gld, GL_VERTEX_SHADER, vertex_shader);
752 gld->fgmt_shader = load_shader(gld, GL_FRAGMENT_SHADER, fragment_shader);
753
754 // Create the program object
755 if (!(gld->program = gld->glapi->glCreateProgram()))
756 return;
757
758 gld->glapi->glAttachShader(gld->program, gld->vtx_shader);
759 gld->glapi->glAttachShader(gld->program, gld->fgmt_shader);
760
761 // Bind shader attributes.
762 gld->glapi->glBindAttribLocation(gld->program, 0, "position");
763 gld->glapi->glBindAttribLocation(gld->program, 1, "normal");
764 // Link the program
765 gld->glapi->glLinkProgram(gld->program);
766 gld->glapi->glGetProgramiv(gld->program, GL_LINK_STATUS, &linked);
767
768 if (!linked)
769 {
770 GLint len = 0;
771 877
772 gld->glapi->glGetProgramiv(gld->program, GL_INFO_LOG_LENGTH, &len); 878// evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_GL, gld);
773 if (len > 1)
774 {
775 char *info = malloc(sizeof(char) * len);
776
777 if (info)
778 {
779 gld->glapi->glGetProgramInfoLog(gld->program, len, NULL, info);
780 printf("Error linking program:\n%s\n", info);
781 free(info);
782 }
783 }
784 gld->glapi->glDeleteProgram(gld->program);
785 }
786
787 gld->glapi->glUseProgram(gld->program);
788 gld->proj_location = gld->glapi->glGetUniformLocation(gld->program, "proj");
789 gld->light_location = gld->glapi->glGetUniformLocation(gld->program, "light");
790 gld->color_location = gld->glapi->glGetUniformLocation(gld->program, "color");
791
792 /* make the gears */
793 gld->gear1 = make_gear(gld, 1.0, 4.0, 1.0, 20, 0.7);
794 gld->gear2 = make_gear(gld, 0.5, 2.0, 2.0, 10, 0.7);
795 gld->gear3 = make_gear(gld, 1.3, 2.0, 0.5, 10, 0.7);
796#endif 879#endif
797 880
881 // In this code, we are making our own camera, so grab it's input when we are focused.
882 evas_object_event_callback_add(gld->win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
883 evas_object_event_callback_add(gld->win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
884 gld->camFocus = 1; // Start with the GL camera focused.
885
798 // NOTE: if you delete r1, this animator will keep running trying to access 886 // NOTE: if you delete r1, this animator will keep running trying to access
799 // r1 so you'd better delete this animator with ecore_animator_del() or 887 // r1 so you'd better delete this animator with ecore_animator_del() or
800 // structure how you do animation differently. you can also attach it like 888 // structure how you do animation differently. you can also attach it like
801 // evasgl, sfc, etc. etc. if this animator is specific to this object 889 // evasGl, sfc, etc. etc. if this animator is specific to this object
802 // only and delete it in the del handler for the obj. 890 // only and delete it in the del handler for the obj.
803 // 891 //
804 // 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. 892 // 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.
805 // 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. 893 // 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.
806// ecore_animator_frametime_set(1.0); 894
895 // Jiggling this seems to produce a trade off between flickering and frame rate. Nothing else changed the flickering.
896 ecore_animator_frametime_set(0.04); // Default is 1/30, or 0.033333
807 gld->animator = ecore_animator_add(doFrame, gld); // This animator will be called every frame tick, which defaults to 1/30 seconds. 897 gld->animator = ecore_animator_add(doFrame, gld); // This animator will be called every frame tick, which defaults to 1/30 seconds.
808 898
809 // In this code, we are making our own camera, so grab it's input when we are focused.
810 evas_object_event_callback_add(gld->win, EVAS_CALLBACK_KEY_DOWN, _on_camera_input_down, gld);
811 evas_object_event_callback_add(gld->win, EVAS_CALLBACK_KEY_UP, _on_camera_input_up, gld);
812 evas_object_event_callback_add(gld->r1, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_GL, gld);
813 gld->camFocus = 1; // Start with the GL camera focused.
814
815 return; 899 return;
816} 900}
817 901
@@ -833,12 +917,6 @@ static void _promote(void *data, Evas_Object *obj , void *event_info )
833 elm_naviframe_item_promote(data); 917 elm_naviframe_item_promote(data);
834} 918}
835 919
836static void _on_done(void *data, Evas_Object *obj, void *event_info)
837{
838 evas_object_del((Evas_Object*)data);
839 elm_exit();
840}
841
842static char *_grid_label_get(void *data, Evas_Object *obj, const char *part) 920static char *_grid_label_get(void *data, Evas_Object *obj, const char *part)
843{ 921{
844 ezGrid *thisGrid = data; 922 ezGrid *thisGrid = data;
@@ -924,16 +1002,17 @@ static Evas_Object *_viewer_content_get(void *data, Evas_Object *obj, const char
924static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info) 1002static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info)
925{ 1003{
926 ezGrid *thisGrid = data; 1004 ezGrid *thisGrid = data;
1005 GLData *gld = thisGrid->gld;
927 char buf[PATH_MAX]; 1006 char buf[PATH_MAX];
928 1007
929// sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", w - (w / 5), h - 30, w / 5, y, thisGrid->splashPage); 1008// sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage);
930 sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", w - (w / 5), h - 30, w / 5, y, thisGrid->splashPage); 1009 sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage);
931 printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info); 1010 printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info);
932// comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times. 1011// comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times.
933// system(buf); 1012// system(buf);
934} 1013}
935 1014
936static void fill(Evas_Object *win) 1015static void fill(GLData *gld, Evas_Object *win)
937{ 1016{
938 Evas_Object *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; 1017 Evas_Object *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu;
939 Elm_Object_Item *tb_it, *menu_it, *tab_it; 1018 Elm_Object_Item *tb_it, *menu_it, *tab_it;
@@ -943,7 +1022,7 @@ static void fill(Evas_Object *win)
943 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. 1022 // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle.
944 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. 1023 // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle.
945 bg = evas_object_rectangle_add(evas_object_evas_get(win)); 1024 bg = evas_object_rectangle_add(evas_object_evas_get(win));
946 evas_object_color_set(bg, 100, 0, 200, 200); 1025 evas_object_color_set(bg, 50, 0, 100, 100);
947 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1026 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
948 elm_win_resize_object_add(win, bg); 1027 elm_win_resize_object_add(win, bg);
949 evas_object_show(bg); 1028 evas_object_show(bg);
@@ -979,7 +1058,7 @@ static void fill(Evas_Object *win)
979 elm_menu_item_separator_add(menu, menu_it); 1058 elm_menu_item_separator_add(menu, menu_it);
980 elm_menu_item_add(menu, menu_it, NULL, "about extantz", NULL, NULL); 1059 elm_menu_item_add(menu, menu_it, NULL, "about extantz", NULL, NULL);
981 elm_menu_item_separator_add(menu, menu_it); 1060 elm_menu_item_separator_add(menu, menu_it);
982 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, win); 1061 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld);
983 1062
984 // The toolbar needs to be packed into the box AFTER the menus are added. 1063 // The toolbar needs to be packed into the box AFTER the menus are added.
985 elm_box_pack_end(bx, tb); 1064 elm_box_pack_end(bx, tb);
@@ -1006,6 +1085,7 @@ static void fill(Evas_Object *win)
1006 thisGrid->loginURI = gridTest[i][1]; 1085 thisGrid->loginURI = gridTest[i][1];
1007 thisGrid->splashPage = gridTest[i][2]; 1086 thisGrid->splashPage = gridTest[i][2];
1008 thisGrid->icon = "folder"; 1087 thisGrid->icon = "folder";
1088 thisGrid->gld = gld;
1009 thisGrid->item = elm_genlist_item_append(gridList, grid_gic, thisGrid, NULL, ELM_GENLIST_ITEM_TREE, _grid_sel_cb, thisGrid); 1089 thisGrid->item = elm_genlist_item_append(gridList, grid_gic, thisGrid, NULL, ELM_GENLIST_ITEM_TREE, _grid_sel_cb, thisGrid);
1010 eina_hash_add(grids, thisGrid->name, thisGrid); 1090 eina_hash_add(grids, thisGrid->name, thisGrid);
1011 } 1091 }
@@ -1066,9 +1146,11 @@ static void fill(Evas_Object *win)
1066 1146
1067#if USE_EO 1147#if USE_EO
1068 // Not ready for prime time yet, or I'm missing a step. Causes it to hang after closing the window. 1148 // Not ready for prime time yet, or I'm missing a step. Causes it to hang after closing the window.
1149 // Slightly better now, it bitches instead of hanging.
1069 bt = eo_add(ELM_OBJ_BUTTON_CLASS, win); 1150 bt = eo_add(ELM_OBJ_BUTTON_CLASS, win);
1070 elm_object_text_set(bt, "Login"); // No eo interface for this that I can find. 1151 elm_object_text_set(bt, "Login"); // No eo interface for this that I can find.
1071 eo_do(bt, 1152 eo_do(bt,
1153// evas_obj_text_set("Login"),
1072 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), 1154 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
1073 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), 1155 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
1074 evas_obj_visibility_set(EINA_TRUE) 1156 evas_obj_visibility_set(EINA_TRUE)
@@ -1184,58 +1266,65 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1184 if (!(gld = calloc(1, sizeof(GLData)))) return; 1266 if (!(gld = calloc(1, sizeof(GLData)))) return;
1185 gldata_init(gld); 1267 gldata_init(gld);
1186 1268
1187 // Set the engine to opengl_x11 1269 // Set the engine to opengl_x11, then open our window.
1188 if (gld->useEGL) 1270 if (gld->useEGL)
1189 elm_config_preferred_engine_set("opengl_x11"); 1271 elm_config_preferred_engine_set("opengl_x11");
1190// else
1191// elm_config_preferred_engine_set("software_x11");
1192 gld->win = elm_win_add(NULL, "extantz", ELM_WIN_BASIC); 1272 gld->win = elm_win_add(NULL, "extantz", ELM_WIN_BASIC);
1193 // Set preferred engine back to default from config 1273 // Set preferred engine back to default from config
1194 elm_config_preferred_engine_set(NULL); 1274 elm_config_preferred_engine_set(NULL);
1195 1275
1276#if USE_PHYSICS
1196 if (!ephysics_init()) 1277 if (!ephysics_init())
1197 return 1; 1278 return 1;
1279#endif
1198 1280
1199 elm_win_title_set(gld->win, "extantz virtual world manager"); 1281 elm_win_title_set(gld->win, "extantz virtual world manager");
1200 evas_object_smart_callback_add(gld->win, "delete,request", _on_done, NULL); 1282 evas_object_smart_callback_add(gld->win, "delete,request", _on_done, gld);
1201 1283
1202 elm_win_screen_size_get(gld->win, &x, &y, &gld->scr_w, &gld->scr_h); 1284 // Get the screen size.
1203 w = gld->scr_w / 2; 1285 elm_win_screen_size_get(gld->win, &gld->win_x, &gld->win_y, &gld->scr_w, &gld->scr_h);
1204 h = gld->scr_h - 30; 1286 gld->win_w = gld->scr_w / 2;
1287 gld->win_h = gld->scr_h - 30;
1205 1288
1289 // Note, we don't need an Elm_bg, the entire thing gets covered with the GL rendering surface anyway.
1290#if 0
1206 bg = elm_bg_add(gld->win); 1291 bg = elm_bg_add(gld->win);
1207 elm_bg_load_size_set(bg, w, h); 1292 elm_bg_load_size_set(bg, gld->win_w, gld->win_h);
1208 elm_bg_option_set(bg, ELM_BG_OPTION_CENTER); 1293 elm_bg_option_set(bg, ELM_BG_OPTION_CENTER);
1209 snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get()); 1294 snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", elm_app_data_dir_get());
1210 elm_bg_file_set(bg, buf, NULL); 1295 elm_bg_file_set(bg, buf, NULL);
1211 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1296 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1212 elm_win_resize_object_add(gld->win, bg); 1297 elm_win_resize_object_add(gld->win, bg);
1213 evas_object_show(bg); 1298 evas_object_show(bg);
1299#endif
1214 1300
1215 gld->bx = elm_box_add(gld->win); 1301 gld->bx = elm_box_add(gld->win);
1216 elm_win_resize_object_add(gld->win, gld->bx);
1217 evas_object_size_hint_weight_set(gld->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 1302 evas_object_size_hint_weight_set(gld->bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1218 evas_object_size_hint_align_set(gld->bx, EVAS_HINT_FILL, EVAS_HINT_FILL); 1303 evas_object_size_hint_align_set(gld->bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1219// elm_win_resize_object_add(gld->bx, bg); 1304 elm_win_resize_object_add(gld->win, gld->bx);
1220 evas_object_show(gld->bx); 1305 evas_object_show(gld->bx);
1221 1306
1307// TODO - add the main menu here, in a toolbar, in the box. The windows still need their own menus, just different from the ones we have now.
1308
1309#if 1
1222 win3 = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE); 1310 win3 = elm_win_add(gld->win, "inlined", ELM_WIN_INLINED_IMAGE);
1223 evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld); 1311 evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld);
1224 elm_win_alpha_set(win3, EINA_TRUE); 1312 elm_win_alpha_set(win3, EINA_TRUE);
1225 fill(win3); 1313 fill(gld, win3);
1226 // Odd, it needs to be resized twice? 1314 // image object for win3 is unlinked to its pos/size - so manual control
1227 evas_object_resize(win3, w / 3, h / 4); 1315 // this allows also for using map and other things with it.
1228 // image object for win3 is unlinked to its pos/size - so manual control
1229 // this allows also for using map and other things with it.
1230 evas_object_move(elm_win_inlined_image_object_get(win3), 13, 13); 1316 evas_object_move(elm_win_inlined_image_object_get(win3), 13, 13);
1231 evas_object_resize(elm_win_inlined_image_object_get(win3), w / 3, h / 4); 1317 // Odd, it needs to be resized twice. WTF?
1318 evas_object_resize(win3, gld->win_w / 3, gld->win_h / 3);
1319 evas_object_resize(elm_win_inlined_image_object_get(win3), gld->win_w / 3, gld->win_h / 3);
1232 evas_object_show(win3); 1320 evas_object_show(win3);
1233 create_handles(elm_win_inlined_image_object_get(win3)); 1321 create_handles(elm_win_inlined_image_object_get(win3));
1322#endif
1234 1323
1235#if USE_PHYSICS 1324#if USE_PHYSICS
1236 // ePhysics stuff. 1325 // ePhysics stuff.
1237 world = ephysics_world_new(); 1326 world = ephysics_world_new();
1238 ephysics_world_render_geometry_set(world, 0, 0, -50, w, h, 100); 1327 ephysics_world_render_geometry_set(world, 0, 0, -50, gld->win_w, gld->win_h, 100);
1239 1328
1240 boundary = ephysics_body_bottom_boundary_add(world); 1329 boundary = ephysics_body_bottom_boundary_add(world);
1241 ephysics_body_restitution_set(boundary, 1); 1330 ephysics_body_restitution_set(boundary, 1);
@@ -1255,7 +1344,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1255 1344
1256 box1 = elm_image_add(gld->win); 1345 box1 = elm_image_add(gld->win);
1257 elm_image_file_set(box1, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "blue-cube"); 1346 elm_image_file_set(box1, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "blue-cube");
1258 evas_object_move(box1, w / 2 - 80, h - 200); 1347 evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200);
1259 evas_object_resize(box1, 70, 70); 1348 evas_object_resize(box1, 70, 70);
1260 evas_object_show(box1); 1349 evas_object_show(box1);
1261 1350
@@ -1269,7 +1358,7 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1269 1358
1270 box2 = elm_image_add(gld->win); 1359 box2 = elm_image_add(gld->win);
1271 elm_image_file_set(box2, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube"); 1360 elm_image_file_set(box2, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
1272 evas_object_move(box2, w / 2 + 10, h - 200); 1361 evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200);
1273 evas_object_resize(box2, 70, 70); 1362 evas_object_resize(box2, 70, 70);
1274 evas_object_show(box2); 1363 evas_object_show(box2);
1275 1364
@@ -1284,11 +1373,12 @@ EAPI_MAIN int elm_main(int argc, char **argv)
1284 ephysics_world_gravity_set(world, 0, 0, 0); 1373 ephysics_world_gravity_set(world, 0, 0, 0);
1285#endif 1374#endif
1286 1375
1287 // This does an elm_box_pack_end(), so needs to be after the others. 1376 // This does a elm_box_pack_end(), so needs to be after the others.
1288 init_evas_gl(gld, w, h); 1377 init_evas_gl(gld);
1378 evas_object_show(gld->win);
1289 1379
1290 evas_object_move(gld->win, x, y); 1380 evas_object_move(gld->win, gld->win_x, gld->win_y);
1291 evas_object_resize(gld->win, w, h); 1381 evas_object_resize(gld->win, gld->win_w, gld->win_h);
1292 evas_object_show(gld->win); 1382 evas_object_show(gld->win);
1293 1383
1294 elm_run(); 1384 elm_run();
diff --git a/ClientHamr/extantz/extantz.h b/ClientHamr/extantz/extantz.h
index 336e965..af0c1d3 100644
--- a/ClientHamr/extantz/extantz.h
+++ b/ClientHamr/extantz/extantz.h
@@ -1,3 +1,18 @@
1#define USE_EO 0
2#define USE_PHYSICS 1
3#define USE_EGL 1 // If using Evas_GL, though it might be via Elm.
4#define USE_ELM_GL 1
5#define USE_IRR 1
6#define USE_DEMO 1
7#define DO_GEARS 0
8
9#if USE_EO
10 /* Enable access to unstable EFL API that are still in beta */
11 #define EFL_BETA_API_SUPPORT 1
12 /* Enable access to unstable EFL EO API. */
13 #define EFL_EO_API_SUPPORT 1
14#endif
15
1#include <Elementary.h> 16#include <Elementary.h>
2#include <elm_widget_glview.h> 17#include <elm_widget_glview.h>
3#include <Evas_GL.h> 18#include <Evas_GL.h>
@@ -50,11 +65,18 @@ typedef struct ICameraSceneNode ICameraSceneNode;
50#endif 65#endif
51 66
52 67
53#define USE_PHYSICS 0 68#define CRI(...) EINA_LOG_DOM_CRIT(_log_domain, _VA_ARGS__)
54#define USE_EGL 0 69#define ERR(...) EINA_LOG_DOM_ERR(_log_domain, __VA_ARGS__)
55#define USE_IRR 0 70#define WRN(...) EINA_LOG_DOM_WARN(_log_domain, __VA_ARGS__)
71#define INF(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__)
72#define DBG(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__)
73
74extern int _log_domain;
56 75
57 76
77typedef struct _Gear Gear;
78typedef struct _GLData GLData;
79
58typedef enum 80typedef enum
59{ 81{
60 EZP_NONE, 82 EZP_NONE,
@@ -92,6 +114,7 @@ typedef struct
92 ezPlatform platform; 114 ezPlatform platform;
93 ezViewer *viewer; 115 ezViewer *viewer;
94 Elm_Object_Item *item; 116 Elm_Object_Item *item;
117GLData *gld; // Just a temporary evil hack to pass gld to _grid_sel_cb().
95} ezGrid; 118} ezGrid;
96 119
97typedef struct 120typedef struct
@@ -113,9 +136,6 @@ typedef struct
113} ezLandmark; 136} ezLandmark;
114 137
115 138
116typedef struct _Gear Gear;
117typedef struct _GLData GLData;
118
119 139
120struct _Gear 140struct _Gear
121{ 141{
@@ -129,21 +149,29 @@ struct _GLData
129{ 149{
130 Evas_Object *win; 150 Evas_Object *win;
131 151
152 Ecore_Evas *ee;
153 Evas *canvas;
154 Evas_Native_Surface ns;
155
132 Evas_GL_Context *ctx; 156 Evas_GL_Context *ctx;
133 Evas_GL_Surface *sfc; 157 Evas_GL_Surface *sfc;
134 Evas_GL_Config *cfg; 158 Evas_GL_Config *cfg;
135 Evas_GL *evasgl; 159 Evas_GL *evasGl; // The Evas way.
136 Evas_GL_API *glapi; 160 Evas_Object *elmGl; // The Elm way.
161 Evas_GL_API *glApi;
137 162
138 GLuint program; 163 GLuint program;
139 GLuint vtx_shader; 164 GLuint vtx_shader;
140 GLuint fgmt_shader; 165 GLuint fgmt_shader;
141 int scr_w, scr_h; 166 int scr_w, scr_h; // The size of the screen.
142 int sfc_w, sfc_h; 167 int win_w, win_h; // The size of the window.
143 int img_w, img_h; 168 int win_x, win_y; // The position of the window.
169 int sfc_w, sfc_h; // This is what Irrlicht is using, size of the GL image surface / glview.
170 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?
144 int useEGL : 1; 171 int useEGL : 1;
145 int useIrr : 1; 172 int useIrr : 1;
146 int doneIrr : 1; 173 int doneIrr : 1;
174 int gearsInited : 1;
147 int resized : 1; 175 int resized : 1;
148 int camFocus : 1; 176 int camFocus : 1;
149 177