Exemple #1
0
static void android_gfx_ctx_destroy(void *data)
{
   gfx_ctx_android_data_t *android = (gfx_ctx_android_data_t*)
      driver.video_context_data;
   (void)data;

   if (!android)
      return;

   android_gfx_ctx_destroy_resources(android);

   if (driver.video_context_data)
      free(driver.video_context_data);
   driver.video_context_data = NULL;
}
Exemple #2
0
static void android_gfx_ctx_destroy(void *data)
{
   driver_t *driver = driver_get_ptr();
   gfx_ctx_android_data_t *android = NULL;
   
   android = (gfx_ctx_android_data_t*)driver->video_context_data;
   (void)data;

   if (!android)
      return;

   android_gfx_ctx_destroy_resources(android);

   if (driver->video_context_data)
      free(driver->video_context_data);
   driver->video_context_data = NULL;
}
Exemple #3
0
static bool android_gfx_ctx_init(void *data)
{
   int var;
   EGLint num_config, egl_version_major, egl_version_minor;
   EGLint format;
   EGLint context_attributes[] = {
      EGL_CONTEXT_CLIENT_VERSION, g_es3 ? 3 : 2,
      EGL_NONE
   };
   const EGLint attribs[] = {
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
      EGL_BLUE_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_RED_SIZE, 8,
      EGL_ALPHA_SIZE, 8,
      EGL_DEPTH_SIZE, 16,
      EGL_NONE
   };
   driver_t *driver = driver_get_ptr();
   gfx_ctx_android_data_t *android = NULL;
   struct android_app *android_app = (struct android_app*)g_android;
   
   if (!android_app)
      return false;

   android = (gfx_ctx_android_data_t*)
      calloc(1, sizeof(gfx_ctx_android_data_t));

   if (!android)
      return false;

   RARCH_LOG("Android EGL: GLES version = %d.\n", g_es3 ? 3 : 2);

   android->g_egl_dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
   android->g_use_hw_ctx = ((gl_t*)data)->shared_context_use;

   if (!android->g_egl_dpy)
   {
      RARCH_ERR("[Android/EGL]: Couldn't get EGL display.\n");
      goto error;
   }

   if (!eglInitialize(android->g_egl_dpy,
            &egl_version_major, &egl_version_minor))
      goto error;

   RARCH_LOG("[ANDROID/EGL]: EGL version: %d.%d\n",
         egl_version_major, egl_version_minor);

   if (!eglChooseConfig(android->g_egl_dpy,
            attribs, &android->g_egl_config, 1, &num_config))
      goto error;

   var = eglGetConfigAttrib(android->g_egl_dpy, android->g_egl_config,
         EGL_NATIVE_VISUAL_ID, &format);

   if (!var)
   {
      RARCH_ERR("eglGetConfigAttrib failed: %d.\n", var);
      goto error;
   }

   ANativeWindow_setBuffersGeometry(android_app->window, 0, 0, format);

   android->g_egl_ctx = eglCreateContext(android->g_egl_dpy,
         android->g_egl_config, EGL_NO_CONTEXT, context_attributes);
   RARCH_LOG("[Android/EGL]: EGL context: %p.\n", (void*)android->g_egl_ctx);

   if (android->g_egl_ctx == EGL_NO_CONTEXT)
      goto error;

   if (android->g_use_hw_ctx)
   {
      android->g_egl_hw_ctx = eglCreateContext(android->g_egl_dpy,
           android->g_egl_config, android->g_egl_ctx,
            context_attributes);
      RARCH_LOG("[Android/EGL]: Created shared context: %p.\n",
            (void*)android->g_egl_hw_ctx);

      if (android->g_egl_hw_ctx == EGL_NO_CONTEXT)
         goto error;
   }

   android->g_egl_surf = eglCreateWindowSurface(android->g_egl_dpy,
         android->g_egl_config, android_app->window, 0);
   if (!android->g_egl_surf)
      goto error;

   if (!eglMakeCurrent(android->g_egl_dpy, android->g_egl_surf,
            android->g_egl_surf, android->g_egl_ctx))
      goto error;

   driver->video_context_data = android;

   return true;

error:
   android_gfx_ctx_destroy_resources(android);

   if (android)
      free(android);

   return false;
}