Languages

Menu
Sites
Language
Is difference beetwin launching OpenGL app on emulator and on real device?

I've created app with using OpenGL lib, and it works good on emulator. But when I sent it on galaxy store to certification - evasGL not shows, only blue screen(Evas rectangle under  evasGL).

What could be the problem?

#GearS2UAInside

 

Responses

4 Replies
daniel kim

Hi,

 I think that some code snippet or more details will be helpful to see what was happened in your application. and I would suggest you to check your tpk using real devices in remote test lab

      http://developer.samsung.com/remotetestlab/rtlDeviceList.action

Regards

Sergey Artuh

Code snippets which related to rendering.
Unfortunately remote test lab for Gear S2 not launching(other devices works)

static void
_launch_game(void *data, Evas_Object *obj, void *info) {
    appdata_s *ad = data;
    Evas_Object * box, * gl;
    Elm_Object_Item *nf_it = NULL;

    box = elm_box_add(ad->naviframe);

    evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);


    gl = elm_glview_add(box);
    
    ELEMENTARY_GLVIEW_GLOBAL_USE(gl);
    evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
    evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

    elm_glview_mode_set(gl, ELM_GLVIEW_DEPTH);

    elm_glview_resize_policy_set(gl, ELM_GLVIEW_RESIZE_POLICY_RECREATE);
    evas_object_event_callback_add(gl, EVAS_CALLBACK_MOUSE_DOWN, _back_to_menu_cb, ad);

    elm_glview_render_policy_set(gl, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND);

    elm_glview_init_func_set(gl, init_gl);
    elm_glview_del_func_set(gl, del_gl);
    elm_glview_resize_func_set(gl, resize_gl);
    elm_glview_render_func_set(gl, render_gl);
    elm_box_pack_end(box, gl);

    ad->igl.score_label = evas_object_text_add(evas_object_evas_get(box));
    label_init(ad->igl.score_label, "",40, "Sans", score_label_main_color, score_label_outline_color,180,30);
    evas_object_smart_member_add(ad->igl.score_label, box);
    evas_object_color_set(ad->igl.score_label, score_label_main_color[R], score_label_main_color[G], score_label_main_color[B],255);
    elm_box_pack_end(ad->igl.score_label, gl);
    evas_object_show(ad->igl.score_label);

    ad->anim = ecore_animator_add(animator_cb , gl);

    elm_object_focus_set(gl, EINA_TRUE);

    evas_object_data_set(gl, "ad", ad);

    evas_object_show(gl);
    evas_object_show(box);

    eext_rotary_event_handler_add(_rotary_cb,NULL);

    nf_it = elm_naviframe_item_push(ad->naviframe, NULL, NULL, NULL, box, "empty");
    elm_naviframe_item_pop_cb_set(nf_it, _nf_game_back_cb, ad);
}



static void
init_gl(Evas_Object *obj) {

    appdata_s *ad = (appdata_s *)evas_object_data_get(obj, "ad");

    ELEMENTARY_GLVIEW_USE(obj);
    init_shaders(obj);
    init_texture(obj);                  //render to texture
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_TEXTURE_2D);


    dlog_print(DLOG_FATAL, LOG_TAG, "gl init");
}

static void
init_shaders(Evas_Object *obj) {

    appdata_s *ad = (appdata_s *)evas_object_data_get(obj, "ad");
    View * view = get_view(TUBE_VIEW);
    unsigned int vert_shader, frag_shader, program;
    char * p;

    ELEMENTARY_GLVIEW_USE(obj);
    p = get_shader(VERTEX, 0);
    vert_shader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vert_shader, 1, (const char **)&p, NULL);
    glCompileShader(vert_shader);

    p = get_shader(FRAGMENT, 0);
    frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(frag_shader, 1, (const char **)&p, NULL);
    glCompileShader(frag_shader);


    ad->main_program = glCreateProgram();
    glAttachShader(ad->main_program, vert_shader);
    glAttachShader(ad->main_program, frag_shader);
    glLinkProgram(ad->main_program);


    view->id_color = glGetAttribLocation(ad->main_program, "a_color");
    view->id_mvp = glGetUniformLocation(ad->main_program, "u_mvpMatrix");
    id_user_position = glGetUniformLocation(ad->main_program, "a_user");

    p = get_shader(VERTEX, 1);
    vert_shader = glCreateShader(GL_VERTEX_SHADER);
    glShaderSource(vert_shader, 1, (const char **)&p, NULL);
    glCompileShader(vert_shader);

    p = get_shader(FRAGMENT, 1);
    frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
    glShaderSource(frag_shader, 1, (const char **)&p, NULL);
    glCompileShader(frag_shader);


    ad->tex_program = glCreateProgram();
    glAttachShader(ad->tex_program, vert_shader);
    glAttachShader(ad->tex_program, frag_shader);
    glLinkProgram(ad->tex_program);

    view->rend_tex.id_texCoord = glGetAttribLocation(ad->tex_program, "a_texCoord");
    view->rend_tex.id_position =  glGetAttribLocation(ad->tex_program, "a_position");
    view->rend_tex.id_tex = glGetUniformLocation(ad->tex_program, "u_tex");

    glUseProgram(program);

}



static void
init_texture(Evas_Object *obj) {
    appdata_s *ad = (appdata_s *)evas_object_data_get(obj, "ad");

    int i;

    float texVertexes[] = {-1,-1,0,        -1,1,0,        1,1,0,        1,-1,0};
    unsigned int texIndexes[] ={0,2,1,    0,2,3};
    float texCoor[] = {0,0,        0,1,    1,1,    1,0};

    View * v = get_view(TUBE_VIEW);
    for(i=0; i < 8; ++i)
        v->rend_tex.texCoor[i] = texCoor[i];

    for(i=0; i < 6; ++i)
        v->rend_tex.texIndexes[i] = texIndexes[i];

    for(i=0; i < 12; ++i)
        v->rend_tex.texVertexes[i] = texVertexes[i];

    ELEMENTARY_GLVIEW_USE(obj);

    glGenFramebuffers(1,&ad->framebufer);
    glBindFramebuffer(GL_FRAMEBUFFER, ad->framebufer);

    glActiveTexture(GL_TEXTURE0);
    glGenTextures(1, &v->rend_tex.texture);
    glBindTexture(GL_TEXTURE_2D, v->rend_tex.texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,texBuffSize[X],texBuffSize[Y], 0, GL_RGBA, GL_FLOAT,NULL);//texBuffSize = 720

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, v->rend_tex.texture, 0);


    unsigned int renderBuffer;
    glGenRenderbuffers(1, &renderBuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
    glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, texBuffSize[X],texBuffSize[Y]);
    glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBuffer);
}



static void
render_gl(Evas_Object *obj) {
    int i;
    View * view = get_view(0);
    appdata_s *ad = (appdata_s *)evas_object_data_get(obj, "ad");


    ELEMENTARY_GLVIEW_USE(obj);

    glBindFramebuffer(GL_FRAMEBUFFER, ad->framebufer);
    glViewport(0, 0, texBuffSize[X],texBuffSize[Y]);

    glClearColor(0.033f, 0.03f, 0.03f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glUseProgram(ad->main_program);

    glVertexAttribPointer(view->id_position, 3, GL_FLOAT, GL_FALSE,
                3 * sizeof(float), view->vertexes);
    glVertexAttribPointer(view->id_color, 4, GL_FLOAT, GL_FALSE,
                4 * sizeof(float), view->colors);

    glEnableVertexAttribArray(view->id_position);
    glEnableVertexAttribArray(view->id_color);

    glUniformMatrix4fv(view->id_mvp, 1, GL_FALSE, view->mvp);
    glDrawElements(GL_TRIANGLES, view->index_n, GL_UNSIGNED_INT, view->indexes);

    glBindFramebuffer(GL_FRAMEBUFFER, 0);

    glViewport(0, 0, 360, 360);
    glClearColor(0.1f, 0.1f, 0.3f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    render_from_texture(obj);


    glFlush();
}

static void
render_from_texture(Evas_Object *obj) {
    View * view = get_view(TUBE_VIEW);
    appdata_s *ad = (appdata_s *)evas_object_data_get(obj, "ad");
    ELEMENTARY_GLVIEW_USE(obj);

    glUseProgram(ad->tex_program);

    glVertexAttribPointer(view->rend_tex.id_position, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), view->rend_tex.texVertexes);
    glVertexAttribPointer(view->rend_tex.id_texCoord, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), view->rend_tex.texCoor);

    glEnableVertexAttribArray(view->rend_tex.id_position);
    glEnableVertexAttribArray(view->rend_tex.id_texCoord);


    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, view->rend_tex.texture);
    glUniform1i(view->rend_tex.id_tex, 0);

    glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, view->rend_tex.texIndexes);
}

Shaders


static const char vertex_shader[] =
                "uniform mat4 u_mvpMatrix;\n"
                "uniform vec4 a_user;\n"
                "uniform sampler2D u_tex;\n"
                "attribute vec4 a_position;\n"
                "attribute vec4 a_color;\n"
                "varying vec4 v_color;\n"
                "varying float dis;\n"
                "\n"
                "void main()\n"
                "{\n"
                "    gl_Position = u_mvpMatrix * a_position;\n"
                "    float dis =  distance(gl_Position, vec4(0,0,0,0.3));\n"
                "    v_color = a_color * exp(-dis * 0.075);\n"

                "}";

static const char fragment_shader[] =
                "#ifdef GL_ES\n"
                //"precision highp float;\n"
                "#endif\n"
                "uniform vec4 a_user;"
                "varying vec4 v_color;\n"
                "\n"
                "void main (void)\n"
                "{\n"
                "    gl_FragColor = v_color;\n"
                "}";


static const char rend_to_tex_vert_shader[] =
                "uniform sampler2D u_tex;\n"
                "attribute vec2 a_texCoord;\n"
                "attribute vec4 a_position;\n"
                "varying vec2 texCoord;\n"
                "\n"
                "void main()\n"
                "{\n"
                "       texCoord = a_texCoord;\n"
                "       gl_Position = a_position;\n"
                "}";


   static const char rend_to_tex_frag_shader[] =
                "uniform sampler2D u_tex;\n"
                "varying vec2 texCoord;\n"
                "\n"
                "void main (void)\n"
                "{\n"
                "vec4 sum = vec4(0.0);\n"
                "       for (int x = -1; x <= 1; x++)\n"
                "                for (int y = -1; y <= 1; y++)\n"
                "                       sum += texture2D(u_tex,vec2(texCoord.x + x * 0.00138888, texCoord.y + y * 0.00138888) ) / 9;\n"
                "   gl_FragColor = sum;\n"
                "}";
Alex Dem

Hi,
I tried simple EvasGL Cube wearable example. It works on Gear S2. Did you try this one or any simple examples from sdk on your watch?
Alexey.

Alex Dem

Hi,
I have checked on Gear S2 : GLView Shader Sample - it is ok too.
But to adapt your code snippet - it needed some time. Better share fully working sample which reproduces your problem.
Alexey.