Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2011-04-18 11:24:51 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-10-13 17:34:30 -04:00
|
|
|
#include "cogl-util.h"
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
#include "cogl-internal.h"
|
2011-06-14 17:33:44 -04:00
|
|
|
#include "cogl-private.h"
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
#include "cogl-object.h"
|
2011-08-25 12:26:44 -04:00
|
|
|
#include "cogl-context-private.h"
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
|
|
|
|
#include "cogl-renderer.h"
|
|
|
|
#include "cogl-renderer-private.h"
|
|
|
|
#include "cogl-display-private.h"
|
|
|
|
#include "cogl-winsys-private.h"
|
2011-05-17 10:00:38 -04:00
|
|
|
#include "cogl-winsys-stub-private.h"
|
2011-08-03 13:15:54 -04:00
|
|
|
#include "cogl-config-private.h"
|
2012-08-31 14:28:27 -04:00
|
|
|
#include "cogl-error-private.h"
|
2011-11-09 02:19:26 -05:00
|
|
|
|
2011-12-13 11:23:25 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
|
2011-12-08 12:24:40 -05:00
|
|
|
#include "cogl-winsys-egl-x11-private.h"
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
#include "cogl-winsys-egl-wayland-private.h"
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
|
|
|
#include "cogl-winsys-egl-kms-private.h"
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
#include "cogl-winsys-egl-gdl-private.h"
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT
|
|
|
|
#include "cogl-winsys-egl-android-private.h"
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT
|
|
|
|
#include "cogl-winsys-egl-null-private.h"
|
|
|
|
#endif
|
2011-02-25 06:29:08 -05:00
|
|
|
#ifdef COGL_HAS_GLX_SUPPORT
|
2012-03-06 13:21:28 -05:00
|
|
|
#include "cogl-winsys-glx-private.h"
|
2011-02-25 06:29:08 -05:00
|
|
|
#endif
|
2011-05-09 12:48:50 -04:00
|
|
|
#ifdef COGL_HAS_WGL_SUPPORT
|
2012-03-06 13:21:28 -05:00
|
|
|
#include "cogl-winsys-wgl-private.h"
|
2011-05-09 12:48:50 -04:00
|
|
|
#endif
|
2011-12-14 07:09:53 -05:00
|
|
|
#ifdef COGL_HAS_SDL_SUPPORT
|
2012-03-06 13:21:28 -05:00
|
|
|
#include "cogl-winsys-sdl-private.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if COGL_HAS_XLIB_SUPPORT
|
|
|
|
#include "cogl-xlib-renderer.h"
|
2011-12-14 07:09:53 -05:00
|
|
|
#endif
|
2011-02-25 06:29:08 -05:00
|
|
|
|
|
|
|
typedef const CoglWinsysVtable *(*CoglWinsysVtableGetter) (void);
|
|
|
|
|
2012-08-31 19:04:00 -04:00
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
extern const CoglTextureDriver _cogl_texture_driver_gl;
|
|
|
|
extern const CoglDriverVtable _cogl_driver_gl;
|
|
|
|
#endif
|
|
|
|
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
|
|
|
|
extern const CoglTextureDriver _cogl_texture_driver_gles;
|
|
|
|
extern const CoglDriverVtable _cogl_driver_gles;
|
|
|
|
#endif
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static CoglWinsysVtableGetter _cogl_winsys_vtable_getters[] =
|
|
|
|
{
|
|
|
|
#ifdef COGL_HAS_GLX_SUPPORT
|
|
|
|
_cogl_winsys_glx_get_vtable,
|
|
|
|
#endif
|
2011-12-13 11:23:25 -05:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
|
|
|
|
_cogl_winsys_egl_xlib_get_vtable,
|
2011-12-08 12:24:40 -05:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
_cogl_winsys_egl_wayland_get_vtable,
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
|
|
|
_cogl_winsys_egl_kms_get_vtable,
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
|
|
|
|
_cogl_winsys_egl_gdl_get_vtable,
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_ANDROID_SUPPORT
|
|
|
|
_cogl_winsys_egl_android_get_vtable,
|
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_NULL_SUPPORT
|
|
|
|
_cogl_winsys_egl_null_get_vtable,
|
2011-05-09 12:48:50 -04:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_WGL_SUPPORT
|
|
|
|
_cogl_winsys_wgl_get_vtable,
|
2011-12-14 07:09:53 -05:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_SDL_SUPPORT
|
|
|
|
_cogl_winsys_sdl_get_vtable,
|
2011-02-25 06:29:08 -05:00
|
|
|
#endif
|
2011-05-17 10:00:38 -04:00
|
|
|
_cogl_winsys_stub_get_vtable,
|
2011-02-25 06:29:08 -05:00
|
|
|
};
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
static void _cogl_renderer_free (CoglRenderer *renderer);
|
|
|
|
|
|
|
|
COGL_OBJECT_DEFINE (Renderer, renderer);
|
|
|
|
|
2011-04-13 11:41:41 -04:00
|
|
|
typedef struct _CoglNativeFilterClosure
|
|
|
|
{
|
|
|
|
CoglNativeFilterFunc func;
|
|
|
|
void *data;
|
|
|
|
} CoglNativeFilterClosure;
|
|
|
|
|
2012-08-31 14:28:27 -04:00
|
|
|
uint32_t
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
cogl_renderer_error_quark (void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string ("cogl-renderer-error-quark");
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
static const CoglWinsysVtable *
|
|
|
|
_cogl_renderer_get_winsys (CoglRenderer *renderer)
|
|
|
|
{
|
|
|
|
return renderer->winsys_vtable;
|
|
|
|
}
|
|
|
|
|
2011-04-13 11:41:41 -04:00
|
|
|
static void
|
|
|
|
native_filter_closure_free (CoglNativeFilterClosure *closure)
|
|
|
|
{
|
|
|
|
g_slice_free (CoglNativeFilterClosure, closure);
|
|
|
|
}
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
static void
|
|
|
|
_cogl_renderer_free (CoglRenderer *renderer)
|
|
|
|
{
|
2011-02-25 06:29:08 -05:00
|
|
|
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
2012-01-25 14:29:29 -05:00
|
|
|
|
|
|
|
if (winsys)
|
|
|
|
winsys->renderer_disconnect (renderer);
|
2011-04-13 11:41:41 -04:00
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
|
|
|
|
if (renderer->libgl_module)
|
|
|
|
g_module_close (renderer->libgl_module);
|
|
|
|
#endif
|
|
|
|
|
2011-04-13 11:41:41 -04:00
|
|
|
g_slist_foreach (renderer->event_filters,
|
|
|
|
(GFunc) native_filter_closure_free,
|
|
|
|
NULL);
|
|
|
|
g_slist_free (renderer->event_filters);
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
g_free (renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglRenderer *
|
|
|
|
cogl_renderer_new (void)
|
|
|
|
{
|
|
|
|
CoglRenderer *renderer = g_new0 (CoglRenderer, 1);
|
|
|
|
|
2011-06-14 17:33:44 -04:00
|
|
|
_cogl_init ();
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
renderer->connected = FALSE;
|
2011-04-13 11:41:41 -04:00
|
|
|
renderer->event_filters = NULL;
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
|
2011-12-16 13:50:49 -05:00
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
|
|
|
renderer->xlib_enable_event_retrieval = TRUE;
|
|
|
|
#endif
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
return _cogl_renderer_object_new (renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if COGL_HAS_XLIB_SUPPORT
|
|
|
|
void
|
2011-06-28 09:16:24 -04:00
|
|
|
cogl_xlib_renderer_set_foreign_display (CoglRenderer *renderer,
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
Display *xdisplay)
|
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
|
|
|
|
/* NB: Renderers are considered immutable once connected */
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
|
|
|
|
renderer->foreign_xdpy = xdisplay;
|
2011-12-16 13:50:49 -05:00
|
|
|
|
|
|
|
/* If the application is using a foreign display then we can assume
|
|
|
|
it will also do its own event retrieval */
|
|
|
|
cogl_xlib_renderer_set_event_retrieval_enabled (renderer, FALSE);
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
Display *
|
2011-06-28 09:16:24 -04:00
|
|
|
cogl_xlib_renderer_get_foreign_display (CoglRenderer *renderer)
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (cogl_is_renderer (renderer), NULL);
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
|
|
|
|
return renderer->foreign_xdpy;
|
|
|
|
}
|
2011-12-16 13:50:49 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
cogl_xlib_renderer_set_event_retrieval_enabled (CoglRenderer *renderer,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool enable)
|
2011-12-16 13:50:49 -05:00
|
|
|
{
|
|
|
|
_COGL_RETURN_IF_FAIL (cogl_is_renderer (renderer));
|
|
|
|
/* NB: Renderers are considered immutable once connected */
|
|
|
|
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
|
|
|
|
|
|
|
renderer->xlib_enable_event_retrieval = enable;
|
|
|
|
}
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
#endif /* COGL_HAS_XLIB_SUPPORT */
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
|
|
|
|
CoglOnscreenTemplate *onscreen_template,
|
2012-08-31 14:28:27 -04:00
|
|
|
CoglError **error)
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
{
|
2010-11-05 08:28:33 -04:00
|
|
|
CoglDisplay *display;
|
|
|
|
|
2011-12-05 14:11:52 -05:00
|
|
|
if (!cogl_renderer_connect (renderer, error))
|
2010-11-05 08:28:33 -04:00
|
|
|
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);
|
2011-05-17 10:00:38 -04:00
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
static CoglBool
|
2011-07-07 15:44:56 -04:00
|
|
|
_cogl_renderer_choose_driver (CoglRenderer *renderer,
|
2012-08-31 14:28:27 -04:00
|
|
|
CoglError **error)
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
|
|
|
const char *driver_name = g_getenv ("COGL_DRIVER");
|
|
|
|
const char *libgl_name;
|
2012-04-26 07:18:56 -04:00
|
|
|
CoglBool support_gles2_constraint = FALSE;
|
|
|
|
GList *l;
|
2011-07-07 15:44:56 -04:00
|
|
|
|
2011-08-03 13:15:54 -04:00
|
|
|
if (!driver_name)
|
|
|
|
driver_name = _cogl_config_driver;
|
|
|
|
|
2012-04-26 07:18:56 -04:00
|
|
|
for (l = renderer->constraints; l; l = l->next)
|
|
|
|
{
|
|
|
|
CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
|
|
|
|
if (constraint == COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2)
|
|
|
|
{
|
|
|
|
support_gles2_constraint = TRUE;
|
|
|
|
|
|
|
|
if (!driver_name && renderer->driver_override == COGL_DRIVER_ANY)
|
|
|
|
renderer->driver_override = COGL_DRIVER_GLES2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-20 03:47:41 -04:00
|
|
|
#ifdef COGL_DEFAULT_DRIVER
|
|
|
|
if (!driver_name)
|
|
|
|
driver_name = COGL_DEFAULT_DRIVER;
|
|
|
|
#endif
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
#ifdef HAVE_COGL_GL
|
2012-02-23 11:41:27 -05:00
|
|
|
if (renderer->driver_override == COGL_DRIVER_GL ||
|
|
|
|
(renderer->driver_override == COGL_DRIVER_ANY &&
|
|
|
|
(driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gl"))))
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
|
|
|
renderer->driver = COGL_DRIVER_GL;
|
|
|
|
libgl_name = COGL_GL_LIBNAME;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_COGL_GLES2
|
2012-02-23 11:41:27 -05:00
|
|
|
if (renderer->driver_override == COGL_DRIVER_GLES2 ||
|
|
|
|
(renderer->driver_override == COGL_DRIVER_ANY &&
|
|
|
|
(driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles2"))))
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
|
|
|
renderer->driver = COGL_DRIVER_GLES2;
|
|
|
|
libgl_name = COGL_GLES2_LIBNAME;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_COGL_GLES
|
2012-02-23 11:41:27 -05:00
|
|
|
if (renderer->driver_override == COGL_DRIVER_GLES1 ||
|
|
|
|
(renderer->driver_override == COGL_DRIVER_ANY &&
|
|
|
|
(driver_name == NULL || !g_ascii_strcasecmp (driver_name, "gles1"))))
|
2011-07-07 15:44:56 -04:00
|
|
|
{
|
|
|
|
renderer->driver = COGL_DRIVER_GLES1;
|
|
|
|
libgl_name = COGL_GLES1_LIBNAME;
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error,
|
2011-07-07 15:44:56 -04:00
|
|
|
COGL_DRIVER_ERROR,
|
|
|
|
COGL_DRIVER_ERROR_NO_SUITABLE_DRIVER_FOUND,
|
|
|
|
"No suitable driver found");
|
|
|
|
return FALSE;
|
|
|
|
|
2012-04-26 07:18:56 -04:00
|
|
|
found:
|
|
|
|
|
|
|
|
if (support_gles2_constraint &&
|
|
|
|
renderer->driver != COGL_DRIVER_GLES2)
|
|
|
|
{
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error,
|
2012-04-26 07:18:56 -04:00
|
|
|
COGL_RENDERER_ERROR,
|
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"No suitable driver found");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-07 15:44:56 -04:00
|
|
|
|
|
|
|
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
|
|
|
|
|
2011-07-18 13:07:06 -04:00
|
|
|
renderer->libgl_module = g_module_open (libgl_name,
|
2011-07-07 15:44:56 -04:00
|
|
|
G_MODULE_BIND_LAZY);
|
|
|
|
|
|
|
|
if (renderer->libgl_module == NULL)
|
|
|
|
{
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error, COGL_DRIVER_ERROR,
|
2011-07-07 15:44:56 -04:00
|
|
|
COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY,
|
|
|
|
"Failed to dynamically open the GL library \"%s\"",
|
|
|
|
libgl_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_DIRECTLY_LINKED_GL_LIBRARY */
|
|
|
|
|
2012-08-31 19:04:00 -04:00
|
|
|
switch (renderer->driver)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
case COGL_DRIVER_GL:
|
|
|
|
renderer->driver_vtable = &_cogl_driver_gl;
|
|
|
|
renderer->texture_driver = &_cogl_texture_driver_gl;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined (HAVE_COGL_GLES) || defined (HAVE_COGL_GLES2)
|
|
|
|
case COGL_DRIVER_GLES1:
|
|
|
|
case COGL_DRIVER_GLES2:
|
|
|
|
renderer->driver_vtable = &_cogl_driver_gles;
|
|
|
|
renderer->texture_driver = &_cogl_texture_driver_gles;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
/* Final connection API */
|
|
|
|
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 16:56:40 -04:00
|
|
|
CoglBool
|
2012-08-31 14:28:27 -04:00
|
|
|
cogl_renderer_connect (CoglRenderer *renderer, CoglError **error)
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
{
|
2011-02-25 06:29:08 -05:00
|
|
|
int i;
|
|
|
|
GString *error_message;
|
2012-04-26 07:18:56 -04:00
|
|
|
CoglBool constraints_failed = FALSE;
|
2011-02-25 06:29:08 -05:00
|
|
|
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
if (renderer->connected)
|
|
|
|
return TRUE;
|
|
|
|
|
2011-07-07 15:44:56 -04:00
|
|
|
/* The driver needs to be chosen before connecting the renderer
|
|
|
|
because eglInitialize requires the library containing the GL API
|
|
|
|
to be loaded before its called */
|
|
|
|
if (!_cogl_renderer_choose_driver (renderer, error))
|
|
|
|
return FALSE;
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
error_message = g_string_new ("");
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (_cogl_winsys_vtable_getters); i++)
|
|
|
|
{
|
|
|
|
const CoglWinsysVtable *winsys = _cogl_winsys_vtable_getters[i]();
|
2012-08-31 14:28:27 -04:00
|
|
|
CoglError *tmp_error = NULL;
|
2012-01-13 11:48:26 -05:00
|
|
|
GList *l;
|
2012-04-26 07:18:56 -04:00
|
|
|
CoglBool skip_due_to_constraints = FALSE;
|
2011-04-18 11:24:51 -04:00
|
|
|
|
2011-06-20 08:29:12 -04:00
|
|
|
if (renderer->winsys_id_override != COGL_WINSYS_ID_ANY)
|
|
|
|
{
|
|
|
|
if (renderer->winsys_id_override != winsys->id)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *user_choice = getenv ("COGL_RENDERER");
|
2011-08-03 13:15:54 -04:00
|
|
|
if (!user_choice)
|
|
|
|
user_choice = _cogl_config_renderer;
|
2011-12-09 12:13:17 -05:00
|
|
|
if (user_choice &&
|
|
|
|
g_ascii_strcasecmp (winsys->name, user_choice) != 0)
|
2011-06-20 08:29:12 -04:00
|
|
|
continue;
|
|
|
|
}
|
2011-04-18 11:24:51 -04:00
|
|
|
|
2012-01-13 11:48:26 -05:00
|
|
|
for (l = renderer->constraints; l; l = l->next)
|
|
|
|
{
|
|
|
|
CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
|
|
|
|
if (!(winsys->constraints & constraint))
|
|
|
|
{
|
2012-04-26 07:18:56 -04:00
|
|
|
skip_due_to_constraints = TRUE;
|
2012-01-13 11:48:26 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-04-26 07:18:56 -04:00
|
|
|
if (skip_due_to_constraints)
|
|
|
|
{
|
|
|
|
constraints_failed |= TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-13 11:48:26 -05:00
|
|
|
|
2011-05-24 20:49:44 -04:00
|
|
|
/* 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;
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
if (!winsys->renderer_connect (renderer, &tmp_error))
|
|
|
|
{
|
|
|
|
g_string_append_c (error_message, '\n');
|
|
|
|
g_string_append (error_message, tmp_error->message);
|
2012-08-31 14:28:27 -04:00
|
|
|
cogl_error_free (tmp_error);
|
2011-02-25 06:29:08 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
renderer->connected = TRUE;
|
|
|
|
g_string_free (error_message, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2010-11-05 08:28:33 -04:00
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
if (!renderer->connected)
|
|
|
|
{
|
2012-04-26 07:18:56 -04:00
|
|
|
if (constraints_failed)
|
|
|
|
{
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error, COGL_RENDERER_ERROR,
|
2012-04-26 07:18:56 -04:00
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"Failed to connected to any renderer due to constraints");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-25 06:29:08 -05:00
|
|
|
renderer->winsys_vtable = NULL;
|
2012-08-31 14:28:27 -04:00
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
2011-02-25 06:29:08 -05:00
|
|
|
COGL_WINSYS_ERROR_INIT,
|
|
|
|
"Failed to connected to any renderer: %s",
|
|
|
|
error_message->str);
|
|
|
|
g_string_free (error_message, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
Adds renderer,display,onscreen-template and swap-chain stubs
As part of the process of splitting Cogl out as a standalone graphics
API we need to introduce some API concepts that will allow us to
initialize a new CoglContext when Clutter isn't there to handle that for
us...
The new objects roughly in the order that they are (optionally) involved
in constructing a context are: CoglRenderer, CoglOnscreenTemplate,
CoglSwapChain and CoglDisplay.
Conceptually a CoglRenderer represents a means for rendering. Cogl
supports rendering via OpenGL or OpenGL ES 1/2.0 and those APIs are
accessed through a number of different windowing APIs such as GLX, EGL,
SDL or WGL and more. Potentially in the future Cogl could render using
D3D or even by using libdrm and directly banging the hardware. All these
choices are wrapped up in the configuration of a CoglRenderer.
Conceptually a CoglDisplay represents a display pipeline for a renderer.
Although Cogl doesn't aim to provide a detailed abstraction of display
hardware, on some platforms we can give control over multiple display
planes (On TV platforms for instance video content may be on one plane
and 3D would be on another so a CoglDisplay lets you select the plane
up-front.)
Another aspect of CoglDisplay is that it lets us negotiate a display
pipeline that best supports the type of CoglOnscreen framebuffers we are
planning to create. For instance if you want transparent CoglOnscreen
framebuffers then we have to be sure the display pipeline wont discard
the alpha component of your framebuffers. Or if you want to use
double/tripple buffering that requires support from the display
pipeline.
CoglOnscreenTemplate and CoglSwapChain are how we describe our default
CoglOnscreen framebuffer configuration which can affect the
configuration of the display pipeline.
The default/simple way we expect most CoglContexts to be constructed
will be via something like:
if (!cogl_context_new (NULL, &error))
g_error ("Failed to construct a CoglContext: %s", error->message);
Where that NULL is for an optional "display" parameter and NULL says to
Cogl "please just try to do something sensible".
If you want some more control though you can manually construct a
CoglDisplay something like:
display = cogl_display_new (NULL, NULL);
cogl_gdl_display_set_plane (display, plane);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
And in a similar fashion to cogl_context_new() you can optionally pass
a NULL "renderer" and/or a NULL "onscreen template" so Cogl will try to
just do something sensible.
If you need to change the CoglOnscreen defaults you can provide a
template something like:
chain = cogl_swap_chain_new ();
cogl_swap_chain_set_has_alpha (chain, TRUE);
cogl_swap_chain_set_length (chain, 3);
onscreen_template = cogl_onscreen_template_new (chain);
cogl_onscreen_template_set_pixel_format (onscreen_template,
COGL_PIXEL_FORMAT_RGB565);
display = cogl_display_new (NULL, onscreen_template);
if (!cogl_display_setup (display, &error))
g_error ("Failed to setup a CoglDisplay: %s", error->message);
2011-02-25 12:06:50 -05:00
|
|
|
}
|
2011-04-13 11:41:41 -04:00
|
|
|
|
|
|
|
CoglFilterReturn
|
2011-06-28 08:38:50 -04:00
|
|
|
_cogl_renderer_handle_native_event (CoglRenderer *renderer,
|
|
|
|
void *event)
|
2011-04-13 11:41:41 -04:00
|
|
|
{
|
|
|
|
GSList *l, *next;
|
|
|
|
|
|
|
|
/* Pass the event on to all of the registered filters in turn */
|
|
|
|
for (l = renderer->event_filters; l; l = next)
|
|
|
|
{
|
|
|
|
CoglNativeFilterClosure *closure = l->data;
|
|
|
|
|
|
|
|
/* The next pointer is taken now so that we can handle the
|
|
|
|
closure being removed during emission */
|
|
|
|
next = l->next;
|
|
|
|
|
|
|
|
if (closure->func (event, closure->data) == COGL_FILTER_REMOVE)
|
|
|
|
return COGL_FILTER_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the backend for the renderer also wants to see the events, it
|
|
|
|
should just register its own filter */
|
|
|
|
|
|
|
|
return COGL_FILTER_CONTINUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-28 08:38:50 -04:00
|
|
|
_cogl_renderer_add_native_filter (CoglRenderer *renderer,
|
|
|
|
CoglNativeFilterFunc func,
|
|
|
|
void *data)
|
2011-04-13 11:41:41 -04:00
|
|
|
{
|
|
|
|
CoglNativeFilterClosure *closure;
|
|
|
|
|
|
|
|
closure = g_slice_new (CoglNativeFilterClosure);
|
|
|
|
closure->func = func;
|
|
|
|
closure->data = data;
|
|
|
|
|
|
|
|
renderer->event_filters = g_slist_prepend (renderer->event_filters, closure);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-06-28 08:38:50 -04:00
|
|
|
_cogl_renderer_remove_native_filter (CoglRenderer *renderer,
|
|
|
|
CoglNativeFilterFunc func,
|
|
|
|
void *data)
|
2011-04-13 11:41:41 -04:00
|
|
|
{
|
|
|
|
GSList *l, *prev = NULL;
|
|
|
|
|
|
|
|
for (l = renderer->event_filters; l; prev = l, l = l->next)
|
|
|
|
{
|
|
|
|
CoglNativeFilterClosure *closure = l->data;
|
|
|
|
|
|
|
|
if (closure->func == func && closure->data == data)
|
|
|
|
{
|
|
|
|
native_filter_closure_free (closure);
|
|
|
|
if (prev)
|
|
|
|
prev->next = g_slist_delete_link (prev->next, l);
|
|
|
|
else
|
|
|
|
renderer->event_filters =
|
|
|
|
g_slist_delete_link (renderer->event_filters, l);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-20 08:29:12 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
cogl_renderer_set_winsys_id (CoglRenderer *renderer,
|
|
|
|
CoglWinsysID winsys_id)
|
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
2011-06-20 08:29:12 -04:00
|
|
|
|
|
|
|
renderer->winsys_id_override = winsys_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglWinsysID
|
|
|
|
cogl_renderer_get_winsys_id (CoglRenderer *renderer)
|
|
|
|
{
|
2011-10-13 17:34:30 -04:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (renderer->connected, 0);
|
2011-06-20 08:29:12 -04:00
|
|
|
|
|
|
|
return renderer->winsys_vtable->id;
|
|
|
|
}
|
2011-07-27 07:30:02 -04:00
|
|
|
|
|
|
|
void *
|
|
|
|
_cogl_renderer_get_proc_address (CoglRenderer *renderer,
|
2012-06-20 07:42:31 -04:00
|
|
|
const char *name,
|
|
|
|
CoglBool in_core)
|
2011-07-27 07:30:02 -04:00
|
|
|
{
|
|
|
|
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
|
|
|
|
2012-06-20 07:42:31 -04:00
|
|
|
return winsys->renderer_get_proc_address (renderer, name, in_core);
|
2011-07-27 07:30:02 -04:00
|
|
|
}
|
2011-08-25 12:26:44 -04:00
|
|
|
|
|
|
|
int
|
|
|
|
cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer)
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
_COGL_GET_CONTEXT (ctx, 0);
|
|
|
|
|
|
|
|
#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES2)
|
|
|
|
if (ctx->driver == COGL_DRIVER_GL || ctx->driver == COGL_DRIVER_GLES2)
|
|
|
|
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
2012-01-13 11:48:26 -05:00
|
|
|
|
|
|
|
void
|
2012-01-17 09:49:28 -05:00
|
|
|
cogl_renderer_add_constraint (CoglRenderer *renderer,
|
|
|
|
CoglRendererConstraint constraint)
|
2012-01-13 11:48:26 -05:00
|
|
|
{
|
|
|
|
g_return_if_fail (!renderer->connected);
|
|
|
|
renderer->constraints = g_list_prepend (renderer->constraints,
|
|
|
|
GUINT_TO_POINTER (constraint));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cogl_renderer_remove_constraint (CoglRenderer *renderer,
|
|
|
|
CoglRendererConstraint constraint)
|
|
|
|
{
|
|
|
|
g_return_if_fail (!renderer->connected);
|
|
|
|
renderer->constraints = g_list_remove (renderer->constraints,
|
|
|
|
GUINT_TO_POINTER (constraint));
|
|
|
|
}
|
|
|
|
|
2012-02-23 11:41:27 -05:00
|
|
|
void
|
|
|
|
cogl_renderer_set_driver (CoglRenderer *renderer,
|
|
|
|
CoglDriver driver)
|
|
|
|
{
|
|
|
|
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
|
|
|
renderer->driver_override = driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglDriver
|
|
|
|
cogl_renderer_get_driver (CoglRenderer *renderer)
|
|
|
|
{
|
|
|
|
_COGL_RETURN_VAL_IF_FAIL (renderer->connected, 0);
|
|
|
|
|
|
|
|
return renderer->driver;
|
|
|
|
}
|