[Cogl] [PATCH] sdl: Bind the default window when currently bound window is destroyed

Robert Bragg robert at sixbynine.org
Thu Dec 6 03:45:46 PST 2012


This looks good to land to me:

Reviewed-by: Robert Bragg <robert at linux.intel.com>

thanks,
- Robert

On Wed, Dec 5, 2012 at 7:43 PM, Neil Roberts <neil at linux.intel.com> wrote:
> Cogl always needs to have the context bound to something so that it
> can freely create resources such as textures even if there is no
> current window. When the currently bound SDLWindow is destroyed, SDL
> apparently explicitly unbinds the GL context. If something then later
> for example tries to create a texture Cogl would start getting GL
> errors and fail. To fix this the SDL winsys now just binds the dummy
> window before deiniting the currently bound onscreen.
> ---
>  cogl/winsys/cogl-winsys-sdl2.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/cogl/winsys/cogl-winsys-sdl2.c b/cogl/winsys/cogl-winsys-sdl2.c
> index 8c0c256..ca4f5fd 100644
> --- a/cogl/winsys/cogl-winsys-sdl2.c
> +++ b/cogl/winsys/cogl-winsys-sdl2.c
> @@ -388,7 +388,18 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
>        CoglContextSdl2 *sdl_context = context->winsys;
>
>        if (sdl_context->current_window == sdl_onscreen->window)
> -        sdl_context->current_window = NULL;
> +        {
> +          CoglDisplaySdl2 *sdl_display = context->display->winsys;
> +
> +          /* SDL explicitly unbinds the context when the currently
> +           * bound window is destroyed. Cogl always needs a context
> +           * bound so that for example it can create texture resources
> +           * at any time even without flushing a framebuffer.
> +           * Therefore we'll bind the dummy window. */
> +          SDL_GL_MakeCurrent (sdl_display->dummy_window,
> +                              sdl_display->context);
> +          sdl_context->current_window = sdl_display->dummy_window;
> +        }
>
>        SDL_DestroyWindow (sdl_onscreen->window);
>        sdl_onscreen->window = NULL;
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl


More information about the Cogl mailing list