aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-04-27 14:57:13 +1000
committerDavid Walter Seikel2014-04-27 14:57:13 +1000
commitb02b36e5ec90fa8350c4d7b9e3abf40111b38dc4 (patch)
tree5047e68f91fabb429e5b8bfb3a788a0a4746c485 /src
parentTODO++ (diff)
downloadSledjHamr-b02b36e5ec90fa8350c4d7b9e3abf40111b38dc4.zip
SledjHamr-b02b36e5ec90fa8350c4d7b9e3abf40111b38dc4.tar.gz
SledjHamr-b02b36e5ec90fa8350c4d7b9e3abf40111b38dc4.tar.bz2
SledjHamr-b02b36e5ec90fa8350c4d7b9e3abf40111b38dc4.tar.xz
Added stuff cut and pasted from the new Evas_3d examples, but they are broken anyway. Just leaving it commented out for now.
Diffstat (limited to 'src')
-rw-r--r--src/GuiLua/GuiLua.c228
-rw-r--r--src/GuiLua/GuiLua.h15
2 files changed, 243 insertions, 0 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index c7a368c..8dbc2ff 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -143,10 +143,209 @@ and ordinary elementary widgets. Proper introspection can come later.
143#include "GuiLua.h" 143#include "GuiLua.h"
144 144
145 145
146typedef struct _Scene_Data
147{
148 Evas_3D_Scene *scene;
149 Evas_3D_Node *root_node;
150 Evas_3D_Node *camera_node;
151 Evas_3D_Node *light_node;
152 Evas_3D_Node *mesh_node;
153
154 Evas_3D_Camera *camera;
155 Evas_3D_Light *light;
156 Evas_3D_Mesh *mesh;
157 Evas_3D_Material *material;
158} Scene_Data;
159
160static const float cube_vertices[] =
161{
162 /* Front */
163 -1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0,
164 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0,
165 -1.0, -1.0, 1.0, 0.0, 0.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.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
190 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
191
192 /* Bottom */
193 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
194 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
195 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
196 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
197};
198
199static const unsigned short cube_indices[] =
200{
201 /* Front */
202 0, 1, 2, 2, 1, 3,
203
204 /* Back */
205 4, 5, 6, 6, 5, 7,
206
207 /* Left */
208 8, 9, 10, 10, 9, 11,
209
210 /* Right */
211 12, 13, 14, 14, 13, 15,
212
213 /* Top */
214 16, 17, 18, 18, 17, 19,
215
216 /* Bottom */
217 20, 21, 22, 22, 21, 23
218};
219
220
146globals ourGlobals; 221globals ourGlobals;
147static const char *globName = "ourGlobals"; 222static const char *globName = "ourGlobals";
148 223
149 224
225static Scene_Data data;
226
227static Eina_Bool
228_animate_scene(void *data)
229{
230 static float angle = 0.0f;
231/*
232 Scene_Data *scene = (Scene_Data *)data;
233
234 angle += 0.5;
235
236 evas_3d_node_orientation_angle_axis_set(scene->mesh_node, angle, 1.0, 1.0, 1.0);
237*/
238
239 /* Rotate */
240 if (angle > 360.0)
241 angle -= 360.0f;
242 return EINA_TRUE;
243}
244
245static void
246_camera_setup(Scene_Data *data)
247{
248/*
249 data->camera = evas_3d_camera_add(evas);
250 evas_3d_camera_projection_perspective_set(data->camera, 60.0, 1.0, 2.0, 50.0);
251
252 data->camera_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_CAMERA);
253 evas_3d_node_camera_set(data->camera_node, data->camera);
254 evas_3d_node_member_add(data->root_node, data->camera_node);
255 evas_3d_node_position_set(data->camera_node, 0.0, 0.0, 10.0);
256 evas_3d_node_look_at_set(data->camera_node, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
257 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0);
258*/
259}
260
261static void
262_light_setup(Scene_Data *data)
263{
264/*
265 data->light = evas_3d_light_add(evas);
266 evas_3d_light_ambient_set(data->light, 0.2, 0.2, 0.2, 1.0);
267 evas_3d_light_diffuse_set(data->light, 1.0, 1.0, 1.0, 1.0);
268 evas_3d_light_specular_set(data->light, 1.0, 1.0, 1.0, 1.0);
269
270 data->light_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_LIGHT);
271 evas_3d_node_light_set(data->light_node, data->light);
272 evas_3d_node_member_add(data->root_node, data->light_node);
273 evas_3d_node_position_set(data->light_node, 0.0, 0.0, 10.0);
274 evas_3d_node_look_at_set(data->light_node, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
275 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0);
276*/
277}
278
279static void
280_mesh_setup(Scene_Data *data)
281{
282 /* Setup material. */
283/*
284 data->material = evas_3d_material_add(evas);
285
286 evas_3d_material_enable_set(data->material, EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE);
287 evas_3d_material_enable_set(data->material, EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE);
288 evas_3d_material_enable_set(data->material, EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE);
289
290 evas_3d_material_color_set(data->material, EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0);
291 evas_3d_material_color_set(data->material, EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0);
292 evas_3d_material_color_set(data->material, EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0);
293 evas_3d_material_shininess_set(data->material, 100.0);
294*/
295
296 /* Setup mesh. */
297/*
298 data->mesh = evas_3d_mesh_add(evas);
299 evas_3d_mesh_vertex_count_set(data->mesh, 24);
300 evas_3d_mesh_frame_add(data->mesh, 0);
301
302 evas_3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_3D_VERTEX_POSITION,
303 12 * sizeof(float), &cube_vertices[ 0]);
304 evas_3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_3D_VERTEX_NORMAL,
305 12 * sizeof(float), &cube_vertices[ 3]);
306 evas_3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_3D_VERTEX_COLOR,
307 12 * sizeof(float), &cube_vertices[ 6]);
308 evas_3d_mesh_frame_vertex_data_set(data->mesh, 0, EVAS_3D_VERTEX_TEXCOORD,
309 12 * sizeof(float), &cube_vertices[10]);
310
311 evas_3d_mesh_index_data_set(data->mesh, EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
312 36, &cube_indices[0]);
313 evas_3d_mesh_vertex_assembly_set(data->mesh, EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES);
314
315 evas_3d_mesh_shade_mode_set(data->mesh, EVAS_3D_SHADE_MODE_PHONG);
316
317 evas_3d_mesh_frame_material_set(data->mesh, 0, data->material);
318
319 data->mesh_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_MESH);
320 evas_3d_node_member_add(data->root_node, data->mesh_node);
321 evas_3d_node_mesh_add(data->mesh_node, data->mesh);
322*/
323}
324
325static void
326_scene_setup(globals *ourGlobals, Scene_Data *data)
327{
328/*
329 data->scene = evas_3d_scene_add(ourGlobals->evas);
330 evas_3d_scene_size_set(data->scene, WIDTH, HEIGHT);
331 evas_3d_scene_background_color_set(data->scene, 0.0, 0.0, 0.0, 0.0);
332
333 data->root_node = evas_3d_node_add(evas, EVAS_3D_NODE_TYPE_NODE);
334*/
335
336 _camera_setup(data);
337 _light_setup(data);
338 _mesh_setup(data);
339
340/*
341 evas_3d_scene_root_node_set(data->scene, data->root_node);
342 evas_3d_scene_camera_node_set(data->scene, data->camera_node);
343*/
344}
345
346
347
348
150// TODO - These functions should be able to deal with multiple windows. 349// TODO - These functions should be able to deal with multiple windows.
151// TODO - Should be able to open external and internal windows, and even switch between them on the fly. 350// TODO - Should be able to open external and internal windows, and even switch between them on the fly.
152static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 351static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
@@ -282,6 +481,35 @@ static int window(lua_State *L)
282 evas_object_move(ourGlobals->win, 0, 0); 481 evas_object_move(ourGlobals->win, 0, 0);
283 evas_object_show(ourGlobals->win); 482 evas_object_show(ourGlobals->win);
284 483
484 // 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.
485 ourGlobals->evas = evas_object_evas_get(ourGlobals->win);
486 // An Ecore_Evas holds an Evas.
487 // Get the Ecore_Evas that wraps an Evas.
488// ourGlobals->ecore_evas = ecore_evas_ecore_evas_get(ourGlobals->evas); // Only use this on Evas that was created with Ecore_Evas.
489
490 _scene_setup(ourGlobals, &data);
491
492 /* Add an image object for 3D scene rendering. */
493/*
494 ourGlobals->image = elm_image_add(ourGlobals->win);
495 elm_image_no_scale_set(ourGlobals->image, EINA_TRUE);
496 elm_image_resizable_set(ourGlobals->image, EINA_FALSE, EINA_TRUE);
497 elm_image_smooth_set(ourGlobals->image, EINA_FALSE);
498 elm_image_orient_set(ourGlobals->image, ELM_IMAGE_FLIP_HORIZONTAL);
499 elm_image_aspect_fixed_set(ourGlobals->image, EINA_TRUE);
500 elm_image_fill_outside_set(ourGlobals->image, EINA_TRUE);
501 elm_image_editable_set(ourGlobals->image, EINA_TRUE);
502 evas_object_size_hint_weight_set(ourGlobals->image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
503 elm_win_resize_object_add(ourGlobals->win, ourGlobals->image);
504 evas_object_show(ourGlobals->image);
505
506 // Set the image object as render target for 3D scene.
507 evas_object_image_scene_set(ourGlobals->image, data.scene);
508*/
509
510 // Add animation timer callback.
511 ecore_timer_add(0.016, _animate_scene, &data);
512
285 lua_pushlightuserdata(L, &ourGlobals->win); 513 lua_pushlightuserdata(L, &ourGlobals->win);
286 return 1; 514 return 1;
287 } 515 }
diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h
index 156fa1a..95353fb 100644
--- a/src/GuiLua/GuiLua.h
+++ b/src/GuiLua/GuiLua.h
@@ -1,9 +1,19 @@
1 1
2#define EFL_API_OVERRIDE 1
3/* Enable access to unstable EFL API that are still in beta */
4#define EFL_BETA_API_SUPPORT 1
5/* Enable access to unstable EFL EO API. */
6#define EFL_EO_API_SUPPORT 1
7
2#include <stdio.h> 8#include <stdio.h>
3#include <ctype.h> 9#include <ctype.h>
4 10
5#include <Elementary.h> 11#include <Elementary.h>
6 12
13// This got left out.
14//EAPI Evas_3D_Scene *evas_3d_scene_add(Evas *e);
15
16
7#include <lua.h> 17#include <lua.h>
8#include <luajit.h> 18#include <luajit.h>
9#include <lualib.h> 19#include <lualib.h>
@@ -28,6 +38,11 @@ struct _globals
28{ 38{
29 Evas_Object *win; // Our Elm window. 39 Evas_Object *win; // Our Elm window.
30 int logDom; // Our logging domain. 40 int logDom; // Our logging domain.
41
42//Ecore_Evas *ecore_evas;
43Evas *evas;
44//Evas_Object *background;
45Evas_Object *image;
31}; 46};
32 47
33 48