107 lines
2.6 KiB
C
107 lines
2.6 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)
|
||
|
{
|
||
|
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)
|
||
|
{
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
/* Final connection API */
|
||
|
|
||
|
gboolean
|
||
|
cogl_renderer_connect (CoglRenderer *renderer, GError **error)
|
||
|
{
|
||
|
if (renderer->connected)
|
||
|
return TRUE;
|
||
|
|
||
|
renderer->connected = TRUE;
|
||
|
return TRUE;
|
||
|
}
|