d40cdfa3e1
This migrates all the GLX window system code down from the Clutter backend code into a Cogl winsys. Moving OpenGL window system binding code down from Clutter into Cogl is the biggest blocker to having Cogl become a standalone 3D graphics library, so this is an important step in that direction.
130 lines
3.1 KiB
C
130 lines
3.1 KiB
C
/*
|
|
* Cogl
|
|
*
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
*
|
|
* Copyright (C) 2011 Intel Corporation.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*
|
|
* Authors:
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include "cogl.h"
|
|
#include "cogl-internal.h"
|
|
#include "cogl-object.h"
|
|
|
|
#include "cogl-renderer.h"
|
|
#include "cogl-renderer-private.h"
|
|
#include "cogl-display-private.h"
|
|
#include "cogl-winsys-private.h"
|
|
|
|
static void _cogl_renderer_free (CoglRenderer *renderer);
|
|
|
|
COGL_OBJECT_DEFINE (Renderer, renderer);
|
|
|
|
GQuark
|
|
cogl_renderer_error_quark (void)
|
|
{
|
|
return g_quark_from_static_string ("cogl-renderer-error-quark");
|
|
}
|
|
|
|
static void
|
|
_cogl_renderer_free (CoglRenderer *renderer)
|
|
{
|
|
#ifdef COGL_HAS_FULL_WINSYS
|
|
_cogl_winsys_renderer_disconnect (renderer);
|
|
#endif
|
|
g_free (renderer);
|
|
}
|
|
|
|
CoglRenderer *
|
|
cogl_renderer_new (void)
|
|
{
|
|
CoglRenderer *renderer = g_new0 (CoglRenderer, 1);
|
|
|
|
renderer->connected = FALSE;
|
|
|
|
return _cogl_renderer_object_new (renderer);
|
|
}
|
|
|
|
#if COGL_HAS_XLIB_SUPPORT
|
|
void
|
|
cogl_renderer_xlib_set_foreign_display (CoglRenderer *renderer,
|
|
Display *xdisplay)
|
|
{
|
|
g_return_if_fail (cogl_is_renderer (renderer));
|
|
|
|
/* NB: Renderers are considered immutable once connected */
|
|
g_return_if_fail (!renderer->connected);
|
|
|
|
renderer->foreign_xdpy = xdisplay;
|
|
}
|
|
|
|
Display *
|
|
cogl_renderer_xlib_get_foreign_display (CoglRenderer *renderer)
|
|
{
|
|
g_return_val_if_fail (cogl_is_renderer (renderer), NULL);
|
|
|
|
return renderer->foreign_xdpy;
|
|
}
|
|
#endif /* COGL_HAS_XLIB_SUPPORT */
|
|
|
|
gboolean
|
|
cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
|
|
CoglOnscreenTemplate *onscreen_template,
|
|
GError **error)
|
|
{
|
|
#ifdef COGL_HAS_FULL_WINSYS
|
|
CoglDisplay *display;
|
|
|
|
if (!_cogl_winsys_renderer_connect (renderer, error))
|
|
return FALSE;
|
|
|
|
display = cogl_display_new (renderer, onscreen_template);
|
|
if (!cogl_display_setup (display, error))
|
|
{
|
|
cogl_object_unref (display);
|
|
return FALSE;
|
|
}
|
|
|
|
cogl_object_unref (display);
|
|
#endif
|
|
return TRUE;
|
|
}
|
|
|
|
/* Final connection API */
|
|
|
|
gboolean
|
|
cogl_renderer_connect (CoglRenderer *renderer, GError **error)
|
|
{
|
|
if (renderer->connected)
|
|
return TRUE;
|
|
|
|
#ifdef COGL_HAS_FULL_WINSYS
|
|
if (!_cogl_winsys_renderer_connect (renderer, error))
|
|
return FALSE;
|
|
#endif
|
|
|
|
renderer->connected = TRUE;
|
|
return TRUE;
|
|
}
|