Thanks Julien, that's good news. Would you have any objection to me writing a wayland ui module for ardor3d based on Zubzub's work? Similar to the swt and awt modules. Any ideas for handling wayland events, should I extend ardor ui events api?
What about the ardor3d domain, would you like me to place a bid and donate it? It could be redirected to jogamp.org. Regards, Peter. |
Administrator
|
In reply to this post by Peter
On 09/21/2015 02:10 AM, Peter [via jogamp] wrote:
> Samsung's Tizen, is Linux with Wayland, Enlightenment and OpenGL ES 2.0 > > Tizen: Samsung Smart TV's, Gear (watch) and phones Z1 and Z3 (due out soon). > > Looking at NEWT's C source code, at this stage it only appears to support X11 > on Linux. Hi Peter, may I ask who is requesting Wayland support and for which application? As Julien mentioned, Wayland support is surely planned, the Ubuntu/Canonical proprietary diversion not at all. Since we are already in a lengthily thread, maybe you can introduce yourself a little bit? Thank you. ~Sven signature.asc (828 bytes) Download Attachment |
It's for an in field (remote) mobile maintenance service application, where the client is required to be able to operate disconnected and report information back to a server when connected again. The application is to allow a tech to annotate components in a 3d model with photographs, text or sound bytes and look up history or procedures for certain parts scheduled for an inspection.
Presently the Tizen platform is the most open mobile platform capable of supporting an SE embedded JVM, headless at present due to a lack of Wayland support. I'm a B. M. Engineer, I'm experienced with Java, networks, CAD, FEA, matrix and vector math, but haven't had much exposure to OpenGL ES, so am looking for a high level 3D scene graph library in which to write the application. Any idea of how far off NEWT / Wayland support might be, and who might be working on it? Regards, Peter. |
This post was updated on .
Hi Peter I (Xerxes), Sven and Erik are working on Wayland support. I recall Erik has already been able to open a NEWT wayland window http://jogamp.org/log/irc/jogamp_20150422050533.html#l41 The hardest part is to figure out the right heuristics for wayland initialization a GNU/Linux system may support Wayland, X11 and direct framebuffer output using the same driver thus we can't guess what the user prefer instead we have to query what the user uses at the moment. I prefer if we did the heuristics in the following order first try to open a wayland window -> if that fail then try to open an X11 window -> if that fail then try to open a direct framebuffer window. the rationale of this order of initialization is that wayland can support opening both x11 and wayland windows however you will get the most performance if you get an wayland window. |
Thanks Xerxes,
I agree with your thoughts on initialization, is the code available from a repository yet? I wouldn't mind testing it on the Tizen emulator. Regards, Peter. |
Administrator
|
In reply to this post by Peter
Hi
Peter, why not working with Zubzuk and other contributors to make Wayland work with NEWT so that you can use an unmodified version of JogAmp's Ardor3D Continuation? Actually, it would be better to redirect it to the JogAmp's Ardor3D Continuation user's guide, wouldn't it? If you prefer, I can place a bid on it. Keep in mind that the events are managed in ardor3d-jogl for NEWT.
Julien Gouesse | Personal blog | Website
|
Ok, is there a repository containing the NEWT experimental code?
I noticed there doesn't seem to be much support for touch screen input in ardor3d, please correct me if I'm mistaken. I could write some or copy from another suitably licensed project The domain can still be renewed and transferred if you know the owner, otherwise I can bid and transfer it, or make a donation if you want to bid directly. Regards, Peter. |
Administrator
|
In reply to this post by Xerxes Rånby
On 09/26/2015 12:01 PM, Xerxes Rånby [via jogamp] wrote:
> Peter wrote > ... > Presently the Tizen platform is the most open mobile platform capable of > supporting an SE embedded JVM, headless at present due to a lack of > Wayland support. > ... > > Any idea of how far off NEWT / Wayland support might be, and who might be > working on it? > Peter. > > Hi Peter > > I (Xerxes), Sven and Erik are working on Wayland support. > > I recall Eric has already been able to open a NEWT wayland window > http://jogamp.org/log/irc/jogamp_20150422050533.html#l41 see features of 2.4.0: <https://jogamp.org/wiki/index.php/SW_Tracking_Report_Objectives_for_the_release_2.4.0> +++ Thank you Peter for your introduction. As I assume your utilization of JogAmp w/ Wayland is of commercial nature. Hence I like to mention that beside contributing code, testing, etc. it may also be possible to contact maintainer directly and ask whether they offer commercial support. Commercial support may allow them to prioritize work on certain subjects or even to work and support JogAmp in general. See <https://jogamp.org/wiki/index.php/Maintainer_and_Contacts> It is generally a great idea for companies w/ enough financial resources who use JogAmp to consider sharing some of their financial resources. This is true not only for JogAmp of course. However, this is not a necessary requirement for companies to participate - but very welcome, sure. Cheers, Sven PS-1: Nope, there are also others who might like to receive funding. PS-2: I hope my 'reminder' of this sort of things is not too annoying :) signature.asc (828 bytes) Download Attachment |
Administrator
|
In reply to this post by Peter
I advise you to read the user's guide. JogAmp's Ardor3D Continuation supports the touch screens, there is no code to skip them. However, NEWT doesn't support touch events on all platforms, Sven can talk about that better than me.
Julien Gouesse | Personal blog | Website
|
In reply to this post by Sven Gothel
Thanks Sven,
Yes, the proposal I've discussed is of a commercial nature, it's good to know there's a commercial support option, in case my boss decides to hit the go button. My offer to assist with the domain is private. I can see another use case, on a personal level, I'm a committer with the Apache River project. I was reading one of NASA's presentations about using Ardor3d with CORBA for their rover / explorers. River provides infrastructure for remote procedure calls using CORBA / IIOP, or JERI (an extensible RPC framework providing connections over various protocols, including https and TLS). River also provides a discovery process and lookup service that allows dynamic discovery and establishment of p2p connections between distributed software programs. IPv4 and NAT has limited River to private networks, however with increasing use of IPv6, River's reach could be much greater; we were only recently assigned global IPv6 multicast addresses. River provides a mechanism for dynamic code download, thus a client only needs River, Java and a service browser installed, to access any service dynamically using a dynamically provided UI, services may also provide multiple UI for different clients. For the internet, with IPv6, unlike IPv4, a hosted server needn't be the provider of these services, anything that's network reachable can provide these services including UI on demand dynamically. I'm working on improving security at present, this is outside of work. Concluding, I can see a use case for Ardor3d, JOGL & NEWT as a supported client UI for River. For example, a virtual world that reflects some real world situation may be provided, where objects are added or removed, appear or disappear dynamically and be accessed by a user browsing the virtual world, UI for these objects would be provided by the objects themselves and hosted by the virtual world. Regards, Peter. |
In reply to this post by gouessej
Thanks Julien, much appreciated.
|
Administrator
|
In reply to this post by Peter
Ardor3D != JogAmp's Ardor3D Continuation. NASA used the former and Renanse complained about some problems when using it with SWT and the old JOGL 1 backend then he used another one based on another library whereas the JOGL 2 backend offers a lot more options (see ardor3d-jogl, ardor3d-jogl-awt and ardor3d-jogl-swt). As far as I know, the touch events are correctly handled under Android, they aren't handled under Windows and I should check whether they are handled under GNU Linux and OS X.
Julien Gouesse | Personal blog | Website
|
Could it be given a new name? I mean Ardor3d continuation is quite a mouthful. What about JSGGE? Java scene graph graphics engine?
Just a thought. Cheers, Peter. |
Administrator
|
Actually, I decided not to choose a new name. Changing it now would be problematic and would cause a lot of confusion. I'll ask Renanse whether he accepts us to get the ardor3d.com domain name.
Julien Gouesse | Personal blog | Website
|
In reply to this post by gouessej
I've been investigating the Tizen platform further, at present I'm experimenting on Tizen 2.3, which uses X, instead of Wayland.
What I've found is that root access is required to access DISPLAY:0, in this case policytool, works from root, but not a user account (see appended). Tizen expects developers to create OpenGL apps via Enlightenment foundation library classes, EvasGL and GLview. The Developer can use OpenGL API, but there's a level of indirection and the GL headers aren't used directly. However it appears possible to create a wrapper around EvasGL for OpenGL calls. The EFL libraries encapsulate the window system, EGL and OpenGL ES, Although not supported by hardware, OpenGL ES 1.1 is supported by EvasGL and GLView. https://developer.tizen.org/development/guides/native-application/graphics/opengl-es As I don't want to "root" the phone to get access to a native window, I'm going to investigate Tizen's permission model further to see if it's possible to gain access. I've also ordered a Samsung Z3, to experiment with. Regards, Peter. sh-4.1$ policytool Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable. at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method) at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java :65) at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115) at java.security.AccessController.doPrivileged(Native Method) at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:7 4) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103) at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvi ronment.java:82) at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:126) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at java.awt.Toolkit$2.run(Toolkit.java:860) at java.awt.Toolkit$2.run(Toolkit.java:855) at java.security.AccessController.doPrivileged(Native Method) at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854) at javax.swing.UIManager.getSystemLookAndFeelClassName(UIManager.java:61 1) at sun.security.tools.policytool.PolicyTool.<clinit>(PolicyTool.java:90) sh-4.1$ |
Administrator
|
Hi
I hope you'll succeed without writing a wrapper around EvasGL. It's really painful, why don't they make it easy to use whatever we want? I hate this kind of controlled environments with silly policies. The developers shouldn't be forced to use Enlightenment.
Julien Gouesse | Personal blog | Website
|
I agree, being forced to use Enlightenment would be lousy, will let you know how I get on. Although at first appearance, this appears to be the case, due to documentation focusing on Enlightenment based development, I think the privilege model is the issue. Tizen uses Smack for mandatory access control.
All necessary libraries are in place in Tizen 2.3.1 (will let you know what I find in Tizen 2.4): sh-4.1$ ls /usr/lib/libEGL.so /usr/lib/libEGL.so sh-4.1$ ls /usr/lib/libG* /usr/lib/libGLESv1_CM.so /usr/lib/libGLESv2.so /usr/lib/libGLESv2.so.2 /usr/lib/libGLESv1_CM.so.1 /usr/lib/libGLESv2.so.1 The security framework requires applications to declare necessary privileges in the application package manifest. In this case I think I need to declare a socket privilege in the manifest in order to open a socket to the X server. Some useful links for anyone attempting to use Tizen: https://wiki.tizen.org/wiki/Porting_Guide/Graphics_and_UI https://wiki.tizen.org/wiki/Security/Privileges_Study_For_Tizen3/List_Of_Privileges#Table_of_all_the_privileges https://wiki.tizen.org/wiki/Security/Application_installation_and_Manifest http://schaufler-ca.com/home https://wiki.tizen.org/wiki/Security/Overview https://developer.tizen.org/development/getting-started/native-application/tizen-application-model With respect to Java, I need to develop an application wrapper in C, that uses JNI to invoke Java, provided I can solve the privilege issue. Regards, Peter. |
Well, firstly the bad news, it's locked down, the EGL and GLES libraries are not public api, applications aren't able to use these directly.
OpenAL is available as public API. To use GLES it must be accessed via Enlightenment. THE FOLLOWING IS A QUOTATION FROM THE TIZEN GRAPHICS GUIDE: OpenGL ES The OpenGL ES overview shows the interaction among Graphics subsystems, OpenGL ES, and EGL defined by the Khronos Group. OpenGL ES is a standard specification defining a cross-language, cross-platform OpenGL ES API for writing applications that produce 2D and 3D computer graphics. OpenGL ES 1.1, 2.0, and 3.0 are supported in Tizen 2.4. EGL is an adhesive layer between OpenGL ES and the underlying native platform window system. EGL communicates with the Window system to get information on the application window, creates the drawing surface, and manages rendering context and resources. Figure: OpenGL ES structure OpenGL ES structure OpenGL ES in Tizen Building an OpenGL ES application in Tizen requires knowledge about designing UI applications with EFL. Tizen native applications do not depend on the Window system, because the Window system is an internal Tizen module, which can be enhanced or replaced. EFL provides a method that draws the OpenGL ES content and encapsulates the EGL and the native Window system. Figure: OpenGL ES and EFL OpenGL ES and EFL A GLView creates a drawable GL surface for the application, and sets up all the required callbacks. The application can use GLView with various UI components, such as toolbar or button. GLView internally uses EvasGL. It is an abstraction layer on top of EGL, which provides the necessary features for most applications in a platform-independent way. Since the goal of EvasGL is to abstract the underlying platform, only a subset of the features can be used by applications. Using GLView is recommended for usual OpenGL ES programs, such as 3D game applications. But if you need pbuffer surface or extension functions, you have to understand EvasGL. EvasGL vs. GLView While it is possible to create an OpenGL ES application by just using EvasGL, it could be difficult to comprehend due to the low-level nature of these APIs. However, it enables detailed operations. GLView Programming Guide Setting up an OpenGL ES Surface The easiest way to use OpenGL ES within a Tizen application is to rely on the GLView component. GLView is a simple Elementary UI component that sets up an OpenGL ES target surface and a context, and allows you to embed it in any Tizen application. GLView is basically a wrapper around EvasGL, the OpenGL ES/EGL abstraction layer of EFL. Creating a Basic Application Declare the global variable using ELEMENTARY_GLVIEW_GLOBAL_DEFINE(). Create a GLView object and use ELEMENTARY_GLVIEW_GLOBAL_USE(glview). These macros help you to call GL functions directly. Now, you can call GL functions. For more detailed information, see the Elementary_GL_Helpers.h file. #include <app.h> #include <Elementary_GL_Helpers.h> // This code is to be placed at the beginning of any function using GLES 2.0 APIs // When using this macro, you can call all glFunctions without changing their code // For details, see Elementary_GL_Helpers.h ELEMENTARY_GLVIEW_GLOBAL_DEFINE()1.Manage HW acceleration. To develop a GL application, call the elm_config_accel_preference_set() function before creating a window. This makes an application to use GPU. The function is supported since Tizen 2.3. To use the Direct Rendering mode of EvasGL or EFL WebKit (EWK), set the same option values (depth, stencil, and MSAA) to a rendering engine and a GLView object. The EWK options are depth24 and stencil8. You can set the option values to a rendering engine using the elm_config_accel_preference_set() function and to a GLView object using the elm_glview_mode_set() function. If the GLView object option values are bigger or higher than the rendering engine's, the Direct Rendering mode is disabled or abnormal rendering occurs. These special options are supported since Tizen 2.3.1. static bool app_create(void *data) { appdata_s *ad = data; elm_config_accel_preference_set("gl"); ad->win = elm_win_util_standard_add("GLView example", "GLView example"); evas_object_show(ad->win); ad->glview = ad->glview_create(ad->win); // This macro sets the global variable holding the GL API, // so that it is available to the application // Use it right after setting up the GL context object // For details, see Elementary_GL_Helpers.h ELEMENTARY_GLVIEW_GLOBAL_USE(ad->glview); glview_start(ad->glview); return true; } 2.Add the OpenGL ES view to the application: // This is the GL initialization function static Evas_Object *glview_create(Evas_Object *win) { Evas_Object *glview; // This creates the UI component itself glview = elm_glview_add(win); elm_win_resize_object_add(win, glview); // Request a surface with Depth and Stencil support (default buffer sizes) elm_glview_mode_set(glview, ELM_GLVIEW_DEPTH | ELM_GLVIEW_STENCIL); // Set the basic policies to handle the view transparently elm_glview_resize_policy_set(glview, ELM_GLVIEW_RESIZE_POLICY_RECREATE); elm_glview_render_policy_set(glview, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); // Set the 4 main callbacks elm_glview_init_func_set(glview, init_gl); elm_glview_del_func_set(glview, del_gl); elm_glview_render_func_set(glview, draw_gl); elm_glview_resize_func_set(glview, resize_gl); // Finally show this view evas_object_size_hint_min_set(glview, 250, 250); evas_object_show(glview); return glview; } Setting up the Callbacks To set up callbacks: 1.Callback for initialization The initialization callback is called when the GLView is created, after a valid OpenGL ES context and surface have been created. This is called from the main loop, just as the 3 other callbacks. // GL Init function static void init_gl(Evas_Object *glview) { glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Do any form of OpenGL ES initialization here // init_shaders(); // init_vertices(); } 2.Callback for resizing The resize callback is called whenever the GLView component is resized. A common action to take here is to reset the viewport. Because the GLView size can be changed by a parent container, you must set a resize callback and reset the viewport size with the new GLView size. // GLView resize function static void resize_gl(Evas_Object *glview) { int w, h; elm_glview_size_get(glview, &w, &h); glViewport(0, 0, w, h); } 3.Callback for drawing The drawing callback is called whenever a new frame has to be drawn. The exact moment when this function is called depends on the policy set when calling. elm_glview_render_policy_set(glview, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); Another policy is ELM_GLVIEW_POLICY_ALWAYS, which requests render always even when it is not visible. So on demand policy is probably what you are looking for. The application can now draw anything using GL primitives when this callback is triggered. All draw operations are restricted to the surface of the GLView object previously created. // GL draw callback static void draw_gl(Evas_Object *glview) { // Paint it blue glClearColor(0.2, 0.2, 0.6, 1.0); glClear(GL_COLOR_BUFFER_BIT); // The usual OpenGL ES draw commands come here // draw_scene(); } 4.Callback for deleting The delete callback is triggered when the GLView is being destroyed, from the main loop, and no other callback can be called on the same object afterwards. // Delete GLView callback static void del_gl(Evas_Object *glview) { // Destroy all the OpenGL ES resources here // destroy_shaders(); // destroy_objects(); } 5.Add an animator. The application above is technically working but the scene does not get updated unless the frame is marked as such. Games sometimes want to use an animator to have a regular update of the scene. The following example shown the default update refresh rate. The animator callback function is also triggered when the display is off. Use the ecore_animator_freeze() and ecore_animator_thaw() functions in the app_pause_cb and app_resume_cb callbacks for power saving. static Eina_Bool anim_cb(void *data) { Evas_Object *glview = data; elm_glview_changed_set(glview); return ECORE_CALLBACK_RENEW; } static void glview_start(Evas_Object *glview) { ecore_animator_add(anim_cb, glview); } Any other event can be used to refresh the view, for example user input if the view need to be updated. Note Since the Evas rendering engine uses its own GL context internally, the application has to call the gl functions inside the 4 GLView callback functions (initialization, resizing, drawing, deleting) to be guaranteed rendering correctness. While GLView is an abstraction above EvasGL, it is possible to use EvasGL directly for more low-level and advanced features, such as: •Creating new contexts •Creating new surfaces •Creating PBuffer surfaces •Calling extensions For all those reasons, a direct access to the EvasGL object is required. When you use GLView, you can use the following code: Evas_GL *evgl = elm_glview_evas_gl_get(glview); // Then it is possible to call any evas_gl function with it Note Do not destroy the EvasGL object. Its life-cycle is defined by the GLView object. EvasGL Programming Guide This guide assumes that the application uses EvasGL directly instead of using the GLView. (If the application uses a GLView, EvasGL is created internally.) First, you can declare the global variable using the EVAS_GL_GLOBAL_GLES2_DEFINE() macro. Then, create an EvasGL and use EVAS_GL_GLOBAL_GLES2_USE(evasgl, evasgl context). This is similar to the GLView macro. Both macros help you to call GL functions directly. Now, you can call GL functions. For more detailed information, see the Evas_GL_GLES2_Helpers.h file. #include <app.h> #include <Evas_GL_GLES2_Helpers.h> // This code is to be placed at the beginning of any function using GLES 2.0 APIs // When using this macro, you can call all glFunctions without changing their code // For details, see Evas_GL_GLES2_Helpers.h EVAS_GL_GLOBAL_GLES2_DEFINE(); Declaration of EvasGL Objects This is how to define the application data structure to hold all the objects for your EvasGL application: typedef struct appdata { Evas_Object *win; Evas_Object *img; Evas_GL *evasgl; Evas_GL_API *glapi; Evas_GL_Context *ctx; Evas_GL_Surface *sfc; Evas_GL_Config *cfg; Evas_Coord sfc_w; Evas_Coord sfc_h; unsigned int program; unsigned int vtx_shader; unsigned int fgmt_shader; unsigned int vbo; } appdata_s;•Evas_Object *win: Application window. •Evas_Object *img: OpenGL ES canvas. •Evas_GL *evasgl: EvasGL Object for rendering gl in Evas. •Evas_GL_API *glapi: EvasGL API object that contains the GL APIs to be used in Evas GL. •Evas_GL_Context *ctx: EvasGL Context object, a GL rendering context in Evas GL. •Evas_GL_Surface *sfc: EvasGL Surface object, a GL rendering target in Evas GL. •Evas_GL_Config *cfg: EvasGL Surface configuration object for surface creation. Creating the Elm Window and EvasGL To create the Elm window and EvasGL: 1.Manage HW acceleration. To develop a GL application, call the elm_config_accel_preference_set() function before creating a window. THis makes an application to use GPU. The function is supported since Tizen 2.3. To use the Direct Rendering mode of EvasGL, set the same option values (depth, stencil, and MSAA) to a rendering engine and a Evas_GL_Surface object. You can set the option values to a rendering engine using the elm_config_accel_preference_set() function and to a Evas_GL_Surface object using the Evas_GL_Config object. If the Evas_GL_Config object option values are bigger or higher than the rendering engine's, the Direct Rendering mode is disabled or abnormal rendering occurs. These special options are supported since Tizen 2.3.1. Evas_Object *win; // To use OpenGL ES, the application must switch on hardware acceleration // To enable that, call elm_config_accel_preference_set() with "opengl" // before creating the Elm window // This function is supported since 2.3. elm_config_accel_preference_set("opengl"); // Creating Elm window ad->win = elm_win_util_standard_add("Evas_GL Example", "Evas_GL Example"); You can create your EvasGL handler using the evas_gl_new(Evas * e) function. This initializer takes as a parameter the Evas canvas on which OpenGL ES is to be used. When developing an application with Elementary, use the canvas of your window: ad->evasgl = evas_gl_new(evas_object_evas_get(ad->win)); To free the memory allocated to this handler, use the evas_gl_free(Evas_GL *evas_gl) function. 2.Create a surface. You must allocate a new config object to fill the surface out using the evas_gl_config_new() function. As long as Evas creates a config object for the user, it takes care of the backward compatibility issue. Once you have your config object, you can specify the surface settings: appdata_s *ad; ad->cfg = evas_gl_config_new(); ad->cfg->color_format = EVAS_GL_RGBA_8888; // Surface Color Format ad->cfg->depth_bits = EVAS_GL_DEPTH_BIT_24; // Surface Depth Format ad->cfg->stencil_bits = EVAS_GL_STENCIL_NONE; // Surface Stencil Format ad->cfg->options_bits = EVAS_GL_OPTIONS_NONE; // Configuration options (here, no extra options) Once we have configured the surface behavior, we must initialize the surface using evas_gl_surface_create(Evas_GL* evas_gl, Evas_GL_Config * cfg, int w, int h). This function takes the given Evas_GL object as the first parameter and the pixel format, and configuration of the rendering surface as the second parameter. The last two parameters are the width and height of the surface, which we recover directly from the window. Evas_Coord w, h; evas_object_geometry_get(ad->win, NULL, NULL, &w, &h); ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, w, h); To manually delete a GL surface, use the evas_gl_surface_destroy(Evas_GL *evas_gl, Evas_GL_Surface *surf) function. 3.Create a context. Create a context for Evas_GL using the evas_gl_context_create(Evas_GL * evas_gl, Evas_GL_Context * share_ctx) function. You can merge the context with a higher context definition you must pass as a second parameter. ad->ctx = evas_gl_context_create(ad->evasgl, NULL); // This macro sets the global variable holding the GL API, // so that it is available to the application // Use it right after setting up the GL context object // For details, see Evas_GL_GLES2_Helpers.h EVAS_GL_GLOBAL_GLES2_USE(ad->evasgl, ad->ctx); To delete the context later, use the evas_gl_context_destroy(Evas_GL *evas_gl, Evas_GL_Context *ctx) function. To delete the entire configuration object, use the evas_gl_config_free(Evas_GL_Config *cfg) function instead. Getting OpenGL ES APIs If you want to get the API of OpenGL ES, you can get the API for rendering OpenGL ES with the evas_gl_api_get(Evas_GL *evas_gl_)function. This function returns a structure that contains all the OpenGL ES functions you can use to render in Evas. These functions consist of all the standard OpenGL ES 2.0 functions and any extra ones Evas has decided to provide in addition. If you have your code ported to OpenGL ES 2.0, it is easy to render to Evas. If you already use a global macro, such as EVAS_GL_GLOBAL_GLES2_XXX, you need not get the APIs. ad->glapi = evas_gl_api_get(ad->evasgl); Callbacks Now that we have configured the EvasGL environment, we declare a UI component in which all the OpenGL ES transformation takes place. In the example below, we selected the image component because it provides callbacks that allow us to play with the mouse events and coordinates, and we set up an image object that inherits the size of the parent window. ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win)); We define the "OpenGL ES main loop" function that is called every time the program attempts to have pixels from the image. We put all the OpenGL ES statements in charge of rendering the scene in this callback. evas_object_image_pixels_get_callback_set(ad->img, img_pixels_get_cb, ad); To define a function that takes care of the drawing using EvasGL (called the OpenGL ES main loop), use: static void img_pixels_get_cb(void *data, Evas_Object *obj) { appdata_s *ad = data; Evas_GL_API *gl = ad->glapi; // Rendering process evas_gl_make_current(ad->evasgl, ad->sfc, ad->ctx); // Because the surface size can be changed, set the viewport in this callback gl->glViewport(0, 0, ad->sfc_w, ad->sfc_h); // Paint it blue gl->glClearColor(0.2, 0.2, 0.6, 1.0); gl->glClear(GL_COLOR_BUFFER_BIT); // The usual OpenGL ES draw commands come here // draw_scene(); } At every tick, we must set the given context as a current context for the given surface using evas_gl_make_current(Evas_GL *evas_gl, Evas_GL_Surface *surf, Evas_GL_Context *ctx). You can use the Ecore_Animator to define the OpenGL ES main loop. To do so, create a callback that is called on every animation tick. This animation callback is used only to mark the image as "dirty", meaning that it needs an update next time Evas renders. It calls the pixel get callback that redraws the scene. The animator callback function is also triggered when the display is off. Use the ecore_animator_freeze() and ecore_animator_thaw() functions in the app_pause_cb and app_resume_cb callbacks for power saving. static Eina_Bool animate_cb(void *data) { Evas_Object *img = data; evas_object_image_pixels_dirty_set(img, EINA_TRUE); return ECORE_CALLBACK_RENEW; } ecore_animator_add(animate_cb, ad->img); You can define several other callbacks that have an impact on the drawing depending on the mouse, resize, and deletion events. evas_object_event_callback_add(ad->img, EVAS_CALLBACK_DEL, img_del_cb, ad); 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); evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, ad); Because the window size can be changed, you must set a resize callback for the window. In addition, you must recreate an Evas_GL_Surface in the resize callback and reset the viewport size with the new window size: 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_object_geometry_get(obj, NULL, NULL, &ad->sfc_w, &ad->sfc_h); evas_object_image_size_set(ad->img, ad->sfc_w, ad->sfc_h); evas_object_resize(ad->img, ad->sfc_w, ad->sfc_h); evas_object_show(ad->img); if (!ad->sfc) { Evas_Native_Surface ns; ad->sfc = evas_gl_surface_create(ad->evasgl, ad->cfg, ad->sfc_w, ad->sfc_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); } } Setting a Surface into the Image Object We can also fill in the native Surface information from the given EvasGL surface. For example, to adapt the surface to the target image when the size of the canvas changes, use the following code. Evas_Native_Surface ns; evas_gl_native_surface_get(ad->evasgl, ad->sfc, &ns); evas_object_image_native_surface_set(ad->img, &ns); |
Administrator
|
What's your plan then?
Julien Gouesse | Personal blog | Website
|
With Tizen, the only way to verify that an application uses approved api is to upload it to the store, they have a script that verifies if the libraries used by the app are legal.
I'll do this including a headless embedded jvm as part of the app. I haven't thought of what the app might do yet, it's only a test, but suggestions are welcome. If that passes it verifies the jvm can legally be included in an app. In that case it will be time to investigate, either how to create a tizen back end for jogl, or find another platform. Cheers, Peter. |
Free forum by Nabble | Edit this page |