I’m working on Tizen 2.3. I have an issue with Evas_GL_GLES1_Helpers.h (OpenGL 1.1). My sample create from Tizen project sample name : Evas GL Sample (Navtive App OpenGL 2.0). And then change to OpenGL1.1. But it’s not working. Anything wrong with my code? (I have just set screen color with this command : ” glClearColor(0.0f, 0.5f, 0.5f, 1.0f);” )
/*
*/
#include <app.h>
#include <system_settings.h>
#include <Evas_GL_GLES1_Helpers.h>
#include <efl_extension.h>
#include <dlog.h>
#include <Elementary.h>
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "evasgl11"
typedef struct appdata {
const char *name;
Evas_Object *win;
/* GL related data here... */
Evas_GL *evasgl;
Evas_GL_Context *ctx;
Evas_GL_Surface *sfc;
Evas_GL_Config *cfg;
Evas_Object *img;
} appdata_s;
EVAS_GL_GLOBAL_GLES1_DEFINE();
/* Define the cube's vertices
Each vertex consist of x, y, z, r, g, b */
static void
win_back_cb(void *data, Evas_Object *obj, void *event_info)
{
appdata_s *ad = data;
/* Let window go to hide state. */
elm_win_lower(ad->win);
}
static void
win_delete_request_cb(void *data , Evas_Object *obj , void *event_info)
{
ui_app_exit();
}
static void
img_pixel_cb(void *data, Evas_Object *obj)
{
if(false)
return;
/* Define the model view projection matrix */
appdata_s *ad = data;
Evas_Coord w, h;
evas_object_image_size_get(obj, &w, &h);
/* Set up the context and surface as the current one */
evas_gl_make_current(ad->evasgl, ad->sfc, ad->ctx);
glClearColor(0.0f, 0.5f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
static void
img_del_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
{
appdata_s *ad = data;
Ecore_Animator *ani = evas_object_data_get(ad->img, "ani");
ecore_animator_del(ani);
/* Free the gl resources when image object is deleted. */
evas_gl_make_current(ad->evasgl, ad->sfc, ad->ctx);
evas_gl_surface_destroy(ad->evasgl, ad->sfc);
evas_gl_context_destroy(ad->evasgl, ad->ctx);
evas_gl_config_free(ad->cfg);
evas_gl_free(ad->evasgl);
}
static Eina_Bool
animate_cb(void *data)
{
Evas_Object *img = data;
/* Animate here whenever an animation tick happens and then mark the image as
"dirty" meaning it needs an update next time evas renders. it will call the
pixel get callback then. */
evas_object_image_pixels_dirty_set(img, EINA_TRUE);
return ECORE_CALLBACK_RENEW;
}
static void
mouse_down_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
{
}
static void
mouse_move_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
{
}
static void
mouse_up_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
{
}
static void
win_resize_cb(void *data, Evas *e , Evas_Object *obj , void *event_info)
{
appdata_s *ad = data;
if(ad->sfc) {
evas_object_image_native_surface_set(ad->img, NULL);
evas_gl_surface_destroy(ad->evasgl, ad->sfc);
ad->sfc = NULL;
}
Evas_Coord w,h;
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
evas_object_image_size_set(ad->img, w, h);
evas_object_resize(ad->img, w, h);
evas_object_show(ad->img);
if(!ad->sfc) {
Evas_Native_Surface ns;
ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, w, h);
evas_gl_native_surface_get(ad->evasgl, ad->sfc, &ns);
evas_object_image_native_surface_set(ad->img, &ns);
evas_object_image_pixels_dirty_set(ad->img, EINA_TRUE);
}
}
static void
init_evasgl(appdata_s *ad)
{
Ecore_Animator *ani;
/* Set config of the surface for evas gl */
ad->cfg = evas_gl_config_new();
ad->cfg->color_format = EVAS_GL_RGB_888;
ad->cfg->depth_bits = EVAS_GL_DEPTH_BIT_24;
ad->cfg->stencil_bits = EVAS_GL_STENCIL_NONE;
ad->cfg->options_bits = EVAS_GL_OPTIONS_NONE;
/* Get the window size */
Evas_Coord w,h;
evas_object_geometry_get(ad->win, NULL, NULL, &w, &h);
/* Get the evas gl handle for doing gl things */
ad->evasgl = evas_gl_new(evas_object_evas_get(ad->win));
/* Create a surface and context */
ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, w, h);
ad->ctx = evas_gl_context_version_create(ad->evasgl, NULL,EVAS_GL_GLES_1_X);
EVAS_GL_GLOBAL_GLES1_USE(ad->evasgl, ad->ctx);
/* Set up the image object. A filled one by default. */
ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win));
evas_object_event_callback_add(ad->img, EVAS_CALLBACK_DEL, img_del_cb, ad);
evas_object_image_pixels_get_callback_set(ad->img, img_pixel_cb, ad);
/* Add Mouse Event Callbacks */
evas_object_event_callback_add(ad->img, EVAS_CALLBACK_MOUSE_DOWN, mouse_down_cb, ad);
evas_object_event_callback_add(ad->img, EVAS_CALLBACK_MOUSE_UP, mouse_up_cb, ad);
evas_object_event_callback_add(ad->img, EVAS_CALLBACK_MOUSE_MOVE, mouse_move_cb, ad);
ani = ecore_animator_add(animate_cb, ad->img);
evas_object_data_set(ad->img, "ani", ani);
}
Evas_Object *
add_win(const char *name)
{
Evas_Object *win;
elm_config_accel_preference_set("opengl");
win = elm_win_util_standard_add(name, "UI Template");
if (!win)
return NULL;
evas_object_show(win);
return win;
}
static bool
app_create(void *data)
{
/* Hook to take necessary actions before main event loop starts
Initialize UI resources and application's data
If this function returns true, the main loop of application starts
If this function returns false, the application is terminated. */
appdata_s *ad;
Evas_Object *win;
if (!data)
return false;
ad = data;
win = add_win(ad->name);
if (!win)
return false;
ad->win = win;
init_evasgl(ad);
eext_object_event_callback_add(win, EEXT_CALLBACK_BACK, win_back_cb, ad);
evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, ad);
evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
return true;
}
static void
app_control(app_control_h app_control, void *data)
{
/* Handle the launch request. */
}
static void
app_pause(void *data)
{
/* Take necessary actions when application becomes invisible. */
}
static void
app_resume(void *data)
{
/* Take necessary actions when application becomes visible. */
}
static void
app_terminate(void *data)
{
/* Release all resources. */
}
static void
ui_app_lang_changed(app_event_info_h event_info, void *user_data)
{
/*APP_EVENT_LANGUAGE_CHANGED*/
char *locale = NULL;
system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale);
elm_language_set(locale);
free(locale);
return;
}
static void
ui_app_orient_changed(app_event_info_h event_info, void *user_data)
{
/*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
return;
}
static void
ui_app_region_changed(app_event_info_h event_info, void *user_data)
{
/*APP_EVENT_REGION_FORMAT_CHANGED*/
}
static void
ui_app_low_battery(app_event_info_h event_info, void *user_data)
{
/*APP_EVENT_LOW_BATTERY*/
}
static void
ui_app_low_memory(app_event_info_h event_info, void *user_data)
{
/*APP_EVENT_LOW_MEMORY*/
}
int
main(int argc, char *argv[])
{
appdata_s ad = {0,};
int ret = 0;
ui_app_lifecycle_callback_s event_callback = {0,};
app_event_handler_h handlers[5] = {NULL, };
event_callback.create = app_create;
event_callback.terminate = app_terminate;
event_callback.pause = app_pause;
event_callback.resume = app_resume;
event_callback.app_control = app_control;
ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);
ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]);
ret = ui_app_main(argc, argv, &event_callback, &ad);
if (ret != APP_ERROR_NONE) {
dlog_print(DLOG_ERROR, LOG_TAG, "The application failed to start, and returned %d", ret);
}
return ret;
}
OpenGL
Hi guys,
I’m working on Tizen 2.3. I have an issue with Evas_GL_GLES1_Helpers.h (OpenGL 1.1). My sample create from Tizen project sample name : Evas GL Sample (Navtive App OpenGL 2.0). And then change to OpenGL1.1. But it’s not working. Anything wrong with my code? (I have just set screen color with this command : ” glClearColor(0.0f, 0.5f, 0.5f, 1.0f);” )
BY
04 Nov 2024
Tizen Studio
BY
02 Apr 2024
Tizen Studio
BY
30 Oct 2023
Tizen Studio