* Add EvasGL support to software backend using OSMesa. Requires OSMesa
library. Due to caveats in OSMesa, surface config stays with a
- context
+ context rather than with a surface. So for now, the config of a
+ surface remains with the first context that it binds to. May need
+ to come up with a different solution in the near future.
+
+2012-01-12 Sung W. Park (sung_)
+
+ * Add new api evas_gl_config_new/free() to ensure backward compatibility.
+ Previously, the user simply declared a Evas_GL_Config object but this
+ can cause issues if new configs are added. Now we have evas allocate it
+ for you.
+
+
EVAS_GL_DEPTH_BIT_8 = 1,
EVAS_GL_DEPTH_BIT_16 = 2,
EVAS_GL_DEPTH_BIT_24 = 3,
- EVAS_GL_DEPTH_BIT_32 = 4,
+ EVAS_GL_DEPTH_BIT_32 = 4
} Evas_GL_Depth_Bits;
typedef enum _Evas_GL_Stencil_Bits
EVAS_GL_STENCIL_BIT_2 = 2,
EVAS_GL_STENCIL_BIT_4 = 3,
EVAS_GL_STENCIL_BIT_8 = 4,
- EVAS_GL_STENCIL_BIT_16 = 5,
+ EVAS_GL_STENCIL_BIT_16 = 5
} Evas_GL_Stencil_Bits;
+typedef enum _Evas_GL_Options_Bits
+{
+ EVAS_GL_OPTIONS_NONE = 0,
+ EVAS_GL_OPTIONS_DIRECT = (1<<0)
+} Evas_GL_Options_Bits;
+
struct _Evas_GL_Config
{
- Evas_GL_Color_Format color_format;
- Evas_GL_Depth_Bits depth_bits;
- Evas_GL_Stencil_Bits stencil_bits;
+ Evas_GL_Color_Format color_format;
+ Evas_GL_Depth_Bits depth_bits;
+ Evas_GL_Stencil_Bits stencil_bits;
+ Evas_GL_Options_Bits options_bits;
};
#define EVAS_GL_EXTENSIONS 1
{
Evas_GL_Context *ctx;
Evas_GL_Surface *sfc;
+ Evas_GL_Config *cfg;
Evas_GL *evasgl;
Evas_GL_API *glapi;
GLuint program;
int
main(int argc, char **argv)
{
- // config for the surface for evas_gl
- Evas_GL_Config config =
- {
- EVAS_GL_RGBA_8888,
- EVAS_GL_DEPTH_NONE,
- EVAS_GL_STENCIL_NONE
- };
// a size by default
int w = 256, h = 256;
// some variables we will use
// get the evas gl handle for doing gl things
gld->evasgl = evas_gl_new(canvas);
gld->glapi = evas_gl_api_get(gld->evasgl);
+
+ // Set a surface config
+ gld->cfg = evas_gl_config_new();
+ gld->cfg->color_format = EVAS_GL_RGBA_8888;
+ //gld->cfg->depth_bits = EVAS_GL_DEPTH_NONE; // Othe config options
+ //gld->cfg->stencil_bits = EVAS_GL_STENCIL_NONE;
+ //gld->cfg->options_bits = EVAS_GL_OPTIONS_NONE;
+
// create a surface and context
- gld->sfc = evas_gl_surface_create(gld->evasgl, &config, w, h);
+ gld->sfc = evas_gl_surface_create(gld->evasgl, gld->cfg, w, h);
gld->ctx = evas_gl_context_create(gld->evasgl, NULL);
//-//
//-//-//-// END GL INIT BLOB
evas_gl_surface_destroy(gld->evasgl, gld->sfc);
evas_gl_context_destroy(gld->evasgl, gld->ctx);
+ evas_gl_config_free(gld->cfg);
evas_gl_free(gld->evasgl);
free(gld);
}
EAPI void evas_gl_free (Evas_GL *evas_gl) EINA_ARG_NONNULL(1);
/**
+ * Allocates a new config object for the user to fill out.
+ *
+ * As long as the Evas creates a config object for the user, it takes care
+ * of the backward compatibility issue.
+ */
+EAPI Evas_GL_Config *evas_gl_config_new ();
+
+/**
+ * Frees a config object created from evas_gl_config_new.
+ *
+ * As long as the Evas creates a config object for the user, it takes care
+ * of the backward compatibility issue.
+ */
+EAPI void evas_gl_config_free (Evas_GL_Config *cfg) EINA_ARG_NONNULL(1);
+
+/**
* Creates and returns new Evas_GL_Surface object for GL Rendering.
*
* @param evas_gl The given Evas_GL object.
evas_gl->magic = MAGIC_EVAS_GL;
evas_gl->evas = e;
+ if (!evas_gl->evas->engine.func->gl_context_create)
+ {
+ ERR("GL engine not available\n");
+ free(evas_gl);
+ return NULL;
+ }
+
return evas_gl;
}
free(evas_gl);
}
+EAPI Evas_GL_Config *
+evas_gl_config_new()
+{
+ Evas_GL_Config *cfg;
+
+ cfg = calloc(1, sizeof(Evas_GL_Config));
+
+ if (!cfg) return NULL;
+
+ return cfg;
+}
+
+EAPI void
+evas_gl_config_free(Evas_GL_Config *cfg)
+{
+ if (cfg) free(cfg);
+}
+
EAPI Evas_GL_Surface *
evas_gl_surface_create(Evas_GL *evas_gl, Evas_GL_Config *config, int width, int height)
{
surf = calloc(1, sizeof(Evas_GL_Surface));
+ if (!surf) return NULL;
+
surf->data = evas_gl->evas->engine.func->gl_surface_create(evas_gl->evas->engine.data.output, config, width, height);
if (!surf->data)
return NULL;
}
- if (!evas_gl->evas->engine.func->gl_context_create)
- {
- ERR("GL engine not available\n");
- return NULL;
- }
-
// Call engine->gl_create_context
if (share_ctx)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
// EGL Extensions
- evasglexts = glsym_eglQueryString(re->win->egl_disp, EGL_EXTENSIONS);
+ if (glsym_eglQueryString)
+ {
+ evasglexts = glsym_eglQueryString(re->win->egl_disp, EGL_EXTENSIONS);
#else
- evasglexts = glXQueryExtensionsString(re->info->info.display,
- re->info->info.screen);
+ if (glsym_glXQueryExtensionsString)
+ {
+ evasglexts = glXQueryExtensionsString(re->info->info.display,
+ re->info->info.screen);
#endif
- DBG("--------EvasGL Extensions----------");
- for (i = 0; _evasgl_ext_entries[i].name != NULL; i++)
- {
- if ( (strstr(evasglexts, _evasgl_ext_entries[i].name) != NULL) ||
- (strstr(evasglexts, _evasgl_ext_entries[i].real_name) != NULL) )
+ DBG("--------EvasGL Extensions----------");
+ for (i = 0; _evasgl_ext_entries[i].name != NULL; i++)
{
- _evasgl_ext_entries[i].supported = 1;
- strcat(_evasgl_ext_string, _evasgl_ext_entries[i].name);
- strcat(_evasgl_ext_string, " ");
- DBG("\t%s", _evasgl_ext_entries[i].name);
+ if ( (strstr(evasglexts, _evasgl_ext_entries[i].name) != NULL) ||
+ (strstr(evasglexts, _evasgl_ext_entries[i].real_name) != NULL) )
+ {
+ _evasgl_ext_entries[i].supported = 1;
+ strcat(_evasgl_ext_string, _evasgl_ext_entries[i].name);
+ strcat(_evasgl_ext_string, " ");
+ DBG("\t%s", _evasgl_ext_entries[i].name);
+ }
}
+ DBG(" ");
}
- DBG(" ");
}
int _evas_engine_GL_X11_log_dom = -1;