summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/evas/Evas_Eo.h4
-rw-r--r--src/lib/evas/include/evas_private.h10
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d.c166
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_common.h3
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_private.h6
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_3d_shader.c15
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c33
7 files changed, 216 insertions, 21 deletions
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h
index 39c568ba4a..8fa89b30ba 100644
--- a/src/lib/evas/Evas_Eo.h
+++ b/src/lib/evas/Evas_Eo.h
@@ -487,6 +487,7 @@ typedef enum _Evas_3D_State
487 EVAS_3D_STATE_MESH_SHADE_MODE, 487 EVAS_3D_STATE_MESH_SHADE_MODE,
488 EVAS_3D_STATE_MESH_FOG, 488 EVAS_3D_STATE_MESH_FOG,
489 EVAS_3D_STATE_MESH_BLENDING, 489 EVAS_3D_STATE_MESH_BLENDING,
490 EVAS_3D_STATE_MESH_COLOR_PICK,
490 491
491 EVAS_3D_STATE_CAMERA_PROJECTION = 1, 492 EVAS_3D_STATE_CAMERA_PROJECTION = 1,
492 493
@@ -777,7 +778,8 @@ typedef enum _Evas_3D_Shade_Mode
777 EVAS_3D_SHADE_MODE_NORMAL_MAP, 778 EVAS_3D_SHADE_MODE_NORMAL_MAP,
778 /**< fragment color is defined by its z-coord*/ 779 /**< fragment color is defined by its z-coord*/
779 EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER, 780 EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER,
780 781 /**< rendering to additional frame bufer*/
782 EVAS_3D_SHADE_MODE_COLOR_PICK,
781} Evas_3D_Shade_Mode; 783} Evas_3D_Shade_Mode;
782 784
783/** 785/**
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 673b6aab77..e0f8171e26 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -340,6 +340,9 @@ struct _Evas_3D_Mesh
340 340
341 Evas_Color fog_color; 341 Evas_Color fog_color;
342 Eina_Bool fog_enabled :1; 342 Eina_Bool fog_enabled :1;
343
344 double color_pick_key;
345 Eina_Bool color_pick_enabled :1;
343}; 346};
344 347
345struct _Evas_3D_Texture 348struct _Evas_3D_Texture
@@ -376,6 +379,9 @@ struct _Evas_3D_Scene_Public_Data
376 Eina_List *light_nodes; 379 Eina_List *light_nodes;
377 Eina_List *mesh_nodes; 380 Eina_List *mesh_nodes;
378 Eina_Bool shadows_enabled :1; 381 Eina_Bool shadows_enabled :1;
382 Eina_Bool color_pick_enabled :1;
383 Eina_Hash *node_mesh_colors;
384 Eina_Hash *colors_node_mesh;
379}; 385};
380 386
381struct _Evas_3D_Pick_Data 387struct _Evas_3D_Pick_Data
@@ -1319,6 +1325,10 @@ struct _Evas_Func
1319 void *(*image_drawable_set) (void *data, void *image, void *drawable); 1325 void *(*image_drawable_set) (void *data, void *image, void *drawable);
1320 1326
1321 void (*drawable_scene_render) (void *data, void *drawable, void *scene_data); 1327 void (*drawable_scene_render) (void *data, void *drawable, void *scene_data);
1328 Eina_Bool (*drawable_scene_render_to_texture) (void *data, void *drawable, void *scene_data);
1329
1330 int (*drawable_texture_color_pick_id_get) (void *drawable);
1331 double (*drawable_texture_pixel_color_get) (unsigned int tex EINA_UNUSED, int x, int y, void *drawable);
1322 1332
1323 void *(*texture_new) (void *data); 1333 void *(*texture_new) (void *data);
1324 void (*texture_free) (void *data, void *texture); 1334 void (*texture_free) (void *data, void *texture);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d.c b/src/modules/evas/engines/gl_common/evas_gl_3d.c
index 4f045d29e7..ee464f4d34 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_3d.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c
@@ -1,6 +1,23 @@
1#include "evas_gl_private.h" 1#include "evas_gl_private.h"
2#include "evas_gl_3d_private.h" 2#include "evas_gl_3d_private.h"
3 3
4#define RENDER_MESH_NODE_ITERATE_BEGIN(param) \
5 Evas_Mat4 matrix_mv; \
6 Evas_Mat4 matrix_mvp; \
7 Eina_Iterator *it; \
8 void *ptr; \
9 evas_mat4_multiply(&matrix_mv, matrix_##param, &pd_mesh_node->data.mesh.matrix_local_to_world); \
10 evas_mat4_multiply(&matrix_mvp, &pd->projection, &matrix_mv); \
11 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes); \
12 while (eina_iterator_next(it, &ptr)) \
13 { \
14 Evas_3D_Node_Mesh *nm = (Evas_3D_Node_Mesh *)ptr; \
15 Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_3D_MESH_CLASS);
16
17#define RENDER_MESH_NODE_ITERATE_END \
18 } \
19 eina_iterator_free(it);
20
4void 21void
5e3d_texture_param_update(E3D_Texture *texture) 22e3d_texture_param_update(E3D_Texture *texture)
6{ 23{
@@ -407,7 +424,7 @@ E3D_Drawable *
407e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_format) 424e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_format)
408{ 425{
409 E3D_Drawable *drawable = NULL; 426 E3D_Drawable *drawable = NULL;
410 GLuint tex, fbo, texDepth; 427 GLuint tex, fbo, texDepth, texcolorpick, color_pick_fb_id;
411 GLuint depth_stencil_buf = 0; 428 GLuint depth_stencil_buf = 0;
412 GLuint depth_buf = 0; 429 GLuint depth_buf = 0;
413 GLuint stencil_buf = 0; 430 GLuint stencil_buf = 0;
@@ -435,6 +452,18 @@ e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_fo
435 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, w, h, 0, GL_RED, GL_UNSIGNED_SHORT, 0); 452 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, w, h, 0, GL_RED, GL_UNSIGNED_SHORT, 0);
436#endif 453#endif
437 454
455 glGenTextures(1, &texcolorpick);
456 glBindTexture(GL_TEXTURE_2D, texcolorpick);
457 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
458 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
459 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
460 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
461#ifndef GL_GLES
462 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, w, h, 0, GL_RED, GL_UNSIGNED_SHORT, 0);
463#endif
464
465 glGenFramebuffers(1, &color_pick_fb_id);
466
438 glGenFramebuffers(1, &fbo); 467 glGenFramebuffers(1, &fbo);
439 glBindFramebuffer(GL_FRAMEBUFFER, fbo); 468 glBindFramebuffer(GL_FRAMEBUFFER, fbo);
440 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0); 469 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
@@ -511,6 +540,8 @@ e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_fo
511 drawable->tex = tex; 540 drawable->tex = tex;
512 drawable->fbo = fbo; 541 drawable->fbo = fbo;
513 drawable->depth_stencil_buf = depth_stencil_buf; 542 drawable->depth_stencil_buf = depth_stencil_buf;
543 drawable->texcolorpick = texcolorpick;
544 drawable->color_pick_fb_id = color_pick_fb_id;
514 drawable->depth_buf = depth_buf; 545 drawable->depth_buf = depth_buf;
515 drawable->stencil_buf = stencil_buf; 546 drawable->stencil_buf = stencil_buf;
516 drawable->texDepth = texDepth; 547 drawable->texDepth = texDepth;
@@ -522,9 +553,13 @@ error:
522 553
523 if (tex) 554 if (tex)
524 glDeleteTextures(1, &tex); 555 glDeleteTextures(1, &tex);
556 if (texcolorpick)
557 glDeleteTextures(1, &texcolorpick);
525 558
526 if (fbo) 559 if (fbo)
527 glDeleteFramebuffers(1, &fbo); 560 glDeleteFramebuffers(1, &fbo);
561 if (color_pick_fb_id)
562 glDeleteFramebuffers(1, &color_pick_fb_id);
528 563
529 if (depth_stencil_buf) 564 if (depth_stencil_buf)
530 { 565 {
@@ -595,6 +630,12 @@ e3d_drawable_texture_id_get(E3D_Drawable *drawable)
595 return drawable->tex; 630 return drawable->tex;
596} 631}
597 632
633GLuint
634e3d_drawable_texture_color_pick_id_get(E3D_Drawable *drawable)
635{
636 return drawable->texcolorpick;
637}
638
598GLenum 639GLenum
599e3d_drawable_format_get(E3D_Drawable *drawable) 640e3d_drawable_format_get(E3D_Drawable *drawable)
600{ 641{
@@ -1105,6 +1146,12 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
1105 if (pdmesh->shadowed) 1146 if (pdmesh->shadowed)
1106 data->flags |= E3D_SHADER_FLAG_SHADOWED; 1147 data->flags |= E3D_SHADER_FLAG_SHADOWED;
1107 1148
1149 if (pdmesh->color_pick_enabled)
1150 {
1151 data->flags |= E3D_SHADER_FLAG_COLOR_PICK_ENABLED;
1152 data->color_pick_key = pdmesh->color_pick_key;
1153 }
1154
1108 data->blending = pdmesh->blending; 1155 data->blending = pdmesh->blending;
1109 data->blend_sfactor = pdmesh->blend_sfactor; 1156 data->blend_sfactor = pdmesh->blend_sfactor;
1110 data->blend_dfactor = pdmesh->blend_dfactor; 1157 data->blend_dfactor = pdmesh->blend_dfactor;
@@ -1141,6 +1188,10 @@ _mesh_draw_data_build(E3D_Draw_Data *data,
1141 { 1188 {
1142 BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); 1189 BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
1143 } 1190 }
1191 else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_COLOR_PICK)
1192 {
1193 BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
1194 }
1144 else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_DIFFUSE) 1195 else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_DIFFUSE)
1145 { 1196 {
1146 BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); 1197 BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE);
@@ -1256,32 +1307,18 @@ void _shadowmap_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_S
1256 1307
1257 EINA_LIST_FOREACH(data->mesh_nodes, l, n) 1308 EINA_LIST_FOREACH(data->mesh_nodes, l, n)
1258 { 1309 {
1259 Evas_Mat4 matrix_mv;
1260 Evas_Mat4 matrix_mvp;
1261 Eina_Iterator *it;
1262 void *ptr;
1263
1264 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS); 1310 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS);
1265 1311
1266 if (evas_is_sphere_in_frustum(&pd_mesh_node->bsphere, planes)) 1312 if (evas_is_sphere_in_frustum(&pd_mesh_node->bsphere, planes))
1267 { 1313 {
1268 1314 RENDER_MESH_NODE_ITERATE_BEGIN(light_eye)
1269 evas_mat4_multiply(&matrix_mv, matrix_light_eye, &pd_mesh_node->data.mesh.matrix_local_to_world);
1270 evas_mat4_multiply(&matrix_mvp, &pd->projection,
1271 &matrix_mv);
1272
1273 it = eina_hash_iterator_data_new(pd_mesh_node->data.mesh.node_meshes);
1274
1275 while (eina_iterator_next(it, &ptr))
1276 { 1315 {
1277 Evas_3D_Node_Mesh *nm = (Evas_3D_Node_Mesh *)ptr;
1278 Evas_3D_Mesh_Data *pdmesh = eo_data_scope_get(nm->mesh, EVAS_3D_MESH_CLASS);
1279 shade_mode = pdmesh->shade_mode; 1316 shade_mode = pdmesh->shade_mode;
1280 pdmesh->shade_mode = EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER; 1317 pdmesh->shade_mode = EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER;
1281 _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_light_eye, &matrix_mv, &matrix_mvp, &matrix_mvp); 1318 _mesh_draw(renderer, nm->mesh, nm->frame, light, matrix_light_eye, &matrix_mv, &matrix_mvp, &matrix_mvp);
1282 pdmesh->shade_mode = shade_mode; 1319 pdmesh->shade_mode = shade_mode;
1283 } 1320 }
1284 eina_iterator_free(it); 1321 RENDER_MESH_NODE_ITERATE_END
1285 } 1322 }
1286 } 1323 }
1287 1324
@@ -1367,3 +1404,98 @@ e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3
1367 } 1404 }
1368 e3d_renderer_flush(renderer); 1405 e3d_renderer_flush(renderer);
1369} 1406}
1407
1408Eina_Bool
1409e3d_drawable_scene_render_to_texture(E3D_Drawable *drawable, E3D_Renderer *renderer,
1410 Evas_3D_Scene_Public_Data *data)
1411{
1412 const Evas_Mat4 *matrix_eye;
1413 Evas_3D_Shade_Mode shade_mode;
1414 Eina_Stringshare *tmp;
1415 Eina_Iterator *itmn;
1416 void *ptrmn;
1417 Eina_List *repeat_node = NULL;
1418 Evas_Color c = {0, 0, 0}, *unic_color = NULL;
1419
1420 glBindFramebuffer(GL_FRAMEBUFFER, drawable->color_pick_fb_id);
1421 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
1422 GL_TEXTURE_2D, drawable->texcolorpick, 0);
1423#ifdef GL_GLES
1424 glBindTexture(GL_TEXTURE_2D, drawable->depth_stencil_buf);
1425 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
1426 GL_TEXTURE_2D, drawable->depth_stencil_buf, 0);
1427#else
1428 glBindRenderbuffer(GL_RENDERBUFFER, drawable->depth_stencil_buf);
1429 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
1430 GL_RENDERBUFFER, drawable->depth_stencil_buf);
1431#endif
1432
1433 e3d_renderer_clear(renderer, &c);
1434
1435 Evas_3D_Node_Data *pd_camera_node = eo_data_scope_get(data->camera_node, EVAS_3D_NODE_CLASS);
1436 matrix_eye = &pd_camera_node->data.camera.matrix_world_to_eye;
1437 Evas_3D_Camera_Data *pd = eo_data_scope_get(pd_camera_node->data.camera.camera, EVAS_3D_CAMERA_CLASS);
1438
1439 itmn = eina_hash_iterator_data_new(data->colors_node_mesh);
1440
1441 while (eina_iterator_next(itmn, &ptrmn))
1442 {
1443 Evas_3D_Node *n;
1444 Eina_Array *arr = NULL;
1445
1446 arr = (Eina_Array *)ptrmn;
1447 n = (Evas_3D_Node *)eina_array_data_get(arr, 0);
1448 /*To avoid repeatedly render mesh*/
1449 if (!repeat_node)
1450 repeat_node = eina_list_append(repeat_node, (void*)n);
1451 else
1452 {
1453 if (eina_list_data_find(repeat_node, (void *)n))
1454 continue;
1455 else
1456 repeat_node = eina_list_append(repeat_node, (void *)n);
1457 }
1458 Evas_3D_Node_Data *pd_mesh_node = eo_data_scope_get(n, EVAS_3D_NODE_CLASS);
1459 RENDER_MESH_NODE_ITERATE_BEGIN(eye)
1460 {
1461 if (pdmesh->color_pick_enabled)
1462 {
1463 tmp = eina_stringshare_printf("%p %p", n, nm->mesh);
1464 unic_color = (Evas_Color *)eina_hash_find(data->node_mesh_colors, tmp);
1465 if (unic_color)
1466 {
1467 pdmesh->color_pick_key = unic_color->r;
1468 shade_mode = pdmesh->shade_mode;
1469 pdmesh->shade_mode = EVAS_3D_SHADE_MODE_COLOR_PICK;
1470 _mesh_draw(renderer, nm->mesh, nm->frame, NULL, matrix_eye, &matrix_mv,
1471 &matrix_mvp, NULL);
1472 pdmesh->shade_mode = shade_mode;
1473 }
1474 eina_stringshare_del(tmp);
1475 }
1476 }
1477 RENDER_MESH_NODE_ITERATE_END
1478 }
1479
1480 eina_iterator_free(itmn);
1481 eina_list_free(repeat_node);
1482 glBindFramebuffer(GL_FRAMEBUFFER, drawable->fbo);
1483 return EINA_TRUE;
1484}
1485
1486double
1487e3d_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y,
1488 void *drawable)
1489{
1490 E3D_Drawable *d = (E3D_Drawable *)drawable;
1491 GLuint pixel;
1492
1493 glBindFramebuffer(GL_FRAMEBUFFER, d->color_pick_fb_id);
1494 /*TODO Bottle neck - get more effective getting pixels from openGL*/
1495 glReadPixels(x, y, 1, 1, GL_RED, GL_UNSIGNED_SHORT, &pixel);
1496 glBindFramebuffer(GL_FRAMEBUFFER, d->fbo);
1497 return (double)pixel / USHRT_MAX;
1498}
1499
1500#undef RENDER_MESH_NODE_ITERATE_BEGIN
1501#undef RENDER_MESH_NODE_ITERATE_END
diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_common.h b/src/modules/evas/engines/gl_common/evas_gl_3d_common.h
index ceba63e5f0..f119b40c46 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_3d_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_3d_common.h
@@ -28,8 +28,11 @@ void e3d_texture_filter_get(const E3D_Texture *texture, Evas_3D_
28E3D_Drawable *e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_format); 28E3D_Drawable *e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_format);
29void e3d_drawable_free(E3D_Drawable *drawable); 29void e3d_drawable_free(E3D_Drawable *drawable);
30void e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data); 30void e3d_drawable_scene_render(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data);
31Eina_Bool e3d_drawable_scene_render_to_texture(E3D_Drawable *drawable, E3D_Renderer *renderer, Evas_3D_Scene_Public_Data *data);
31void e3d_drawable_size_get(E3D_Drawable *drawable, int *w, int *h); 32void e3d_drawable_size_get(E3D_Drawable *drawable, int *w, int *h);
32GLuint e3d_drawable_texture_id_get(E3D_Drawable *drawable); 33GLuint e3d_drawable_texture_id_get(E3D_Drawable *drawable);
34GLuint e3d_drawable_texture_color_pick_id_get(E3D_Drawable *drawable);
35double e3d_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y, void *drawable);
33GLenum e3d_drawable_format_get(E3D_Drawable *drawable); 36GLenum e3d_drawable_format_get(E3D_Drawable *drawable);
34 37
35/* Renderer */ 38/* Renderer */
diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_private.h b/src/modules/evas/engines/gl_common/evas_gl_3d_private.h
index 75a76acb31..6d956f554d 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_3d_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_3d_private.h
@@ -37,7 +37,7 @@ typedef unsigned long E3D_Shader_Flag;
37#define E3D_SHADER_FLAG_NORMAL_TEXTURE_BLEND (1 << 28) 37#define E3D_SHADER_FLAG_NORMAL_TEXTURE_BLEND (1 << 28)
38#define E3D_SHADER_FLAG_FOG_ENABLED (1 << 29) 38#define E3D_SHADER_FLAG_FOG_ENABLED (1 << 29)
39#define E3D_SHADER_FLAG_SHADOWED (1 << 30) 39#define E3D_SHADER_FLAG_SHADOWED (1 << 30)
40 40#define E3D_SHADER_FLAG_COLOR_PICK_ENABLED (1 << 31)
41 41
42static inline Eina_Bool 42static inline Eina_Bool
43_flags_need_tex_coord(E3D_Shader_Flag flags) 43_flags_need_tex_coord(E3D_Shader_Flag flags)
@@ -100,6 +100,7 @@ struct _E3D_Draw_Data
100 Evas_Color specular; 100 Evas_Color specular;
101 } light; 101 } light;
102 Evas_Color fog_color; 102 Evas_Color fog_color;
103 double color_pick_key;
103}; 104};
104 105
105struct _E3D_Texture 106struct _E3D_Texture
@@ -126,13 +127,14 @@ struct _E3D_Drawable
126 GLenum format; 127 GLenum format;
127 GLenum depth_format; 128 GLenum depth_format;
128 GLenum stencil_format; 129 GLenum stencil_format;
129
130 GLuint tex; 130 GLuint tex;
131 GLuint fbo; 131 GLuint fbo;
132 GLuint depth_stencil_buf; 132 GLuint depth_stencil_buf;
133 GLuint depth_buf; 133 GLuint depth_buf;
134 GLuint stencil_buf; 134 GLuint stencil_buf;
135 GLuint texDepth; 135 GLuint texDepth;
136 GLuint texcolorpick;
137 GLuint color_pick_fb_id;
136}; 138};
137 139
138/* Texture internal functions. */ 140/* Texture internal functions. */
diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c b/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c
index c036aa1840..e042c83b83 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c
@@ -49,6 +49,7 @@ typedef enum _E3D_Uniform
49 E3D_UNIFORM_MATERIAL_SHININESS, 49 E3D_UNIFORM_MATERIAL_SHININESS,
50 E3D_UNIFORM_FOG_FACTOR, 50 E3D_UNIFORM_FOG_FACTOR,
51 E3D_UNIFORM_FOG_COLOR, 51 E3D_UNIFORM_FOG_COLOR,
52 E3D_UNIFORM_COLOR_PICK,
52 53
53 E3D_UNIFORM_COUNT, 54 E3D_UNIFORM_COUNT,
54} E3D_Uniform; 55} E3D_Uniform;
@@ -526,6 +527,9 @@ _fragment_shader_string_variable_add(E3D_Shader_String *shader,
526 ADD_LINE("uniform sampler2D uShadowMap;"); 527 ADD_LINE("uniform sampler2D uShadowMap;");
527 } 528 }
528 529
530 if (flags & E3D_SHADER_FLAG_COLOR_PICK_ENABLED)
531 ADD_LINE("uniform float uColorPick;");
532
529 /* Materials. */ 533 /* Materials. */
530 if (flags & E3D_SHADER_FLAG_DIFFUSE) 534 if (flags & E3D_SHADER_FLAG_DIFFUSE)
531 { 535 {
@@ -1151,6 +1155,11 @@ _fragment_shader_string_get(E3D_Shader_String *shader,
1151 ADD_LINE("gl_FragColor = mix(uFogColor, gl_FragColor, fogFactor );"); 1155 ADD_LINE("gl_FragColor = mix(uFogColor, gl_FragColor, fogFactor );");
1152 } 1156 }
1153 1157
1158 if (mode == EVAS_3D_SHADE_MODE_COLOR_PICK)
1159 {
1160 ADD_LINE("gl_FragColor = vec4(uColorPick);");
1161 }
1162
1154 ADD_LINE("}"); 1163 ADD_LINE("}");
1155} 1164}
1156 1165
@@ -1321,7 +1330,8 @@ static const char *uniform_names[] =
1321 "uMaterialEmission", 1330 "uMaterialEmission",
1322 "uMaterialShininess", 1331 "uMaterialShininess",
1323 "uFogFactor", 1332 "uFogFactor",
1324 "uFogColor" 1333 "uFogColor",
1334 "uColorPick"
1325}; 1335};
1326 1336
1327static inline void 1337static inline void
@@ -1498,6 +1508,9 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data)
1498 case E3D_UNIFORM_FOG_COLOR: 1508 case E3D_UNIFORM_FOG_COLOR:
1499 glUniform4f(loc, data->fog_color.r, data->fog_color.g, data->fog_color.b, 1); 1509 glUniform4f(loc, data->fog_color.r, data->fog_color.g, data->fog_color.b, 1);
1500 break; 1510 break;
1511 case E3D_UNIFORM_COLOR_PICK:
1512 glUniform1f(loc, data->color_pick_key);
1513 break;
1501 default: 1514 default:
1502 ERR("Invalid uniform ID."); 1515 ERR("Invalid uniform ID.");
1503 break; 1516 break;
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index e280fddf91..082ac0d921 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1836,6 +1836,35 @@ eng_drawable_scene_render(void *data, void *drawable, void *scene_data)
1836 e3d_drawable_scene_render(drawable, renderer, scene_data); 1836 e3d_drawable_scene_render(drawable, renderer, scene_data);
1837} 1837}
1838 1838
1839static int
1840eng_drawable_texture_color_pick_id_get(void *drawable)
1841{
1842 return e3d_drawable_texture_color_pick_id_get((E3D_Drawable *)drawable);
1843}
1844
1845static double
1846eng_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y, void *drawable)
1847{
1848 return e3d_drawable_texture_pixel_color_get(tex, x, y, drawable);
1849}
1850
1851static Eina_Bool
1852eng_drawable_scene_render_to_texture(void *data, void *drawable, void *scene_data)
1853{
1854 Evas_Engine_GL_Context *gl_context;
1855 Render_Engine_GL_Generic *re = data;
1856 E3D_Renderer *renderer = NULL;
1857
1858 re->window_use(re->software.ob);
1859 gl_context = re->window_gl_context_get(re->software.ob);
1860 evas_gl_common_context_flush(gl_context);
1861
1862 eng_context_3d_use(data);
1863 renderer = eng_renderer_3d_get(data);
1864
1865 return e3d_drawable_scene_render_to_texture((E3D_Drawable *)drawable, renderer, scene_data);
1866}
1867
1839static void * 1868static void *
1840eng_texture_new(void *data EINA_UNUSED) 1869eng_texture_new(void *data EINA_UNUSED)
1841{ 1870{
@@ -2045,6 +2074,10 @@ module_open(Evas_Module *em)
2045 2074
2046 ORD(drawable_scene_render); 2075 ORD(drawable_scene_render);
2047 2076
2077 ORD(drawable_texture_color_pick_id_get);
2078 ORD(drawable_texture_pixel_color_get);
2079 ORD(drawable_scene_render_to_texture);
2080
2048 ORD(texture_new); 2081 ORD(texture_new);
2049 ORD(texture_free); 2082 ORD(texture_free);
2050 ORD(texture_data_set); 2083 ORD(texture_data_set);