2 * @defgroup GLView GLView
5 * @image html glview_inheritance_tree.png
6 * @image latex glview_inheritance_tree.eps
8 * A GLView widget allows for simple GL rendering in elementary environment.
9 * GLView hides all the complicated evas_gl details so that the user only
10 * has to deal with registering a few callback functions for rendering
11 * to a surface using OpenGL APIs.
13 * Below is an illustrative example of how to use GLView and and OpenGL
14 * to render in elementary environment.
15 * @ref glview_example_01_page
19 typedef void (*Elm_GLView_Func_Cb)(Evas_Object *obj);
21 typedef enum _Elm_GLView_Mode
24 ELM_GLVIEW_ALPHA = (1<<1), /**< Alpha channel enabled rendering mode */
25 ELM_GLVIEW_DEPTH = (1<<2), /**< Depth buffer enabled rendering mode */
26 ELM_GLVIEW_STENCIL = (1<<3), /**< Stencil buffer enabled rendering mode */
27 ELM_GLVIEW_DIRECT = (1<<4) /**< Direct rendering optimization hint */
31 * Defines a policy for the glview resizing.
33 * The resizing policy tells glview what to do with the underlying
34 * surface when resize happens. ELM_GLVIEW_RESIZE_POLICY_RECREATE
35 * will destroy the current surface and recreate the surface to the
36 * new size. ELM_GLVIEW_RESIZE_POLICY_SCALE will instead keep the
37 * current surface but only display the result at the desired size
40 * @note Default is ELM_GLVIEW_RESIZE_POLICY_RECREATE
44 ELM_GLVIEW_RESIZE_POLICY_RECREATE = 1, /**< Resize the internal surface along with the image */
45 ELM_GLVIEW_RESIZE_POLICY_SCALE = 2 /**< Only resize the internal image and not the surface */
46 } Elm_GLView_Resize_Policy;
49 * Defines a policy for gl rendering.
51 * The rendering policy tells glview where to run the gl rendering code.
52 * ELM_GLVIEW_RENDER_POLICY_ON_DEMAND tells glview to call the rendering
53 * calls on demand, which means that the rendering code gets called
54 * only when it is visible.
56 * @note Default is ELM_GLVIEW_RENDER_POLICY_ON_DEMAND
60 ELM_GLVIEW_RENDER_POLICY_ON_DEMAND = 1, /**< Render only when there is a need for redrawing */
61 ELM_GLVIEW_RENDER_POLICY_ALWAYS = 2 /**< Render always even when it is not visible */
62 } Elm_GLView_Render_Policy;
65 * Add a new glview to the parent
67 * @param parent The parent object
68 * @return The new object or NULL if it cannot be created
72 EAPI Evas_Object *elm_glview_add(Evas_Object *parent);
75 * Sets the size of the glview
77 * @param obj The glview object
78 * @param w width of the glview object
79 * @param h height of the glview object
83 EAPI void elm_glview_size_set(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
86 * Gets the size of the glview.
88 * @param obj The glview object
89 * @param w width of the glview object
90 * @param h height of the glview object
92 * Note that this function returns the actual image size of the
93 * glview. This means that when the scale policy is set to
94 * ELM_GLVIEW_RESIZE_POLICY_SCALE, it'll return the non-scaled
99 EAPI void elm_glview_size_get(const Evas_Object *obj, Evas_Coord *w, Evas_Coord *h);
102 * Gets the gl api struct for gl rendering
104 * @param obj The glview object
105 * @return The api object or NULL if it cannot be created
109 EAPI Evas_GL_API *elm_glview_gl_api_get(const Evas_Object *obj);
112 * Set the mode of the GLView. Supports alpha, depth, stencil.
114 * @param obj The glview object
115 * @param mode The mode Options OR'ed enabling Alpha, Depth, Stencil, Direct.
116 * @return True if set properly.
118 * Direct is a hint for the elm_glview to render directly to the window
119 * given that the right conditions are met. Otherwise it falls back
120 * to rendering to an offscreen buffer before it gets composited to the
125 EAPI Eina_Bool elm_glview_mode_set(Evas_Object *obj, Elm_GLView_Mode mode);
128 * Set the resize policy for the glview object.
130 * @param obj The glview object.
131 * @param policy The scaling policy.
133 * By default, the resize policy is set to ELM_GLVIEW_RESIZE_POLICY_RECREATE.
134 * When resize is called it destroys the previous surface and recreates the
135 * newly specified size. If the policy is set to
136 * ELM_GLVIEW_RESIZE_POLICY_SCALE, however, glview only scales the image
137 * object and not the underlying GL Surface.
141 EAPI Eina_Bool elm_glview_resize_policy_set(Evas_Object *obj, Elm_GLView_Resize_Policy policy);
144 * Set the render policy for the glview object.
146 * @param obj The glview object.
147 * @param policy The render policy.
149 * By default, the render policy is set to ELM_GLVIEW_RENDER_POLICY_ON_DEMAND.
150 * This policy is set such that during the render loop, glview is only
151 * redrawn if it needs to be redrawn. (i.e. when it is visible) If the policy
152 * is set to ELM_GLVIEWW_RENDER_POLICY_ALWAYS, it redraws regardless of
153 * whether it is visible or needs redrawing.
157 EAPI Eina_Bool elm_glview_render_policy_set(Evas_Object *obj, Elm_GLView_Render_Policy policy);
160 * Set the init function that runs once in the main loop.
162 * @param obj The glview object.
163 * @param func The init function to be registered.
165 * The registered init function gets called once during the render loop.
166 * This function allows glview to hide all the rendering context/surface
167 * details and have the user just call GL calls that they desire
168 * for initialization GL calls.
172 EAPI void elm_glview_init_func_set(Evas_Object *obj, Elm_GLView_Func_Cb func);
175 * Set the render function that runs in the main loop.
177 * @param obj The glview object.
178 * @param func The delete function to be registered.
180 * The registered del function gets called when GLView object is deleted.
181 * This function allows glview to hide all the rendering context/surface
182 * details and have the user just call GL calls that they desire
183 * when delete happens.
187 EAPI void elm_glview_del_func_set(Evas_Object *obj, Elm_GLView_Func_Cb func);
190 * Set the resize function that gets called when resize happens.
192 * @param obj The glview object.
193 * @param func The resize function to be registered.
195 * The resize function gets called during the render loop.
196 * This function allows glview to hide all the rendering context/surface
197 * details and have the user just call GL calls that they desire
198 * when resize happens.
202 EAPI void elm_glview_resize_func_set(Evas_Object *obj, Elm_GLView_Func_Cb func);
205 * Set the render function that runs in the main loop.
207 * The render function gets called in the main loop but whether it runs
208 * depends on the rendering policy and whether elm_glview_changed_set()
211 * @param obj The glview object.
212 * @param func The render function to be registered.
216 EAPI void elm_glview_render_func_set(Evas_Object *obj, Elm_GLView_Func_Cb func);
219 * Notifies that there has been changes in the GLView.
221 * @param obj The glview object.
225 EAPI void elm_glview_changed_set(Evas_Object *obj);