OpenGL ES 2.0 - Generating Textures Using Evas Object

This code shows how to generate textures from Evas Objects very simply. evas_object_image_data_get API provides a helpful way to load PNG file into OpenGL ES 2.0 texture memory area without hassle. More detailed OpenGL ES 2.0 things for Tizen are well explained in GLViewCube Sample in SDK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
void load_texture(appdata_s *ad) {
    Evas* evas = evas_object_evas_get(ad->win);
    Evas_Object* image = evas_object_image_filled_add(evas);
    char path[200];
    sprintf(path, "%stest.png", app_get_resource_path());
    evas_object_image_file_set(image, path, NULL);
    evas_object_image_size_get(image, &ad->texture_width, &ad->texture_height);
    ad->texture_data = evas_object_image_data_get(image, EINA_FALSE);
    evas_object_del(image);
    glGenTextures(1, &ad->texture_id);
    glBindTexture(GL_TEXTURE_2D, ad->texture_id); // unsigned int texture_id;
    glActiveTexture(GL_TEXTURE0);
    glUniform1i(ad->handle_texture_uniform, 0);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, ad->texture_width, ad->texture_height, // int texture_width, texture_height;
            0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, ad->texture_data); // void *texture_data;
    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_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX