summaryrefslogtreecommitdiff
path: root/src/examples
diff options
context:
space:
mode:
authorBogdan Devichev <b.devichev@samsung.com>2015-03-18 14:48:50 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-03-18 15:22:21 +0100
commit4c0f37b93ce143d90d4557680c5c50a331217d0a (patch)
treea162831c128bc3e29d9a7cc5afa4b9da7afdc433 /src/examples
parentdb7d448ca277d6df02881db4b4d22ea382206862 (diff)
evas: Evas_3d proxy example uses cube primitives.
Reviewers: Hermet, raster, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2172 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/evas/evas-3d-proxy.c83
1 files changed, 4 insertions, 79 deletions
diff --git a/src/examples/evas/evas-3d-proxy.c b/src/examples/evas/evas-3d-proxy.c
index c6375e7..7fbe8e3 100644
--- a/src/examples/evas/evas-3d-proxy.c
+++ b/src/examples/evas/evas-3d-proxy.c
@@ -4,7 +4,7 @@
4 * Data which will be used as texture can be generated directly in application. 4 * Data which will be used as texture can be generated directly in application.
5 * 5 *
6 * @verbatim 6 * @verbatim
7 * gcc -o evas-3d-proxy evas-3d-proxy.c `pkg-config --libs --cflags evas ecore ecore-evas eo` 7 * gcc -o evas-3d-proxy evas-3d-proxy.c evas-3d-primitives.c `pkg-config --libs --cflags evas ecore ecore-evas eo` -lm
8 * @endverbatim 8 * @endverbatim
9 */ 9 */
10 10
@@ -15,6 +15,7 @@
15#include <Ecore.h> 15#include <Ecore.h>
16#include <Ecore_Evas.h> 16#include <Ecore_Evas.h>
17#include <Evas.h> 17#include <Evas.h>
18#include "evas-3d-primitives.h"
18 19
19#define WIDTH 400 20#define WIDTH 400
20#define HEIGHT 400 21#define HEIGHT 400
@@ -43,66 +44,6 @@ static Eo *background = NULL;
43static Eo *image = NULL; 44static Eo *image = NULL;
44static Eo *source = NULL; 45static Eo *source = NULL;
45 46
46static const float cube_vertices[] =
47{
48 /*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1.0, 0.0,
71
72 /* Top */
73 -1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0,
74 1.0, 1.0, -1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0,
75 -1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0,
76 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0,
77
78 /* Bottom */
79 1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0,
80 -1.0, -1.0, -1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0,
81 1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0,
82 -1.0, -1.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0,
83};
84
85static const unsigned short cube_indices[] =
86{
87 /* Front */
88 0, 1, 2, 2, 1, 3,
89
90 /* Back */
91 4, 5, 6, 6, 5, 7,
92
93 /* Left */
94 8, 9, 10, 10, 9, 11,
95
96 /* Right */
97 12, 13, 14, 14, 13, 15,
98
99 /* Top */
100 16, 17, 18, 18, 17, 19,
101
102 /* Bottom */
103 20, 21, 22, 22, 21, 23
104};
105
106static void 47static void
107_on_delete(Ecore_Evas *ee EINA_UNUSED) 48_on_delete(Ecore_Evas *ee EINA_UNUSED)
108{ 49{
@@ -168,7 +109,7 @@ _camera_setup(Scene_Data *data)
168 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA)); 109 evas_3d_node_constructor(EVAS_3D_NODE_TYPE_CAMERA));
169 eo_do(data->camera_node, 110 eo_do(data->camera_node,
170 evas_3d_node_camera_set(data->camera), 111 evas_3d_node_camera_set(data->camera),
171 evas_3d_node_position_set(0.0, 0.0, 10.0), 112 evas_3d_node_position_set(0.0, 0.0, 5.0),
172 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0, 113 evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 0.0,
173 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0)); 114 EVAS_3D_SPACE_PARENT, 0.0, 1.0, 0.0));
174 eo_do(data->root_node, 115 eo_do(data->root_node,
@@ -220,25 +161,9 @@ _mesh_setup(Scene_Data *data)
220 161
221 /* Setup mesh. */ 162 /* Setup mesh. */
222 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas); 163 data->mesh = eo_add(EVAS_3D_MESH_CLASS, evas);
164 evas_3d_add_cube_frame(data->mesh, 0);
223 eo_do(data->mesh, 165 eo_do(data->mesh,
224 evas_3d_mesh_vertex_count_set(24),
225 evas_3d_mesh_frame_add(0),
226
227 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_POSITION,
228 12 * sizeof(float), &cube_vertices[ 0]),
229 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_NORMAL,
230 12 * sizeof(float), &cube_vertices[ 3]),
231 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_COLOR,
232 12 * sizeof(float), &cube_vertices[ 6]),
233 evas_3d_mesh_frame_vertex_data_set(0, EVAS_3D_VERTEX_TEXCOORD,
234 12 * sizeof(float), &cube_vertices[10]),
235
236 evas_3d_mesh_index_data_set(EVAS_3D_INDEX_FORMAT_UNSIGNED_SHORT,
237 36, &cube_indices[0]),
238 evas_3d_mesh_vertex_assembly_set(EVAS_3D_VERTEX_ASSEMBLY_TRIANGLES),
239
240 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_FLAT), 166 evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_FLAT),
241
242 evas_3d_mesh_frame_material_set(0, data->material)); 167 evas_3d_mesh_frame_material_set(0, data->material));
243 168
244 data->mesh_node = 169 data->mesh_node =