Cogl 2.0 Reference Manual | ||||
---|---|---|---|---|
Top | Description |
CoglOnscreen; CoglBool cogl_is_onscreen (void *object
); #define COGL_ONSCREEN (X) CoglOnscreen * cogl_onscreen_new (CoglContext *context
,int width
,int height
); void (*CoglOnscreenX11MaskCallback) (CoglOnscreen *onscreen
,uint32_t event_mask
,void *user_data
); void cogl_x11_onscreen_set_foreign_window_xid (CoglOnscreen *onscreen
,uint32_t xid
,CoglOnscreenX11MaskCallback update
,void *user_data
); uint32_t cogl_x11_onscreen_get_window_xid (CoglOnscreen *onscreen
); uint32_t cogl_x11_onscreen_get_visual_xid (CoglOnscreen *onscreen
); void cogl_win32_onscreen_set_foreign_window (CoglOnscreen *onscreen
,HWND hwnd
); HWND cogl_win32_onscreen_get_window (CoglOnscreen *onscreen
); void cogl_onscreen_show (CoglOnscreen *onscreen
); void cogl_onscreen_hide (CoglOnscreen *onscreen
); void (*CoglFrameCallback) (CoglOnscreen *onscreen
,CoglFrameEvent event
,CoglFrameInfo *info
,void *user_data
); typedef CoglFrameClosure; CoglFrameClosure * cogl_onscreen_add_frame_callback (CoglOnscreen *onscreen
,CoglFrameCallback callback
,void *user_data
,CoglUserDataDestroyCallback destroy
); void cogl_onscreen_remove_frame_callback (CoglOnscreen *onscreen
,CoglFrameClosure *closure
); struct CoglOnscreenDirtyInfo; void (*CoglOnscreenDirtyCallback) (CoglOnscreen *onscreen
,const CoglOnscreenDirtyInfo *info
,void *user_data
); typedef CoglOnscreenDirtyClosure; CoglOnscreenDirtyClosure * cogl_onscreen_add_dirty_callback (CoglOnscreen *onscreen
,CoglOnscreenDirtyCallback callback
,void *user_data
,CoglUserDataDestroyCallback destroy
); void cogl_onscreen_remove_dirty_callback (CoglOnscreen *onscreen
,CoglOnscreenDirtyClosure *closure
); void (*CoglOnscreenResizeCallback) (CoglOnscreen *onscreen
,int width
,int height
,void *user_data
); typedef CoglOnscreenResizeClosure; CoglOnscreenResizeClosure * cogl_onscreen_add_resize_callback (CoglOnscreen *onscreen
,CoglOnscreenResizeCallback callback
,void *user_data
,CoglUserDataDestroyCallback destroy
); void cogl_onscreen_remove_resize_callback (CoglOnscreen *onscreen
,CoglOnscreenResizeClosure *closure
); void cogl_onscreen_swap_buffers (CoglOnscreen *onscreen
); void cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen
,const int *rectangles
,int n_rectangles
); void cogl_onscreen_swap_region (CoglOnscreen *onscreen
,const int *rectangles
,int n_rectangles
); void cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen
,CoglBool throttled
); void (*CoglSwapBuffersNotify) (CoglFramebuffer *framebuffer
,void *user_data
); unsigned int cogl_onscreen_add_swap_buffers_callback (CoglOnscreen *onscreen
,CoglSwapBuffersNotify callback
,void *user_data
); void cogl_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen
,unsigned int id
);
CoglBool cogl_is_onscreen (void *object
);
Gets whether the given object references a CoglOnscreen.
|
A CoglObject pointer |
Returns : |
TRUE if the object references a CoglOnscreen
and FALSE otherwise. |
Since 1.10
Stability Level: Unstable
CoglOnscreen * cogl_onscreen_new (CoglContext *context
,int width
,int height
);
Instantiates an "unallocated" CoglOnscreen framebuffer that may be
configured before later being allocated, either implicitly when
it is first used or explicitly via cogl_framebuffer_allocate()
.
|
A CoglContext |
|
The desired framebuffer width |
|
The desired framebuffer height |
Returns : |
A newly instantiated CoglOnscreen framebuffer. [transfer full] |
Since 1.8
Stability Level: Unstable
void (*CoglOnscreenX11MaskCallback) (CoglOnscreen *onscreen
,uint32_t event_mask
,void *user_data
);
void cogl_x11_onscreen_set_foreign_window_xid (CoglOnscreen *onscreen
,uint32_t xid
,CoglOnscreenX11MaskCallback update
,void *user_data
);
Ideally we would recommend that you let Cogl be responsible for
creating any X window required to back an onscreen framebuffer but
if you really need to target a window created manually this
function can be called before onscreen
has been allocated to set a
foreign XID for your existing X window.
Since Cogl needs, for example, to track changes to the size of an X
window it requires that certain events be selected for via the core
X protocol. This requirement may also be changed asynchronously so
you must pass in an update
callback to inform you of Cogl's
required event mask.
For example if you are using Xlib you could use this API roughly as follows: [{ static void my_update_cogl_x11_event_mask (CoglOnscreen *onscreen, uint32_t event_mask, void *user_data) { XSetWindowAttributes attrs; MyData *data = user_data; attrs.event_mask = event_mask | data->my_event_mask; XChangeWindowAttributes (data->xdpy, data->xwin, CWEventMask, &attrs); }
{ *snip* cogl_x11_onscreen_set_foreign_window_xid (onscreen, data->xwin, my_update_cogl_x11_event_mask, data); *snip* } }]
|
The unallocated framebuffer to associated with an X window. |
|
The XID of an existing X window |
|
A callback that notifies of updates to what Cogl requires to be in the core X protocol event mask. |
|
user data passed to update
|
Since 2.0
Stability Level: Unstable
uint32_t cogl_x11_onscreen_get_window_xid (CoglOnscreen *onscreen
);
Assuming you know the given onscreen
framebuffer is based on an x11 window
this queries the XID of that window. If
cogl_x11_onscreen_set_foreign_window_xid()
was previously called then it
will return that same XID otherwise it will be the XID of a window Cogl
created internally. If the window has not been allocated yet and a foreign
xid has not been set then it's undefined what value will be returned.
It's undefined what this function does if called when not using an x11 based renderer.
|
A CoglOnscreen framebuffer |
Since 1.10
Stability Level: Unstable
uint32_t cogl_x11_onscreen_get_visual_xid (CoglOnscreen *onscreen
);
void cogl_win32_onscreen_set_foreign_window (CoglOnscreen *onscreen
,HWND hwnd
);
Ideally we would recommend that you let Cogl be responsible for
creating any window required to back an onscreen framebuffer but
if you really need to target a window created manually this
function can be called before onscreen
has been allocated to set a
foreign XID for your existing X window.
|
A CoglOnscreen framebuffer |
|
A win32 window handle |
Since 1.10
Stability Level: Unstable
HWND cogl_win32_onscreen_get_window (CoglOnscreen *onscreen
);
Queries the internally created window HWND backing the given onscreen
framebuffer. If cogl_win32_onscreen_set_foreign_window()
has been used then
it will return the same handle set with that API.
|
A CoglOnscreen framebuffer |
Since 1.10
Stability Level: Unstable
void cogl_onscreen_show (CoglOnscreen *onscreen
);
This requests to make onscreen
visible to the user.
Actually the precise semantics of this function depend on the window system currently in use, and if you don't have a multi-windowining system this function may in-fact do nothing.
This function will implicitly allocate the given onscreen
framebuffer before showing it if it hasn't already been allocated.
When using the Wayland winsys calling this will set the surface to
a toplevel type which will make it appear. If the application wants
to set a different type for the surface, it can avoid calling
cogl_onscreen_show()
and set its own type directly with the Wayland
client API via cogl_wayland_onscreen_get_surface()
.
|
The onscreen framebuffer to make visible |
Since 2.0
Stability Level: Unstable
void cogl_onscreen_hide (CoglOnscreen *onscreen
);
This requests to make onscreen
invisible to the user.
Actually the precise semantics of this function depend on the window system currently in use, and if you don't have a multi-windowining system this function may in-fact do nothing.
This function does not implicitly allocate the given onscreen
framebuffer before hiding it.
|
The onscreen framebuffer to make invisible |
Since 2.0
Stability Level: Unstable
void (*CoglFrameCallback) (CoglOnscreen *onscreen
,CoglFrameEvent event
,CoglFrameInfo *info
,void *user_data
);
Is a callback that can be registered via
cogl_onscreen_add_frame_callback()
to be called when a frame
progresses in some notable way.
Please see the documentation for CoglFrameEvent and
cogl_onscreen_add_frame_callback()
for more details about what
events can be notified.
|
The onscreen that the frame is associated with |
|
A CoglFrameEvent notifying how the frame has progressed |
|
The meta information, such as timing information, about the frame that has progressed. |
|
The user pointer passed to
cogl_onscreen_add_frame_callback()
|
Since 1.14
Stability Level: Unstable
typedef struct _CoglClosure CoglFrameClosure;
An opaque type that tracks a CoglFrameCallback and associated user
data. A CoglFrameClosure pointer will be returned from
cogl_onscreen_add_frame_callback()
and it allows you to remove a
callback later using cogl_onscreen_remove_frame_callback()
.
Since 1.14
Stability Level: Unstable
CoglFrameClosure * cogl_onscreen_add_frame_callback (CoglOnscreen *onscreen
,CoglFrameCallback callback
,void *user_data
,CoglUserDataDestroyCallback destroy
);
Installs a callback
function that will be called for significant
events relating to the given onscreen
framebuffer.
The callback
will be used to notify when the system compositor is
ready for this application to render a new frame. In this case
COGL_FRAME_EVENT_SYNC
will be passed as the event argument to the
given callback
in addition to the CoglFrameInfo corresponding to
the frame beeing acknowledged by the compositor.
The callback
will also be called to notify when the frame has
ended. In this case COGL_FRAME_EVENT_COMPLETE
will be passed as
the event argument to the given callback
in addition to the
CoglFrameInfo corresponding to the newly presented frame. The
meaning of "ended" here simply means that no more timing
information will be collected within the corresponding
CoglFrameInfo and so this is a good opportunity to analyse the
given info. It does not necessarily mean that the GPU has finished
rendering the corresponding frame.
We highly recommend throttling your application according to
COGL_FRAME_EVENT_SYNC
events so that your application can avoid
wasting resources, drawing more frames than your system compositor
can display.
|
A CoglOnscreen framebuffer |
|
A callback function to call for frame events. [scope notified] |
|
A private pointer to be passed to callback . [closure]
|
|
An optional callback to destroy user_data
when the callback is removed or onscreen is freed. [allow-none]
|
Returns : |
a CoglFrameClosure pointer that can be used to
remove the callback and associated user_data later. |
Since 1.14
Stability Level: Unstable
void cogl_onscreen_remove_frame_callback (CoglOnscreen *onscreen
,CoglFrameClosure *closure
);
Removes a callback and associated user data that were previously
registered using cogl_onscreen_add_frame_callback()
.
If a destroy callback was passed to
cogl_onscreen_add_frame_callback()
to destroy the user data then
this will get called.
|
A CoglOnscreen |
|
A CoglFrameClosure returned from
cogl_onscreen_add_frame_callback()
|
Since 1.14
Stability Level: Unstable
struct CoglOnscreenDirtyInfo { int x, y; int width, height; };
A structure passed to callbacks registered using
cogl_onscreen_add_dirty_callback()
. The members describe a
rectangle within the onscreen buffer that should be redrawn.
Left edge of the dirty rectangle | |
Top edge of the dirty rectangle, measured from the top of the window | |
Width of the dirty rectangle | |
Height of the dirty rectangle |
Since 1.16
Stability Level: Unstable
void (*CoglOnscreenDirtyCallback) (CoglOnscreen *onscreen
,const CoglOnscreenDirtyInfo *info
,void *user_data
);
Is a callback that can be registered via
cogl_onscreen_add_dirty_callback()
to be called when the windowing
system determines that a region of the onscreen window has been
lost and the application should redraw it.
|
The onscreen that the frame is associated with |
|
A CoglOnscreenDirtyInfo struct containing the details of the dirty area |
|
The user pointer passed to
cogl_onscreen_add_frame_callback()
|
Since 1.16
Stability Level: Unstable
typedef struct _CoglClosure CoglOnscreenDirtyClosure;
An opaque type that tracks a CoglOnscreenDirtyCallback and associated
user data. A CoglOnscreenDirtyClosure pointer will be returned from
cogl_onscreen_add_dirty_callback()
and it allows you to remove a
callback later using cogl_onscreen_remove_dirty_callback()
.
Since 1.16
Stability Level: Unstable
CoglOnscreenDirtyClosure * cogl_onscreen_add_dirty_callback (CoglOnscreen *onscreen
,CoglOnscreenDirtyCallback callback
,void *user_data
,CoglUserDataDestroyCallback destroy
);
Installs a callback
function that will be called whenever the
window system has lost the contents of a region of the onscreen
buffer and the application should redraw it to repair the buffer.
For example this may happen in a window system without a compositor
if a window that was previously covering up the onscreen window has
been moved causing a region of the onscreen to be exposed.
The callback
will be passed a CoglOnscreenDirtyInfo struct which
decribes a rectangle containing the newly dirtied region. Note that
this may be called multiple times to describe a non-rectangular
region composed of multiple smaller rectangles.
The dirty events are separate from COGL_FRAME_EVENT_SYNC
events so
the application should also listen for this event before rendering
the dirty region to ensure that the framebuffer is actually ready
for rendering.
|
A CoglOnscreen framebuffer |
|
A callback function to call for dirty events. [scope notified] |
|
A private pointer to be passed to callback . [closure]
|
|
An optional callback to destroy user_data when the
callback is removed or onscreen is freed. [allow-none]
|
Returns : |
a CoglOnscreenDirtyClosure pointer that can be used to
remove the callback and associated user_data later. |
Since 1.16
Stability Level: Unstable
void cogl_onscreen_remove_dirty_callback (CoglOnscreen *onscreen
,CoglOnscreenDirtyClosure *closure
);
Removes a callback and associated user data that were previously
registered using cogl_onscreen_add_dirty_callback()
.
If a destroy callback was passed to
cogl_onscreen_add_dirty_callback()
to destroy the user data then
this will also get called.
|
A CoglOnscreen |
|
A CoglOnscreenDirtyClosure returned from
cogl_onscreen_add_dirty_callback()
|
Since 1.16
Stability Level: Unstable
void (*CoglOnscreenResizeCallback) (CoglOnscreen *onscreen
,int width
,int height
,void *user_data
);
Is a callback type used with the
cogl_onscreen_add_resize_callback()
allowing applications to be
notified whenever an onscreen
framebuffer is resized.
onscreen
framebuffer that is resized so this callback is also an indication
that the viewport has been modified too
cogl_poll_renderer_dispatch()
. This is so that callbacks shouldn't
occur while an application might have arbitrary locks held for
example.
|
A CoglOnscreen framebuffer that was resized |
|
The new width of onscreen
|
|
The new height of onscreen
|
|
The private passed to
cogl_onscreen_add_resize_callback()
|
Since 2.0
typedef struct _CoglClosure CoglOnscreenResizeClosure;
An opaque type that tracks a CoglOnscreenResizeCallback and
associated user data. A CoglOnscreenResizeClosure pointer will be
returned from cogl_onscreen_add_resize_callback()
and it allows you
to remove a callback later using
cogl_onscreen_remove_resize_callback()
.
Since 2.0
Stability Level: Unstable
CoglOnscreenResizeClosure * cogl_onscreen_add_resize_callback (CoglOnscreen *onscreen
,CoglOnscreenResizeCallback callback
,void *user_data
,CoglUserDataDestroyCallback destroy
);
Registers a callback
with onscreen
that will be called whenever
the onscreen
framebuffer changes size.
The callback
can be removed using
cogl_onscreen_remove_resize_callback()
passing the returned closure
pointer.
onscreen
framebuffer that is resized, a resize callback can also be used to
track when the viewport has been changed automatically by Cogl in
case your application needs more specialized control over the
viewport.
cogl_poll_renderer_dispatch()
. This is so that callbacks shouldn't
occur while an application might have arbitrary locks held for
example.
|
A CoglOnscreen framebuffer |
|
A CoglOnscreenResizeCallback to call when
the onscreen changes size. [scope notified]
|
|
Private data to be passed to callback . [closure]
|
|
An optional callback to destroy user_data
when the callback is removed or onscreen is freed. [allow-none]
|
Returns : |
a CoglOnscreenResizeClosure pointer that can be used to
remove the callback and associated user_data later. |
Since 2.0
void cogl_onscreen_remove_resize_callback (CoglOnscreen *onscreen
,CoglOnscreenResizeClosure *closure
);
Removes a resize callback
and user_data
pair that were previously
associated with onscreen
via cogl_onscreen_add_resize_callback()
.
|
A CoglOnscreen framebuffer |
|
An identifier returned from cogl_onscreen_add_resize_callback()
|
Since 2.0
void cogl_onscreen_swap_buffers (CoglOnscreen *onscreen
);
Swaps the current back buffer being rendered too, to the front for display.
This function also implicitly discards the contents of the color, depth and
stencil buffers as if cogl_framebuffer_discard_buffers()
were used. The
significance of the discard is that you should not expect to be able to
start a new frame that incrementally builds on the contents of the previous
frame.
cogl_onscreen_swap_buffers_with_damage()
instead whenever possible
and also use the cogl_onscreen_get_buffer_age()
api so they can
perform incremental updates to older buffers instead of having to
render a full buffer for every frame.
|
A CoglOnscreen framebuffer |
Since 1.10
Stability Level: Unstable
void cogl_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen
,const int *rectangles
,int n_rectangles
);
Swaps the current back buffer being rendered too, to the front for display and provides information to any system compositor about what regions of the buffer have changed (damage) with respect to the last swapped buffer.
This function has the same semantics as
cogl_framebuffer_swap_buffers()
except that it additionally allows
applications to pass a list of damaged rectangles which may be
passed on to a compositor so that it can minimize how much of the
screen is redrawn in response to this applications newly swapped
front buffer.
For example if your application is only animating a small object in the corner of the screen and everything else is remaining static then it can help the compositor to know that only the bottom right corner of your newly swapped buffer has really changed with respect to your previously swapped front buffer.
If n_rectangles
is 0 then the whole buffer will implicitly be
reported as damaged as if cogl_onscreen_swap_buffers()
had been
called.
This function also implicitly discards the contents of the color,
depth and stencil buffers as if cogl_framebuffer_discard_buffers()
were used. The significance of the discard is that you should not
expect to be able to start a new frame that incrementally builds on
the contents of the previous frame. If you want to perform
incremental updates to older back buffers then please refer to the
cogl_onscreen_get_buffer_age()
api.
Whenever possible it is recommended that applications use this
function instead of cogl_onscreen_swap_buffers()
to improve
performance when running under a compositor.
cogl_onscreen_get_buffer_age()
api so that your application can
perform incremental rendering based on old back buffers.
|
A CoglOnscreen framebuffer |
|
An array of integer 4-tuples representing damaged rectangles as (x, y, width, height) tuples. |
|
The number of 4-tuples to be read from rectangles
|
Since 1.16
Stability Level: Unstable
void cogl_onscreen_swap_region (CoglOnscreen *onscreen
,const int *rectangles
,int n_rectangles
);
Swaps a region of the back buffer being rendered too, to the front for
display. rectangles
represents the region as array of n_rectangles
each
defined by 4 sequential (x, y, width, height) integers.
This function also implicitly discards the contents of the color, depth and
stencil buffers as if cogl_framebuffer_discard_buffers()
were used. The
significance of the discard is that you should not expect to be able to
start a new frame that incrementally builds on the contents of the previous
frame.
|
A CoglOnscreen framebuffer |
|
An array of integer 4-tuples representing rectangles as (x, y, width, height) tuples. |
|
The number of 4-tuples to be read from rectangles
|
Since 1.10
Stability Level: Unstable
void cogl_onscreen_set_swap_throttled (CoglOnscreen *onscreen
,CoglBool throttled
);
Requests that the given onscreen
framebuffer should have swap buffer
requests (made using cogl_onscreen_swap_buffers()
) throttled either by a
displays vblank period or perhaps some other mechanism in a composited
environment.
|
A CoglOnscreen framebuffer |
|
Whether swap throttling is wanted or not. |
Since 1.8
Stability Level: Unstable
void (*CoglSwapBuffersNotify) (CoglFramebuffer *framebuffer
,void *user_data
);
unsigned int cogl_onscreen_add_swap_buffers_callback (CoglOnscreen *onscreen
,CoglSwapBuffersNotify callback
,void *user_data
);
cogl_onscreen_add_swap_buffers_callback
has been deprecated since version 1.14 and should not be used in newly-written code. Use cogl_onscreen_add_frame_callback()
instead
Installs a callback
function that should be called whenever a swap buffers
request (made using cogl_onscreen_swap_buffers()
) for the given
onscreen
completes.
COGL_FEATURE_ID_SWAP_BUFFERS_EVENT
feature before using this API. It's currently undefined when and if
registered callbacks will be called if this feature is not supported.
We recommend using this mechanism when available to manually throttle your
applications (in conjunction with cogl_onscreen_set_swap_throttled()
) so
your application will be able to avoid long blocks in the driver caused by
throttling when you request to swap buffers too quickly.
|
A CoglOnscreen framebuffer |
|
A callback function to call when a swap has completed. [scope notified] |
|
A private pointer to be passed to callback . [closure]
|
Returns : |
a unique identifier that can be used to remove to remove the callback later. |
Since 1.10
Stability Level: Unstable
void cogl_onscreen_remove_swap_buffers_callback (CoglOnscreen *onscreen
,unsigned int id
);
cogl_onscreen_remove_swap_buffers_callback
has been deprecated since version 1.14 and should not be used in newly-written code. Use cogl_onscreen_remove_frame_callback()
instead
Removes a callback that was previously registered
using cogl_onscreen_add_swap_buffers_callback()
.
|
A CoglOnscreen framebuffer |
|
An identifier returned from cogl_onscreen_add_swap_buffers_callback()
|
Since 1.10
Stability Level: Unstable