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 17:06:50 +00:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
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 17:06:50 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Intel Corporation.
|
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
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 17:06:50 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
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 17:06:50 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
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 17:06:50 +00:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-04-18 15:24:51 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2011-10-13 21:34:30 +00:00
|
|
|
#include "cogl-util.h"
|
2011-06-14 21:33:44 +00: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 17:06:50 +00:00
|
|
|
#include "cogl-object.h"
|
2011-08-25 16:26:44 +00:00
|
|
|
#include "cogl-context-private.h"
|
2013-01-20 18:47:40 +00:00
|
|
|
#include "cogl-util-gl-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 17:06:50 +00:00
|
|
|
|
|
|
|
#include "cogl-renderer.h"
|
|
|
|
#include "cogl-renderer-private.h"
|
|
|
|
#include "cogl-display-private.h"
|
|
|
|
#include "cogl-winsys-private.h"
|
2011-05-17 14:00:38 +00:00
|
|
|
#include "cogl-winsys-stub-private.h"
|
2011-08-03 17:15:54 +00:00
|
|
|
#include "cogl-config-private.h"
|
2012-08-31 18:28:27 +00:00
|
|
|
#include "cogl-error-private.h"
|
2011-11-09 07:19:26 +00:00
|
|
|
|
2011-12-13 16:23:25 +00:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
|
2011-12-08 17:24:40 +00: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 11:29:08 +00:00
|
|
|
#ifdef COGL_HAS_GLX_SUPPORT
|
2012-03-06 18:21:28 +00:00
|
|
|
#include "cogl-winsys-glx-private.h"
|
2011-02-25 11:29:08 +00:00
|
|
|
#endif
|
2011-05-09 16:48:50 +00:00
|
|
|
#ifdef COGL_HAS_WGL_SUPPORT
|
2012-03-06 18:21:28 +00:00
|
|
|
#include "cogl-winsys-wgl-private.h"
|
2011-05-09 16:48:50 +00:00
|
|
|
#endif
|
2011-12-14 12:09:53 +00:00
|
|
|
#ifdef COGL_HAS_SDL_SUPPORT
|
2012-03-06 18:21:28 +00:00
|
|
|
#include "cogl-winsys-sdl-private.h"
|
|
|
|
#endif
|
|
|
|
|
2012-12-29 02:00:00 +00:00
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
2012-03-06 18:21:28 +00:00
|
|
|
#include "cogl-xlib-renderer.h"
|
2011-12-14 12:09:53 +00:00
|
|
|
#endif
|
2011-02-25 11:29:08 +00:00
|
|
|
|
|
|
|
typedef const CoglWinsysVtable *(*CoglWinsysVtableGetter) (void);
|
|
|
|
|
2012-08-31 23:04:00 +00: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
|
|
|
|
|
2012-09-12 21:39:46 +00:00
|
|
|
extern const CoglDriverVtable _cogl_driver_nop;
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
typedef struct _CoglDriverDescription
|
|
|
|
{
|
|
|
|
CoglDriver id;
|
|
|
|
const char *name;
|
|
|
|
CoglRendererConstraint constraints;
|
2013-11-25 16:11:36 +00:00
|
|
|
/* It would be nice to make this a pointer and then use a compound
|
|
|
|
* literal from C99 to initialise it but we probably can't get away
|
|
|
|
* with using C99 here. Instead we'll just use a fixed-size array.
|
|
|
|
* GCC should complain if someone adds an 8th feature to a
|
|
|
|
* driver. */
|
|
|
|
const CoglPrivateFeature private_features[8];
|
2013-05-11 17:15:25 +00:00
|
|
|
const CoglDriverVtable *vtable;
|
|
|
|
const CoglTextureDriver *texture_driver;
|
|
|
|
const char *libgl_name;
|
|
|
|
} CoglDriverDescription;
|
|
|
|
|
|
|
|
static CoglDriverDescription _cogl_drivers[] =
|
|
|
|
{
|
|
|
|
#ifdef HAVE_COGL_GL
|
|
|
|
{
|
|
|
|
COGL_DRIVER_GL,
|
|
|
|
"gl",
|
|
|
|
0,
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
COGL_PRIVATE_FEATURE_GL_FIXED,
|
2013-05-11 17:15:25 +00:00
|
|
|
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
|
2013-11-25 16:11:36 +00:00
|
|
|
-1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_gl,
|
|
|
|
&_cogl_texture_driver_gl,
|
|
|
|
COGL_GL_LIBNAME,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
COGL_DRIVER_GL3,
|
|
|
|
"gl3",
|
|
|
|
0,
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
2013-05-11 17:15:25 +00:00
|
|
|
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
|
2013-11-25 16:11:36 +00:00
|
|
|
-1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_gl,
|
|
|
|
&_cogl_texture_driver_gl,
|
|
|
|
COGL_GL_LIBNAME,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_COGL_GLES2
|
|
|
|
{
|
|
|
|
COGL_DRIVER_GLES2,
|
|
|
|
"gles2",
|
|
|
|
COGL_RENDERER_CONSTRAINT_SUPPORTS_COGL_GLES2,
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
COGL_PRIVATE_FEATURE_GL_EMBEDDED,
|
2013-05-11 17:15:25 +00:00
|
|
|
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
|
2013-11-25 16:11:36 +00:00
|
|
|
-1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_gles,
|
|
|
|
&_cogl_texture_driver_gles,
|
|
|
|
COGL_GLES2_LIBNAME,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_COGL_GLES
|
|
|
|
{
|
|
|
|
COGL_DRIVER_GLES1,
|
|
|
|
"gles1",
|
|
|
|
0,
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
COGL_PRIVATE_FEATURE_GL_EMBEDDED,
|
2013-05-11 17:15:25 +00:00
|
|
|
COGL_PRIVATE_FEATURE_GL_FIXED,
|
2013-11-25 16:11:36 +00:00
|
|
|
-1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_gles,
|
|
|
|
&_cogl_texture_driver_gles,
|
|
|
|
COGL_GLES1_LIBNAME,
|
|
|
|
},
|
2013-05-11 19:02:43 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USING_EMSCRIPTEN
|
|
|
|
{
|
|
|
|
COGL_DRIVER_WEBGL,
|
|
|
|
"webgl",
|
|
|
|
0,
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
COGL_PRIVATE_FEATURE_GL_EMBEDDED,
|
|
|
|
COGL_PRIVATE_FEATURE_GL_PROGRAMMABLE,
|
2013-05-11 19:02:43 +00:00
|
|
|
COGL_PRIVATE_FEATURE_GL_WEB,
|
2013-11-25 16:11:36 +00:00
|
|
|
-1 },
|
2013-05-11 19:02:43 +00:00
|
|
|
&_cogl_driver_gles,
|
|
|
|
&_cogl_texture_driver_gles,
|
|
|
|
NULL,
|
|
|
|
},
|
2013-05-11 17:15:25 +00:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
COGL_DRIVER_NOP,
|
|
|
|
"nop",
|
|
|
|
0, /* constraints satisfied */
|
2013-11-25 16:11:36 +00:00
|
|
|
{ -1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_nop,
|
|
|
|
NULL, /* texture driver */
|
|
|
|
NULL /* libgl_name */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-02-25 11:29:08 +00:00
|
|
|
static CoglWinsysVtableGetter _cogl_winsys_vtable_getters[] =
|
|
|
|
{
|
|
|
|
#ifdef COGL_HAS_GLX_SUPPORT
|
|
|
|
_cogl_winsys_glx_get_vtable,
|
|
|
|
#endif
|
2011-12-13 16:23:25 +00:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
|
|
|
|
_cogl_winsys_egl_xlib_get_vtable,
|
2011-12-08 17:24:40 +00: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 16:48:50 +00:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_WGL_SUPPORT
|
|
|
|
_cogl_winsys_wgl_get_vtable,
|
2011-12-14 12:09:53 +00:00
|
|
|
#endif
|
|
|
|
#ifdef COGL_HAS_SDL_SUPPORT
|
|
|
|
_cogl_winsys_sdl_get_vtable,
|
2011-02-25 11:29:08 +00:00
|
|
|
#endif
|
2011-05-17 14:00:38 +00:00
|
|
|
_cogl_winsys_stub_get_vtable,
|
2011-02-25 11:29:08 +00: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 17:06:50 +00:00
|
|
|
static void _cogl_renderer_free (CoglRenderer *renderer);
|
|
|
|
|
|
|
|
COGL_OBJECT_DEFINE (Renderer, renderer);
|
|
|
|
|
2011-04-13 15:41:41 +00:00
|
|
|
typedef struct _CoglNativeFilterClosure
|
|
|
|
{
|
|
|
|
CoglNativeFilterFunc func;
|
|
|
|
void *data;
|
|
|
|
} CoglNativeFilterClosure;
|
|
|
|
|
2012-08-31 18:28:27 +00: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 17:06:50 +00:00
|
|
|
cogl_renderer_error_quark (void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string ("cogl-renderer-error-quark");
|
|
|
|
}
|
|
|
|
|
2011-02-25 11:29:08 +00:00
|
|
|
static const CoglWinsysVtable *
|
|
|
|
_cogl_renderer_get_winsys (CoglRenderer *renderer)
|
|
|
|
{
|
|
|
|
return renderer->winsys_vtable;
|
|
|
|
}
|
|
|
|
|
2011-04-13 15:41:41 +00: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 17:06:50 +00:00
|
|
|
static void
|
|
|
|
_cogl_renderer_free (CoglRenderer *renderer)
|
|
|
|
{
|
2011-02-25 11:29:08 +00:00
|
|
|
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
2012-01-25 19:29:29 +00:00
|
|
|
|
2013-04-18 13:19:43 +00:00
|
|
|
_cogl_closure_list_disconnect_all (&renderer->idle_closures);
|
|
|
|
|
2012-01-25 19:29:29 +00:00
|
|
|
if (winsys)
|
|
|
|
winsys->renderer_disconnect (renderer);
|
2011-04-13 15:41:41 +00:00
|
|
|
|
2011-07-07 19:44:56 +00:00
|
|
|
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
|
|
|
|
if (renderer->libgl_module)
|
|
|
|
g_module_close (renderer->libgl_module);
|
|
|
|
#endif
|
|
|
|
|
2011-04-13 15:41:41 +00:00
|
|
|
g_slist_foreach (renderer->event_filters,
|
|
|
|
(GFunc) native_filter_closure_free,
|
|
|
|
NULL);
|
|
|
|
g_slist_free (renderer->event_filters);
|
|
|
|
|
2013-04-16 22:46:03 +00:00
|
|
|
g_array_free (renderer->poll_fds, 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 17:06:50 +00:00
|
|
|
g_free (renderer);
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglRenderer *
|
|
|
|
cogl_renderer_new (void)
|
|
|
|
{
|
|
|
|
CoglRenderer *renderer = g_new0 (CoglRenderer, 1);
|
|
|
|
|
2011-06-14 21:33:44 +00: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 17:06:50 +00:00
|
|
|
renderer->connected = FALSE;
|
2011-04-13 15:41:41 +00: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 17:06:50 +00:00
|
|
|
|
2013-04-16 22:46:03 +00:00
|
|
|
renderer->poll_fds = g_array_new (FALSE, TRUE, sizeof (CoglPollFD));
|
|
|
|
|
2013-06-08 22:03:25 +00:00
|
|
|
_cogl_list_init (&renderer->idle_closures);
|
2013-04-18 13:19:43 +00:00
|
|
|
|
2011-12-16 18:50:49 +00:00
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
|
|
|
renderer->xlib_enable_event_retrieval = TRUE;
|
|
|
|
#endif
|
|
|
|
|
2013-05-14 14:43:04 +00:00
|
|
|
#ifdef COGL_HAS_WIN32_SUPPORT
|
|
|
|
renderer->win32_enable_event_retrieval = TRUE;
|
|
|
|
#endif
|
|
|
|
|
2013-07-04 12:14:04 +00:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
|
|
|
renderer->wayland_enable_event_dispatch = TRUE;
|
|
|
|
#endif
|
|
|
|
|
2014-02-28 14:40:31 +00:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_KMS_SUPPORT
|
|
|
|
renderer->kms_fd = -1;
|
|
|
|
#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 17:06:50 +00:00
|
|
|
return _cogl_renderer_object_new (renderer);
|
|
|
|
}
|
|
|
|
|
2012-12-29 02:00:00 +00:00
|
|
|
#ifdef COGL_HAS_XLIB_SUPPORT
|
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 17:06:50 +00:00
|
|
|
void
|
2011-06-28 13:16:24 +00: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 17:06:50 +00:00
|
|
|
Display *xdisplay)
|
|
|
|
{
|
2011-10-13 21:34:30 +00: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 17:06:50 +00:00
|
|
|
|
|
|
|
/* NB: Renderers are considered immutable once connected */
|
2011-10-13 21:34:30 +00: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 17:06:50 +00:00
|
|
|
|
|
|
|
renderer->foreign_xdpy = xdisplay;
|
2011-12-16 18:50:49 +00: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 17:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Display *
|
2011-06-28 13:16:24 +00: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 17:06:50 +00:00
|
|
|
{
|
2011-10-13 21:34:30 +00: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 17:06:50 +00:00
|
|
|
|
|
|
|
return renderer->foreign_xdpy;
|
|
|
|
}
|
2011-12-16 18:50:49 +00: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 20:56:40 +00:00
|
|
|
CoglBool enable)
|
2011-12-16 18:50:49 +00: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 17:06:50 +00: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 20:56:40 +00: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 17:06:50 +00:00
|
|
|
cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
|
|
|
|
CoglOnscreenTemplate *onscreen_template,
|
2012-08-31 18:28:27 +00: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 17:06:50 +00:00
|
|
|
{
|
2010-11-05 12:28:33 +00:00
|
|
|
CoglDisplay *display;
|
|
|
|
|
2011-12-05 19:11:52 +00:00
|
|
|
if (!cogl_renderer_connect (renderer, error))
|
2010-11-05 12:28:33 +00: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 14:00:38 +00: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 17:06:50 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
typedef CoglBool (*DriverCallback) (CoglDriverDescription *description,
|
|
|
|
void *user_data);
|
2011-07-07 19:44:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
static void
|
|
|
|
foreach_driver_description (CoglDriver driver_override,
|
|
|
|
DriverCallback callback,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
#ifdef COGL_DEFAULT_DRIVER
|
|
|
|
const CoglDriverDescription *default_driver = NULL;
|
|
|
|
#endif
|
|
|
|
int i;
|
2011-08-03 17:15:54 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
if (driver_override != COGL_DRIVER_ANY)
|
2012-04-26 11:18:56 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
|
2012-04-26 11:18:56 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
if (_cogl_drivers[i].id == driver_override)
|
|
|
|
{
|
|
|
|
callback (&_cogl_drivers[i], user_data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-04-26 11:18:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
g_warn_if_reached ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef COGL_DEFAULT_DRIVER
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
|
|
|
|
{
|
|
|
|
const CoglDriverDescription *desc = &_cogl_drivers[i];
|
|
|
|
if (g_ascii_strcasecmp (desc->name, COGL_DEFAULT_DRIVER) == 0)
|
|
|
|
{
|
|
|
|
default_driver = desc;
|
2012-04-26 11:18:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
if (default_driver)
|
|
|
|
{
|
|
|
|
if (!callback (default_driver, user_data))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
|
|
|
|
{
|
2012-06-20 07:47:41 +00:00
|
|
|
#ifdef COGL_DEFAULT_DRIVER
|
2013-05-11 17:15:25 +00:00
|
|
|
if (&_cogl_drivers[i] == default_driver)
|
|
|
|
continue;
|
2012-06-20 07:47:41 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
if (!callback (&_cogl_drivers[i], user_data))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglDriver
|
|
|
|
driver_name_to_id (const char *name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
|
2011-07-07 19:44:56 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
if (g_ascii_strcasecmp (_cogl_drivers[i].name, name) == 0)
|
|
|
|
return _cogl_drivers[i].id;
|
2011-07-07 19:44:56 +00:00
|
|
|
}
|
2012-09-26 19:32:36 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
return COGL_DRIVER_ANY;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
driver_id_to_name (CoglDriver id)
|
|
|
|
{
|
|
|
|
switch (id)
|
2012-09-26 19:32:36 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
case COGL_DRIVER_GL:
|
|
|
|
return "gl";
|
|
|
|
case COGL_DRIVER_GL3:
|
|
|
|
return "gl3";
|
|
|
|
case COGL_DRIVER_GLES1:
|
|
|
|
return "gles1";
|
|
|
|
case COGL_DRIVER_GLES2:
|
|
|
|
return "gles2";
|
2013-05-11 19:02:43 +00:00
|
|
|
case COGL_DRIVER_WEBGL:
|
|
|
|
return "webgl";
|
2013-05-11 17:15:25 +00:00
|
|
|
case COGL_DRIVER_NOP:
|
|
|
|
return "nop";
|
|
|
|
case COGL_DRIVER_ANY:
|
|
|
|
g_warn_if_reached ();
|
|
|
|
return "any";
|
2012-09-26 19:32:36 +00:00
|
|
|
}
|
2011-07-07 19:44:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
g_warn_if_reached ();
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _SatisfyConstraintsState
|
|
|
|
{
|
|
|
|
GList *constraints;
|
|
|
|
const CoglDriverDescription *driver_description;
|
|
|
|
} SatisfyConstraintsState;
|
|
|
|
|
|
|
|
static CoglBool
|
|
|
|
satisfy_constraints (CoglDriverDescription *description,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
SatisfyConstraintsState *state = user_data;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = state->constraints; l; l = l->next)
|
2011-07-07 19:44:56 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
|
|
|
|
|
2013-06-27 08:30:04 +00:00
|
|
|
/* Most of the constraints only affect the winsys selection so
|
|
|
|
* we'll filter them out */
|
|
|
|
if (!(constraint & COGL_RENDERER_DRIVER_CONSTRAINTS))
|
|
|
|
continue;
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
/* If the driver doesn't satisfy any constraint then continue
|
|
|
|
* to the next driver description */
|
|
|
|
if (!(constraint & description->constraints))
|
|
|
|
return TRUE;
|
2011-07-07 19:44:56 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
state->driver_description = description;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static CoglBool
|
|
|
|
_cogl_renderer_choose_driver (CoglRenderer *renderer,
|
|
|
|
CoglError **error)
|
|
|
|
{
|
|
|
|
const char *driver_name = g_getenv ("COGL_DRIVER");
|
|
|
|
CoglDriver driver_override = COGL_DRIVER_ANY;
|
|
|
|
const char *invalid_override = NULL;
|
|
|
|
const char *libgl_name;
|
|
|
|
SatisfyConstraintsState state;
|
|
|
|
const CoglDriverDescription *desc;
|
2013-11-25 16:11:36 +00:00
|
|
|
int i;
|
2013-05-11 17:15:25 +00:00
|
|
|
|
|
|
|
if (!driver_name)
|
|
|
|
driver_name = _cogl_config_driver;
|
|
|
|
|
|
|
|
if (driver_name)
|
2011-07-07 19:44:56 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
driver_override = driver_name_to_id (driver_name);
|
|
|
|
if (driver_override == COGL_DRIVER_ANY)
|
|
|
|
invalid_override = driver_name;
|
2011-07-07 19:44:56 +00:00
|
|
|
}
|
2013-06-27 08:57:02 +00:00
|
|
|
|
|
|
|
if (renderer->driver_override != COGL_DRIVER_ANY)
|
|
|
|
{
|
|
|
|
if (driver_override != COGL_DRIVER_ANY &&
|
|
|
|
renderer->driver_override != driver_override)
|
|
|
|
{
|
|
|
|
_cogl_set_error (error,
|
|
|
|
COGL_RENDERER_ERROR,
|
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"Application driver selection conflicts with driver "
|
|
|
|
"specified in configuration");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver_override = renderer->driver_override;
|
|
|
|
}
|
2011-07-07 19:44:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
if (driver_override != COGL_DRIVER_ANY)
|
2012-09-12 21:39:46 +00:00
|
|
|
{
|
2013-05-11 17:15:25 +00:00
|
|
|
CoglBool found = FALSE;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < G_N_ELEMENTS (_cogl_drivers); i++)
|
|
|
|
{
|
|
|
|
if (_cogl_drivers[i].id == driver_override)
|
|
|
|
{
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
|
|
|
invalid_override = driver_id_to_name (driver_override);
|
2012-09-12 21:39:46 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
if (invalid_override)
|
|
|
|
{
|
|
|
|
_cogl_set_error (error,
|
|
|
|
COGL_RENDERER_ERROR,
|
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"Driver \"%s\" is not available",
|
|
|
|
invalid_override);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
state.driver_description = NULL;
|
|
|
|
state.constraints = renderer->constraints;
|
2011-07-07 19:44:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
foreach_driver_description (driver_override,
|
|
|
|
satisfy_constraints,
|
|
|
|
&state);
|
2012-04-26 11:18:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
if (!state.driver_description)
|
2012-04-26 11:18:56 +00:00
|
|
|
{
|
2012-08-31 18:28:27 +00:00
|
|
|
_cogl_set_error (error,
|
2013-05-11 17:15:25 +00:00
|
|
|
COGL_RENDERER_ERROR,
|
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"No suitable driver found");
|
2012-04-26 11:18:56 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-07 19:44:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
desc = state.driver_description;
|
|
|
|
renderer->driver = desc->id;
|
|
|
|
renderer->driver_vtable = desc->vtable;
|
|
|
|
renderer->texture_driver = desc->texture_driver;
|
|
|
|
libgl_name = desc->libgl_name;
|
|
|
|
|
2013-11-25 16:11:36 +00:00
|
|
|
memset(renderer->private_features, 0, sizeof (renderer->private_features));
|
|
|
|
for (i = 0; desc->private_features[i] != -1; i++)
|
|
|
|
COGL_FLAGS_SET (renderer->private_features,
|
|
|
|
desc->private_features[i], TRUE);
|
|
|
|
|
2011-07-07 19:44:56 +00:00
|
|
|
#ifndef HAVE_DIRECTLY_LINKED_GL_LIBRARY
|
|
|
|
|
2013-11-25 16:11:36 +00:00
|
|
|
if (COGL_FLAGS_GET (renderer->private_features,
|
|
|
|
COGL_PRIVATE_FEATURE_ANY_GL))
|
2011-07-07 19:44:56 +00:00
|
|
|
{
|
2012-09-12 21:39:46 +00:00
|
|
|
renderer->libgl_module = g_module_open (libgl_name,
|
|
|
|
G_MODULE_BIND_LAZY);
|
|
|
|
|
|
|
|
if (renderer->libgl_module == NULL)
|
|
|
|
{
|
|
|
|
_cogl_set_error (error, COGL_DRIVER_ERROR,
|
|
|
|
COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY,
|
|
|
|
"Failed to dynamically open the GL library \"%s\"",
|
|
|
|
libgl_name);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-07-07 19:44:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_DIRECTLY_LINKED_GL_LIBRARY */
|
|
|
|
|
|
|
|
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 17:06:50 +00: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 20:56:40 +00:00
|
|
|
CoglBool
|
2012-08-31 18:28:27 +00: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 17:06:50 +00:00
|
|
|
{
|
2011-02-25 11:29:08 +00:00
|
|
|
int i;
|
|
|
|
GString *error_message;
|
2012-04-26 11:18:56 +00:00
|
|
|
CoglBool constraints_failed = FALSE;
|
2011-02-25 11:29:08 +00: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 17:06:50 +00:00
|
|
|
if (renderer->connected)
|
|
|
|
return TRUE;
|
|
|
|
|
2011-07-07 19:44:56 +00: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 11:29:08 +00: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 18:28:27 +00:00
|
|
|
CoglError *tmp_error = NULL;
|
2012-01-13 16:48:26 +00:00
|
|
|
GList *l;
|
2012-04-26 11:18:56 +00:00
|
|
|
CoglBool skip_due_to_constraints = FALSE;
|
2011-04-18 15:24:51 +00:00
|
|
|
|
2011-06-20 12:29:12 +00: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 17:15:54 +00:00
|
|
|
if (!user_choice)
|
|
|
|
user_choice = _cogl_config_renderer;
|
2011-12-09 17:13:17 +00:00
|
|
|
if (user_choice &&
|
|
|
|
g_ascii_strcasecmp (winsys->name, user_choice) != 0)
|
2011-06-20 12:29:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-04-18 15:24:51 +00:00
|
|
|
|
2012-01-13 16:48:26 +00:00
|
|
|
for (l = renderer->constraints; l; l = l->next)
|
|
|
|
{
|
|
|
|
CoglRendererConstraint constraint = GPOINTER_TO_UINT (l->data);
|
|
|
|
if (!(winsys->constraints & constraint))
|
|
|
|
{
|
2012-04-26 11:18:56 +00:00
|
|
|
skip_due_to_constraints = TRUE;
|
2012-01-13 16:48:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-04-26 11:18:56 +00:00
|
|
|
if (skip_due_to_constraints)
|
|
|
|
{
|
|
|
|
constraints_failed |= TRUE;
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-13 16:48:26 +00:00
|
|
|
|
2011-05-25 00:49:44 +00: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 11:29:08 +00: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 18:28:27 +00:00
|
|
|
cogl_error_free (tmp_error);
|
2011-02-25 11:29:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
renderer->connected = TRUE;
|
|
|
|
g_string_free (error_message, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2010-11-05 12:28:33 +00:00
|
|
|
|
2011-02-25 11:29:08 +00:00
|
|
|
if (!renderer->connected)
|
|
|
|
{
|
2012-04-26 11:18:56 +00:00
|
|
|
if (constraints_failed)
|
|
|
|
{
|
2012-08-31 18:28:27 +00:00
|
|
|
_cogl_set_error (error, COGL_RENDERER_ERROR,
|
2012-04-26 11:18:56 +00:00
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"Failed to connected to any renderer due to constraints");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-02-25 11:29:08 +00:00
|
|
|
renderer->winsys_vtable = NULL;
|
2012-08-31 18:28:27 +00:00
|
|
|
_cogl_set_error (error, COGL_WINSYS_ERROR,
|
2011-02-25 11:29:08 +00: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 17:06:50 +00:00
|
|
|
}
|
2011-04-13 15:41:41 +00:00
|
|
|
|
|
|
|
CoglFilterReturn
|
2011-06-28 12:38:50 +00:00
|
|
|
_cogl_renderer_handle_native_event (CoglRenderer *renderer,
|
|
|
|
void *event)
|
2011-04-13 15:41:41 +00: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 12:38:50 +00:00
|
|
|
_cogl_renderer_add_native_filter (CoglRenderer *renderer,
|
|
|
|
CoglNativeFilterFunc func,
|
|
|
|
void *data)
|
2011-04-13 15:41:41 +00: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 12:38:50 +00:00
|
|
|
_cogl_renderer_remove_native_filter (CoglRenderer *renderer,
|
|
|
|
CoglNativeFilterFunc func,
|
|
|
|
void *data)
|
2011-04-13 15:41:41 +00: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 12:29:12 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
cogl_renderer_set_winsys_id (CoglRenderer *renderer,
|
|
|
|
CoglWinsysID winsys_id)
|
|
|
|
{
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_IF_FAIL (!renderer->connected);
|
2011-06-20 12:29:12 +00:00
|
|
|
|
|
|
|
renderer->winsys_id_override = winsys_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglWinsysID
|
|
|
|
cogl_renderer_get_winsys_id (CoglRenderer *renderer)
|
|
|
|
{
|
2011-10-13 21:34:30 +00:00
|
|
|
_COGL_RETURN_VAL_IF_FAIL (renderer->connected, 0);
|
2011-06-20 12:29:12 +00:00
|
|
|
|
|
|
|
return renderer->winsys_vtable->id;
|
|
|
|
}
|
2011-07-27 11:30:02 +00:00
|
|
|
|
|
|
|
void *
|
|
|
|
_cogl_renderer_get_proc_address (CoglRenderer *renderer,
|
2012-06-20 11:42:31 +00:00
|
|
|
const char *name,
|
|
|
|
CoglBool in_core)
|
2011-07-27 11:30:02 +00:00
|
|
|
{
|
|
|
|
const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer);
|
|
|
|
|
2012-06-20 11:42:31 +00:00
|
|
|
return winsys->renderer_get_proc_address (renderer, name, in_core);
|
2011-07-27 11:30:02 +00:00
|
|
|
}
|
2011-08-25 16:26:44 +00: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)
|
2013-01-30 13:53:48 +00:00
|
|
|
if (cogl_has_feature (ctx, COGL_FEATURE_ID_GLSL) ||
|
|
|
|
cogl_has_feature (ctx, COGL_FEATURE_ID_ARBFP))
|
2011-08-25 16:26:44 +00:00
|
|
|
GE (ctx, glGetIntegerv (GL_MAX_TEXTURE_IMAGE_UNITS, &n));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
2012-01-13 16:48:26 +00:00
|
|
|
|
|
|
|
void
|
2012-01-17 14:49:28 +00:00
|
|
|
cogl_renderer_add_constraint (CoglRenderer *renderer,
|
|
|
|
CoglRendererConstraint constraint)
|
2012-01-13 16:48:26 +00: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 16:41:27 +00: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;
|
|
|
|
}
|
2013-01-21 01:18:25 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
cogl_renderer_foreach_output (CoglRenderer *renderer,
|
|
|
|
CoglOutputCallback callback,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
_COGL_RETURN_IF_FAIL (renderer->connected);
|
|
|
|
_COGL_RETURN_IF_FAIL (callback != NULL);
|
|
|
|
|
|
|
|
for (l = renderer->outputs; l; l = l->next)
|
|
|
|
callback (l->data, user_data);
|
|
|
|
}
|