Tizen(Headed) Native API  6.5
Evas GL GLES2 helpers

Provides a set of helper functions and macros to use GLES 2.0 with Evas GL.

This file redefines all the OpenGL-ES 2.0 functions as follow:

#define glFunction  __evas_gl_glapi->glFunction

Extension functions can then be checked for existence simply by writing:

if (glExtensionFunction)
  {
     ...
     glExtensionFunction(...);
     ...
  }

When using Elementary GLView, please include the header file Elementary_GL_Helpers.h instead.

This header file should be included when using Evas GL directly at a low level and with an OpenGL-ES 2.0 context only.

Note:
When this file is included, all glFunctions are now macros, which means that the Evas_GL_API struct can't be used anyore.
See also:
OpenGL with Elementary

Defines

#define EVAS_GL_GLES2_USE(evasgl, context)   Evas_GL_API *__evas_gl_glapi = evas_gl_context_api_get(evasgl, context);
 Macro to place at the beginning of any function using GLES 2.0 APIs.
#define EVAS_GL_GLES2_USE_OR_RETURN(evasgl, context, retval)
 Macro to place at the beginning of any function using GLES 2.0 APIs.
#define EVAS_GL_GLOBAL_GLES2_DECLARE()   extern Evas_GL_API *__evas_gl_glapi;
 Convenience macro to use the GL helpers in simple applications: declare.
#define EVAS_GL_GLOBAL_GLES2_DEFINE()   Evas_GL_API *__evas_gl_glapi = NULL;
 Convenience macro to use the GL helpers in simple applications: define.
#define EVAS_GL_GLOBAL_GLES2_USE(evgl, ctx)   do { __evas_gl_glapi = evas_gl_context_api_get(evgl, ctx); } while (0)
 Convenience macro to use the GL helpers in simple applications: use.
#define EVAS_GL_GLES2_API_CHECK()   ((__evas_gl_glapi != NULL) && (__evas_gl_glapi->version == EVAS_GL_API_VERSION) && (glActiveTexture))
 Macro to check that the GL APIs are properly set (GLES 2.0)

Define Documentation

#define EVAS_GL_GLES2_API_CHECK ( )    ((__evas_gl_glapi != NULL) && (__evas_gl_glapi->version == EVAS_GL_API_VERSION) && (glActiveTexture))

Macro to check that the GL APIs are properly set (GLES 2.0)

Since :
2.3
#define EVAS_GL_GLES2_USE (   evasgl,
  context 
)    Evas_GL_API *__evas_gl_glapi = evas_gl_context_api_get(evasgl, context);

Macro to place at the beginning of any function using GLES 2.0 APIs.

Normally, it is necessary to call each function using its pointer as in:

glapi->glFunction();

When using this macro, developers can then call all glFunctions without changing their code:

EVAS_GL_GLES2_USE(evasgl, context); // Add this at the beginning
glFunction(); // All calls 'look' normal
Note:
Please use ELEMENTARY_GLVIEW_USE() instead, when possible.
Since :
2.3
#define EVAS_GL_GLES2_USE_OR_RETURN (   evasgl,
  context,
  retval 
)
Value:
Evas_GL_API *__evas_gl_glapi = evas_gl_context_api_get(evasgl, context); \
   if (!__evas_gl_glapi) return retval;

Macro to place at the beginning of any function using GLES 2.0 APIs.

This is similar to EVAS_GL_GLES2_USE except that it will return from the function if the GL API can not be used.

Note:
Please use ELEMENTARY_GLVIEW_USE() instead, when possible.
Since :
2.3
#define EVAS_GL_GLOBAL_GLES2_DECLARE ( )    extern Evas_GL_API *__evas_gl_glapi;

Convenience macro to use the GL helpers in simple applications: declare.

EVAS_GL_GLOBAL_GLES2_DECLARE should be used in a global header for the application. For example, in a platform-specific compatibility header file.

To be used with OpenGL-ES 2.0 contexts.

Example of a global header file main.h:

#include <Evas_GL_GLES2_Helpers.h>
// other includes...

EVAS_GL_GLOBAL_GLES2_DECLARE()

// ...
Note:
Please use ELEMENTARY_GLVIEW_USE() instead, when possible.
See also:
ELEMENTARY_GLVIEW_GLOBAL_DECLARE
EVAS_GL_GLOBAL_GLES2_DEFINE
EVAS_GL_GLOBAL_GLES2_USE
Since :
2.3
#define EVAS_GL_GLOBAL_GLES2_DEFINE ( )    Evas_GL_API *__evas_gl_glapi = NULL;

Convenience macro to use the GL helpers in simple applications: define.

To be used with OpenGL-ES 2.0 contexts.

Example of a file glview.c:

#include "main.h"
EVAS_GL_GLOBAL_GLES2_DEFINE()

// ...

static inline void
evgl_init(...)
{
   // ...
   evasgl = evas_gl_new(canvas);
   // ...
   ctx = evas_gl_context_version_create(evasgl, NULL, EVAS_GL_GLES_2_X);
   EVAS_GL_GLOBAL_GLES2_USE(evasgl, ctx);
   // ...
}

// ...
See also:
ELEMENTARY_GLVIEW_GLOBAL_DEFINE
EVAS_GL_GLOBAL_GLES2_DECLARE
EVAS_GL_GLOBAL_GLES2_USE
Since :
2.3
#define EVAS_GL_GLOBAL_GLES2_USE (   evgl,
  ctx 
)    do { __evas_gl_glapi = evas_gl_context_api_get(evgl, ctx); } while (0)

Convenience macro to use the GL helpers in simple applications: use.

This macro will set the global variable holding the GL API so that it's available to the application.

It should be used right after setting up the GL context object.

See also:
ELEMENTARY_GLVIEW_GLOBAL_USE
EVAS_GL_GLOBAL_GLES2_DECLARE
EVAS_GL_GLOBAL_GLES2_DEFINE
Since :
2.3