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>
|
|
|
|
*/
|
|
|
|
|
2016-05-05 14:21:51 +00:00
|
|
|
#include "cogl-config.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
|
|
|
|
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"
|
2016-05-05 07:20:07 +00:00
|
|
|
#include "cogl-mutter.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"
|
2013-09-02 15:02:42 +00:00
|
|
|
#include "cogl-gtype-private.h"
|
2011-11-09 07:19:26 +00:00
|
|
|
|
2018-05-21 19:57:38 +00:00
|
|
|
#include "winsys/cogl-winsys-private.h"
|
|
|
|
|
2011-12-13 16:23:25 +00:00
|
|
|
#ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
|
2018-05-21 19:57:38 +00:00
|
|
|
#include "winsys/cogl-winsys-egl-x11-private.h"
|
2011-12-08 17:24:40 +00:00
|
|
|
#endif
|
2011-02-25 11:29:08 +00:00
|
|
|
#ifdef COGL_HAS_GLX_SUPPORT
|
2018-05-21 19:57:38 +00:00
|
|
|
#include "winsys/cogl-winsys-glx-private.h"
|
2011-02-25 11:29:08 +00:00
|
|
|
#endif
|
2012-03-06 18:21:28 +00:00
|
|
|
|
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
|
|
|
|
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
|
2018-05-04 21:14:19 +00:00
|
|
|
#if defined (HAVE_COGL_GLES2)
|
2012-08-31 23:04:00 +00:00
|
|
|
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;
|
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",
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
-1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_gl,
|
|
|
|
&_cogl_texture_driver_gl,
|
|
|
|
COGL_GL_LIBNAME,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
COGL_DRIVER_GL3,
|
|
|
|
"gl3",
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
-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",
|
2013-11-25 16:11:36 +00:00
|
|
|
{ COGL_PRIVATE_FEATURE_ANY_GL,
|
|
|
|
-1 },
|
2013-05-11 17:15:25 +00:00
|
|
|
&_cogl_driver_gles,
|
|
|
|
&_cogl_texture_driver_gles,
|
|
|
|
COGL_GLES2_LIBNAME,
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
COGL_DRIVER_NOP,
|
|
|
|
"nop",
|
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-02-25 11:29:08 +00:00
|
|
|
#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
|
|
|
static void _cogl_renderer_free (CoglRenderer *renderer);
|
|
|
|
|
|
|
|
COGL_OBJECT_DEFINE (Renderer, renderer);
|
2013-09-02 15:02:42 +00:00
|
|
|
COGL_GTYPE_DEFINE_CLASS (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
|
|
|
|
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
|
|
|
if (renderer->libgl_module)
|
|
|
|
g_module_close (renderer->libgl_module);
|
|
|
|
|
2019-05-15 18:56:35 +00:00
|
|
|
g_slist_free_full (renderer->event_filters,
|
|
|
|
(GDestroyNotify) native_filter_closure_free);
|
2011-04-13 15:41:41 +00:00
|
|
|
|
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
|
|
|
|
|
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)
|
|
|
|
{
|
2019-06-17 21:40:06 +00:00
|
|
|
g_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 */
|
2019-06-17 21:40:06 +00:00
|
|
|
g_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 */
|
2019-10-24 20:13:05 +00:00
|
|
|
renderer->xlib_enable_event_retrieval = 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
|
|
|
{
|
2019-06-17 21:42:01 +00:00
|
|
|
g_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
|
|
|
|
2016-05-29 18:29:49 +00:00
|
|
|
void
|
|
|
|
cogl_xlib_renderer_request_reset_on_video_memory_purge (CoglRenderer *renderer,
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean enable)
|
2016-05-29 18:29:49 +00:00
|
|
|
{
|
2019-06-17 21:40:06 +00:00
|
|
|
g_return_if_fail (cogl_is_renderer (renderer));
|
|
|
|
g_return_if_fail (!renderer->connected);
|
2016-05-29 18:29:49 +00:00
|
|
|
|
|
|
|
renderer->xlib_want_reset_on_video_memory_purge = 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 */
|
|
|
|
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean
|
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,
|
2019-06-18 06:02:10 +00:00
|
|
|
GError **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;
|
|
|
|
}
|
|
|
|
|
2018-11-24 12:04:47 +00:00
|
|
|
typedef gboolean (*CoglDriverCallback) (CoglDriverDescription *description,
|
2014-03-06 12:13:07 +00:00
|
|
|
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,
|
2014-03-06 12:13:07 +00:00
|
|
|
CoglDriverCallback callback,
|
2013-05-11 17:15:25 +00:00
|
|
|
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_GLES2:
|
|
|
|
return "gles2";
|
|
|
|
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
|
|
|
|
{
|
|
|
|
const CoglDriverDescription *driver_description;
|
|
|
|
} SatisfyConstraintsState;
|
|
|
|
|
2019-03-19 21:50:39 +00:00
|
|
|
/* XXX this is still uglier than it needs to be */
|
2018-11-24 12:04:47 +00:00
|
|
|
static gboolean
|
2013-05-11 17:15:25 +00:00
|
|
|
satisfy_constraints (CoglDriverDescription *description,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
SatisfyConstraintsState *state = user_data;
|
2011-07-07 19:44:56 +00:00
|
|
|
|
2013-05-11 17:15:25 +00:00
|
|
|
state->driver_description = description;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-11-24 12:04:47 +00:00
|
|
|
static gboolean
|
2013-05-11 17:15:25 +00:00
|
|
|
_cogl_renderer_choose_driver (CoglRenderer *renderer,
|
2019-06-18 06:02:10 +00:00
|
|
|
GError **error)
|
2013-05-11 17:15:25 +00:00
|
|
|
{
|
|
|
|
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)
|
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)
|
|
|
|
{
|
2019-06-18 06:02:10 +00:00
|
|
|
g_set_error (error, COGL_RENDERER_ERROR,
|
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"Application driver selection conflicts with driver "
|
|
|
|
"specified in configuration");
|
2013-06-27 08:57:02 +00:00
|
|
|
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
|
|
|
{
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean found = FALSE;
|
2013-05-11 17:15:25 +00:00
|
|
|
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)
|
|
|
|
{
|
2019-06-18 06:02:10 +00:00
|
|
|
g_set_error (error, COGL_RENDERER_ERROR,
|
|
|
|
COGL_RENDERER_ERROR_BAD_CONSTRAINT,
|
|
|
|
"Driver \"%s\" is not available",
|
|
|
|
invalid_override);
|
2013-05-11 17:15:25 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
state.driver_description = NULL;
|
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
|
|
|
{
|
2019-06-18 06:02:10 +00:00
|
|
|
g_set_error (error, 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);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-06-18 06:02:10 +00:00
|
|
|
g_set_error (error, COGL_DRIVER_ERROR,
|
2012-09-12 21:39:46 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
|
|
|
|
2016-05-05 07:20:07 +00:00
|
|
|
void
|
2016-09-23 03:49:10 +00:00
|
|
|
cogl_renderer_set_custom_winsys (CoglRenderer *renderer,
|
2017-07-24 08:03:02 +00:00
|
|
|
CoglCustomWinsysVtableGetter winsys_vtable_getter,
|
|
|
|
void *user_data)
|
2016-05-05 07:20:07 +00:00
|
|
|
{
|
2017-07-24 08:03:02 +00:00
|
|
|
renderer->custom_winsys_user_data = user_data;
|
2016-05-05 07:20:07 +00:00
|
|
|
renderer->custom_winsys_vtable_getter = winsys_vtable_getter;
|
|
|
|
}
|
|
|
|
|
2018-11-24 12:04:47 +00:00
|
|
|
static gboolean
|
2016-05-05 07:20:07 +00:00
|
|
|
connect_custom_winsys (CoglRenderer *renderer,
|
2019-06-18 06:02:10 +00:00
|
|
|
GError **error)
|
2016-05-05 07:20:07 +00:00
|
|
|
{
|
2016-09-23 03:49:10 +00:00
|
|
|
const CoglWinsysVtable *winsys;
|
2019-06-18 06:02:10 +00:00
|
|
|
GError *tmp_error = NULL;
|
2016-05-05 07:20:07 +00:00
|
|
|
GString *error_message;
|
|
|
|
|
2016-09-23 03:49:10 +00:00
|
|
|
winsys = renderer->custom_winsys_vtable_getter (renderer);
|
2016-05-05 07:20:07 +00:00
|
|
|
renderer->winsys_vtable = winsys;
|
|
|
|
|
|
|
|
error_message = g_string_new ("");
|
|
|
|
if (!winsys->renderer_connect (renderer, &tmp_error))
|
|
|
|
{
|
|
|
|
g_string_append_c (error_message, '\n');
|
|
|
|
g_string_append (error_message, tmp_error->message);
|
2019-06-18 06:02:10 +00:00
|
|
|
g_error_free (tmp_error);
|
2016-05-05 07:20:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
renderer->connected = TRUE;
|
|
|
|
g_string_free (error_message, TRUE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer->winsys_vtable = NULL;
|
2019-06-18 06:02:10 +00:00
|
|
|
g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_INIT,
|
|
|
|
"Failed to connected to any renderer: %s", error_message->str);
|
2016-05-05 07:20:07 +00:00
|
|
|
g_string_free (error_message, TRUE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean
|
2019-06-18 06:02:10 +00:00
|
|
|
cogl_renderer_connect (CoglRenderer *renderer, GError **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;
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean 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;
|
|
|
|
|
2016-05-05 07:20:07 +00:00
|
|
|
if (renderer->custom_winsys_vtable_getter)
|
|
|
|
return connect_custom_winsys (renderer, error);
|
|
|
|
|
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]();
|
2019-06-18 06:02:10 +00:00
|
|
|
GError *tmp_error = NULL;
|
2012-01-13 16:48:26 +00:00
|
|
|
GList *l;
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean 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-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);
|
2019-06-18 06:02:10 +00:00
|
|
|
g_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)
|
|
|
|
{
|
2019-06-18 06:02:10 +00:00
|
|
|
g_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;
|
2019-06-18 06:02:10 +00:00
|
|
|
g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_INIT,
|
2011-02-25 11:29:08 +00:00
|
|
|
"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)
|
|
|
|
{
|
2019-06-17 21:40:06 +00:00
|
|
|
g_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)
|
|
|
|
{
|
2019-06-17 21:42:01 +00:00
|
|
|
g_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,
|
2018-11-24 12:04:47 +00:00
|
|
|
gboolean 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
|
|
|
|
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)
|
|
|
|
{
|
2019-06-17 21:40:06 +00:00
|
|
|
g_return_if_fail (!renderer->connected);
|
2012-02-23 16:41:27 +00:00
|
|
|
renderer->driver_override = driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoglDriver
|
|
|
|
cogl_renderer_get_driver (CoglRenderer *renderer)
|
|
|
|
{
|
2019-06-17 21:42:01 +00:00
|
|
|
g_return_val_if_fail (renderer->connected, 0);
|
2012-02-23 16:41:27 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2019-06-17 21:40:06 +00:00
|
|
|
g_return_if_fail (renderer->connected);
|
|
|
|
g_return_if_fail (callback != NULL);
|
2013-01-21 01:18:25 +00:00
|
|
|
|
|
|
|
for (l = renderer->outputs; l; l = l->next)
|
|
|
|
callback (l->data, user_data);
|
|
|
|
}
|