summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChunEon Park <hermet@hermet.pe.kr>2014-06-02 22:50:33 +0900
committerChunEon Park <hermet@hermet.pe.kr>2014-06-02 22:50:33 +0900
commitd0258f5fd3c0ef9d27156ad5b39c17b777fa5edf (patch)
tree34929830586c04fd6ca5bd5b3dca27f5dc46bdd4
parent1e2f983098b1599ff60ddd82ff91b6b64d5295dc (diff)
examples - clean up 3d_scene_on_button_example.
-rw-r--r--src/examples/3d_scene_on_button_example.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/examples/3d_scene_on_button_example.c b/src/examples/3d_scene_on_button_example.c
index 5c69638e2..6f107ea07 100644
--- a/src/examples/3d_scene_on_button_example.c
+++ b/src/examples/3d_scene_on_button_example.c
@@ -167,9 +167,12 @@ _mesh_setup(Scene_Data *data)
167 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), 167 evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE),
168 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), 168 evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE),
169 169
170 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT, 0.2, 0.2, 0.2, 1.0), 170 evas_3d_material_color_set(EVAS_3D_MATERIAL_AMBIENT,
171 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE, 0.8, 0.8, 0.8, 1.0), 171 0.2, 0.2, 0.2, 1.0),
172 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR, 1.0, 1.0, 1.0, 1.0), 172 evas_3d_material_color_set(EVAS_3D_MATERIAL_DIFFUSE,
173 0.8, 0.8, 0.8, 1.0),
174 evas_3d_material_color_set(EVAS_3D_MATERIAL_SPECULAR,
175 1.0, 1.0, 1.0, 1.0),
173 evas_3d_material_shininess_set(100.0)); 176 evas_3d_material_shininess_set(100.0));
174 177
175 /* Setup mesh. */ 178 /* Setup mesh. */
@@ -179,20 +182,22 @@ _mesh_setup(Scene_Data *data)
179 evas_3d_mesh_frame_add(0), 182 evas_3d_mesh_frame_add(0),
180 183
181 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION, 184 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION,
182 12 * sizeof(float), &cube_vertices[ 0]), 185 12 * sizeof(float),
186 &cube_vertices[ 0]),
183 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL, 187 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL,
184 12 * sizeof(float), &cube_vertices[ 3]), 188 12 * sizeof(float),
189 &cube_vertices[ 3]),
185 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR, 190 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR,
186 12 * sizeof(float), &cube_vertices[ 6]), 191 12 * sizeof(float),
192 &cube_vertices[ 6]),
187 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD, 193 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD,
188 12 * sizeof(float), &cube_vertices[10]), 194 12 * sizeof(float),
195 &cube_vertices[10]),
189 196
190 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT, 197 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
191 36, &cube_indices[0]), 198 36, &cube_indices[0]),
192 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES), 199 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
193
194 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG), 200 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG),
195
196 evas_3d_mesh_frame_material_set(0, data->material)); 201 evas_3d_mesh_frame_material_set(0, data->material));
197 202
198 data->mesh_node = 203 data->mesh_node =
@@ -238,8 +243,12 @@ _stop_scene(void *data,
238 if (ev->button == 1) 243 if (ev->button == 1)
239 { 244 {
240 if (eo_do(d->scene, 245 if (eo_do(d->scene,
241 evas_3d_scene_exist((ev->canvas.x - d_w/2), (ev->canvas.y - d_h/2), d->mesh_node))) 246 evas_3d_scene_exist((ev->canvas.x - (d_w / 2)),
242 d_angle = 0; 247 (ev->canvas.y - (d_h / 2)),
248 d->mesh_node)))
249 {
250 d_angle = 0;
251 }
243 } 252 }
244} 253}
245 254
@@ -258,24 +267,22 @@ _play_scene(void *data,
258} 267}
259 268
260int 269int
261main(void) 270elm_main(int argc, char **argv)
262{ 271{
263 setenv("ELM_ENGINE", "opengl_x11", 1);
264
265 Scene_Data data; 272 Scene_Data data;
266 273
267 if (!elm_init(0,0)) return 0; 274 elm_config_preferred_engine_set("opengl_x11");
268
269 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); 275 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
270 276
271 win = elm_win_util_standard_add("__WIN__", "3d object on the button"); 277 win = elm_win_util_standard_add("__WIN__", "3d object on the button");
278 if (!win) return 0;
279
272 elm_win_autodel_set(win, EINA_TRUE); 280 elm_win_autodel_set(win, EINA_TRUE);
273 evas_object_resize(win, WIDTH, HEIGHT); 281 evas_object_resize(win, WIDTH, HEIGHT);
274 evas_object_show(win); 282 evas_object_show(win);
275 283
276 evas = evas_object_evas_get(win); 284 evas = evas_object_evas_get(win);
277 285 if (!evas) return 0;
278 if ((!win) || (!evas)) return 0;
279 286
280 _scene_setup(&data); 287 _scene_setup(&data);
281 288
@@ -288,13 +295,15 @@ main(void)
288 295
289 /* Setup scene to the widget button. */ 296 /* Setup scene to the widget button. */
290 btn = elm_button_add(win); 297 btn = elm_button_add(win);
291 elm_object_part_content_set(btn, "elm.swallow.content", image); 298 elm_object_content_set(btn, image);
292 evas_object_resize(btn, WIDTH - d_w, HEIGHT - d_h); 299 evas_object_resize(btn, (WIDTH - d_w), (HEIGHT - d_h));
293 evas_object_move(btn, d_w/2, d_h/2); 300 evas_object_move(btn, (d_w / 2), (d_h / 2));
294 evas_object_show(btn); 301 evas_object_show(btn);
295 302
296 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN, _stop_scene, &data); 303 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN, _stop_scene,
297 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _play_scene, &data); 304 &data);
305 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _play_scene,
306 &data);
298 307
299 /* Add animation timer callback. */ 308 /* Add animation timer callback. */
300 ecore_timer_add(0.016, _animate_scene, &data); 309 ecore_timer_add(0.016, _animate_scene, &data);
@@ -306,3 +315,4 @@ main(void)
306 315
307 return 0; 316 return 0;
308} 317}
318ELM_MAIN()