Exemplo n.º 1
0
/**
 * Called via eglCreateContext(), drv->API.CreateContext().
 */
static EGLContext
xlib_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
                      EGLContext share_list, const EGLint *attrib_list)
{
   struct xlib_egl_driver *xdrv = xlib_egl_driver(drv);
   _EGLConfig *conf = _eglLookupConfig(drv, dpy, config);
   struct xlib_egl_context *ctx;
   struct st_context *share_ctx = NULL; /* XXX fix */
   __GLcontextModes visual;

   ctx = CALLOC_STRUCT(xlib_egl_context);
   if (!ctx)
      return EGL_NO_CONTEXT;

   /* let EGL lib init the common stuff */
   if (!_eglInitContext(drv, dpy, &ctx->Base, config, attrib_list)) {
      free(ctx);
      return EGL_NO_CONTEXT;
   }

   /* API-dependent context creation */
   switch (ctx->Base.ClientAPI) {
   case EGL_OPENVG_API:
   case EGL_OPENGL_ES_API:
      _eglLog(_EGL_DEBUG, "Create Context for ES version %d\n",
              ctx->Base.ClientVersion);
      /* fall-through */
   case EGL_OPENGL_API:
      /* create a softpipe context */
      ctx->pipe = softpipe_create(xdrv->screen, xdrv->winsys, NULL);
      /* Now do xlib / state tracker inits here */
      _eglConfigToContextModesRec(conf, &visual);
      ctx->Context = st_create_context(ctx->pipe, &visual, share_ctx);
      break;
   default:
      _eglError(EGL_BAD_MATCH, "eglCreateContext(unsupported API)");
      free(ctx);
      return EGL_NO_CONTEXT;
   }

   _eglSaveContext(&ctx->Base);

   return _eglGetContextHandle(&ctx->Base);
}
/**
 * Just a placeholder/demo function.  Real driver will never use this!
 */
EGLContext
_eglCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
                  EGLContext share_list, const EGLint *attrib_list)
{
#if 0 /* example code */
   _EGLContext *context;

   context = (_EGLContext *) calloc(1, sizeof(_EGLContext));
   if (!context)
      return EGL_NO_CONTEXT;

   if (!_eglInitContext(drv, dpy, context, config, attrib_list)) {
      free(context);
      return EGL_NO_CONTEXT;
   }

   _eglSaveContext(context);
   return context->Handle;
#endif
   return EGL_NO_CONTEXT;
}
Exemplo n.º 3
0
static EGLContext
fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)
{
   GLcontext *ctx;
   _EGLConfig *conf;
   fbContext *c;
   _EGLDisplay *disp = _eglLookupDisplay(dpy);
   struct dd_function_table functions;
   GLvisual vis;
   int i;

   conf = _eglLookupConfig(drv, dpy, config);
   if (!conf) {
      _eglError(EGL_BAD_CONFIG, "eglCreateContext");
      return EGL_NO_CONTEXT;
   }

   for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
      switch (attrib_list[i]) {
         /* no attribs defined for now */
      default:
         _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext");
         return EGL_NO_CONTEXT;
      }
   }

   c = (fbContext *) calloc(1, sizeof(fbContext));
   if (!c)
      return EGL_NO_CONTEXT;

   _eglInitContext(&c->Base);
   c->Base.Display = disp;
   c->Base.Config = conf;
   c->Base.DrawSurface = EGL_NO_SURFACE;
   c->Base.ReadSurface = EGL_NO_SURFACE;

   /* generate handle and insert into hash table */
   _eglSaveContext(&c->Base);
   assert(c->Base.Handle);

   /* Init default driver functions then plug in our FBdev-specific functions
    */
   _mesa_init_driver_functions(&functions);
   init_core_functions(&functions);

   _eglConfigToContextModesRec(conf, &vis);

   ctx = c->glCtx = _mesa_create_context(&vis, NULL, &functions, (void *)c);
   if (!c->glCtx) {
      _mesa_free(c);
      return GL_FALSE;
   }

   /* Create module contexts */
   _swrast_CreateContext( ctx );
   _vbo_CreateContext( ctx );
   _tnl_CreateContext( ctx );
   _swsetup_CreateContext( ctx );
   _swsetup_Wakeup( ctx );


   /* use default TCL pipeline */
   {
      TNLcontext *tnl = TNL_CONTEXT(ctx);
      tnl->Driver.RunPipeline = _tnl_run_pipeline;
   }

   _mesa_enable_sw_extensions(ctx);

   return c->Base.Handle;
}