diff options
author | David Walter Seikel | 2014-05-02 19:52:58 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-02 19:52:58 +1000 |
commit | bb23c72a3ef3e460c8b88230354af65e78240d49 (patch) | |
tree | 0caabb852301d0310ed61168be6a0daacdb0ad9f /src/extantz/extantz.c | |
parent | Minor clean ups of the overlay comments. (diff) | |
download | SledjHamr-bb23c72a3ef3e460c8b88230354af65e78240d49.zip SledjHamr-bb23c72a3ef3e460c8b88230354af65e78240d49.tar.gz SledjHamr-bb23c72a3ef3e460c8b88230354af65e78240d49.tar.bz2 SledjHamr-bb23c72a3ef3e460c8b88230354af65e78240d49.tar.xz |
Major cleanup of extantz, part one.
Diffstat (limited to '')
-rw-r--r-- | src/extantz/extantz.c | 421 |
1 files changed, 156 insertions, 265 deletions
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 | { |