Hi all,

As you all know, I've been working on adding GL rendering features to Evas and
we now have an early working version of Evas_GL in the svn.

Since then, there's been a request from people around me for an
elementary widget that
allows simple GL rendering.  Since Evas_GL can be seen as a low level API it
made sense to have a user friendly layer that allows GL rendering.  I
thought it
went well with the EFL philosophy.  Take away some control but make it easy to
use for the users as you go up the layers from Evas->Ecore->ELM-> etc.

So, I've decided to take a crack at elm_glview.  By the way, this is
my first time writing
an elementary widget so I KNOW I've missed a lot that i need to handle.  Also,
I'm aware of the fact thatI need to handle input events. I'll need to
figure that out
but I open to comments and suggestions.  However, before I get all the
nitty gritty
detail right, I wanted to start a discussion with the community on the APIs and
ask for suggestions.

So far, after discussing this with a few people, we've come up with
the following.

   typedef enum _Elm_GLView_Scale_Policy
     {
        ELM_GLVIEW_POLICY_RESIZE,   /**< Resize the internal surface
along with the image */
        ELM_GLVIEW_POLICY_SCALE     /**< Only reize the internal image
and not the surface */
     } Elm_GLView_Scale_Policy;

   Evas_Object *elm_glview_add(Evas_Object *parent);
   void              elm_glview_size_set(Evas_Object *obj, Evas_Coord
width, Evas_Coord height);
   void              elm_glview_size_get(Evas_Object *obj, Evas_Coord
*width, Evas_Coord *height);
   Evas_GL_API  *elm_glview_gl_api_get(Evas_Object *obj);
   Eina_Bool        elm_glview_mode_set(Evas_Object *obj, Elm_GLView_Mode mode);
   Eina_Bool        elm_glview_scale_policy_set(Evas_Object *obj,
Elm_GLView_Scale_Policy policy);
   void             elm_glview_display_func(Evas_Object *obj,
Elm_GLView_Func func);
   void             elm_glview_changed_set(Evas_Object *obj);
   Eina_Bool    elm_glview_z_get(Evas_Object *obj, Evas_Coord x,
Evas_Coord y, Evas_Coord *z);


Internally, elm_glview handles creating an image object, evas_gl
object, evas_gl context,
surface, doing make current for display function. You just need to set
the display_function
callback and put your GL calls in there. The scale policy concerns how the
glview would resize.  setting it to SCALE would keep the current
glview but simply scale
the underlying image.  otherwise, it would recreate the surface.  The
API is pretty straight forward
in my opinion.  It's very much GLUT-like adapted for EFL.

In order to use the elm_glview, you would do something like

main()
{
   ...
   // Add a GLView
   glview = elm_glview_add(win);
   glapi = elm_glview_gl_api_get(glview);
   elm_glview_mode_set(glview, ELM_GLVIEW_ALPHA | ELM_GLVIEW_DEPTH);
   elm_glview_scale_policy_set(glview, ELM_GLVIEW_POLICY_SCALE);
   elm_glview_display_func(glview, (Elm_GLView_Func)draw);
   evas_object_resize(glview, 256, 256);
   evas_object_show(glview);
   ecore_animator_add(on_animate, glview);
   ...
}

on_animate()
{
   elm_glview_changed_set((Evas_Object*)data);
   return EINA_TRUE;
}

// GL calls
draw()
{
   elm_glview_size_get(..., &w, &h);
   glapi->glViewport(..., w, h);
   ...
}

I guess it's easier to see the sample files and run the code to see
how they actually work.
I'm including a patch that shows the above example.  I'm including the
following files.

1. elm_glview.path
  -. apply using: patch -p0 elm_glview.patch
2. elm_glview.c
  -. copy the file to src/lib
  -. make/ install elmentary
3. elmglviewsample1.c, elmglviewgears.c, Makefile
  -. do a make on the samples using the given makefile.

Ok, that's all for now.  I'd love to hear comments and suggestions on
it as I continue to
work on it.

thanks!

cheers,
Sung

Attachment: elmglview.tgz
Description: GNU Zip compressed data

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to