summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-03-16 17:35:25 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-03-16 17:35:25 +0900
commitdcbd9de0851c16aa7b69c44f50a02d95da43846e (patch)
treefb1ec27094d22b351be925d6e9d02a30ba95cb47
parent8bd482203307e6ea66c85261c1399cc4a9b58086 (diff)
pouet
-rw-r--r--CMakeLists.txt2
-rw-r--r--glcube.c30
-rw-r--r--glesgears.c17
-rw-r--r--glview.c27
-rw-r--r--main.c19
-rw-r--r--tests.c13
6 files changed, 77 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d58ee61..a857cfc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,7 +50,7 @@ target_link_libraries(${PROJECT_NAME}
50 ${ECORE_X_LIBRARIES} 50 ${ECORE_X_LIBRARIES}
51 ${ELEMENTARY_LIBRARIES} 51 ${ELEMENTARY_LIBRARIES}
52 ${EO_LIBRARIES} 52 ${EO_LIBRARIES}
53 -lm -lX11 53 -lm -lX11 -ldl
54 ) 54 )
55 55
56add_definitions(-fpie) 56add_definitions(-fpie)
diff --git a/glcube.c b/glcube.c
index d993288..6ad50fe 100644
--- a/glcube.c
+++ b/glcube.c
@@ -407,11 +407,10 @@ draw_gl(AppData *ad, int w, int h, int rotation)
407 else 407 else
408 GL()glDisable(GL_DEPTH_TEST); 408 GL()glDisable(GL_DEPTH_TEST);
409 409
410 if (ad->enable_stencil) 410 if (!ad->enable_stencil)
411 clearbit |= GL_STENCIL_BUFFER_BIT; 411 {
412 else 412 GL()glDisable(GL_STENCIL_TEST); GLERR();
413 GL()glDisable(GL_STENCIL_TEST); 413 }
414 GLERR();
415 414
416 // Enable blending with premultiplied alpha 415 // Enable blending with premultiplied alpha
417 GL()glEnable(GL_BLEND); GLERR(); 416 GL()glEnable(GL_BLEND); GLERR();
@@ -423,9 +422,14 @@ draw_gl(AppData *ad, int w, int h, int rotation)
423 // Draw 1s in the stencil buffer 422 // Draw 1s in the stencil buffer
424 GL()glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); GLERR(); 423 GL()glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); GLERR();
425 GL()glDepthMask(GL_FALSE); GLERR(); 424 GL()glDepthMask(GL_FALSE); GLERR();
426 GL()glStencilMask(0xFF); GLERR(); 425
427 GL()glStencilFunc(GL_NEVER, 1, 0xFF); GLERR(); 426 if (ad->enable_stencil)
428 GL()glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); GLERR(); 427 {
428 GL()glStencilMask(0xFF); GLERR();
429 GL()glStencilFunc(GL_NEVER, 1, 0xFF); GLERR();
430 GL()glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); GLERR();
431 GL()glClear(GL_STENCIL_BUFFER_BIT); GLERR();
432 }
429 433
430 // Draw small rectangle (values will be 1) 434 // Draw small rectangle (values will be 1)
431 GL()glUseProgram(ad->program[1]); GLERR(); 435 GL()glUseProgram(ad->program[1]); GLERR();
@@ -443,16 +447,14 @@ draw_gl(AppData *ad, int w, int h, int rotation)
443 GL()glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); GLERR(); 447 GL()glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); GLERR();
444 if (ad->enable_depth) 448 if (ad->enable_depth)
445 { 449 {
446 GL()glDepthMask(GL_TRUE); 450 GL()glDepthMask(GL_TRUE); GLERR();
447 GLERR();
448 } 451 }
449 GL()glStencilMask(0x00); GLERR();
450 GL()glStencilFunc(GL_EQUAL, 1, 0xFF); GLERR();
451 452
452 if (ad->enable_stencil) 453 if (ad->enable_stencil)
453 { 454 {
454 GL()glEnable(GL_STENCIL_TEST); 455 GL()glStencilMask(0x00); GLERR();
455 GLERR(); 456 GL()glStencilFunc(GL_EQUAL, 1, 0xFF); GLERR();
457 GL()glEnable(GL_STENCIL_TEST); GLERR();
456 } 458 }
457 459
458 //Draw cube 460 //Draw cube
diff --git a/glesgears.c b/glesgears.c
index 3fc0b15..230ae23 100644
--- a/glesgears.c
+++ b/glesgears.c
@@ -13,6 +13,7 @@
13 13
14#include "evasgl_test.h" 14#include "evasgl_test.h"
15 15
16#include <dlfcn.h>
16/* Conversion to use vertex buffer objects by Michael J. Clark */ 17/* Conversion to use vertex buffer objects by Michael J. Clark */
17#ifdef EVAS_GL_GLES1 18#ifdef EVAS_GL_GLES1
18 19
@@ -323,6 +324,21 @@ draw(AppData *ad, int w, int h)
323 324
324 GL()glDisable(GL_MULTISAMPLE); 325 GL()glDisable(GL_MULTISAMPLE);
325 GL()glFlush(); 326 GL()glFlush();
327
328 /*
329 GL()glClearColor(0, 1, 0, 1);
330 GL()glClear(GL_COLOR_BUFFER_BIT);
331 GL()glFinish();
332 unsigned int pix;
333 GL()glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pix);
334 assert(pix == 0xFF00FF00);
335
336 static void *handle = NULL;
337 if (!handle) handle = dlopen("libEGL.so", RTLD_NOW);
338 static void (*func)(int) = NULL;
339 if (!func) func = dlsym(handle, "eglWaitNative");
340 func(0x305B);
341 */
326} 342}
327 343
328void 344void
@@ -347,7 +363,6 @@ init_gles1(AppData *ad)
347 static const GLfloat green[4] = {0.0, 0.8, 0.2, 1.0}; 363 static const GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
348 static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0}; 364 static const GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
349 365
350
351 assert(GL()glLightfv); // GL()glES 1.1 366 assert(GL()glLightfv); // GL()glES 1.1
352 367
353 GL()glLightfv(GL_LIGHT0, GL_POSITION, pos); 368 GL()glLightfv(GL_LIGHT0, GL_POSITION, pos);
diff --git a/glview.c b/glview.c
index 08ad539..5f90a12 100644
--- a/glview.c
+++ b/glview.c
@@ -12,6 +12,7 @@ _init_gl(Evas_Object *obj)
12 AppData *ad = APPDATA_GET(obj); 12 AppData *ad = APPDATA_GET(obj);
13 static Eina_Bool tests_run = EINA_FALSE; 13 static Eina_Bool tests_run = EINA_FALSE;
14 14
15 ELEMENTARY_GLVIEW_GLOBAL_USE(obj);
15 ad->evasgl = elm_glview_evas_gl_get(ad->glview); 16 ad->evasgl = elm_glview_evas_gl_get(ad->glview);
16 init_shaders(ad); 17 init_shaders(ad);
17 init_vertices(ad); 18 init_vertices(ad);
@@ -53,9 +54,12 @@ static void
53_init_gl1(Evas_Object *obj) 54_init_gl1(Evas_Object *obj)
54{ 55{
55 AppData *ad = APPDATA_GET(obj); 56 AppData *ad = APPDATA_GET(obj);
57 ELEMENTARY_GLVIEW_GLOBAL_USE(obj);
56 58
57 ad->evasgl = elm_glview_evas_gl_get(ad->glview); 59 ad->evasgl = elm_glview_evas_gl_get(ad->glview);
58 init_gles1(ad); 60 init_gles1(ad);
61
62 test_extensions(ad);
59} 63}
60 64
61static void 65static void
@@ -312,11 +316,10 @@ void
312glview_init(AppData *ad) 316glview_init(AppData *ad)
313{ 317{
314 Evas_Object *o = ad->glview; 318 Evas_Object *o = ad->glview;
315 Eina_Bool pbuf; 319 Eina_Bool pbuf, ok;
316 if (!o) return; 320 if (!o) return;
317 assert(o); 321 assert(o);
318 322
319 ELEMENTARY_GLVIEW_GLOBAL_USE(o);
320#ifdef EVAS_GL_GLES2_API_CHECK 323#ifdef EVAS_GL_GLES2_API_CHECK
321 if (!EVAS_GL_GLES2_API_CHECK()) 324 if (!EVAS_GL_GLES2_API_CHECK())
322 abort(); 325 abort();
@@ -327,15 +330,19 @@ glview_init(AppData *ad)
327 ad->pbuffer.enabled = pbuf; 330 ad->pbuffer.enabled = pbuf;
328 331
329 ad->evasgl = elm_glview_evas_gl_get(o); 332 ad->evasgl = elm_glview_evas_gl_get(o);
330 elm_glview_mode_set(o, 333 ok = elm_glview_mode_set(o, 0
331 ELM_GLVIEW_ALPHA | 334 | ELM_GLVIEW_ALPHA
332 ELM_GLVIEW_DEPTH | 335 | ELM_GLVIEW_DEPTH_32
333 ELM_GLVIEW_STENCIL | 336 | ELM_GLVIEW_STENCIL_16
334 (ad->direct ? ELM_GLVIEW_DIRECT : 0) | 337 | (ad->direct ? ELM_GLVIEW_DIRECT : 0)
335 (ad->client_side ? ELM_GLVIEW_CLIENT_SIDE_ROTATION : 0) | 338 | (ad->client_side ? ELM_GLVIEW_CLIENT_SIDE_ROTATION : 0)
336 //ELM_GLVIEW_MULTISAMPLE_HIGH 339 | ELM_GLVIEW_MULTISAMPLE_MED
337 0
338 ); 340 );
341 if (!ok)
342 {
343 printf("FAILED TO SET UP GLVIEW\n");
344 return;
345 }
339 elm_glview_resize_policy_set(o, ELM_GLVIEW_RESIZE_POLICY_RECREATE); 346 elm_glview_resize_policy_set(o, ELM_GLVIEW_RESIZE_POLICY_RECREATE);
340 elm_glview_render_policy_set(o, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); 347 elm_glview_render_policy_set(o, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);
341 348
diff --git a/main.c b/main.c
index 62e6b74..24ecb44 100644
--- a/main.c
+++ b/main.c
@@ -45,6 +45,8 @@ _glview_create(AppData *ad)
45 } 45 }
46#endif 46#endif
47 elm_table_pack(ad->pd->table, o, 1, 1, 3, 1); 47 elm_table_pack(ad->pd->table, o, 1, 1, 3, 1);
48 evas_object_size_hint_min_set(o, 256, 256);
49 evas_object_size_hint_max_set(o, 256, 256);
48 SX(o); 50 SX(o);
49 51
50 evas_object_data_set(o, APPDATA_KEY, ad); 52 evas_object_data_set(o, APPDATA_KEY, ad);
@@ -79,6 +81,9 @@ _transparent_check_cb(void *data, Evas_Object *obj,
79{ 81{
80 AppData *ad = data; 82 AppData *ad = data;
81 ad->transparent = elm_check_state_get(obj); 83 ad->transparent = elm_check_state_get(obj);
84
85//#warning HACK
86 //elm_win_alpha_set(ad->pd->win, ad->transparent);
82} 87}
83 88
84static void 89static void
@@ -216,6 +221,9 @@ _anim_cb(void *data)
216 221
217 ad->xangle += 1.5; 222 ad->xangle += 1.5;
218 ad->yangle += 1.0; 223 ad->yangle += 1.0;
224#if 0
225 if (rand() % 3 == 0)
226#endif
219 elm_glview_changed_set(ad->glview); 227 elm_glview_changed_set(ad->glview);
220 return ECORE_CALLBACK_RENEW; 228 return ECORE_CALLBACK_RENEW;
221} 229}
@@ -307,7 +315,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
307 315
308 // Force OpenGL engine 316 // Force OpenGL engine
309 //elm_config_engine_set("opengl_x11"); 317 //elm_config_engine_set("opengl_x11");
310 elm_config_accel_preference_set("hw"); 318 elm_config_accel_preference_set("hw:depth:stencil");
311 elm_config_accel_preference_override_set(EINA_TRUE); 319 elm_config_accel_preference_override_set(EINA_TRUE);
312 320
313 ad = calloc(1, sizeof(*ad)); 321 ad = calloc(1, sizeof(*ad));
@@ -473,6 +481,15 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
473 SF(o); 481 SF(o);
474 } 482 }
475 483
484#if 0
485 /* hack */
486 o = elm_video_add(ad->pd->win);
487 elm_video_file_set(o, "/home/jpeg/dwhelper/fire.mp4");
488 elm_table_pack(t, o, 1, 1, 3, 1);
489 elm_video_play(o);
490 SF(o);
491#endif
492
476 _glview_create(ad); 493 _glview_create(ad);
477 //ecore_animator_frametime_set(1.0 / 60.0); 494 //ecore_animator_frametime_set(1.0 / 60.0);
478 ad->pd->anim = ecore_animator_add(_anim_cb, ad); 495 ad->pd->anim = ecore_animator_add(_anim_cb, ad);
diff --git a/tests.c b/tests.c
index aa50a77..22b9495 100644
--- a/tests.c
+++ b/tests.c
@@ -4,17 +4,21 @@
4void 4void
5test_extensions(AppData *ad) 5test_extensions(AppData *ad)
6{ 6{
7 const char *extensions; 7 const char *extensions, *version;
8 void (*func)() = NULL; 8 void (*func)() = NULL;
9 void (*func2)() = NULL; 9 void (*func2)() = NULL;
10 10
11 assert(ad); 11 assert(ad);
12 assert(ad->glview); 12 assert(ad->glview);
13 13
14 return; 14 //return;
15 15
16 extensions = evas_gl_string_query(ad->evasgl, EVAS_GL_EXTENSIONS); 16 // FIXME: this is bad
17 //extensions = evas_gl_string_query(ad->evasgl, EVAS_GL_EXTENSIONS);
18 version = GL()glGetString(GL_VERSION);
19 extensions = GL()glGetString(GL_EXTENSIONS);
17 assert(extensions && *extensions); 20 assert(extensions && *extensions);
21 fprintf(stdout, "glGetString(GL_VERSION) returns: %s\n", version);
18 fprintf(stdout, "Extensions advertised by Evas GL:\n%s\n", extensions); 22 fprintf(stdout, "Extensions advertised by Evas GL:\n%s\n", extensions);
19 23
20 if (strstr(extensions, "GL_NV_fence")) 24 if (strstr(extensions, "GL_NV_fence"))
@@ -37,7 +41,8 @@ test_extensions(AppData *ad)
37 assert(func || func2); 41 assert(func || func2);
38 42
39 func = evas_gl_proc_address_get(ad->evasgl, "glDebugMessageControlBLAH"); 43 func = evas_gl_proc_address_get(ad->evasgl, "glDebugMessageControlBLAH");
40 assert(!func); 44 //assert(!func);
45 if (func) fprintf(stdout, "FAILED: evas_gl_proc_address_get() returned an address to an invalid function!\n");
41 } 46 }
42 47
43 if (strstr(extensions, "get_program_binary")) 48 if (strstr(extensions, "get_program_binary"))