语言

Menu
Sites
Language
OpenGL multi texture corrupts evas object on device

Hi,

I'm working on a watch face that has some OpenGL ES 3.0 drawn on a image surface and som other ordinary image objects for the watch face for exampel the hour and minute hands. It works perfect on the emulator and on device as longa as I only has one texture loaded in OpenGL.

As soon as I start using a second or more textures in OpenGL then all other object are turned in to black boxes on my Gear S3 but are ok on the emulator except if the original image is twice as big or bigger as the one I want to show on the screen, really weird bug.

Edje images are also turned in to black frames.

The second texture and the images works ok in the emulator. As a workaround I have made all the images with twice the size and it works ok except when I do evas_map_util_rotate for the second hand and the angel is 0 degrees or 360. It works all the way around for all other angels but not for 0 where the image get black with alpha 1. Very annoying!

The fragment shader:

/* Fragment Shader Source */
static const char fragment_shader[] =
  "#ifdef GL_ES\n"
  "precision mediump float;\n"
  "#endif\n"
  "varying vec2 frag_texcoord;\n"
  "varying vec3 frag_position;\n"
  "varying float intensity;\n"
  "uniform sampler2D u_texture;\n"
  "uniform sampler2D u_normal_map;\n"
  "uniform sampler2D u_specular_map;\n"
  "\n"
  "void main(void)\n"
  "{\n"
  "    vec3 light;\n"
  "    vec4 diffuse;\n"
  "    vec4 normal;\n"
  "    vec4 specular;\n"
  "    vec4 color;\n"
  "\n"
  "    light = vec3(0.8*intensity, 0.8*intensity, 0.8*intensity);\n"
  "    diffuse = texture2D(u_texture, frag_texcoord);\n"
  "    normal = texture2D(u_normal_map, frag_texcoord);\n"
  "    specular = texture2D(u_specular_map, frag_texcoord);\n"
  "    color = vec4(light, 1.0) * diffuse * specular;\n"
  "    gl_FragColor = color;\n"
  "}\n";

If I remove specular in above then all works as normal on both emulator and my device a Gear S3.
I shrunk the OpenGL textures just to see if it was a memory problem but it did not have any effect and the OpenGL stuff works ok on the device.

This is the rotate source that doesn't work for 0 degrees:

void view_rotate_hand(Evas_Object *hand, double degree, Evas_Coord cx, Evas_Coord cy)
{
  Evas_Map *m = NULL;

  ;m = evas_map_new(4);
  evas_map_util_points_populate_from_object(m, hand);
  evas_map_util_rotate(m, degree, cx, cy);
  evas_object_map_set(hand, m);
  evas_object_map_enable_set(hand, EINA_TRUE);
  evas_map_free(m);
}

I do not know what to do with the multi texture problem and it is a mayor bug.

Has anyone else manage to use multiple textures and also used evas image object without any problems ?

/Christian

响应

1 回复
Christian Westlin

I found a way around this bug now.
Not so pretty but when evas map is at 0 degrees and not rotating the image then I disable the map.
But some objects has their image not rotated but needs to be moved slightly but I solved that too with some sin and cosine formulas.

/Christian