renderer: set winsys on renderer before ->renderer_connect

When iterating through all the possible window systems trying to find
one we can successfully connect we now associated the current winsys
vtable with the renderer before calling winsys->renderer_connect in case
the implementation calls some other Cogl API that expects to be able to
determine the current winsys. For example calling _cogl_get_proc_address
when querying winsys extensions as part of a successful connect will
need to get at the current winsys vtable.
This commit is contained in:
Robert Bragg 2011-05-25 01:49:44 +01:00
parent 656f28de2f
commit b934859dde

View File

@ -184,6 +184,11 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
if (renderer_name && strcmp (winsys->name, renderer_name) != 0) if (renderer_name && strcmp (winsys->name, renderer_name) != 0)
continue; continue;
/* At least temporarily we will associate this winsys with
* the renderer in-case ->renderer_connect calls API that
* wants to query the current winsys... */
renderer->winsys_vtable = winsys;
if (!winsys->renderer_connect (renderer, &tmp_error)) if (!winsys->renderer_connect (renderer, &tmp_error))
{ {
g_string_append_c (error_message, '\n'); g_string_append_c (error_message, '\n');
@ -192,7 +197,6 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
} }
else else
{ {
renderer->winsys_vtable = winsys;
renderer->connected = TRUE; renderer->connected = TRUE;
g_string_free (error_message, TRUE); g_string_free (error_message, TRUE);
return TRUE; return TRUE;